File: voidFunctionAssignmentCompat.js

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (34 lines) | stat: -rw-r--r-- 1,476 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//// [voidFunctionAssignmentCompat.ts]
var fa = function(): any { return 3; }
fa = function() { } // should not work

var fv = function(): void {}
fv = function() { return 0; } // should work

function execAny(callback:(val:any)=>any) { return callback(0) }
execAny(function () {}); // should work

function execVoid(callback:(val:any)=>void) { callback(0); }
execVoid(function () {return 0;}); // should work

var fra: (v:any)=>any = function() { return function () {}; } // should work
var frv: (v:any)=>void = function() { return function () { return 0; } } // should work

var fra3: (v:any)=>string = (function() { return function (v:string) {return v;}; })() // should work
var frv3: (v:any)=>number = (function() { return function () { return 0; } })() // should work



//// [voidFunctionAssignmentCompat.js]
var fa = function () { return 3; };
fa = function () { }; // should not work
var fv = function () { };
fv = function () { return 0; }; // should work
function execAny(callback) { return callback(0); }
execAny(function () { }); // should work
function execVoid(callback) { callback(0); }
execVoid(function () { return 0; }); // should work
var fra = function () { return function () { }; }; // should work
var frv = function () { return function () { return 0; }; }; // should work
var fra3 = (function () { return function (v) { return v; }; })(); // should work
var frv3 = (function () { return function () { return 0; }; })(); // should work