File: localTypes4.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (54 lines) | stat: -rw-r--r-- 1,697 bytes parent folder | download | duplicates (2)
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
48
49
50
51
52
53
54
tests/cases/conformance/types/localTypes/localTypes4.ts(11,19): error TS2304: Cannot find name 'T'.
tests/cases/conformance/types/localTypes/localTypes4.ts(11,23): error TS2304: Cannot find name 'T'.
tests/cases/conformance/types/localTypes/localTypes4.ts(19,16): error TS2300: Duplicate identifier 'T'.
tests/cases/conformance/types/localTypes/localTypes4.ts(20,19): error TS2300: Duplicate identifier 'T'.


==== tests/cases/conformance/types/localTypes/localTypes4.ts (4 errors) ====
    
    function f1() {
        // Type parameters are in scope in parameters and return types
        function f<T>(x: T): T {
            return undefined;
        }
    }
    
    function f2() {
        // Local types are not in scope in parameters and return types
        function f(x: T): T {
                      ~
!!! error TS2304: Cannot find name 'T'.
                          ~
!!! error TS2304: Cannot find name 'T'.
            interface T { }
            return undefined;
        }
    }
    
    function f3() {
        // Type parameters and top-level local types are in same declaration space
        function f<T>() {
                   ~
!!! error TS2300: Duplicate identifier 'T'.
            interface T { }
                      ~
!!! error TS2300: Duplicate identifier 'T'.
            return undefined;
        }
    }
    
    function f4() {
        // Local types are block scoped
        interface T { x: number }
        let v: T;
        v.x = 10;
        if (true) {
            interface T { x: string }
            let v: T;
            v.x = "hello";
        }
        else {
            v.x = 20;
        }
    }