File: arrayAssignmentTest4.types

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 (47 lines) | stat: -rw-r--r-- 957 bytes parent folder | download | duplicates (5)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
=== tests/cases/compiler/arrayAssignmentTest4.ts ===
class C3 {
>C3 : C3

    CM3M1() { return 3;}
>CM3M1 : () => number
>3 : 3
}


/*

This behaves unexpectedly with teh following types:

Type 1 of any[]:

* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[].

* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass.

*/
var c3 : C3 = new C3();
>c3 : C3
>new C3() : C3
>C3 : typeof C3

var o1 = {one : 1};
>o1 : { one: number; }
>{one : 1} : { one: number; }
>one : number
>1 : 1

var arr_any: any[] = [];
>arr_any : any[]
>[] : undefined[]

arr_any = function () { return null;} // should be an error - is
>arr_any = function () { return null;} : () => any
>arr_any : any[]
>function () { return null;} : () => any
>null : null

arr_any = c3; // should be an error - is
>arr_any = c3 : C3
>arr_any : any[]
>c3 : C3