75 lines
2.6 KiB
Text
75 lines
2.6 KiB
Text
|
=== tests/cases/compiler/voidFunctionAssignmentCompat.ts ===
|
||
|
var fa = function(): any { return 3; }
|
||
|
>fa : () => any
|
||
|
>function(): any { return 3; } : () => any
|
||
|
|
||
|
fa = function() { } // should not work
|
||
|
>fa = function() { } : () => void
|
||
|
>fa : () => any
|
||
|
>function() { } : () => void
|
||
|
|
||
|
var fv = function(): void {}
|
||
|
>fv : () => void
|
||
|
>function(): void {} : () => void
|
||
|
|
||
|
fv = function() { return 0; } // should work
|
||
|
>fv = function() { return 0; } : () => number
|
||
|
>fv : () => void
|
||
|
>function() { return 0; } : () => number
|
||
|
|
||
|
function execAny(callback:(val:any)=>any) { return callback(0) }
|
||
|
>execAny : (callback: (val: any) => any) => any
|
||
|
>callback : (val: any) => any
|
||
|
>val : any
|
||
|
>callback(0) : any
|
||
|
>callback : (val: any) => any
|
||
|
|
||
|
execAny(function () {}); // should work
|
||
|
>execAny(function () {}) : any
|
||
|
>execAny : (callback: (val: any) => any) => any
|
||
|
>function () {} : () => void
|
||
|
|
||
|
function execVoid(callback:(val:any)=>void) { callback(0); }
|
||
|
>execVoid : (callback: (val: any) => void) => void
|
||
|
>callback : (val: any) => void
|
||
|
>val : any
|
||
|
>callback(0) : void
|
||
|
>callback : (val: any) => void
|
||
|
|
||
|
execVoid(function () {return 0;}); // should work
|
||
|
>execVoid(function () {return 0;}) : void
|
||
|
>execVoid : (callback: (val: any) => void) => void
|
||
|
>function () {return 0;} : () => number
|
||
|
|
||
|
var fra: (v:any)=>any = function() { return function () {}; } // should work
|
||
|
>fra : (v: any) => any
|
||
|
>v : any
|
||
|
>function() { return function () {}; } : () => () => void
|
||
|
>function () {} : () => void
|
||
|
|
||
|
var frv: (v:any)=>void = function() { return function () { return 0; } } // should work
|
||
|
>frv : (v: any) => void
|
||
|
>v : any
|
||
|
>function() { return function () { return 0; } } : () => () => number
|
||
|
>function () { return 0; } : () => number
|
||
|
|
||
|
var fra3: (v:any)=>string = (function() { return function (v:string) {return v;}; })() // should work
|
||
|
>fra3 : (v: any) => string
|
||
|
>v : any
|
||
|
>(function() { return function (v:string) {return v;}; })() : (v: string) => string
|
||
|
>(function() { return function (v:string) {return v;}; }) : () => (v: string) => string
|
||
|
>function() { return function (v:string) {return v;}; } : () => (v: string) => string
|
||
|
>function (v:string) {return v;} : (v: string) => string
|
||
|
>v : string
|
||
|
>v : string
|
||
|
|
||
|
var frv3: (v:any)=>number = (function() { return function () { return 0; } })() // should work
|
||
|
>frv3 : (v: any) => number
|
||
|
>v : any
|
||
|
>(function() { return function () { return 0; } })() : () => number
|
||
|
>(function() { return function () { return 0; } }) : () => () => number
|
||
|
>function() { return function () { return 0; } } : () => () => number
|
||
|
>function () { return 0; } : () => number
|
||
|
|
||
|
|