File: typeFromJSInitializer.errors.txt

package info (click to toggle)
node-typescript 4.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 396,552 kB
  • sloc: javascript: 1,444,377; makefile: 7; sh: 3
file content (75 lines) | stat: -rw-r--r-- 2,433 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
tests/cases/conformance/salsa/a.js(3,5): error TS7008: Member 'unknown' implicitly has an 'any' type.
tests/cases/conformance/salsa/a.js(4,5): error TS7008: Member 'unknowable' implicitly has an 'any' type.
tests/cases/conformance/salsa/a.js(5,5): error TS7008: Member 'empty' implicitly has an 'any[]' type.
tests/cases/conformance/salsa/a.js(25,12): error TS7006: Parameter 'a' implicitly has an 'any' type.
tests/cases/conformance/salsa/a.js(25,29): error TS7006: Parameter 'l' implicitly has an 'any[]' type.
tests/cases/conformance/salsa/a.js(37,5): error TS2322: Type '"error"' is not assignable to type 'number | undefined'.


==== tests/cases/conformance/salsa/a.js (6 errors) ====
    function A () {
        // should get any on this-assignments in constructor
        this.unknown = null
        ~~~~~~~~~~~~~~~~~~~
!!! error TS7008: Member 'unknown' implicitly has an 'any' type.
        this.unknowable = undefined
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS7008: Member 'unknowable' implicitly has an 'any' type.
        this.empty = []
        ~~~~~~~~~~~~~~~
!!! error TS7008: Member 'empty' implicitly has an 'any[]' type.
    }
    var a = new A()
    a.unknown = 1
    a.unknown = true
    a.unknown = {}
    a.unknown = 'hi'
    a.unknowable = 1
    a.unknowable = true
    a.unknowable = {}
    a.unknowable = 'hi'
    a.empty.push(1)
    a.empty.push(true)
    a.empty.push({})
    a.empty.push('hi')
    
    /** @type {number | undefined} */
    var n;
    
    // should get any on parameter initialisers
    function f(a = null, b = n, l = []) {
               ~~~~~~~~
!!! error TS7006: Parameter 'a' implicitly has an 'any' type.
                                ~~~~~~
!!! error TS7006: Parameter 'l' implicitly has an 'any[]' type.
        // a should be any
        a = undefined
        a = null
        a = 1
        a = true
        a = {}
        a = 'ok'
    
        // b should be number | undefined, not any
        b = 1
        b = undefined
        b = 'error'
        ~
!!! error TS2322: Type '"error"' is not assignable to type 'number | undefined'.
    
        // l should be any[]
        l.push(1)
        l.push('ok')
    }
    
    // should get any on variable initialisers
    var u = undefined;
    var l = [];
    u = undefined
    u = 1
    u = true
    u = {}
    u = 'ok'
    
    l.push('ok')