mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
45 lines
1.8 KiB
Plaintext
45 lines
1.8 KiB
Plaintext
assignmentToObjectAndFunction.ts(1,24): error TS2322: Type 'number' is not assignable to type '() => string'.
|
|
assignmentToObjectAndFunction.ts(8,5): error TS2740: Type '{}' is missing the following properties from type 'Function': apply, call, bind, prototype, and 5 more.
|
|
assignmentToObjectAndFunction.ts(29,5): error TS2322: Type 'typeof bad' is not assignable to type 'Function'.
|
|
Types of property 'apply' are incompatible.
|
|
Type 'number' is not assignable to type '(this: Function, thisArg: any, argArray?: any) => any'.
|
|
|
|
|
|
==== assignmentToObjectAndFunction.ts (3 errors) ====
|
|
var errObj: Object = { toString: 0 }; // Error, incompatible toString
|
|
~~~~~~~~
|
|
!!! error TS2322: Type 'number' is not assignable to type '() => string'.
|
|
var goodObj: Object = {
|
|
toString(x?) {
|
|
return "";
|
|
}
|
|
}; // Ok, because toString is a subtype of Object's toString
|
|
|
|
var errFun: Function = {}; // Error for no call signature
|
|
~~~~~~
|
|
!!! error TS2740: Type '{}' is missing the following properties from type 'Function': apply, call, bind, prototype, and 5 more.
|
|
|
|
function foo() { }
|
|
namespace foo {
|
|
export var boom = 0;
|
|
}
|
|
|
|
var goodFundule: Function = foo; // ok
|
|
|
|
function bar() { }
|
|
namespace bar {
|
|
export function apply(thisArg: string, argArray?: string) { }
|
|
}
|
|
|
|
var goodFundule2: Function = bar; // ok
|
|
|
|
function bad() { }
|
|
namespace bad {
|
|
export var apply = 0;
|
|
}
|
|
|
|
var badFundule: Function = bad; // error
|
|
~~~~~~~~~~
|
|
!!! error TS2322: Type 'typeof bad' is not assignable to type 'Function'.
|
|
!!! error TS2322: Types of property 'apply' are incompatible.
|
|
!!! error TS2322: Type 'number' is not assignable to type '(this: Function, thisArg: any, argArray?: any) => any'. |