mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 05:17:43 -05:00
Add tests and update baselines
This commit is contained in:
@@ -14,12 +14,15 @@ const obj = {
|
||||
lol,
|
||||
/** @type {number} */
|
||||
['b' + 'ar1']: 42,
|
||||
/** @type {function(number): number} */
|
||||
arrowFunc: (num) => num + 42
|
||||
}
|
||||
obj.foo = 'string'
|
||||
obj.lol
|
||||
obj.bar = undefined;
|
||||
var k = obj.method1(0);
|
||||
obj.bar1 = "42";
|
||||
obj.bar1 = "42";
|
||||
obj.arrowFunc(0);
|
||||
|
||||
//// [0.js]
|
||||
// @ts-check
|
||||
@@ -38,10 +41,13 @@ var obj = (_a = {
|
||||
},
|
||||
/** @type {number} */
|
||||
_a['b' + 'ar1'] = 42,
|
||||
/** @type {function(number): number} */
|
||||
_a.arrowFunc = function (num) { return num + 42; },
|
||||
_a);
|
||||
obj.foo = 'string';
|
||||
obj.lol;
|
||||
obj.bar = undefined;
|
||||
var k = obj.method1(0);
|
||||
obj.bar1 = "42";
|
||||
obj.arrowFunc(0);
|
||||
var _a;
|
||||
|
||||
@@ -30,6 +30,11 @@ const obj = {
|
||||
|
||||
/** @type {number} */
|
||||
['b' + 'ar1']: 42,
|
||||
/** @type {function(number): number} */
|
||||
arrowFunc: (num) => num + 42
|
||||
>arrowFunc : Symbol(arrowFunc, Decl(0.js, 14, 20))
|
||||
>num : Symbol(num, Decl(0.js, 16, 14))
|
||||
>num : Symbol(num, Decl(0.js, 16, 14))
|
||||
}
|
||||
obj.foo = 'string'
|
||||
>obj.foo : Symbol(foo, Decl(0.js, 2, 13))
|
||||
@@ -48,7 +53,7 @@ obj.bar = undefined;
|
||||
>undefined : Symbol(undefined)
|
||||
|
||||
var k = obj.method1(0);
|
||||
>k : Symbol(k, Decl(0.js, 19, 3))
|
||||
>k : Symbol(k, Decl(0.js, 21, 3))
|
||||
>obj.method1 : Symbol(method1, Decl(0.js, 6, 12))
|
||||
>obj : Symbol(obj, Decl(0.js, 2, 5))
|
||||
>method1 : Symbol(method1, Decl(0.js, 6, 12))
|
||||
@@ -56,3 +61,8 @@ var k = obj.method1(0);
|
||||
obj.bar1 = "42";
|
||||
>obj : Symbol(obj, Decl(0.js, 2, 5))
|
||||
|
||||
obj.arrowFunc(0);
|
||||
>obj.arrowFunc : Symbol(arrowFunc, Decl(0.js, 14, 20))
|
||||
>obj : Symbol(obj, Decl(0.js, 2, 5))
|
||||
>arrowFunc : Symbol(arrowFunc, Decl(0.js, 14, 20))
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@ var lol = "hello Lol"
|
||||
>"hello Lol" : "hello Lol"
|
||||
|
||||
const obj = {
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; }
|
||||
>{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42,} : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; }
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; }
|
||||
>{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; }
|
||||
|
||||
/** @type {string|undefined} */
|
||||
foo: undefined,
|
||||
@@ -38,24 +38,33 @@ const obj = {
|
||||
>'b' + 'ar1' : string
|
||||
>'b' : "b"
|
||||
>'ar1' : "ar1"
|
||||
>42 : 42
|
||||
|
||||
/** @type {function(number): number} */
|
||||
arrowFunc: (num) => num + 42
|
||||
>arrowFunc : (arg0: number) => number
|
||||
>(num) => num + 42 : (num: any) => any
|
||||
>num : any
|
||||
>num + 42 : any
|
||||
>num : any
|
||||
>42 : 42
|
||||
}
|
||||
obj.foo = 'string'
|
||||
>obj.foo = 'string' : "string"
|
||||
>obj.foo : string | undefined
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; }
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; }
|
||||
>foo : string | undefined
|
||||
>'string' : "string"
|
||||
|
||||
obj.lol
|
||||
>obj.lol : string
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; }
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; }
|
||||
>lol : string
|
||||
|
||||
obj.bar = undefined;
|
||||
>obj.bar = undefined : undefined
|
||||
>obj.bar : string | undefined
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; }
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; }
|
||||
>bar : string | undefined
|
||||
>undefined : undefined
|
||||
|
||||
@@ -63,14 +72,21 @@ var k = obj.method1(0);
|
||||
>k : number
|
||||
>obj.method1(0) : number
|
||||
>obj.method1 : (arg0: number) => number
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; }
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; }
|
||||
>method1 : (arg0: number) => number
|
||||
>0 : 0
|
||||
|
||||
obj.bar1 = "42";
|
||||
>obj.bar1 = "42" : "42"
|
||||
>obj.bar1 : any
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; }
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; }
|
||||
>bar1 : any
|
||||
>"42" : "42"
|
||||
|
||||
obj.arrowFunc(0);
|
||||
>obj.arrowFunc(0) : number
|
||||
>obj.arrowFunc : (arg0: number) => number
|
||||
>obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; }
|
||||
>arrowFunc : (arg0: number) => number
|
||||
>0 : 0
|
||||
|
||||
|
||||
@@ -3,11 +3,15 @@ tests/cases/conformance/jsdoc/0.js(7,3): error TS2322: Type '(n1: any) => string
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsdoc/0.js(11,3): error TS2322: Type '(n1: any) => string' is not assignable to type '(arg0: number) => number'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/jsdoc/0.js(13,3): error TS2322: Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsdoc/0.js(17,5): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsdoc/0.js(13,3): error TS2322: Type '(num?: string) => string' is not assignable to type '(arg0: number) => number'.
|
||||
Types of parameters 'num' and 'arg0' are incompatible.
|
||||
Type 'number' is not assignable to type 'string | undefined'.
|
||||
tests/cases/conformance/jsdoc/0.js(15,3): error TS2322: Type 'undefined' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsdoc/0.js(19,5): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/jsdoc/0.js(22,22): error TS2345: Argument of type '"0"' is not assignable to parameter of type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsdoc/0.js (5 errors) ====
|
||||
==== tests/cases/conformance/jsdoc/0.js (7 errors) ====
|
||||
// @ts-check
|
||||
var lol;
|
||||
const obj = {
|
||||
@@ -27,6 +31,12 @@ tests/cases/conformance/jsdoc/0.js(17,5): error TS2322: Type 'number' is not ass
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '(n1: any) => string' is not assignable to type '(arg0: number) => number'.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
/** @type {function(number): number} */
|
||||
arrowFunc: (num="0") => num + 42,
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '(num?: string) => string' is not assignable to type '(arg0: number) => number'.
|
||||
!!! error TS2322: Types of parameters 'num' and 'arg0' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'.
|
||||
/** @type {string} */
|
||||
lol
|
||||
~~~
|
||||
@@ -36,4 +46,9 @@ tests/cases/conformance/jsdoc/0.js(17,5): error TS2322: Type 'number' is not ass
|
||||
/** @type {string} */
|
||||
var s = obj.method1(0);
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
/** @type {string} */
|
||||
var s1 = obj.method2("0");
|
||||
~~~
|
||||
!!! error TS2345: Argument of type '"0"' is not assignable to parameter of type 'number'.
|
||||
@@ -10,12 +10,17 @@ const obj = {
|
||||
},
|
||||
/** @type {function(number): number} */
|
||||
method2: (n1) => "lol",
|
||||
/** @type {function(number): number} */
|
||||
arrowFunc: (num="0") => num + 42,
|
||||
/** @type {string} */
|
||||
lol
|
||||
}
|
||||
lol = "string"
|
||||
/** @type {string} */
|
||||
var s = obj.method1(0);
|
||||
var s = obj.method1(0);
|
||||
|
||||
/** @type {string} */
|
||||
var s1 = obj.method2("0");
|
||||
|
||||
//// [0.js]
|
||||
// @ts-check
|
||||
@@ -29,9 +34,16 @@ var obj = {
|
||||
},
|
||||
/** @type {function(number): number} */
|
||||
method2: function (n1) { return "lol"; },
|
||||
/** @type {function(number): number} */
|
||||
arrowFunc: function (num) {
|
||||
if (num === void 0) { num = "0"; }
|
||||
return num + 42;
|
||||
},
|
||||
/** @type {string} */
|
||||
lol: lol
|
||||
};
|
||||
lol = "string";
|
||||
/** @type {string} */
|
||||
var s = obj.method1(0);
|
||||
/** @type {string} */
|
||||
var s1 = obj.method2("0");
|
||||
|
||||
@@ -18,9 +18,12 @@ const obj = {
|
||||
lol,
|
||||
/** @type {number} */
|
||||
['b' + 'ar1']: 42,
|
||||
/** @type {function(number): number} */
|
||||
arrowFunc: (num) => num + 42
|
||||
}
|
||||
obj.foo = 'string'
|
||||
obj.lol
|
||||
obj.bar = undefined;
|
||||
var k = obj.method1(0);
|
||||
obj.bar1 = "42";
|
||||
obj.bar1 = "42";
|
||||
obj.arrowFunc(0);
|
||||
@@ -14,9 +14,14 @@ const obj = {
|
||||
},
|
||||
/** @type {function(number): number} */
|
||||
method2: (n1) => "lol",
|
||||
/** @type {function(number): number} */
|
||||
arrowFunc: (num="0") => num + 42,
|
||||
/** @type {string} */
|
||||
lol
|
||||
}
|
||||
lol = "string"
|
||||
/** @type {string} */
|
||||
var s = obj.method1(0);
|
||||
var s = obj.method1(0);
|
||||
|
||||
/** @type {string} */
|
||||
var s1 = obj.method2("0");
|
||||
Reference in New Issue
Block a user