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')
|