From 67d8c2768d3bffba90a19970f64aab6e9bb5d9df Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 10 Jun 2025 12:48:52 -0700 Subject: [PATCH 1/6] add `@this` support --- internal/parser/reparser.go | 28 ++++++++- .../compiler/thisInFunctionCallJs.errors.txt | 10 +-- .../compiler/thisInFunctionCallJs.symbols | 10 +++ .../thisInFunctionCallJs.symbols.diff | 12 +++- .../compiler/thisInFunctionCallJs.types | 24 +++---- .../constructorTagWithThisTag.symbols | 6 ++ .../constructorTagWithThisTag.symbols.diff | 12 ++-- .../constructorTagWithThisTag.types | 18 +++--- .../conformance/inferThis.errors.txt | 40 ------------ .../submodule/conformance/inferThis.symbols | 4 +- .../conformance/inferThis.symbols.diff | 4 +- .../submodule/conformance/inferThis.types | 28 ++++----- .../submodule/conformance/thisTag1.errors.txt | 20 ------ .../submodule/conformance/thisTag1.symbols | 3 + .../conformance/thisTag1.symbols.diff | 8 +-- .../submodule/conformance/thisTag1.types | 22 +++---- .../submodule/conformance/thisTag2.types | 4 +- .../submodule/conformance/thisTag3.errors.txt | 5 +- .../submodule/conformance/thisTag3.types | 4 +- .../thisInFunctionCallJs.errors.txt.diff | 36 ----------- .../compiler/thisInFunctionCallJs.types.diff | 52 ---------------- .../constructorTagWithThisTag.types.diff | 21 +------ .../conformance/inferThis.errors.txt.diff | 44 ------------- .../conformance/inferThis.types.diff | 62 ------------------- .../conformance/thisTag1.errors.txt.diff | 24 ------- .../conformance/thisTag1.types.diff | 47 -------------- .../conformance/thisTag2.types.diff | 13 ---- .../conformance/thisTag3.errors.txt.diff | 21 ------- .../conformance/thisTag3.types.diff | 4 +- 29 files changed, 131 insertions(+), 455 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/conformance/inferThis.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/inferThis.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index d2a8ccc812..6334a4e47f 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -265,6 +265,32 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } } } + case ast.KindJSDocThisTag: + if fun, ok := getFunctionLikeHost(parent); ok { + // Only add a this parameter if we don't already have one + params := fun.Parameters() + if len(params) == 0 || params[0].Name().Text() != "this" { + thisParam := p.factory.NewParameterDeclaration( + nil, /* decorators */ + nil, /* modifiers */ + p.factory.NewIdentifier("this"), + nil, /* questionToken */ + nil, /* type */ + nil, /* initializer */ + ) + thisParam.AsParameterDeclaration().Type = p.makeNewType(tag.AsJSDocThisTag().TypeExpression, thisParam) + thisParam.Loc = tag.AsJSDocThisTag().TagName.Loc + thisParam.Flags = p.contextFlags | ast.NodeFlagsReparsed + + newParams := p.nodeSlicePool.NewSlice(len(params) + 1) + newParams[0] = thisParam + for i, param := range params { + newParams[i+1] = param + } + + fun.FunctionLikeData().Parameters = p.newNodeList(thisParam.Loc, newParams) + } + } case ast.KindJSDocReturnTag: if fun, ok := getFunctionLikeHost(parent); ok { if fun.Type() == nil { @@ -319,7 +345,7 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } } } - // !!! other attached tags (@this, @satisfies) support goes here + // !!! other attached tags (@satisfies) support goes here } func (p *Parser) makeQuestionIfOptional(parameter *ast.JSDocParameterTag) *ast.Node { diff --git a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt index e00dbc28f1..d752c5ddc4 100644 --- a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.errors.txt @@ -1,10 +1,8 @@ /a.js(9,26): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. /a.js(15,31): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -/a.js(23,31): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -/a.js(31,26): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -==== /a.js (4 errors) ==== +==== /a.js (2 errors) ==== class Test { constructor() { /** @type {number[]} */ @@ -34,9 +32,6 @@ /** @this {Test} */ function (d) { console.log(d === this.data.length) - ~~~~ -!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -!!! related TS2738 /a.js:22:9: An outer value of 'this' is shadowed by this container. }, this) } @@ -45,9 +40,6 @@ /** @this {Test} */ function (d) { return d === this.data.length - ~~~~ -!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -!!! related TS2738 /a.js:30:9: An outer value of 'this' is shadowed by this container. }, this) } } diff --git a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.symbols b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.symbols index 85dc614666..5bfe9f806e 100644 --- a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.symbols +++ b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.symbols @@ -68,6 +68,11 @@ class Test { >console : Symbol(console, Decl(lib.dom.d.ts, --, --)) >log : Symbol(log, Decl(lib.dom.d.ts, --, --)) >d : Symbol(d, Decl(a.js, 21, 18)) +>this.data.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) +>this.data : Symbol(data, Decl(a.js, 1, 19)) +>this : Symbol((Missing), Decl(a.js, 20, 13)) +>data : Symbol(data, Decl(a.js, 1, 19)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) }, this) >this : Symbol(Test, Decl(a.js, 0, 0)) @@ -89,6 +94,11 @@ class Test { return d === this.data.length >d : Symbol(d, Decl(a.js, 29, 18)) +>this.data.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) +>this.data : Symbol(data, Decl(a.js, 1, 19)) +>this : Symbol((Missing), Decl(a.js, 28, 13)) +>data : Symbol(data, Decl(a.js, 1, 19)) +>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) }, this) >this : Symbol(Test, Decl(a.js, 0, 0)) diff --git a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.symbols.diff b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.symbols.diff index cc66a80b1f..78ff899241 100644 --- a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.symbols.diff @@ -89,6 +89,11 @@ ->this : Symbol(this) ->data : Symbol(Test.data, Decl(a.js, 1, 19)) ->length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) ++>this.data.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) ++>this.data : Symbol(data, Decl(a.js, 1, 19)) ++>this : Symbol((Missing), Decl(a.js, 20, 13)) ++>data : Symbol(data, Decl(a.js, 1, 19)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) }, this) >this : Symbol(Test, Decl(a.js, 0, 0)) @@ -111,7 +116,7 @@ /** @this {Test} */ function (d) { -@@= skipped -64, +59 lines =@@ +@@= skipped -64, +64 lines =@@ return d === this.data.length >d : Symbol(d, Decl(a.js, 29, 18)) @@ -120,6 +125,11 @@ ->this : Symbol(this) ->data : Symbol(Test.data, Decl(a.js, 1, 19)) ->length : Symbol(Array.length, Decl(lib.es5.d.ts, --, --)) ++>this.data.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) ++>this.data : Symbol(data, Decl(a.js, 1, 19)) ++>this : Symbol((Missing), Decl(a.js, 28, 13)) ++>data : Symbol(data, Decl(a.js, 1, 19)) ++>length : Symbol(length, Decl(lib.es5.d.ts, --, --)) }, this) >this : Symbol(Test, Decl(a.js, 0, 0)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.types b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.types index aa86beabe2..5b5f9828c4 100644 --- a/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.types +++ b/testdata/baselines/reference/submodule/compiler/thisInFunctionCallJs.types @@ -84,7 +84,7 @@ class Test { /** @this {Test} */ function (d) { ->function (d) { console.log(d === this.data.length) } : (d: number) => void +>function (d) { console.log(d === this.data.length) } : (this: Test, d: number) => void >d : number console.log(d === this.data.length) @@ -94,11 +94,11 @@ class Test { >log : (...data: any[]) => void >d === this.data.length : boolean >d : number ->this.data.length : any ->this.data : any ->this : any ->data : any ->length : any +>this.data.length : number +>this.data : number[] +>this : Test +>data : number[] +>length : number }, this) >this : this @@ -117,17 +117,17 @@ class Test { /** @this {Test} */ function (d) { ->function (d) { return d === this.data.length } : (d: number) => boolean +>function (d) { return d === this.data.length } : (this: Test, d: number) => boolean >d : number return d === this.data.length >d === this.data.length : boolean >d : number ->this.data.length : any ->this.data : any ->this : any ->data : any ->length : any +>this.data.length : number +>this.data : number[] +>this : Test +>data : number[] +>length : number }, this) >this : this diff --git a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.symbols b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.symbols index 43147dd22a..1b0cd017dd 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.symbols +++ b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.symbols @@ -10,5 +10,11 @@ function C() { >C : Symbol(C, Decl(classthisboth.js, 0, 0)) this.e = this.m + 1 +>this.e : Symbol(e, Decl(classthisboth.js, 2, 11)) +>this : Symbol((Missing), Decl(classthisboth.js, 2, 4)) +>e : Symbol(e, Decl(classthisboth.js, 2, 11)) +>this.m : Symbol(m, Decl(classthisboth.js, 2, 22)) +>this : Symbol((Missing), Decl(classthisboth.js, 2, 4)) +>m : Symbol(m, Decl(classthisboth.js, 2, 22)) } diff --git a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.symbols.diff b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.symbols.diff index 60f30f5ecd..5a60876231 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.symbols.diff @@ -1,13 +1,15 @@ --- old.constructorTagWithThisTag.symbols +++ new.constructorTagWithThisTag.symbols -@@= skipped -9, +9 lines =@@ - >C : Symbol(C, Decl(classthisboth.js, 0, 0)) +@@= skipped -10, +10 lines =@@ this.e = this.m + 1 -->this.e : Symbol(e, Decl(classthisboth.js, 2, 11)) + >this.e : Symbol(e, Decl(classthisboth.js, 2, 11)) ->this : Symbol(this) ->e : Symbol(C.e, Decl(classthisboth.js, 5, 14)) -->this.m : Symbol(m, Decl(classthisboth.js, 2, 22)) ++>this : Symbol((Missing), Decl(classthisboth.js, 2, 4)) ++>e : Symbol(e, Decl(classthisboth.js, 2, 11)) + >this.m : Symbol(m, Decl(classthisboth.js, 2, 22)) ->this : Symbol(this) -->m : Symbol(m, Decl(classthisboth.js, 2, 22)) ++>this : Symbol((Missing), Decl(classthisboth.js, 2, 4)) + >m : Symbol(m, Decl(classthisboth.js, 2, 22)) } diff --git a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.types b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.types index ee61e32e97..04c04bde03 100644 --- a/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.types +++ b/testdata/baselines/reference/submodule/conformance/constructorTagWithThisTag.types @@ -7,17 +7,17 @@ * this-tag should win, both 'e' and 'm' should be defined. */ function C() { ->C : () => void +>C : (this: { e: number; m: number; }) => void this.e = this.m + 1 ->this.e = this.m + 1 : any ->this.e : any ->this : any ->e : any ->this.m + 1 : any ->this.m : any ->this : any ->m : any +>this.e = this.m + 1 : number +>this.e : number +>this : { e: number; m: number; } +>e : number +>this.m + 1 : number +>this.m : number +>this : { e: number; m: number; } +>m : number >1 : 1 } diff --git a/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt b/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt deleted file mode 100644 index fcb93bba30..0000000000 --- a/testdata/baselines/reference/submodule/conformance/inferThis.errors.txt +++ /dev/null @@ -1,40 +0,0 @@ -/a.js(8,9): error TS2322: Type 'typeof C' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof C'. -/a.js(17,9): error TS2322: Type 'this' is not assignable to type 'T'. - 'T' could be instantiated with an arbitrary type which could be unrelated to 'this'. - - -==== /a.js (2 errors) ==== - export class C { - /** - * @template T - * @this {T} - * @return {T} - */ - static a() { - return this; - ~~~~~~ -!!! error TS2322: Type 'typeof C' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof C'. - } - - /** - * @template T - * @this {T} - * @return {T} - */ - b() { - return this; - ~~~~~~ -!!! error TS2322: Type 'this' is not assignable to type 'T'. -!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'this'. - } - } - - const a = C.a(); - a; // typeof C - - const c = new C(); - const b = c.b(); - b; // C - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/inferThis.symbols b/testdata/baselines/reference/submodule/conformance/inferThis.symbols index cd74badd8f..0d16167492 100644 --- a/testdata/baselines/reference/submodule/conformance/inferThis.symbols +++ b/testdata/baselines/reference/submodule/conformance/inferThis.symbols @@ -13,7 +13,7 @@ export class C { >a : Symbol(a, Decl(a.js, 0, 16)) return this; ->this : Symbol(C, Decl(a.js, 0, 0)) +>this : Symbol((Missing), Decl(a.js, 3, 8)) } /** @@ -25,7 +25,7 @@ export class C { >b : Symbol(b, Decl(a.js, 8, 5)) return this; ->this : Symbol(C, Decl(a.js, 0, 0)) +>this : Symbol((Missing), Decl(a.js, 12, 8)) } } diff --git a/testdata/baselines/reference/submodule/conformance/inferThis.symbols.diff b/testdata/baselines/reference/submodule/conformance/inferThis.symbols.diff index d64ec77c0d..f78d012533 100644 --- a/testdata/baselines/reference/submodule/conformance/inferThis.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/inferThis.symbols.diff @@ -9,7 +9,7 @@ return this; ->this : Symbol(this) -+>this : Symbol(C, Decl(a.js, 0, 0)) ++>this : Symbol((Missing), Decl(a.js, 3, 8)) } /** @@ -22,7 +22,7 @@ return this; ->this : Symbol(this) -+>this : Symbol(C, Decl(a.js, 0, 0)) ++>this : Symbol((Missing), Decl(a.js, 12, 8)) } } diff --git a/testdata/baselines/reference/submodule/conformance/inferThis.types b/testdata/baselines/reference/submodule/conformance/inferThis.types index 2a0f14878e..bab430c389 100644 --- a/testdata/baselines/reference/submodule/conformance/inferThis.types +++ b/testdata/baselines/reference/submodule/conformance/inferThis.types @@ -10,10 +10,10 @@ export class C { * @return {T} */ static a() { ->a : () => T +>a : (this: T) => T return this; ->this : typeof C +>this : T } /** @@ -22,22 +22,22 @@ export class C { * @return {T} */ b() { ->b : () => T +>b : (this: T) => T return this; ->this : this +>this : T } } const a = C.a(); ->a : unknown ->C.a() : unknown ->C.a : () => T +>a : typeof C +>C.a() : typeof C +>C.a : (this: T) => T >C : typeof C ->a : () => T +>a : (this: T) => T a; // typeof C ->a : unknown +>a : typeof C const c = new C(); >c : C @@ -45,12 +45,12 @@ const c = new C(); >C : typeof C const b = c.b(); ->b : unknown ->c.b() : unknown ->c.b : () => T +>b : C +>c.b() : C +>c.b : (this: T) => T >c : C ->b : () => T +>b : (this: T) => T b; // C ->b : unknown +>b : C diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt deleted file mode 100644 index 97c3329beb..0000000000 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.errors.txt +++ /dev/null @@ -1,20 +0,0 @@ -a.js(6,12): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. - - -==== a.js (1 errors) ==== - /** @this {{ n: number }} Mount Holyoke Preparatory School - * @param {string} s - * @return {number} - */ - function f(s) { - return this.n + s.length - ~~~~ -!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. - } - - const o = { - f, - n: 1 - } - o.f('hi') - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.symbols b/testdata/baselines/reference/submodule/conformance/thisTag1.symbols index 123d62d3cd..7f4d8f28ed 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.symbols +++ b/testdata/baselines/reference/submodule/conformance/thisTag1.symbols @@ -10,6 +10,9 @@ function f(s) { >s : Symbol(s, Decl(a.js, 4, 11)) return this.n + s.length +>this.n : Symbol(n, Decl(a.js, 0, 12)) +>this : Symbol((Missing), Decl(a.js, 0, 5)) +>n : Symbol(n, Decl(a.js, 0, 12)) >s.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(a.js, 4, 11)) >length : Symbol(length, Decl(lib.es5.d.ts, --, --)) diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.symbols.diff b/testdata/baselines/reference/submodule/conformance/thisTag1.symbols.diff index dd070655e0..ca875e1cec 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/thisTag1.symbols.diff @@ -1,12 +1,12 @@ --- old.thisTag1.symbols +++ new.thisTag1.symbols -@@= skipped -9, +9 lines =@@ - >s : Symbol(s, Decl(a.js, 4, 11)) +@@= skipped -10, +10 lines =@@ return this.n + s.length -->this.n : Symbol(n, Decl(a.js, 0, 12)) + >this.n : Symbol(n, Decl(a.js, 0, 12)) ->this : Symbol(this) -->n : Symbol(n, Decl(a.js, 0, 12)) ++>this : Symbol((Missing), Decl(a.js, 0, 5)) + >n : Symbol(n, Decl(a.js, 0, 12)) ->s.length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) +>s.length : Symbol(length, Decl(lib.es5.d.ts, --, --)) >s : Symbol(s, Decl(a.js, 4, 11)) diff --git a/testdata/baselines/reference/submodule/conformance/thisTag1.types b/testdata/baselines/reference/submodule/conformance/thisTag1.types index 9643db11d1..00893c7608 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag1.types +++ b/testdata/baselines/reference/submodule/conformance/thisTag1.types @@ -6,25 +6,25 @@ * @return {number} */ function f(s) { ->f : (s: string) => number +>f : (this: { n: number; }, s: string) => number >s : string return this.n + s.length ->this.n + s.length : any ->this.n : any ->this : any ->n : any +>this.n + s.length : number +>this.n : number +>this : { n: number; } +>n : number >s.length : number >s : string >length : number } const o = { ->o : { f: (s: string) => number; n: number; } ->{ f, n: 1} : { f: (s: string) => number; n: number; } +>o : { f: (this: { n: number; }, s: string) => number; n: number; } +>{ f, n: 1} : { f: (this: { n: number; }, s: string) => number; n: number; } f, ->f : (s: string) => number +>f : (this: { n: number; }, s: string) => number n: 1 >n : number @@ -32,8 +32,8 @@ const o = { } o.f('hi') >o.f('hi') : number ->o.f : (s: string) => number ->o : { f: (s: string) => number; n: number; } ->f : (s: string) => number +>o.f : (this: { n: number; }, s: string) => number +>o : { f: (this: { n: number; }, s: string) => number; n: number; } +>f : (this: { n: number; }, s: string) => number >'hi' : "hi" diff --git a/testdata/baselines/reference/submodule/conformance/thisTag2.types b/testdata/baselines/reference/submodule/conformance/thisTag2.types index 948118dc86..e4851664c3 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag2.types +++ b/testdata/baselines/reference/submodule/conformance/thisTag2.types @@ -3,9 +3,9 @@ === a.js === /** @this {string} */ export function f1() {} ->f1 : () => void +>f1 : (this: string) => void /** @this */ export function f2() {} ->f2 : () => void +>f2 : (this: any) => void diff --git a/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt index 5815a12963..81623b16ce 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/thisTag3.errors.txt @@ -1,7 +1,8 @@ +/a.js(7,9): error TS2730: An arrow function cannot have a 'this' parameter. /a.js(10,21): error TS2339: Property 'fn' does not exist on type 'C'. -==== /a.js (1 errors) ==== +==== /a.js (2 errors) ==== /** * @typedef {{fn(a: string): void}} T */ @@ -9,6 +10,8 @@ class C { /** * @this {T} + ~~~~ +!!! error TS2730: An arrow function cannot have a 'this' parameter. * @param {string} a */ p = (a) => this.fn("" + a); diff --git a/testdata/baselines/reference/submodule/conformance/thisTag3.types b/testdata/baselines/reference/submodule/conformance/thisTag3.types index 7a0779ce9c..b62ff516aa 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTag3.types +++ b/testdata/baselines/reference/submodule/conformance/thisTag3.types @@ -13,8 +13,8 @@ class C { * @param {string} a */ p = (a) => this.fn("" + a); ->p : (a: string) => any ->(a) => this.fn("" + a) : (a: string) => any +>p : (this: { fn(a: string): void; }, a: string) => any +>(a) => this.fn("" + a) : (this: { fn(a: string): void; }, a: string) => any >a : string >this.fn("" + a) : any >this.fn : any diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff deleted file mode 100644 index 64df6affc6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.errors.txt.diff +++ /dev/null @@ -1,36 +0,0 @@ ---- old.thisInFunctionCallJs.errors.txt -+++ new.thisInFunctionCallJs.errors.txt -@@= skipped -0, +0 lines =@@ - /a.js(9,26): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. - /a.js(15,31): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -- -- --==== /a.js (2 errors) ==== -+/a.js(23,31): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+/a.js(31,26): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+ -+ -+==== /a.js (4 errors) ==== - class Test { - constructor() { - /** @type {number[]} */ -@@= skipped -31, +33 lines =@@ - /** @this {Test} */ - function (d) { - console.log(d === this.data.length) -+ ~~~~ -+!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+!!! related TS2738 /a.js:22:9: An outer value of 'this' is shadowed by this container. - }, this) - } - -@@= skipped -8, +11 lines =@@ - /** @this {Test} */ - function (d) { - return d === this.data.length -+ ~~~~ -+!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+!!! related TS2738 /a.js:30:9: An outer value of 'this' is shadowed by this container. - }, this) - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.types.diff deleted file mode 100644 index e6d1ca987f..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/thisInFunctionCallJs.types.diff +++ /dev/null @@ -1,52 +0,0 @@ ---- old.thisInFunctionCallJs.types -+++ new.thisInFunctionCallJs.types -@@= skipped -83, +83 lines =@@ - - /** @this {Test} */ - function (d) { -->function (d) { console.log(d === this.data.length) } : (this: Test, d: number) => void -+>function (d) { console.log(d === this.data.length) } : (d: number) => void - >d : number - - console.log(d === this.data.length) -@@= skipped -10, +10 lines =@@ - >log : (...data: any[]) => void - >d === this.data.length : boolean - >d : number -->this.data.length : number -->this.data : number[] -->this : Test -->data : number[] -->length : number -+>this.data.length : any -+>this.data : any -+>this : any -+>data : any -+>length : any - - }, this) - >this : this -@@= skipped -23, +23 lines =@@ - - /** @this {Test} */ - function (d) { -->function (d) { return d === this.data.length } : (this: Test, d: number) => boolean -+>function (d) { return d === this.data.length } : (d: number) => boolean - >d : number - - return d === this.data.length - >d === this.data.length : boolean - >d : number -->this.data.length : number -->this.data : number[] -->this : Test -->data : number[] -->length : number -+>this.data.length : any -+>this.data : any -+>this : any -+>data : any -+>length : any - - }, this) - >this : this \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.types.diff index a387f3f4a5..2a4233801f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/constructorTagWithThisTag.types.diff @@ -5,24 +5,7 @@ */ function C() { ->C : typeof C -+>C : () => void ++>C : (this: { e: number; m: number; }) => void this.e = this.m + 1 -->this.e = this.m + 1 : number -->this.e : number -->this : { e: number; m: number; } -->e : number -->this.m + 1 : number -->this.m : number -->this : { e: number; m: number; } -->m : number -+>this.e = this.m + 1 : any -+>this.e : any -+>this : any -+>e : any -+>this.m + 1 : any -+>this.m : any -+>this : any -+>m : any - >1 : 1 - } + >this.e = this.m + 1 : number \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff deleted file mode 100644 index 583b8a4509..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.errors.txt.diff +++ /dev/null @@ -1,44 +0,0 @@ ---- old.inferThis.errors.txt -+++ new.inferThis.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(8,9): error TS2322: Type 'typeof C' is not assignable to type 'T'. -+ 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof C'. -+/a.js(17,9): error TS2322: Type 'this' is not assignable to type 'T'. -+ 'T' could be instantiated with an arbitrary type which could be unrelated to 'this'. -+ -+ -+==== /a.js (2 errors) ==== -+ export class C { -+ /** -+ * @template T -+ * @this {T} -+ * @return {T} -+ */ -+ static a() { -+ return this; -+ ~~~~~~ -+!!! error TS2322: Type 'typeof C' is not assignable to type 'T'. -+!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'typeof C'. -+ } -+ -+ /** -+ * @template T -+ * @this {T} -+ * @return {T} -+ */ -+ b() { -+ return this; -+ ~~~~~~ -+!!! error TS2322: Type 'this' is not assignable to type 'T'. -+!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'this'. -+ } -+ } -+ -+ const a = C.a(); -+ a; // typeof C -+ -+ const c = new C(); -+ const b = c.b(); -+ b; // C -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.types.diff deleted file mode 100644 index a190113349..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/inferThis.types.diff +++ /dev/null @@ -1,62 +0,0 @@ ---- old.inferThis.types -+++ new.inferThis.types -@@= skipped -9, +9 lines =@@ - * @return {T} - */ - static a() { -->a : (this: T) => T -+>a : () => T - - return this; -->this : T -+>this : typeof C - } - - /** -@@= skipped -12, +12 lines =@@ - * @return {T} - */ - b() { -->b : (this: T) => T -+>b : () => T - - return this; -->this : T -+>this : this - } - } - - const a = C.a(); -->a : typeof C -->C.a() : typeof C -->C.a : (this: T) => T -+>a : unknown -+>C.a() : unknown -+>C.a : () => T - >C : typeof C -->a : (this: T) => T -+>a : () => T - - a; // typeof C -->a : typeof C -+>a : unknown - - const c = new C(); - >c : C -@@= skipped -23, +23 lines =@@ - >C : typeof C - - const b = c.b(); -->b : C -->c.b() : C -->c.b : (this: T) => T -+>b : unknown -+>c.b() : unknown -+>c.b : () => T - >c : C -->b : (this: T) => T -+>b : () => T - - b; // C -->b : C -+>b : unknown diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff deleted file mode 100644 index 61974e0794..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.errors.txt.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.thisTag1.errors.txt -+++ new.thisTag1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+a.js(6,12): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+ -+ -+==== a.js (1 errors) ==== -+ /** @this {{ n: number }} Mount Holyoke Preparatory School -+ * @param {string} s -+ * @return {number} -+ */ -+ function f(s) { -+ return this.n + s.length -+ ~~~~ -+!!! error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation. -+ } -+ -+ const o = { -+ f, -+ n: 1 -+ } -+ o.f('hi') -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.types.diff deleted file mode 100644 index b611b5fde8..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag1.types.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.thisTag1.types -+++ new.thisTag1.types -@@= skipped -5, +5 lines =@@ - * @return {number} - */ - function f(s) { -->f : (this: { n: number; }, s: string) => number -+>f : (s: string) => number - >s : string - - return this.n + s.length -->this.n + s.length : number -->this.n : number -->this : { n: number; } -->n : number -+>this.n + s.length : any -+>this.n : any -+>this : any -+>n : any - >s.length : number - >s : string - >length : number - } - - const o = { -->o : { f: (this: { n: number; }, s: string) => number; n: number; } -->{ f, n: 1} : { f: (this: { n: number; }, s: string) => number; n: number; } -+>o : { f: (s: string) => number; n: number; } -+>{ f, n: 1} : { f: (s: string) => number; n: number; } - - f, -->f : (this: { n: number; }, s: string) => number -+>f : (s: string) => number - - n: 1 - >n : number -@@= skipped -26, +26 lines =@@ - } - o.f('hi') - >o.f('hi') : number -->o.f : (this: { n: number; }, s: string) => number -->o : { f: (this: { n: number; }, s: string) => number; n: number; } -->f : (this: { n: number; }, s: string) => number -+>o.f : (s: string) => number -+>o : { f: (s: string) => number; n: number; } -+>f : (s: string) => number - >'hi' : "hi" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.types.diff deleted file mode 100644 index 99d7f4966c..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag2.types.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.thisTag2.types -+++ new.thisTag2.types -@@= skipped -2, +2 lines =@@ - === a.js === - /** @this {string} */ - export function f1() {} -->f1 : (this: string) => void -+>f1 : () => void - - /** @this */ - export function f2() {} -->f2 : (this: any) => void -+>f2 : () => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff deleted file mode 100644 index e71461d3b2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.errors.txt.diff +++ /dev/null @@ -1,21 +0,0 @@ ---- old.thisTag3.errors.txt -+++ new.thisTag3.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(7,9): error TS2730: An arrow function cannot have a 'this' parameter. - /a.js(10,21): error TS2339: Property 'fn' does not exist on type 'C'. - - --==== /a.js (2 errors) ==== -+==== /a.js (1 errors) ==== - /** - * @typedef {{fn(a: string): void}} T - */ -@@= skipped -9, +8 lines =@@ - class C { - /** - * @this {T} -- ~~~~ --!!! error TS2730: An arrow function cannot have a 'this' parameter. - * @param {string} a - */ - p = (a) => this.fn("" + a); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff index 614ee46645..4e89799208 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/thisTag3.types.diff @@ -6,8 +6,8 @@ p = (a) => this.fn("" + a); ->p : (this: T, a: string) => any ->(a) => this.fn("" + a) : (this: T, a: string) => any -+>p : (a: string) => any -+>(a) => this.fn("" + a) : (a: string) => any ++>p : (this: { fn(a: string): void; }, a: string) => any ++>(a) => this.fn("" + a) : (this: { fn(a: string): void; }, a: string) => any >a : string >this.fn("" + a) : any >this.fn : any \ No newline at end of file From f79f58d039f5226c82d283bb519df33d191be663 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 10 Jun 2025 14:34:27 -0700 Subject: [PATCH 2/6] Add satisfies tag This is the last hosted tag. Just callback is left. --- internal/parser/reparser.go | 67 +++++++++++-------- .../checkJsdocSatisfiesTag1.symbols | 11 --- .../checkJsdocSatisfiesTag1.symbols.diff | 38 +++++++++-- .../conformance/checkJsdocSatisfiesTag1.types | 34 +--------- .../checkJsdocSatisfiesTag10.errors.txt | 21 ------ .../checkJsdocSatisfiesTag10.symbols | 6 -- .../checkJsdocSatisfiesTag10.symbols.diff | 15 ++++- .../checkJsdocSatisfiesTag10.types | 10 --- .../checkJsdocSatisfiesTag11.types | 1 - .../checkJsdocSatisfiesTag14.symbols | 1 - .../checkJsdocSatisfiesTag14.symbols.diff | 7 ++ .../checkJsdocSatisfiesTag14.types | 3 - .../checkJsdocSatisfiesTag2.symbols | 8 --- .../checkJsdocSatisfiesTag2.symbols.diff | 16 +++++ .../conformance/checkJsdocSatisfiesTag2.types | 23 +------ .../checkJsdocSatisfiesTag3.errors.txt | 18 ----- .../checkJsdocSatisfiesTag3.symbols | 8 --- .../checkJsdocSatisfiesTag3.symbols.diff | 19 ++++++ .../conformance/checkJsdocSatisfiesTag3.types | 14 +--- .../checkJsdocSatisfiesTag4.symbols | 3 +- .../checkJsdocSatisfiesTag4.symbols.diff | 15 +++++ .../conformance/checkJsdocSatisfiesTag4.types | 4 -- .../checkJsdocSatisfiesTag5.symbols | 7 -- .../checkJsdocSatisfiesTag5.symbols.diff | 18 +++++ .../conformance/checkJsdocSatisfiesTag5.types | 12 +--- .../checkJsdocSatisfiesTag6.errors.txt | 21 ------ .../checkJsdocSatisfiesTag6.symbols | 1 - .../checkJsdocSatisfiesTag6.symbols.diff | 6 +- .../conformance/checkJsdocSatisfiesTag6.types | 3 - .../checkJsdocSatisfiesTag7.errors.txt | 21 ------ .../checkJsdocSatisfiesTag7.symbols | 6 -- .../checkJsdocSatisfiesTag7.symbols.diff | 15 ++++- .../conformance/checkJsdocSatisfiesTag7.types | 10 --- .../checkJsdocSatisfiesTag8.symbols | 4 -- .../checkJsdocSatisfiesTag8.symbols.diff | 12 ++++ .../conformance/checkJsdocSatisfiesTag8.types | 11 +-- .../checkJsdocSatisfiesTag9.symbols | 15 ----- .../checkJsdocSatisfiesTag9.symbols.diff | 24 +++++++ .../conformance/checkJsdocSatisfiesTag9.types | 28 -------- .../checkJsdocSatisfiesTag1.types.diff | 66 ++++++++++++++---- .../checkJsdocSatisfiesTag10.types.diff | 23 +++++++ .../checkJsdocSatisfiesTag11.types.diff | 7 ++ .../checkJsdocSatisfiesTag14.types.diff | 9 +++ .../checkJsdocSatisfiesTag2.types.diff | 33 ++++----- .../checkJsdocSatisfiesTag3.errors.txt.diff | 26 ------- .../checkJsdocSatisfiesTag3.types.diff | 20 ++---- .../checkJsdocSatisfiesTag4.types.diff | 17 +++++ .../checkJsdocSatisfiesTag5.types.diff | 25 +++---- .../checkJsdocSatisfiesTag6.types.diff | 12 ++++ .../checkJsdocSatisfiesTag7.types.diff | 23 +++++++ .../checkJsdocSatisfiesTag8.types.diff | 16 +++-- .../checkJsdocSatisfiesTag9.types.diff | 39 +++++++++++ 52 files changed, 446 insertions(+), 426 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols.diff create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols.diff create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols.diff create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols.diff create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff create mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 6334a4e47f..f3d2495d18 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -224,10 +224,10 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } } else if parent.Kind == ast.KindReturnStatement { ret := parent.AsReturnStatement() - ret.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), ret.Expression) + ret.Expression = p.makeNewCast(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), ret.Expression, true /*isAssertion*/) } else if parent.Kind == ast.KindParenthesizedExpression { paren := parent.AsParenthesizedExpression() - paren.Expression = p.makeNewTypeAssertion(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), paren.Expression) + paren.Expression = p.makeNewCast(p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, nil), paren.Expression, true /*isAssertion*/) } else if parent.Kind == ast.KindExpressionStatement && parent.AsExpressionStatement().Expression.Kind == ast.KindBinaryExpression { bin := parent.AsExpressionStatement().Expression.AsBinaryExpression() @@ -235,6 +235,11 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) bin.Type = p.makeNewType(tag.AsJSDocTypeTag().TypeExpression, parent.AsExpressionStatement().Expression) } } + case ast.KindJSDocSatisfiesTag: + if parent.Kind == ast.KindParenthesizedExpression { + paren := parent.AsParenthesizedExpression() + paren.Expression = p.makeNewCast(p.makeNewType(tag.AsJSDocSatisfiesTag().TypeExpression, nil), paren.Expression, false /*isAssertion*/) + } case ast.KindJSDocTemplateTag: if fun, ok := getFunctionLikeHost(parent); ok { if fun.TypeParameters() == nil { @@ -266,31 +271,31 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } } case ast.KindJSDocThisTag: - if fun, ok := getFunctionLikeHost(parent); ok { - // Only add a this parameter if we don't already have one - params := fun.Parameters() - if len(params) == 0 || params[0].Name().Text() != "this" { - thisParam := p.factory.NewParameterDeclaration( - nil, /* decorators */ - nil, /* modifiers */ - p.factory.NewIdentifier("this"), - nil, /* questionToken */ - nil, /* type */ - nil, /* initializer */ - ) + if fun, ok := getFunctionLikeHost(parent); ok { + // Only add a this parameter if we don't already have one + params := fun.Parameters() + if len(params) == 0 || params[0].Name().Text() != "this" { + thisParam := p.factory.NewParameterDeclaration( + nil, /* decorators */ + nil, /* modifiers */ + p.factory.NewIdentifier("this"), + nil, /* questionToken */ + nil, /* type */ + nil, /* initializer */ + ) thisParam.AsParameterDeclaration().Type = p.makeNewType(tag.AsJSDocThisTag().TypeExpression, thisParam) - thisParam.Loc = tag.AsJSDocThisTag().TagName.Loc - thisParam.Flags = p.contextFlags | ast.NodeFlagsReparsed - - newParams := p.nodeSlicePool.NewSlice(len(params) + 1) - newParams[0] = thisParam - for i, param := range params { - newParams[i+1] = param - } - - fun.FunctionLikeData().Parameters = p.newNodeList(thisParam.Loc, newParams) - } - } + thisParam.Loc = tag.AsJSDocThisTag().TagName.Loc + thisParam.Flags = p.contextFlags | ast.NodeFlagsReparsed + + newParams := p.nodeSlicePool.NewSlice(len(params) + 1) + newParams[0] = thisParam + for i, param := range params { + newParams[i+1] = param + } + + fun.FunctionLikeData().Parameters = p.newNodeList(thisParam.Loc, newParams) + } + } case ast.KindJSDocReturnTag: if fun, ok := getFunctionLikeHost(parent); ok { if fun.Type() == nil { @@ -345,7 +350,6 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } } } - // !!! other attached tags (@satisfies) support goes here } func (p *Parser) makeQuestionIfOptional(parameter *ast.JSDocParameterTag) *ast.Node { @@ -392,8 +396,13 @@ func getFunctionLikeHost(host *ast.Node) (*ast.Node, bool) { return nil, false } -func (p *Parser) makeNewTypeAssertion(t *ast.TypeNode, e *ast.Node) *ast.Node { - assert := p.factory.NewTypeAssertion(t, e) +func (p *Parser) makeNewCast(t *ast.TypeNode, e *ast.Node, isAssertion bool) *ast.Node { + var assert *ast.Node + if isAssertion { + assert = p.factory.NewTypeAssertion(t, e) + } else { + assert = p.factory.NewSatisfiesExpression(e, t) + } assert.Flags = p.contextFlags | ast.NodeFlagsReparsed assert.Loc = core.NewTextRange(e.Pos(), e.End()) return assert diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols index 41e26adfcd..54ed0c447e 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols @@ -22,12 +22,9 @@ const t1 = /** @satisfies {T1} */ ({ a: 1 }); >t1 : Symbol(t1, Decl(a.js, 19, 5)) ->a : Symbol(a, Decl(a.js, 19, 36)) const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); >t2 : Symbol(t2, Decl(a.js, 20, 5)) ->a : Symbol(a, Decl(a.js, 20, 36)) ->b : Symbol(b, Decl(a.js, 20, 42)) const t3 = /** @satisfies {T1} */ ({}); >t3 : Symbol(t3, Decl(a.js, 21, 5)) @@ -35,25 +32,17 @@ const t3 = /** @satisfies {T1} */ ({}); /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : Symbol(t4, Decl(a.js, 24, 5)) ->a : Symbol(a, Decl(a.js, 24, 36)) /** @type {(m: string) => string} */ const t5 = /** @satisfies {T3} */((m) => m.substring(0)); >t5 : Symbol(t5, Decl(a.js, 27, 5)) ->m : Symbol(m, Decl(a.js, 27, 35)) ->m.substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) ->m : Symbol(m, Decl(a.js, 27, 35)) ->substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) const t6 = /** @satisfies {[number, number]} */ ([1, 2]); >t6 : Symbol(t6, Decl(a.js, 28, 5)) const t7 = /** @satisfies {T4} */ ({ a: 'test' }); >t7 : Symbol(t7, Decl(a.js, 29, 5)) ->a : Symbol(a, Decl(a.js, 29, 36)) const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); >t8 : Symbol(t8, Decl(a.js, 30, 5)) ->a : Symbol(a, Decl(a.js, 30, 36)) ->b : Symbol(b, Decl(a.js, 30, 47)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff index 70be0b72f5..7308c877a9 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff @@ -1,14 +1,40 @@ --- old.checkJsdocSatisfiesTag1.symbols +++ new.checkJsdocSatisfiesTag1.symbols -@@= skipped -40, +40 lines =@@ +@@= skipped -21, +21 lines =@@ + + const t1 = /** @satisfies {T1} */ ({ a: 1 }); + >t1 : Symbol(t1, Decl(a.js, 19, 5)) +->a : Symbol(a, Decl(a.js, 19, 36)) + + const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); + >t2 : Symbol(t2, Decl(a.js, 20, 5)) +->a : Symbol(a, Decl(a.js, 20, 36)) +->b : Symbol(b, Decl(a.js, 20, 42)) + + const t3 = /** @satisfies {T1} */ ({}); + >t3 : Symbol(t3, Decl(a.js, 21, 5)) +@@= skipped -13, +10 lines =@@ + /** @type {T2} */ + const t4 = /** @satisfies {T2} */ ({ a: "a" }); + >t4 : Symbol(t4, Decl(a.js, 24, 5)) +->a : Symbol(a, Decl(a.js, 24, 36)) + + /** @type {(m: string) => string} */ const t5 = /** @satisfies {T3} */((m) => m.substring(0)); >t5 : Symbol(t5, Decl(a.js, 27, 5)) - >m : Symbol(m, Decl(a.js, 27, 35)) +->m : Symbol(m, Decl(a.js, 27, 35)) ->m.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --)) -+>m.substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) - >m : Symbol(m, Decl(a.js, 27, 35)) +->m : Symbol(m, Decl(a.js, 27, 35)) ->substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --)) -+>substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) const t6 = /** @satisfies {[number, number]} */ ([1, 2]); - >t6 : Symbol(t6, Decl(a.js, 28, 5)) \ No newline at end of file + >t6 : Symbol(t6, Decl(a.js, 28, 5)) + + const t7 = /** @satisfies {T4} */ ({ a: 'test' }); + >t7 : Symbol(t7, Decl(a.js, 29, 5)) +->a : Symbol(a, Decl(a.js, 29, 36)) + + const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); + >t8 : Symbol(t8, Decl(a.js, 30, 5)) +->a : Symbol(a, Decl(a.js, 30, 36)) +->b : Symbol(b, Decl(a.js, 30, 47)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types index 565314abff..494de15507 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types @@ -23,64 +23,34 @@ const t1 = /** @satisfies {T1} */ ({ a: 1 }); >t1 : { a: number; } >({ a: 1 }) : { a: number; } ->{ a: 1 } : { a: number; } ->a : number ->1 : 1 const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); >t2 : { a: number; b: number; } >({ a: 1, b: 1 }) : { a: number; b: number; } ->{ a: 1, b: 1 } : { a: number; b: number; } ->a : number ->1 : 1 ->b : number ->1 : 1 const t3 = /** @satisfies {T1} */ ({}); >t3 : {} >({}) : {} ->{} : {} /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : T2 >({ a: "a" }) : { a: string; } ->{ a: "a" } : { a: string; } ->a : string ->"a" : "a" /** @type {(m: string) => string} */ const t5 = /** @satisfies {T3} */((m) => m.substring(0)); >t5 : (m: string) => string >((m) => m.substring(0)) : (m: string) => string ->(m) => m.substring(0) : (m: string) => string ->m : string ->m.substring(0) : string ->m.substring : (start: number, end?: number) => string ->m : string ->substring : (start: number, end?: number) => string ->0 : 0 const t6 = /** @satisfies {[number, number]} */ ([1, 2]); ->t6 : number[] ->([1, 2]) : number[] ->[1, 2] : number[] ->1 : 1 ->2 : 2 +>t6 : [number, number] +>([1, 2]) : [number, number] const t7 = /** @satisfies {T4} */ ({ a: 'test' }); >t7 : { a: string; } >({ a: 'test' }) : { a: string; } ->{ a: 'test' } : { a: string; } ->a : string ->'test' : "test" const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); >t8 : { a: string; b: string; } >({ a: 'test', b: 'test' }) : { a: string; b: string; } ->{ a: 'test', b: 'test' } : { a: string; b: string; } ->a : string ->'test' : "test" ->b : string ->'test' : "test" diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt deleted file mode 100644 index c6a17d12f4..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -/a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. - - -==== /a.js (1 errors) ==== - /** @typedef {"a" | "b" | "c" | "d"} Keys */ - - const p = /** @satisfies {Partial>} */ ({ - a: 0, - b: "hello", - x: 8 // Should error, 'x' isn't in 'Keys' - }); - - // Should be OK -- retain info that a is number and b is string - let a = p.a.toFixed(); - let b = p.b.substring(1); - - // Should error even though 'd' is in 'Keys' - let d = p.d; - ~ -!!! error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols index 3e073f9b5c..2a1286a15b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols @@ -7,14 +7,8 @@ const p = /** @satisfies {Partial>} */ ({ >p : Symbol(p, Decl(a.js, 2, 5)) a: 0, ->a : Symbol(a, Decl(a.js, 2, 63)) - b: "hello", ->b : Symbol(b, Decl(a.js, 3, 9)) - x: 8 // Should error, 'x' isn't in 'Keys' ->x : Symbol(x, Decl(a.js, 4, 15)) - }); // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols.diff index ef04a47cdd..8bc6ad4de6 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols.diff @@ -1,6 +1,19 @@ --- old.checkJsdocSatisfiesTag10.symbols +++ new.checkJsdocSatisfiesTag10.symbols -@@= skipped -19, +19 lines =@@ +@@= skipped -6, +6 lines =@@ + >p : Symbol(p, Decl(a.js, 2, 5)) + + a: 0, +->a : Symbol(a, Decl(a.js, 2, 63)) +- + b: "hello", +->b : Symbol(b, Decl(a.js, 3, 9)) +- + x: 8 // Should error, 'x' isn't in 'Keys' +->x : Symbol(x, Decl(a.js, 4, 15)) +- + }); + // Should be OK -- retain info that a is number and b is string let a = p.a.toFixed(); >a : Symbol(a, Decl(a.js, 9, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types index 19bb42f761..d08526f637 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types @@ -6,20 +6,10 @@ const p = /** @satisfies {Partial>} */ ({ >p : { a: number; b: string; x: number; } >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } ->{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } a: 0, ->a : number ->0 : 0 - b: "hello", ->b : string ->"hello" : "hello" - x: 8 // Should error, 'x' isn't in 'Keys' ->x : number ->8 : 8 - }); // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types index a9dfcaf190..02ad5e1cc3 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types @@ -27,5 +27,4 @@ const t1 = { a: 1 }; const t2 = /** @satisfies {number} */ (1); >t2 : 1 >(1) : 1 ->1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols index 427e411bf2..2c6d63a3f3 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols @@ -15,5 +15,4 @@ const t1 = { a: 1 }; const t2 = /** @satisfies T1 */ ({ a: 1 }); >t2 : Symbol(t2, Decl(a.js, 9, 5)) ->a : Symbol(a, Decl(a.js, 9, 34)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols.diff new file mode 100644 index 0000000000..f0b4fa56ab --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols.diff @@ -0,0 +1,7 @@ +--- old.checkJsdocSatisfiesTag14.symbols ++++ new.checkJsdocSatisfiesTag14.symbols +@@= skipped -14, +14 lines =@@ + + const t2 = /** @satisfies T1 */ ({ a: 1 }); + >t2 : Symbol(t2, Decl(a.js, 9, 5)) +->a : Symbol(a, Decl(a.js, 9, 34)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types index be25ed76fd..fcaf65054b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types @@ -18,7 +18,4 @@ const t1 = { a: 1 }; const t2 = /** @satisfies T1 */ ({ a: 1 }); >t2 : { a: number; } >({ a: 1 }) : { a: number; } ->{ a: 1 } : { a: number; } ->a : number ->1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols index c40b2a537b..6a8f1a551f 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols @@ -7,14 +7,6 @@ const p = /** @satisfies {Predicates} */ ({ >p : Symbol(p, Decl(a.js, 2, 5)) isEven: n => n % 2 === 0, ->isEven : Symbol(isEven, Decl(a.js, 2, 43)) ->n : Symbol(n, Decl(a.js, 3, 11)) ->n : Symbol(n, Decl(a.js, 3, 11)) - isOdd: n => n % 2 === 1 ->isOdd : Symbol(isOdd, Decl(a.js, 3, 29)) ->n : Symbol(n, Decl(a.js, 4, 10)) ->n : Symbol(n, Decl(a.js, 4, 10)) - }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols.diff new file mode 100644 index 0000000000..f04a876a37 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols.diff @@ -0,0 +1,16 @@ +--- old.checkJsdocSatisfiesTag2.symbols ++++ new.checkJsdocSatisfiesTag2.symbols +@@= skipped -6, +6 lines =@@ + >p : Symbol(p, Decl(a.js, 2, 5)) + + isEven: n => n % 2 === 0, +->isEven : Symbol(isEven, Decl(a.js, 2, 43)) +->n : Symbol(n, Decl(a.js, 3, 11)) +->n : Symbol(n, Decl(a.js, 3, 11)) +- + isOdd: n => n % 2 === 1 +->isOdd : Symbol(isOdd, Decl(a.js, 3, 29)) +->n : Symbol(n, Decl(a.js, 4, 10)) +->n : Symbol(n, Decl(a.js, 4, 10)) +- + }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types index 8682c675f8..589f175640 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types @@ -4,29 +4,10 @@ /** @typedef {Object. boolean>} Predicates */ const p = /** @satisfies {Predicates} */ ({ ->p : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } ->({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } ->{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } +>p : any +>({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : any isEven: n => n % 2 === 0, ->isEven : (n: any) => boolean ->n => n % 2 === 0 : (n: any) => boolean ->n : any ->n % 2 === 0 : boolean ->n % 2 : number ->n : any ->2 : 2 ->0 : 0 - isOdd: n => n % 2 === 1 ->isOdd : (n: any) => boolean ->n => n % 2 === 1 : (n: any) => boolean ->n : any ->n % 2 === 1 : boolean ->n % 2 : number ->n : any ->2 : 2 ->1 : 1 - }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt deleted file mode 100644 index f41bb7633d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -/a.js(4,7): error TS7006: Parameter 's' implicitly has an 'any' type. -/a.js(8,49): error TS7006: Parameter 'x' implicitly has an 'any' type. - - -==== /a.js (2 errors) ==== - /** @type {{ f(s: string): void } & Record }} */ - let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ - f(s) { }, // "incorrect" implicit any on 's' - g(s) { } - ~ -!!! error TS7006: Parameter 's' implicitly has an 'any' type. - }); - - // This needs to not crash (outer node is not expression) - /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols index 1f87a5e6db..42685a12de 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols @@ -6,17 +6,9 @@ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ( >obj : Symbol(obj, Decl(a.js, 1, 3)) f(s) { }, // "incorrect" implicit any on 's' ->f : Symbol(f, Decl(a.js, 1, 81)) ->s : Symbol(s, Decl(a.js, 2, 6)) - g(s) { } ->g : Symbol(g, Decl(a.js, 2, 13)) ->s : Symbol(s, Decl(a.js, 3, 6)) - }); // This needs to not crash (outer node is not expression) /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) ->f : Symbol(f, Decl(a.js, 7, 45)) ->x : Symbol(x, Decl(a.js, 7, 48)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols.diff new file mode 100644 index 0000000000..85aa0ada95 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols.diff @@ -0,0 +1,19 @@ +--- old.checkJsdocSatisfiesTag3.symbols ++++ new.checkJsdocSatisfiesTag3.symbols +@@= skipped -5, +5 lines =@@ + >obj : Symbol(obj, Decl(a.js, 1, 3)) + + f(s) { }, // "incorrect" implicit any on 's' +->f : Symbol(f, Decl(a.js, 1, 81)) +->s : Symbol(s, Decl(a.js, 2, 6)) +- + g(s) { } +->g : Symbol(g, Decl(a.js, 2, 13)) +->s : Symbol(s, Decl(a.js, 3, 6)) +- + }); + + // This needs to not crash (outer node is not expression) + /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) +->f : Symbol(f, Decl(a.js, 7, 45)) +->x : Symbol(x, Decl(a.js, 7, 48)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types index 7a15d92fc8..14048d796c 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types @@ -4,23 +4,13 @@ /** @type {{ f(s: string): void } & Record }} */ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ >obj : { f(s: string): void; } & Record ->({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: string): void; g(s: any): void; } ->{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: string): void; g(s: any): void; } +>({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: any): void; g(s: string): void; } f(s) { }, // "incorrect" implicit any on 's' ->f : (s: string) => void ->s : string - g(s) { } ->g : (s: any) => void ->s : any - }); // This needs to not crash (outer node is not expression) /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) ->({ f(x) { } }) : { f(x: any): void; } ->{ f(x) { } } : { f(x: any): void; } ->f : (x: any) => void ->x : any +>({ f(x) { } }) : { f(x: string): void; } diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols index 668caabf6f..248891f379 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols @@ -9,11 +9,10 @@ export default /** @satisfies {Foo} */ ({}); === /b.js === + /** * @typedef {Object} Foo * @property {number} a */ export default /** @satisfies {Foo} */ ({ a: 1 }); ->a : Symbol(a, Decl(b.js, 5, 41)) - diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols.diff new file mode 100644 index 0000000000..f446b0f06c --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols.diff @@ -0,0 +1,15 @@ +--- old.checkJsdocSatisfiesTag4.symbols ++++ new.checkJsdocSatisfiesTag4.symbols +@@= skipped -8, +8 lines =@@ + export default /** @satisfies {Foo} */ ({}); + + === /b.js === ++ + /** + * @typedef {Object} Foo + * @property {number} a + */ + + export default /** @satisfies {Foo} */ ({ a: 1 }); +->a : Symbol(a, Decl(b.js, 5, 41)) +- \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types index 0d01dd7d19..f529622f94 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types @@ -7,7 +7,6 @@ */ export default /** @satisfies {Foo} */ ({}); >({}) : {} ->{} : {} === /b.js === /** @@ -17,7 +16,4 @@ export default /** @satisfies {Foo} */ ({}); export default /** @satisfies {Foo} */ ({ a: 1 }); >({ a: 1 }) : { a: number; } ->{ a: 1 } : { a: number; } ->a : number ->1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols index 93b511fee3..ba59de9b2b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols @@ -7,16 +7,9 @@ const car = /** @satisfies {Movable & Record} */ ({ >car : Symbol(car, Decl(a.js, 2, 5)) start() { }, ->start : Symbol(start, Decl(a.js, 2, 68)) - move(d) { ->move : Symbol(move, Decl(a.js, 3, 16)) ->d : Symbol(d, Decl(a.js, 4, 9)) - // d should be number }, stop() { } ->stop : Symbol(stop, Decl(a.js, 6, 6)) - }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols.diff new file mode 100644 index 0000000000..603a525edc --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols.diff @@ -0,0 +1,18 @@ +--- old.checkJsdocSatisfiesTag5.symbols ++++ new.checkJsdocSatisfiesTag5.symbols +@@= skipped -6, +6 lines =@@ + >car : Symbol(car, Decl(a.js, 2, 5)) + + start() { }, +->start : Symbol(start, Decl(a.js, 2, 68)) +- + move(d) { +->move : Symbol(move, Decl(a.js, 3, 16)) +->d : Symbol(d, Decl(a.js, 4, 9)) +- + // d should be number + }, + stop() { } +->stop : Symbol(stop, Decl(a.js, 6, 6)) +- + }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types index 50d5462d4e..2a95cd9240 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types @@ -4,21 +4,13 @@ /** @typedef {{ move(distance: number): void }} Movable */ const car = /** @satisfies {Movable & Record} */ ({ ->car : { start(): void; move(d: any): void; stop(): void; } ->({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: any): void; stop(): void; } ->{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: any): void; stop(): void; } +>car : { start(): void; move(d: number): void; stop(): void; } +>({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: number): void; stop(): void; } start() { }, ->start : () => void - move(d) { ->move : (d: any) => void ->d : any - // d should be number }, stop() { } ->stop : () => void - }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt deleted file mode 100644 index 81d15c6038..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -/a.js(14,11): error TS2339: Property 'y' does not exist on type '{ x: number; }'. - - -==== /a.js (1 errors) ==== - /** - * @typedef {Object} Point2d - * @property {number} x - * @property {number} y - */ - - // Undesirable behavior today with type annotation - const a = /** @satisfies {Partial} */ ({ x: 10 }); - - // Should OK - console.log(a.x.toFixed()); - - // Should error - let p = a.y; - ~ -!!! error TS2339: Property 'y' does not exist on type '{ x: number; }'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols index d2cf75408b..40ed7808c1 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols @@ -10,7 +10,6 @@ // Undesirable behavior today with type annotation const a = /** @satisfies {Partial} */ ({ x: 10 }); >a : Symbol(a, Decl(a.js, 7, 5)) ->x : Symbol(x, Decl(a.js, 7, 49)) // Should OK console.log(a.x.toFixed()); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols.diff index 9ee7579c27..b592d4f0aa 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols.diff @@ -1,6 +1,10 @@ --- old.checkJsdocSatisfiesTag6.symbols +++ new.checkJsdocSatisfiesTag6.symbols -@@= skipped -13, +13 lines =@@ +@@= skipped -9, +9 lines =@@ + // Undesirable behavior today with type annotation + const a = /** @satisfies {Partial} */ ({ x: 10 }); + >a : Symbol(a, Decl(a.js, 7, 5)) +->x : Symbol(x, Decl(a.js, 7, 49)) // Should OK console.log(a.x.toFixed()); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types index 27731e2ff5..70334ccafc 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types @@ -11,9 +11,6 @@ const a = /** @satisfies {Partial} */ ({ x: 10 }); >a : { x: number; } >({ x: 10 }) : { x: number; } ->{ x: 10 } : { x: number; } ->x : number ->10 : 10 // Should OK console.log(a.x.toFixed()); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt deleted file mode 100644 index 3a364a6628..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -/a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. - - -==== /a.js (1 errors) ==== - /** @typedef {"a" | "b" | "c" | "d"} Keys */ - - const p = /** @satisfies {Record} */ ({ - a: 0, - b: "hello", - x: 8 // Should error, 'x' isn't in 'Keys' - }) - - // Should be OK -- retain info that a is number and b is string - let a = p.a.toFixed(); - let b = p.b.substring(1); - - // Should error even though 'd' is in 'Keys' - let d = p.d; - ~ -!!! error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols index 1de7d258d5..ce35df1689 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols @@ -7,14 +7,8 @@ const p = /** @satisfies {Record} */ ({ >p : Symbol(p, Decl(a.js, 2, 5)) a: 0, ->a : Symbol(a, Decl(a.js, 2, 54)) - b: "hello", ->b : Symbol(b, Decl(a.js, 3, 9)) - x: 8 // Should error, 'x' isn't in 'Keys' ->x : Symbol(x, Decl(a.js, 4, 15)) - }) // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols.diff index e6530aeb83..adeb67184d 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols.diff @@ -1,6 +1,19 @@ --- old.checkJsdocSatisfiesTag7.symbols +++ new.checkJsdocSatisfiesTag7.symbols -@@= skipped -19, +19 lines =@@ +@@= skipped -6, +6 lines =@@ + >p : Symbol(p, Decl(a.js, 2, 5)) + + a: 0, +->a : Symbol(a, Decl(a.js, 2, 54)) +- + b: "hello", +->b : Symbol(b, Decl(a.js, 3, 9)) +- + x: 8 // Should error, 'x' isn't in 'Keys' +->x : Symbol(x, Decl(a.js, 4, 15)) +- + }) + // Should be OK -- retain info that a is number and b is string let a = p.a.toFixed(); >a : Symbol(a, Decl(a.js, 9, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types index e5a245e579..03178cd055 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types @@ -6,20 +6,10 @@ const p = /** @satisfies {Record} */ ({ >p : { a: number; b: string; x: number; } >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } ->{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } a: 0, ->a : number ->0 : 0 - b: "hello", ->b : string ->"hello" : "hello" - x: 8 // Should error, 'x' isn't in 'Keys' ->x : number ->8 : 8 - }) // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols index 1f6e6afdbe..46bc9a56d7 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols @@ -8,10 +8,6 @@ const x = /** @satisfies {Facts} */ ({ >x : Symbol(x, Decl(a.js, 3, 5)) m: true, ->m : Symbol(m, Decl(a.js, 3, 38)) - s: "false" ->s : Symbol(s, Decl(a.js, 4, 12)) - }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols.diff new file mode 100644 index 0000000000..6040bba6b8 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols.diff @@ -0,0 +1,12 @@ +--- old.checkJsdocSatisfiesTag8.symbols ++++ new.checkJsdocSatisfiesTag8.symbols +@@= skipped -7, +7 lines =@@ + >x : Symbol(x, Decl(a.js, 3, 5)) + + m: true, +->m : Symbol(m, Decl(a.js, 3, 38)) +- + s: "false" +->s : Symbol(s, Decl(a.js, 4, 12)) +- + }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types index 201e3b22d0..f5612a902e 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types @@ -5,17 +5,10 @@ // Should be able to detect a failure here const x = /** @satisfies {Facts} */ ({ ->x : { m: boolean; s: string; } ->({ m: true, s: "false"}) : { m: boolean; s: string; } ->{ m: true, s: "false"} : { m: boolean; s: string; } +>x : any +>({ m: true, s: "false"}) : any m: true, ->m : boolean ->true : true - s: "false" ->s : string ->"false" : "false" - }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols index 10ea8be886..0991b55a69 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols @@ -13,22 +13,7 @@ export const Palette = /** @satisfies {Record} */ ({ >Palette : Symbol(Palette, Decl(a.js, 8, 12)) white: { r: 255, g: 255, b: 255 }, ->white : Symbol(white, Decl(a.js, 8, 67)) ->r : Symbol(r, Decl(a.js, 9, 12)) ->g : Symbol(g, Decl(a.js, 9, 20)) ->b : Symbol(b, Decl(a.js, 9, 28)) - black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' ->black : Symbol(black, Decl(a.js, 9, 38)) ->r : Symbol(r, Decl(a.js, 10, 12)) ->g : Symbol(g, Decl(a.js, 10, 18)) ->d : Symbol(d, Decl(a.js, 10, 24)) - blue: { r: 0, g: 0, b: 255 }, ->blue : Symbol(blue, Decl(a.js, 10, 32)) ->r : Symbol(r, Decl(a.js, 11, 11)) ->g : Symbol(g, Decl(a.js, 11, 17)) ->b : Symbol(b, Decl(a.js, 11, 23)) - }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols.diff new file mode 100644 index 0000000000..93a5d31187 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols.diff @@ -0,0 +1,24 @@ +--- old.checkJsdocSatisfiesTag9.symbols ++++ new.checkJsdocSatisfiesTag9.symbols +@@= skipped -12, +12 lines =@@ + >Palette : Symbol(Palette, Decl(a.js, 8, 12)) + + white: { r: 255, g: 255, b: 255 }, +->white : Symbol(white, Decl(a.js, 8, 67)) +->r : Symbol(r, Decl(a.js, 9, 12)) +->g : Symbol(g, Decl(a.js, 9, 20)) +->b : Symbol(b, Decl(a.js, 9, 28)) +- + black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' +->black : Symbol(black, Decl(a.js, 9, 38)) +->r : Symbol(r, Decl(a.js, 10, 12)) +->g : Symbol(g, Decl(a.js, 10, 18)) +->d : Symbol(d, Decl(a.js, 10, 24)) +- + blue: { r: 0, g: 0, b: 255 }, +->blue : Symbol(blue, Decl(a.js, 10, 32)) +->r : Symbol(r, Decl(a.js, 11, 11)) +->g : Symbol(g, Decl(a.js, 11, 17)) +->b : Symbol(b, Decl(a.js, 11, 23)) +- + }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types index 98fe398fad..1c279a2631 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types @@ -12,37 +12,9 @@ export const Palette = /** @satisfies {Record} */ ({ >Palette : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } >({ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },}) : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } ->{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } white: { r: 255, g: 255, b: 255 }, ->white : { r: number; g: number; b: number; } ->{ r: 255, g: 255, b: 255 } : { r: number; g: number; b: number; } ->r : number ->255 : 255 ->g : number ->255 : 255 ->b : number ->255 : 255 - black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' ->black : { r: number; g: number; d: number; } ->{ r: 0, g: 0, d: 0 } : { r: number; g: number; d: number; } ->r : number ->0 : 0 ->g : number ->0 : 0 ->d : number ->0 : 0 - blue: { r: 0, g: 0, b: 255 }, ->blue : { r: number; g: number; b: number; } ->{ r: 0, g: 0, b: 255 } : { r: number; g: number; b: number; } ->r : number ->0 : 0 ->g : number ->0 : 0 ->b : number ->255 : 255 - }); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff index 0d9937ec21..9a7647e686 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff @@ -1,27 +1,67 @@ --- old.checkJsdocSatisfiesTag1.types +++ new.checkJsdocSatisfiesTag1.types -@@= skipped -43, +43 lines =@@ +@@= skipped -22, +22 lines =@@ + const t1 = /** @satisfies {T1} */ ({ a: 1 }); + >t1 : { a: number; } + >({ a: 1 }) : { a: number; } +->{ a: 1 } : { a: number; } +->a : number +->1 : 1 + + const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); + >t2 : { a: number; b: number; } + >({ a: 1, b: 1 }) : { a: number; b: number; } +->{ a: 1, b: 1 } : { a: number; b: number; } +->a : number +->1 : 1 +->b : number +->1 : 1 + + const t3 = /** @satisfies {T1} */ ({}); + >t3 : {} + >({}) : {} +->{} : {} + /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : T2 ->({ a: "a" }) : T2 ->{ a: "a" } : { a: "a"; } ->a : "a" +->"a" : "a" +>({ a: "a" }) : { a: string; } -+>{ a: "a" } : { a: string; } -+>a : string - >"a" : "a" /** @type {(m: string) => string} */ -@@= skipped -18, +18 lines =@@ - >0 : 0 + const t5 = /** @satisfies {T3} */((m) => m.substring(0)); + >t5 : (m: string) => string + >((m) => m.substring(0)) : (m: string) => string +->(m) => m.substring(0) : (m: string) => string +->m : string +->m.substring(0) : string +->m.substring : (start: number, end?: number) => string +->m : string +->substring : (start: number, end?: number) => string +->0 : 0 const t6 = /** @satisfies {[number, number]} */ ([1, 2]); -->t6 : [number, number] -->([1, 2]) : [number, number] + >t6 : [number, number] + >([1, 2]) : [number, number] ->[1, 2] : [number, number] -+>t6 : number[] -+>([1, 2]) : number[] -+>[1, 2] : number[] - >1 : 1 - >2 : 2 +->1 : 1 +->2 : 2 + + const t7 = /** @satisfies {T4} */ ({ a: 'test' }); + >t7 : { a: string; } + >({ a: 'test' }) : { a: string; } +->{ a: 'test' } : { a: string; } +->a : string +->'test' : "test" + + const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); + >t8 : { a: string; b: string; } + >({ a: 'test', b: 'test' }) : { a: string; b: string; } +->{ a: 'test', b: 'test' } : { a: string; b: string; } +->a : string +->'test' : "test" +->b : string +->'test' : "test" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff new file mode 100644 index 0000000000..c654bf7a97 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff @@ -0,0 +1,23 @@ +--- old.checkJsdocSatisfiesTag10.types ++++ new.checkJsdocSatisfiesTag10.types +@@= skipped -5, +5 lines =@@ + const p = /** @satisfies {Partial>} */ ({ + >p : { a: number; b: string; x: number; } + >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } +->{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } + + a: 0, +->a : number +->0 : 0 +- + b: "hello", +->b : string +->"hello" : "hello" +- + x: 8 // Should error, 'x' isn't in 'Keys' +->x : number +->8 : 8 +- + }); + + // Should be OK -- retain info that a is number and b is string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff new file mode 100644 index 0000000000..350cfb3c0c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff @@ -0,0 +1,7 @@ +--- old.checkJsdocSatisfiesTag11.types ++++ new.checkJsdocSatisfiesTag11.types +@@= skipped -26, +26 lines =@@ + const t2 = /** @satisfies {number} */ (1); + >t2 : 1 + >(1) : 1 +->1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff new file mode 100644 index 0000000000..17ffdbd306 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff @@ -0,0 +1,9 @@ +--- old.checkJsdocSatisfiesTag14.types ++++ new.checkJsdocSatisfiesTag14.types +@@= skipped -17, +17 lines =@@ + const t2 = /** @satisfies T1 */ ({ a: 1 }); + >t2 : { a: number; } + >({ a: 1 }) : { a: number; } +->{ a: 1 } : { a: number; } +->a : number +->1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff index 696bd9501d..5b50854ece 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff @@ -7,34 +7,27 @@ ->p : { isEven: (n: number) => boolean; isOdd: (n: number) => boolean; } ->({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : { isEven: (n: number) => boolean; isOdd: (n: number) => boolean; } ->{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: number) => boolean; isOdd: (n: number) => boolean; } -+>p : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } -+>({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } -+>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } ++>p : any ++>({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : any isEven: n => n % 2 === 0, ->isEven : (n: number) => boolean ->n => n % 2 === 0 : (n: number) => boolean ->n : number -+>isEven : (n: any) => boolean -+>n => n % 2 === 0 : (n: any) => boolean -+>n : any - >n % 2 === 0 : boolean - >n % 2 : number +->n % 2 === 0 : boolean +->n % 2 : number ->n : number -+>n : any - >2 : 2 - >0 : 0 - +->2 : 2 +->0 : 0 +- isOdd: n => n % 2 === 1 ->isOdd : (n: number) => boolean ->n => n % 2 === 1 : (n: number) => boolean ->n : number -+>isOdd : (n: any) => boolean -+>n => n % 2 === 1 : (n: any) => boolean -+>n : any - >n % 2 === 1 : boolean - >n % 2 : number +->n % 2 === 1 : boolean +->n % 2 : number ->n : number -+>n : any - >2 : 2 - >1 : 1 +->2 : 2 +->1 : 1 +- + }); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff deleted file mode 100644 index 6aa3005cdd..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.checkJsdocSatisfiesTag3.errors.txt -+++ new.checkJsdocSatisfiesTag3.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. -- -- --==== /a.js (1 errors) ==== -+/a.js(4,7): error TS7006: Parameter 's' implicitly has an 'any' type. -+/a.js(8,49): error TS7006: Parameter 'x' implicitly has an 'any' type. -+ -+ -+==== /a.js (2 errors) ==== - /** @type {{ f(s: string): void } & Record }} */ - let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ - f(s) { }, // "incorrect" implicit any on 's' -+ g(s) { } - ~ - !!! error TS7006: Parameter 's' implicitly has an 'any' type. -- g(s) { } - }); - - // This needs to not crash (outer node is not expression) - /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff index b8afa08392..276b58f59e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff @@ -6,31 +6,21 @@ >obj : { f(s: string): void; } & Record ->({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: string): void; } & Record ->{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } -+>({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: string): void; g(s: any): void; } -+>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: string): void; g(s: any): void; } ++>({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: any): void; g(s: string): void; } f(s) { }, // "incorrect" implicit any on 's' ->f : (s: any) => void ->s : any - -- g(s) { } + g(s) { } ->g : (s: string) => void -+>f : (s: string) => void - >s : string - -+ g(s) { } -+>g : (s: any) => void -+>s : any -+ +->s : string +- }); // This needs to not crash (outer node is not expression) /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) -->({ f(x) { } }) : { f(x: string): void; } + >({ f(x) { } }) : { f(x: string): void; } ->{ f(x) { } } : { f(x: string): void; } ->f : (x: string) => void ->x : string -+>({ f(x) { } }) : { f(x: any): void; } -+>{ f(x) { } } : { f(x: any): void; } -+>f : (x: any) => void -+>x : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff new file mode 100644 index 0000000000..450cfd5f4d --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff @@ -0,0 +1,17 @@ +--- old.checkJsdocSatisfiesTag4.types ++++ new.checkJsdocSatisfiesTag4.types +@@= skipped -6, +6 lines =@@ + */ + export default /** @satisfies {Foo} */ ({}); + >({}) : {} +->{} : {} + + === /b.js === + /** +@@= skipped -10, +9 lines =@@ + + export default /** @satisfies {Foo} */ ({ a: 1 }); + >({ a: 1 }) : { a: number; } +->{ a: 1 } : { a: number; } +->a : number +->1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff index e8ff552ef9..e7b63494e5 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff @@ -1,24 +1,21 @@ --- old.checkJsdocSatisfiesTag5.types +++ new.checkJsdocSatisfiesTag5.types -@@= skipped -3, +3 lines =@@ - /** @typedef {{ move(distance: number): void }} Movable */ - +@@= skipped -5, +5 lines =@@ const car = /** @satisfies {Movable & Record} */ ({ -->car : { start(): void; move(d: number): void; stop(): void; } -->({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: number): void; stop(): void; } + >car : { start(): void; move(d: number): void; stop(): void; } + >({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: number): void; stop(): void; } ->{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } -+>car : { start(): void; move(d: any): void; stop(): void; } -+>({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: any): void; stop(): void; } -+>{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: any): void; stop(): void; } start() { }, - >start : () => void - +->start : () => void +- move(d) { ->move : (d: number) => void ->d : number -+>move : (d: any) => void -+>d : any - +- // d should be number - }, \ No newline at end of file + }, + stop() { } +->stop : () => void +- + }) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff new file mode 100644 index 0000000000..92e8143c61 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff @@ -0,0 +1,12 @@ +--- old.checkJsdocSatisfiesTag6.types ++++ new.checkJsdocSatisfiesTag6.types +@@= skipped -10, +10 lines =@@ + const a = /** @satisfies {Partial} */ ({ x: 10 }); + >a : { x: number; } + >({ x: 10 }) : { x: number; } +->{ x: 10 } : { x: number; } +->x : number +->10 : 10 + + // Should OK + console.log(a.x.toFixed()); \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff new file mode 100644 index 0000000000..40e310d889 --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff @@ -0,0 +1,23 @@ +--- old.checkJsdocSatisfiesTag7.types ++++ new.checkJsdocSatisfiesTag7.types +@@= skipped -5, +5 lines =@@ + const p = /** @satisfies {Record} */ ({ + >p : { a: number; b: string; x: number; } + >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } +->{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } + + a: 0, +->a : number +->0 : 0 +- + b: "hello", +->b : string +->"hello" : "hello" +- + x: 8 // Should error, 'x' isn't in 'Keys' +->x : number +->8 : 8 +- + }) + + // Should be OK -- retain info that a is number and b is string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff index 877d1b8099..dc685942ee 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff @@ -7,13 +7,15 @@ ->x : { m: true; s: string; } ->({ m: true, s: "false"}) : { m: true; s: string; } ->{ m: true, s: "false"} : { m: true; s: string; } -+>x : { m: boolean; s: string; } -+>({ m: true, s: "false"}) : { m: boolean; s: string; } -+>{ m: true, s: "false"} : { m: boolean; s: string; } ++>x : any ++>({ m: true, s: "false"}) : any m: true, ->m : true -+>m : boolean - >true : true - - s: "false" \ No newline at end of file +->true : true +- + s: "false" +->s : string +->"false" : "false" +- + }) diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff new file mode 100644 index 0000000000..6878984c1e --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff @@ -0,0 +1,39 @@ +--- old.checkJsdocSatisfiesTag9.types ++++ new.checkJsdocSatisfiesTag9.types +@@= skipped -11, +11 lines =@@ + export const Palette = /** @satisfies {Record} */ ({ + >Palette : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } + >({ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },}) : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } +->{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } + + white: { r: 255, g: 255, b: 255 }, +->white : { r: number; g: number; b: number; } +->{ r: 255, g: 255, b: 255 } : { r: number; g: number; b: number; } +->r : number +->255 : 255 +->g : number +->255 : 255 +->b : number +->255 : 255 +- + black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' +->black : { r: number; g: number; d: number; } +->{ r: 0, g: 0, d: 0 } : { r: number; g: number; d: number; } +->r : number +->0 : 0 +->g : number +->0 : 0 +->d : number +->0 : 0 +- + blue: { r: 0, g: 0, b: 255 }, +->blue : { r: number; g: number; b: number; } +->{ r: 0, g: 0, b: 255 } : { r: number; g: number; b: number; } +->r : number +->0 : 0 +->g : number +->0 : 0 +->b : number +->255 : 255 +- + }); From 937bf5825dacc7c30291076f326425f873e943ff Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 10 Jun 2025 14:47:06 -0700 Subject: [PATCH 3/6] missed baselines + better check for `this` keyword --- internal/parser/reparser.go | 3 +-- .../checkJsdocSatisfiesTag10.errors.txt | 21 +++++++++++++++++++ .../checkJsdocSatisfiesTag3.errors.txt | 15 +++++++++++++ .../checkJsdocSatisfiesTag6.errors.txt | 21 +++++++++++++++++++ .../checkJsdocSatisfiesTag7.errors.txt | 21 +++++++++++++++++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index f3d2495d18..65fab018eb 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -272,9 +272,8 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } case ast.KindJSDocThisTag: if fun, ok := getFunctionLikeHost(parent); ok { - // Only add a this parameter if we don't already have one params := fun.Parameters() - if len(params) == 0 || params[0].Name().Text() != "this" { + if len(params) == 0 || params[0].Name().Kind != ast.KindThisKeyword { thisParam := p.factory.NewParameterDeclaration( nil, /* decorators */ nil, /* modifiers */ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt new file mode 100644 index 0000000000..c6a17d12f4 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.errors.txt @@ -0,0 +1,21 @@ +/a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. + + +==== /a.js (1 errors) ==== + /** @typedef {"a" | "b" | "c" | "d"} Keys */ + + const p = /** @satisfies {Partial>} */ ({ + a: 0, + b: "hello", + x: 8 // Should error, 'x' isn't in 'Keys' + }); + + // Should be OK -- retain info that a is number and b is string + let a = p.a.toFixed(); + let b = p.b.substring(1); + + // Should error even though 'd' is in 'Keys' + let d = p.d; + ~ +!!! error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt new file mode 100644 index 0000000000..bb8cbbe319 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.errors.txt @@ -0,0 +1,15 @@ +/a.js(3,7): error TS7006: Parameter 's' implicitly has an 'any' type. + + +==== /a.js (1 errors) ==== + /** @type {{ f(s: string): void } & Record }} */ + let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ + f(s) { }, // "incorrect" implicit any on 's' + ~ +!!! error TS7006: Parameter 's' implicitly has an 'any' type. + g(s) { } + }); + + // This needs to not crash (outer node is not expression) + /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt new file mode 100644 index 0000000000..81d15c6038 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.errors.txt @@ -0,0 +1,21 @@ +/a.js(14,11): error TS2339: Property 'y' does not exist on type '{ x: number; }'. + + +==== /a.js (1 errors) ==== + /** + * @typedef {Object} Point2d + * @property {number} x + * @property {number} y + */ + + // Undesirable behavior today with type annotation + const a = /** @satisfies {Partial} */ ({ x: 10 }); + + // Should OK + console.log(a.x.toFixed()); + + // Should error + let p = a.y; + ~ +!!! error TS2339: Property 'y' does not exist on type '{ x: number; }'. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt new file mode 100644 index 0000000000..3a364a6628 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.errors.txt @@ -0,0 +1,21 @@ +/a.js(14,11): error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. + + +==== /a.js (1 errors) ==== + /** @typedef {"a" | "b" | "c" | "d"} Keys */ + + const p = /** @satisfies {Record} */ ({ + a: 0, + b: "hello", + x: 8 // Should error, 'x' isn't in 'Keys' + }) + + // Should be OK -- retain info that a is number and b is string + let a = p.a.toFixed(); + let b = p.b.substring(1); + + // Should error even though 'd' is in 'Keys' + let d = p.d; + ~ +!!! error TS2339: Property 'd' does not exist on type '{ a: number; b: string; x: number; }'. + \ No newline at end of file From e9100512827813e64556ef3d1fadd36e606d8677 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:00:19 -0700 Subject: [PATCH 4/6] baseline synth satisfies nodes --- .../tsbaseline/type_symbol_baseline.go | 2 +- .../checkJsdocSatisfiesTag1.symbols | 11 +++ .../checkJsdocSatisfiesTag1.symbols.diff | 38 ++-------- .../conformance/checkJsdocSatisfiesTag1.types | 38 ++++++++++ .../checkJsdocSatisfiesTag10.symbols | 6 ++ .../checkJsdocSatisfiesTag10.symbols.diff | 15 +--- .../checkJsdocSatisfiesTag10.types | 11 +++ .../checkJsdocSatisfiesTag11.types | 2 + .../checkJsdocSatisfiesTag14.symbols | 1 + .../checkJsdocSatisfiesTag14.symbols.diff | 7 -- .../checkJsdocSatisfiesTag14.types | 4 + .../checkJsdocSatisfiesTag2.symbols | 8 ++ .../checkJsdocSatisfiesTag2.symbols.diff | 16 ---- .../conformance/checkJsdocSatisfiesTag2.types | 20 +++++ .../checkJsdocSatisfiesTag3.symbols | 8 ++ .../checkJsdocSatisfiesTag3.symbols.diff | 19 ----- .../conformance/checkJsdocSatisfiesTag3.types | 12 +++ .../checkJsdocSatisfiesTag4.symbols | 3 +- .../checkJsdocSatisfiesTag4.symbols.diff | 15 ---- .../conformance/checkJsdocSatisfiesTag4.types | 6 ++ .../checkJsdocSatisfiesTag5.symbols | 7 ++ .../checkJsdocSatisfiesTag5.symbols.diff | 18 ----- .../conformance/checkJsdocSatisfiesTag5.types | 9 +++ .../checkJsdocSatisfiesTag6.symbols | 1 + .../checkJsdocSatisfiesTag6.symbols.diff | 6 +- .../conformance/checkJsdocSatisfiesTag6.types | 4 + .../checkJsdocSatisfiesTag7.symbols | 6 ++ .../checkJsdocSatisfiesTag7.symbols.diff | 15 +--- .../conformance/checkJsdocSatisfiesTag7.types | 11 +++ .../checkJsdocSatisfiesTag8.symbols | 4 + .../checkJsdocSatisfiesTag8.symbols.diff | 12 --- .../conformance/checkJsdocSatisfiesTag8.types | 8 ++ .../checkJsdocSatisfiesTag9.symbols | 15 ++++ .../checkJsdocSatisfiesTag9.symbols.diff | 24 ------ .../conformance/checkJsdocSatisfiesTag9.types | 29 +++++++ .../checkJsdocSatisfiesTag1.types.diff | 75 ++++++++++--------- .../checkJsdocSatisfiesTag10.types.diff | 21 +----- .../checkJsdocSatisfiesTag11.types.diff | 6 +- .../checkJsdocSatisfiesTag14.types.diff | 10 +-- .../checkJsdocSatisfiesTag2.types.diff | 30 +++++--- .../checkJsdocSatisfiesTag3.types.diff | 20 ++--- .../checkJsdocSatisfiesTag4.types.diff | 15 ++-- .../checkJsdocSatisfiesTag5.types.diff | 19 +---- .../checkJsdocSatisfiesTag6.types.diff | 13 ++-- .../checkJsdocSatisfiesTag7.types.diff | 21 +----- .../checkJsdocSatisfiesTag8.types.diff | 13 ++-- .../checkJsdocSatisfiesTag9.types.diff | 37 +-------- 47 files changed, 340 insertions(+), 351 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols.diff diff --git a/internal/testutil/tsbaseline/type_symbol_baseline.go b/internal/testutil/tsbaseline/type_symbol_baseline.go index 20ae35c4af..5c70707215 100644 --- a/internal/testutil/tsbaseline/type_symbol_baseline.go +++ b/internal/testutil/tsbaseline/type_symbol_baseline.go @@ -327,7 +327,7 @@ func forEachASTNode(node *ast.Node) []*ast.Node { for len(work) > 0 { elem := work[len(work)-1] work = work[:len(work)-1] - if elem.Flags&ast.NodeFlagsReparsed != 0 && elem.Kind != ast.KindTypeAssertionExpression { + if elem.Flags&ast.NodeFlagsReparsed != 0 && elem.Kind != ast.KindTypeAssertionExpression && elem.Kind != ast.KindSatisfiesExpression { continue } result = append(result, elem) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols index 54ed0c447e..41e26adfcd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols @@ -22,9 +22,12 @@ const t1 = /** @satisfies {T1} */ ({ a: 1 }); >t1 : Symbol(t1, Decl(a.js, 19, 5)) +>a : Symbol(a, Decl(a.js, 19, 36)) const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); >t2 : Symbol(t2, Decl(a.js, 20, 5)) +>a : Symbol(a, Decl(a.js, 20, 36)) +>b : Symbol(b, Decl(a.js, 20, 42)) const t3 = /** @satisfies {T1} */ ({}); >t3 : Symbol(t3, Decl(a.js, 21, 5)) @@ -32,17 +35,25 @@ const t3 = /** @satisfies {T1} */ ({}); /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : Symbol(t4, Decl(a.js, 24, 5)) +>a : Symbol(a, Decl(a.js, 24, 36)) /** @type {(m: string) => string} */ const t5 = /** @satisfies {T3} */((m) => m.substring(0)); >t5 : Symbol(t5, Decl(a.js, 27, 5)) +>m : Symbol(m, Decl(a.js, 27, 35)) +>m.substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) +>m : Symbol(m, Decl(a.js, 27, 35)) +>substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) const t6 = /** @satisfies {[number, number]} */ ([1, 2]); >t6 : Symbol(t6, Decl(a.js, 28, 5)) const t7 = /** @satisfies {T4} */ ({ a: 'test' }); >t7 : Symbol(t7, Decl(a.js, 29, 5)) +>a : Symbol(a, Decl(a.js, 29, 36)) const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); >t8 : Symbol(t8, Decl(a.js, 30, 5)) +>a : Symbol(a, Decl(a.js, 30, 36)) +>b : Symbol(b, Decl(a.js, 30, 47)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff index 7308c877a9..70be0b72f5 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.symbols.diff @@ -1,40 +1,14 @@ --- old.checkJsdocSatisfiesTag1.symbols +++ new.checkJsdocSatisfiesTag1.symbols -@@= skipped -21, +21 lines =@@ - - const t1 = /** @satisfies {T1} */ ({ a: 1 }); - >t1 : Symbol(t1, Decl(a.js, 19, 5)) -->a : Symbol(a, Decl(a.js, 19, 36)) - - const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); - >t2 : Symbol(t2, Decl(a.js, 20, 5)) -->a : Symbol(a, Decl(a.js, 20, 36)) -->b : Symbol(b, Decl(a.js, 20, 42)) - - const t3 = /** @satisfies {T1} */ ({}); - >t3 : Symbol(t3, Decl(a.js, 21, 5)) -@@= skipped -13, +10 lines =@@ - /** @type {T2} */ - const t4 = /** @satisfies {T2} */ ({ a: "a" }); - >t4 : Symbol(t4, Decl(a.js, 24, 5)) -->a : Symbol(a, Decl(a.js, 24, 36)) - - /** @type {(m: string) => string} */ +@@= skipped -40, +40 lines =@@ const t5 = /** @satisfies {T3} */((m) => m.substring(0)); >t5 : Symbol(t5, Decl(a.js, 27, 5)) -->m : Symbol(m, Decl(a.js, 27, 35)) + >m : Symbol(m, Decl(a.js, 27, 35)) ->m.substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --)) -->m : Symbol(m, Decl(a.js, 27, 35)) ++>m.substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) + >m : Symbol(m, Decl(a.js, 27, 35)) ->substring : Symbol(String.substring, Decl(lib.es5.d.ts, --, --)) ++>substring : Symbol(substring, Decl(lib.es5.d.ts, --, --)) const t6 = /** @satisfies {[number, number]} */ ([1, 2]); - >t6 : Symbol(t6, Decl(a.js, 28, 5)) - - const t7 = /** @satisfies {T4} */ ({ a: 'test' }); - >t7 : Symbol(t7, Decl(a.js, 29, 5)) -->a : Symbol(a, Decl(a.js, 29, 36)) - - const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); - >t8 : Symbol(t8, Decl(a.js, 30, 5)) -->a : Symbol(a, Decl(a.js, 30, 36)) -->b : Symbol(b, Decl(a.js, 30, 47)) + >t6 : Symbol(t6, Decl(a.js, 28, 5)) \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types index 494de15507..4dfa52b4aa 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types @@ -23,34 +23,72 @@ const t1 = /** @satisfies {T1} */ ({ a: 1 }); >t1 : { a: number; } >({ a: 1 }) : { a: number; } +>{ a: 1 } : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); >t2 : { a: number; b: number; } >({ a: 1, b: 1 }) : { a: number; b: number; } +>{ a: 1, b: 1 } : { a: number; b: number; } +>{ a: 1, b: 1 } : { a: number; b: number; } +>a : number +>1 : 1 +>b : number +>1 : 1 const t3 = /** @satisfies {T1} */ ({}); >t3 : {} >({}) : {} +>{} : {} +>{} : {} /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : T2 >({ a: "a" }) : { a: string; } +>{ a: "a" } : { a: string; } +>{ a: "a" } : { a: string; } +>a : string +>"a" : "a" /** @type {(m: string) => string} */ const t5 = /** @satisfies {T3} */((m) => m.substring(0)); >t5 : (m: string) => string >((m) => m.substring(0)) : (m: string) => string +>(m) => m.substring(0) : (m: string) => string +>(m) => m.substring(0) : (m: string) => string +>m : string +>m.substring(0) : string +>m.substring : (start: number, end?: number) => string +>m : string +>substring : (start: number, end?: number) => string +>0 : 0 const t6 = /** @satisfies {[number, number]} */ ([1, 2]); >t6 : [number, number] >([1, 2]) : [number, number] +>[1, 2] : [number, number] +>[1, 2] : [number, number] +>1 : 1 +>2 : 2 const t7 = /** @satisfies {T4} */ ({ a: 'test' }); >t7 : { a: string; } >({ a: 'test' }) : { a: string; } +>{ a: 'test' } : { a: string; } +>{ a: 'test' } : { a: string; } +>a : string +>'test' : "test" const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); >t8 : { a: string; b: string; } >({ a: 'test', b: 'test' }) : { a: string; b: string; } +>{ a: 'test', b: 'test' } : { a: string; b: string; } +>{ a: 'test', b: 'test' } : { a: string; b: string; } +>a : string +>'test' : "test" +>b : string +>'test' : "test" diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols index 2a1286a15b..3e073f9b5c 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols @@ -7,8 +7,14 @@ const p = /** @satisfies {Partial>} */ ({ >p : Symbol(p, Decl(a.js, 2, 5)) a: 0, +>a : Symbol(a, Decl(a.js, 2, 63)) + b: "hello", +>b : Symbol(b, Decl(a.js, 3, 9)) + x: 8 // Should error, 'x' isn't in 'Keys' +>x : Symbol(x, Decl(a.js, 4, 15)) + }); // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols.diff index 8bc6ad4de6..ef04a47cdd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.symbols.diff @@ -1,19 +1,6 @@ --- old.checkJsdocSatisfiesTag10.symbols +++ new.checkJsdocSatisfiesTag10.symbols -@@= skipped -6, +6 lines =@@ - >p : Symbol(p, Decl(a.js, 2, 5)) - - a: 0, -->a : Symbol(a, Decl(a.js, 2, 63)) -- - b: "hello", -->b : Symbol(b, Decl(a.js, 3, 9)) -- - x: 8 // Should error, 'x' isn't in 'Keys' -->x : Symbol(x, Decl(a.js, 4, 15)) -- - }); - +@@= skipped -19, +19 lines =@@ // Should be OK -- retain info that a is number and b is string let a = p.a.toFixed(); >a : Symbol(a, Decl(a.js, 9, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types index d08526f637..36f1c2160f 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types @@ -6,10 +6,21 @@ const p = /** @satisfies {Partial>} */ ({ >p : { a: number; b: string; x: number; } >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } +>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } +>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } a: 0, +>a : number +>0 : 0 + b: "hello", +>b : string +>"hello" : "hello" + x: 8 // Should error, 'x' isn't in 'Keys' +>x : number +>8 : 8 + }); // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types index 02ad5e1cc3..c08a8555b1 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types @@ -27,4 +27,6 @@ const t1 = { a: 1 }; const t2 = /** @satisfies {number} */ (1); >t2 : 1 >(1) : 1 +>1 : 1 +>1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols index 2c6d63a3f3..427e411bf2 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols @@ -15,4 +15,5 @@ const t1 = { a: 1 }; const t2 = /** @satisfies T1 */ ({ a: 1 }); >t2 : Symbol(t2, Decl(a.js, 9, 5)) +>a : Symbol(a, Decl(a.js, 9, 34)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols.diff deleted file mode 100644 index f0b4fa56ab..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.symbols.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.checkJsdocSatisfiesTag14.symbols -+++ new.checkJsdocSatisfiesTag14.symbols -@@= skipped -14, +14 lines =@@ - - const t2 = /** @satisfies T1 */ ({ a: 1 }); - >t2 : Symbol(t2, Decl(a.js, 9, 5)) -->a : Symbol(a, Decl(a.js, 9, 34)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types index fcaf65054b..5469de3f90 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types @@ -18,4 +18,8 @@ const t1 = { a: 1 }; const t2 = /** @satisfies T1 */ ({ a: 1 }); >t2 : { a: number; } >({ a: 1 }) : { a: number; } +>{ a: 1 } : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols index 6a8f1a551f..c40b2a537b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols @@ -7,6 +7,14 @@ const p = /** @satisfies {Predicates} */ ({ >p : Symbol(p, Decl(a.js, 2, 5)) isEven: n => n % 2 === 0, +>isEven : Symbol(isEven, Decl(a.js, 2, 43)) +>n : Symbol(n, Decl(a.js, 3, 11)) +>n : Symbol(n, Decl(a.js, 3, 11)) + isOdd: n => n % 2 === 1 +>isOdd : Symbol(isOdd, Decl(a.js, 3, 29)) +>n : Symbol(n, Decl(a.js, 4, 10)) +>n : Symbol(n, Decl(a.js, 4, 10)) + }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols.diff deleted file mode 100644 index f04a876a37..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.symbols.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.checkJsdocSatisfiesTag2.symbols -+++ new.checkJsdocSatisfiesTag2.symbols -@@= skipped -6, +6 lines =@@ - >p : Symbol(p, Decl(a.js, 2, 5)) - - isEven: n => n % 2 === 0, -->isEven : Symbol(isEven, Decl(a.js, 2, 43)) -->n : Symbol(n, Decl(a.js, 3, 11)) -->n : Symbol(n, Decl(a.js, 3, 11)) -- - isOdd: n => n % 2 === 1 -->isOdd : Symbol(isOdd, Decl(a.js, 3, 29)) -->n : Symbol(n, Decl(a.js, 4, 10)) -->n : Symbol(n, Decl(a.js, 4, 10)) -- - }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types index 589f175640..5d108c5b86 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types @@ -6,8 +6,28 @@ const p = /** @satisfies {Predicates} */ ({ >p : any >({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : any +>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : any +>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } isEven: n => n % 2 === 0, +>isEven : (n: any) => boolean +>n => n % 2 === 0 : (n: any) => boolean +>n : any +>n % 2 === 0 : boolean +>n % 2 : number +>n : any +>2 : 2 +>0 : 0 + isOdd: n => n % 2 === 1 +>isOdd : (n: any) => boolean +>n => n % 2 === 1 : (n: any) => boolean +>n : any +>n % 2 === 1 : boolean +>n % 2 : number +>n : any +>2 : 2 +>1 : 1 + }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols index 42685a12de..1f87a5e6db 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols @@ -6,9 +6,17 @@ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ( >obj : Symbol(obj, Decl(a.js, 1, 3)) f(s) { }, // "incorrect" implicit any on 's' +>f : Symbol(f, Decl(a.js, 1, 81)) +>s : Symbol(s, Decl(a.js, 2, 6)) + g(s) { } +>g : Symbol(g, Decl(a.js, 2, 13)) +>s : Symbol(s, Decl(a.js, 3, 6)) + }); // This needs to not crash (outer node is not expression) /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) +>f : Symbol(f, Decl(a.js, 7, 45)) +>x : Symbol(x, Decl(a.js, 7, 48)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols.diff deleted file mode 100644 index 85aa0ada95..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.symbols.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.checkJsdocSatisfiesTag3.symbols -+++ new.checkJsdocSatisfiesTag3.symbols -@@= skipped -5, +5 lines =@@ - >obj : Symbol(obj, Decl(a.js, 1, 3)) - - f(s) { }, // "incorrect" implicit any on 's' -->f : Symbol(f, Decl(a.js, 1, 81)) -->s : Symbol(s, Decl(a.js, 2, 6)) -- - g(s) { } -->g : Symbol(g, Decl(a.js, 2, 13)) -->s : Symbol(s, Decl(a.js, 3, 6)) -- - }); - - // This needs to not crash (outer node is not expression) - /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) -->f : Symbol(f, Decl(a.js, 7, 45)) -->x : Symbol(x, Decl(a.js, 7, 48)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types index 14048d796c..9233704bbf 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types @@ -5,12 +5,24 @@ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ >obj : { f(s: string): void; } & Record >({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: any): void; g(s: string): void; } +>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } +>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } f(s) { }, // "incorrect" implicit any on 's' +>f : (s: any) => void +>s : any + g(s) { } +>g : (s: string) => void +>s : string + }); // This needs to not crash (outer node is not expression) /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) >({ f(x) { } }) : { f(x: string): void; } +>{ f(x) { } } : { f(x: string): void; } +>{ f(x) { } } : { f(x: string): void; } +>f : (x: string) => void +>x : string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols index 248891f379..668caabf6f 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols @@ -9,10 +9,11 @@ export default /** @satisfies {Foo} */ ({}); === /b.js === - /** * @typedef {Object} Foo * @property {number} a */ export default /** @satisfies {Foo} */ ({ a: 1 }); +>a : Symbol(a, Decl(b.js, 5, 41)) + diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols.diff deleted file mode 100644 index f446b0f06c..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.checkJsdocSatisfiesTag4.symbols -+++ new.checkJsdocSatisfiesTag4.symbols -@@= skipped -8, +8 lines =@@ - export default /** @satisfies {Foo} */ ({}); - - === /b.js === -+ - /** - * @typedef {Object} Foo - * @property {number} a - */ - - export default /** @satisfies {Foo} */ ({ a: 1 }); -->a : Symbol(a, Decl(b.js, 5, 41)) -- \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types index f529622f94..e25cf2934b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types @@ -7,6 +7,8 @@ */ export default /** @satisfies {Foo} */ ({}); >({}) : {} +>{} : {} +>{} : {} === /b.js === /** @@ -16,4 +18,8 @@ export default /** @satisfies {Foo} */ ({}); export default /** @satisfies {Foo} */ ({ a: 1 }); >({ a: 1 }) : { a: number; } +>{ a: 1 } : { a: number; } +>{ a: 1 } : { a: number; } +>a : number +>1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols index ba59de9b2b..93b511fee3 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols @@ -7,9 +7,16 @@ const car = /** @satisfies {Movable & Record} */ ({ >car : Symbol(car, Decl(a.js, 2, 5)) start() { }, +>start : Symbol(start, Decl(a.js, 2, 68)) + move(d) { +>move : Symbol(move, Decl(a.js, 3, 16)) +>d : Symbol(d, Decl(a.js, 4, 9)) + // d should be number }, stop() { } +>stop : Symbol(stop, Decl(a.js, 6, 6)) + }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols.diff deleted file mode 100644 index 603a525edc..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.symbols.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.checkJsdocSatisfiesTag5.symbols -+++ new.checkJsdocSatisfiesTag5.symbols -@@= skipped -6, +6 lines =@@ - >car : Symbol(car, Decl(a.js, 2, 5)) - - start() { }, -->start : Symbol(start, Decl(a.js, 2, 68)) -- - move(d) { -->move : Symbol(move, Decl(a.js, 3, 16)) -->d : Symbol(d, Decl(a.js, 4, 9)) -- - // d should be number - }, - stop() { } -->stop : Symbol(stop, Decl(a.js, 6, 6)) -- - }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types index 2a95cd9240..45a70bcd6b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types @@ -6,11 +6,20 @@ const car = /** @satisfies {Movable & Record} */ ({ >car : { start(): void; move(d: number): void; stop(): void; } >({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: number): void; stop(): void; } +>{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } +>{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } start() { }, +>start : () => void + move(d) { +>move : (d: number) => void +>d : number + // d should be number }, stop() { } +>stop : () => void + }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols index 40ed7808c1..d2cf75408b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols @@ -10,6 +10,7 @@ // Undesirable behavior today with type annotation const a = /** @satisfies {Partial} */ ({ x: 10 }); >a : Symbol(a, Decl(a.js, 7, 5)) +>x : Symbol(x, Decl(a.js, 7, 49)) // Should OK console.log(a.x.toFixed()); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols.diff index b592d4f0aa..9ee7579c27 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.symbols.diff @@ -1,10 +1,6 @@ --- old.checkJsdocSatisfiesTag6.symbols +++ new.checkJsdocSatisfiesTag6.symbols -@@= skipped -9, +9 lines =@@ - // Undesirable behavior today with type annotation - const a = /** @satisfies {Partial} */ ({ x: 10 }); - >a : Symbol(a, Decl(a.js, 7, 5)) -->x : Symbol(x, Decl(a.js, 7, 49)) +@@= skipped -13, +13 lines =@@ // Should OK console.log(a.x.toFixed()); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types index 70334ccafc..3d1dea524e 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types @@ -11,6 +11,10 @@ const a = /** @satisfies {Partial} */ ({ x: 10 }); >a : { x: number; } >({ x: 10 }) : { x: number; } +>{ x: 10 } : { x: number; } +>{ x: 10 } : { x: number; } +>x : number +>10 : 10 // Should OK console.log(a.x.toFixed()); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols index ce35df1689..1de7d258d5 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols @@ -7,8 +7,14 @@ const p = /** @satisfies {Record} */ ({ >p : Symbol(p, Decl(a.js, 2, 5)) a: 0, +>a : Symbol(a, Decl(a.js, 2, 54)) + b: "hello", +>b : Symbol(b, Decl(a.js, 3, 9)) + x: 8 // Should error, 'x' isn't in 'Keys' +>x : Symbol(x, Decl(a.js, 4, 15)) + }) // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols.diff index adeb67184d..e6530aeb83 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.symbols.diff @@ -1,19 +1,6 @@ --- old.checkJsdocSatisfiesTag7.symbols +++ new.checkJsdocSatisfiesTag7.symbols -@@= skipped -6, +6 lines =@@ - >p : Symbol(p, Decl(a.js, 2, 5)) - - a: 0, -->a : Symbol(a, Decl(a.js, 2, 54)) -- - b: "hello", -->b : Symbol(b, Decl(a.js, 3, 9)) -- - x: 8 // Should error, 'x' isn't in 'Keys' -->x : Symbol(x, Decl(a.js, 4, 15)) -- - }) - +@@= skipped -19, +19 lines =@@ // Should be OK -- retain info that a is number and b is string let a = p.a.toFixed(); >a : Symbol(a, Decl(a.js, 9, 3)) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types index 03178cd055..7946899b26 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types @@ -6,10 +6,21 @@ const p = /** @satisfies {Record} */ ({ >p : { a: number; b: string; x: number; } >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } +>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } +>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } a: 0, +>a : number +>0 : 0 + b: "hello", +>b : string +>"hello" : "hello" + x: 8 // Should error, 'x' isn't in 'Keys' +>x : number +>8 : 8 + }) // Should be OK -- retain info that a is number and b is string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols index 46bc9a56d7..1f6e6afdbe 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols @@ -8,6 +8,10 @@ const x = /** @satisfies {Facts} */ ({ >x : Symbol(x, Decl(a.js, 3, 5)) m: true, +>m : Symbol(m, Decl(a.js, 3, 38)) + s: "false" +>s : Symbol(s, Decl(a.js, 4, 12)) + }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols.diff deleted file mode 100644 index 6040bba6b8..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.symbols.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.checkJsdocSatisfiesTag8.symbols -+++ new.checkJsdocSatisfiesTag8.symbols -@@= skipped -7, +7 lines =@@ - >x : Symbol(x, Decl(a.js, 3, 5)) - - m: true, -->m : Symbol(m, Decl(a.js, 3, 38)) -- - s: "false" -->s : Symbol(s, Decl(a.js, 4, 12)) -- - }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types index f5612a902e..c1c663fa30 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types @@ -7,8 +7,16 @@ const x = /** @satisfies {Facts} */ ({ >x : any >({ m: true, s: "false"}) : any +>{ m: true, s: "false"} : any +>{ m: true, s: "false"} : { m: boolean; s: string; } m: true, +>m : boolean +>true : true + s: "false" +>s : string +>"false" : "false" + }) diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols index 0991b55a69..10ea8be886 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols @@ -13,7 +13,22 @@ export const Palette = /** @satisfies {Record} */ ({ >Palette : Symbol(Palette, Decl(a.js, 8, 12)) white: { r: 255, g: 255, b: 255 }, +>white : Symbol(white, Decl(a.js, 8, 67)) +>r : Symbol(r, Decl(a.js, 9, 12)) +>g : Symbol(g, Decl(a.js, 9, 20)) +>b : Symbol(b, Decl(a.js, 9, 28)) + black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' +>black : Symbol(black, Decl(a.js, 9, 38)) +>r : Symbol(r, Decl(a.js, 10, 12)) +>g : Symbol(g, Decl(a.js, 10, 18)) +>d : Symbol(d, Decl(a.js, 10, 24)) + blue: { r: 0, g: 0, b: 255 }, +>blue : Symbol(blue, Decl(a.js, 10, 32)) +>r : Symbol(r, Decl(a.js, 11, 11)) +>g : Symbol(g, Decl(a.js, 11, 17)) +>b : Symbol(b, Decl(a.js, 11, 23)) + }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols.diff b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols.diff deleted file mode 100644 index 93a5d31187..0000000000 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.symbols.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.checkJsdocSatisfiesTag9.symbols -+++ new.checkJsdocSatisfiesTag9.symbols -@@= skipped -12, +12 lines =@@ - >Palette : Symbol(Palette, Decl(a.js, 8, 12)) - - white: { r: 255, g: 255, b: 255 }, -->white : Symbol(white, Decl(a.js, 8, 67)) -->r : Symbol(r, Decl(a.js, 9, 12)) -->g : Symbol(g, Decl(a.js, 9, 20)) -->b : Symbol(b, Decl(a.js, 9, 28)) -- - black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' -->black : Symbol(black, Decl(a.js, 9, 38)) -->r : Symbol(r, Decl(a.js, 10, 12)) -->g : Symbol(g, Decl(a.js, 10, 18)) -->d : Symbol(d, Decl(a.js, 10, 24)) -- - blue: { r: 0, g: 0, b: 255 }, -->blue : Symbol(blue, Decl(a.js, 10, 32)) -->r : Symbol(r, Decl(a.js, 11, 11)) -->g : Symbol(g, Decl(a.js, 11, 17)) -->b : Symbol(b, Decl(a.js, 11, 23)) -- - }); diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types index 1c279a2631..b363b74b1d 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types @@ -12,9 +12,38 @@ export const Palette = /** @satisfies {Record} */ ({ >Palette : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } >({ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },}) : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } +>{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } +>{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } white: { r: 255, g: 255, b: 255 }, +>white : { r: number; g: number; b: number; } +>{ r: 255, g: 255, b: 255 } : { r: number; g: number; b: number; } +>r : number +>255 : 255 +>g : number +>255 : 255 +>b : number +>255 : 255 + black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' +>black : { r: number; g: number; d: number; } +>{ r: 0, g: 0, d: 0 } : { r: number; g: number; d: number; } +>r : number +>0 : 0 +>g : number +>0 : 0 +>d : number +>0 : 0 + blue: { r: 0, g: 0, b: 255 }, +>blue : { r: number; g: number; b: number; } +>{ r: 0, g: 0, b: 255 } : { r: number; g: number; b: number; } +>r : number +>0 : 0 +>g : number +>0 : 0 +>b : number +>255 : 255 + }); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff index 9a7647e686..3fb1359cf8 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff @@ -1,26 +1,26 @@ --- old.checkJsdocSatisfiesTag1.types +++ new.checkJsdocSatisfiesTag1.types -@@= skipped -22, +22 lines =@@ - const t1 = /** @satisfies {T1} */ ({ a: 1 }); +@@= skipped -23, +23 lines =@@ >t1 : { a: number; } >({ a: 1 }) : { a: number; } -->{ a: 1 } : { a: number; } -->a : number -->1 : 1 + >{ a: 1 } : { a: number; } ++>{ a: 1 } : { a: number; } + >a : number + >1 : 1 - const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); +@@= skipped -7, +8 lines =@@ >t2 : { a: number; b: number; } >({ a: 1, b: 1 }) : { a: number; b: number; } -->{ a: 1, b: 1 } : { a: number; b: number; } -->a : number -->1 : 1 -->b : number -->1 : 1 - - const t3 = /** @satisfies {T1} */ ({}); + >{ a: 1, b: 1 } : { a: number; b: number; } ++>{ a: 1, b: 1 } : { a: number; b: number; } + >a : number + >1 : 1 + >b : number +@@= skipped -9, +10 lines =@@ >t3 : {} >({}) : {} -->{} : {} + >{} : {} ++>{} : {} /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); @@ -28,40 +28,41 @@ ->({ a: "a" }) : T2 ->{ a: "a" } : { a: "a"; } ->a : "a" -->"a" : "a" +>({ a: "a" }) : { a: string; } ++>{ a: "a" } : { a: string; } ++>{ a: "a" } : { a: string; } ++>a : string + >"a" : "a" /** @type {(m: string) => string} */ - const t5 = /** @satisfies {T3} */((m) => m.substring(0)); +@@= skipped -14, +16 lines =@@ >t5 : (m: string) => string >((m) => m.substring(0)) : (m: string) => string -->(m) => m.substring(0) : (m: string) => string -->m : string -->m.substring(0) : string -->m.substring : (start: number, end?: number) => string -->m : string -->substring : (start: number, end?: number) => string -->0 : 0 - - const t6 = /** @satisfies {[number, number]} */ ([1, 2]); + >(m) => m.substring(0) : (m: string) => string ++>(m) => m.substring(0) : (m: string) => string + >m : string + >m.substring(0) : string + >m.substring : (start: number, end?: number) => string +@@= skipped -11, +12 lines =@@ >t6 : [number, number] >([1, 2]) : [number, number] -->[1, 2] : [number, number] -->1 : 1 -->2 : 2 + >[1, 2] : [number, number] ++>[1, 2] : [number, number] + >1 : 1 + >2 : 2 - const t7 = /** @satisfies {T4} */ ({ a: 'test' }); +@@= skipped -7, +8 lines =@@ >t7 : { a: string; } >({ a: 'test' }) : { a: string; } -->{ a: 'test' } : { a: string; } -->a : string -->'test' : "test" + >{ a: 'test' } : { a: string; } ++>{ a: 'test' } : { a: string; } + >a : string + >'test' : "test" const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); >t8 : { a: string; b: string; } >({ a: 'test', b: 'test' }) : { a: string; b: string; } -->{ a: 'test', b: 'test' } : { a: string; b: string; } -->a : string -->'test' : "test" -->b : string -->'test' : "test" ++>{ a: 'test', b: 'test' } : { a: string; b: string; } + >{ a: 'test', b: 'test' } : { a: string; b: string; } + >a : string + >'test' : "test" \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff index c654bf7a97..3c326a0343 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff @@ -1,23 +1,10 @@ --- old.checkJsdocSatisfiesTag10.types +++ new.checkJsdocSatisfiesTag10.types -@@= skipped -5, +5 lines =@@ - const p = /** @satisfies {Partial>} */ ({ +@@= skipped -6, +6 lines =@@ >p : { a: number; b: string; x: number; } >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } -->{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } + >{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } ++>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } a: 0, -->a : number -->0 : 0 -- - b: "hello", -->b : string -->"hello" : "hello" -- - x: 8 // Should error, 'x' isn't in 'Keys' -->x : number -->8 : 8 -- - }); - - // Should be OK -- retain info that a is number and b is string \ No newline at end of file + >a : number \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff index 350cfb3c0c..cca4442bd9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff @@ -1,7 +1,7 @@ --- old.checkJsdocSatisfiesTag11.types +++ new.checkJsdocSatisfiesTag11.types -@@= skipped -26, +26 lines =@@ - const t2 = /** @satisfies {number} */ (1); +@@= skipped -27, +27 lines =@@ >t2 : 1 >(1) : 1 -->1 : 1 + >1 : 1 ++>1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff index 17ffdbd306..e73bc78a83 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff @@ -1,9 +1,9 @@ --- old.checkJsdocSatisfiesTag14.types +++ new.checkJsdocSatisfiesTag14.types -@@= skipped -17, +17 lines =@@ - const t2 = /** @satisfies T1 */ ({ a: 1 }); +@@= skipped -18, +18 lines =@@ >t2 : { a: number; } >({ a: 1 }) : { a: number; } -->{ a: 1 } : { a: number; } -->a : number -->1 : 1 + >{ a: 1 } : { a: number; } ++>{ a: 1 } : { a: number; } + >a : number + >1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff index 5b50854ece..a0a5949aef 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff @@ -9,25 +9,33 @@ ->{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: number) => boolean; isOdd: (n: number) => boolean; } +>p : any +>({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : any ++>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : any ++>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } isEven: n => n % 2 === 0, ->isEven : (n: number) => boolean ->n => n % 2 === 0 : (n: number) => boolean ->n : number -->n % 2 === 0 : boolean -->n % 2 : number ++>isEven : (n: any) => boolean ++>n => n % 2 === 0 : (n: any) => boolean ++>n : any + >n % 2 === 0 : boolean + >n % 2 : number ->n : number -->2 : 2 -->0 : 0 -- ++>n : any + >2 : 2 + >0 : 0 + isOdd: n => n % 2 === 1 ->isOdd : (n: number) => boolean ->n => n % 2 === 1 : (n: number) => boolean ->n : number -->n % 2 === 1 : boolean -->n % 2 : number ++>isOdd : (n: any) => boolean ++>n => n % 2 === 1 : (n: any) => boolean ++>n : any + >n % 2 === 1 : boolean + >n % 2 : number ->n : number -->2 : 2 -->1 : 1 -- - }); ++>n : any + >2 : 2 + >1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff index 276b58f59e..6adbf80a98 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff @@ -5,22 +5,16 @@ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ >obj : { f(s: string): void; } & Record ->({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: string): void; } & Record -->{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } +>({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: any): void; g(s: string): void; } ++>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } + >{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } f(s) { }, // "incorrect" implicit any on 's' -->f : (s: any) => void -->s : any -- - g(s) { } -->g : (s: string) => void -->s : string -- - }); - +@@= skipped -16, +17 lines =@@ // This needs to not crash (outer node is not expression) /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) >({ f(x) { } }) : { f(x: string): void; } -->{ f(x) { } } : { f(x: string): void; } -->f : (x: string) => void -->x : string ++>{ f(x) { } } : { f(x: string): void; } + >{ f(x) { } } : { f(x: string): void; } + >f : (x: string) => void + >x : string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff index 450cfd5f4d..5e521f2220 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff @@ -1,17 +1,18 @@ --- old.checkJsdocSatisfiesTag4.types +++ new.checkJsdocSatisfiesTag4.types -@@= skipped -6, +6 lines =@@ - */ +@@= skipped -7, +7 lines =@@ export default /** @satisfies {Foo} */ ({}); >({}) : {} -->{} : {} + >{} : {} ++>{} : {} === /b.js === /** -@@= skipped -10, +9 lines =@@ +@@= skipped -9, +10 lines =@@ export default /** @satisfies {Foo} */ ({ a: 1 }); >({ a: 1 }) : { a: number; } -->{ a: 1 } : { a: number; } -->a : number -->1 : 1 ++>{ a: 1 } : { a: number; } + >{ a: 1 } : { a: number; } + >a : number + >1 : 1 \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff index e7b63494e5..44287a7788 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff @@ -1,21 +1,10 @@ --- old.checkJsdocSatisfiesTag5.types +++ new.checkJsdocSatisfiesTag5.types -@@= skipped -5, +5 lines =@@ - const car = /** @satisfies {Movable & Record} */ ({ +@@= skipped -6, +6 lines =@@ >car : { start(): void; move(d: number): void; stop(): void; } >({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: number): void; stop(): void; } -->{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } + >{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } ++>{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } start() { }, -->start : () => void -- - move(d) { -->move : (d: number) => void -->d : number -- - // d should be number - }, - stop() { } -->stop : () => void -- - }) + >start : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff index 92e8143c61..fa530537ab 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff @@ -1,12 +1,9 @@ --- old.checkJsdocSatisfiesTag6.types +++ new.checkJsdocSatisfiesTag6.types -@@= skipped -10, +10 lines =@@ - const a = /** @satisfies {Partial} */ ({ x: 10 }); +@@= skipped -11, +11 lines =@@ >a : { x: number; } >({ x: 10 }) : { x: number; } -->{ x: 10 } : { x: number; } -->x : number -->10 : 10 - - // Should OK - console.log(a.x.toFixed()); \ No newline at end of file + >{ x: 10 } : { x: number; } ++>{ x: 10 } : { x: number; } + >x : number + >10 : 10 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff index 40e310d889..26bb173a50 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff @@ -1,23 +1,10 @@ --- old.checkJsdocSatisfiesTag7.types +++ new.checkJsdocSatisfiesTag7.types -@@= skipped -5, +5 lines =@@ - const p = /** @satisfies {Record} */ ({ +@@= skipped -6, +6 lines =@@ >p : { a: number; b: string; x: number; } >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } -->{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } + >{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } ++>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } a: 0, -->a : number -->0 : 0 -- - b: "hello", -->b : string -->"hello" : "hello" -- - x: 8 // Should error, 'x' isn't in 'Keys' -->x : number -->8 : 8 -- - }) - - // Should be OK -- retain info that a is number and b is string \ No newline at end of file + >a : number \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff index dc685942ee..3df2d3f790 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff @@ -9,13 +9,12 @@ ->{ m: true, s: "false"} : { m: true; s: string; } +>x : any +>({ m: true, s: "false"}) : any ++>{ m: true, s: "false"} : any ++>{ m: true, s: "false"} : { m: boolean; s: string; } m: true, ->m : true -->true : true -- - s: "false" -->s : string -->"false" : "false" -- - }) ++>m : boolean + >true : true + + s: "false" \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff index 6878984c1e..72ad0f80c6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff @@ -1,39 +1,10 @@ --- old.checkJsdocSatisfiesTag9.types +++ new.checkJsdocSatisfiesTag9.types -@@= skipped -11, +11 lines =@@ - export const Palette = /** @satisfies {Record} */ ({ +@@= skipped -12, +12 lines =@@ >Palette : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } >({ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },}) : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } -->{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } + >{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } ++>{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } white: { r: 255, g: 255, b: 255 }, -->white : { r: number; g: number; b: number; } -->{ r: 255, g: 255, b: 255 } : { r: number; g: number; b: number; } -->r : number -->255 : 255 -->g : number -->255 : 255 -->b : number -->255 : 255 -- - black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' -->black : { r: number; g: number; d: number; } -->{ r: 0, g: 0, d: 0 } : { r: number; g: number; d: number; } -->r : number -->0 : 0 -->g : number -->0 : 0 -->d : number -->0 : 0 -- - blue: { r: 0, g: 0, b: 255 }, -->blue : { r: number; g: number; b: number; } -->{ r: 0, g: 0, b: 255 } : { r: number; g: number; b: number; } -->r : number -->0 : 0 -->g : number -->0 : 0 -->b : number -->255 : 255 -- - }); + >white : { r: number; g: number; b: number; } \ No newline at end of file From ffa002e1a8a82318a1c21509a10323340b2e97d0 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 11 Jun 2025 08:46:57 -0700 Subject: [PATCH 5/6] switch to AsExpression --- internal/parser/reparser.go | 2 +- internal/testutil/tsbaseline/type_symbol_baseline.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index bdb584b961..faab4e00b0 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -430,7 +430,7 @@ func getFunctionLikeHost(host *ast.Node) (*ast.Node, bool) { func (p *Parser) makeNewCast(t *ast.TypeNode, e *ast.Node, isAssertion bool) *ast.Node { var assert *ast.Node if isAssertion { - assert = p.factory.NewTypeAssertion(t, e) + assert = p.factory.NewAsExpression(e, t) } else { assert = p.factory.NewSatisfiesExpression(e, t) } diff --git a/internal/testutil/tsbaseline/type_symbol_baseline.go b/internal/testutil/tsbaseline/type_symbol_baseline.go index 5c70707215..4c37e852af 100644 --- a/internal/testutil/tsbaseline/type_symbol_baseline.go +++ b/internal/testutil/tsbaseline/type_symbol_baseline.go @@ -327,7 +327,7 @@ func forEachASTNode(node *ast.Node) []*ast.Node { for len(work) > 0 { elem := work[len(work)-1] work = work[:len(work)-1] - if elem.Flags&ast.NodeFlagsReparsed != 0 && elem.Kind != ast.KindTypeAssertionExpression && elem.Kind != ast.KindSatisfiesExpression { + if elem.Flags&ast.NodeFlagsReparsed != 0 && elem.Kind != ast.KindAsExpression && elem.Kind != ast.KindSatisfiesExpression { continue } result = append(result, elem) From 241d2d86b72f9412eb80ec87c6afd47f47deb066 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 12 Jun 2025 06:56:29 -0700 Subject: [PATCH 6/6] even specialer case for jsdoc cast baselines print their children but not the nodes themselves. This makes the baselines basically identical to the Strada ones. --- .../tsbaseline/type_symbol_baseline.go | 15 +-- .../compiler/arrowExpressionBodyJSDoc.types | 3 - .../compiler/arrowExpressionJs.types | 1 - .../checkJsTypeDefNoUnusedLocalMarked.types | 1 - ...OnlyInferenceFromAnnotatedFunctionJs.types | 1 - ...enceWithAnnotatedOptionalParameterJs.types | 1 - .../compiler/exportDefaultWithJSDoc2.types | 1 - .../compiler/jsFileFunctionOverloads.types | 1 - .../compiler/jsFileFunctionOverloads2.types | 1 - .../jsdocImportTypeNodeNamespace.types | 1 - .../submodule/compiler/jsdocTypeCast.types | 1 - ...enthesizedJSDocCastAtReturnStatement.types | 1 - .../parenthesizedJSDocCastDoesNotNarrow.types | 1 - ...returnConditionalExpressionJSDocCast.types | 1 - .../compiler/strictOptionalProperties4.types | 2 - .../assertionTypePredicates2.types | 1 - .../conformance/checkJsdocSatisfiesTag1.types | 8 -- .../checkJsdocSatisfiesTag10.types | 1 - .../checkJsdocSatisfiesTag11.types | 1 - .../checkJsdocSatisfiesTag14.types | 1 - .../conformance/checkJsdocSatisfiesTag2.types | 1 - .../conformance/checkJsdocSatisfiesTag3.types | 2 - .../conformance/checkJsdocSatisfiesTag4.types | 2 - .../conformance/checkJsdocSatisfiesTag5.types | 1 - .../conformance/checkJsdocSatisfiesTag6.types | 1 - .../conformance/checkJsdocSatisfiesTag7.types | 1 - .../conformance/checkJsdocSatisfiesTag8.types | 1 - .../conformance/checkJsdocSatisfiesTag9.types | 1 - .../conformance/importTypeInJSDoc.types | 4 - .../conformance/jsDeclarationsClasses.types | 3 - .../conformance/jsDeclarationsDefault.types | 2 - ...DeclarationsExportDefinePropertyEmit.types | 2 - .../conformance/jsDeclarationsFunctions.types | 2 - .../jsDeclarationsFunctionsCjs.types | 2 - .../jsdocSignatureOnReturnedFunction.types | 2 - .../conformance/jsdocTypeTagCast.types | 18 --- .../conformance/templateInsideCallback.types | 1 - .../arrowExpressionBodyJSDoc.types.diff | 19 --- .../compiler/arrowExpressionJs.types.diff | 9 -- ...eckJsTypeDefNoUnusedLocalMarked.types.diff | 1 - ...nferenceFromAnnotatedFunctionJs.types.diff | 1 - ...ithAnnotatedOptionalParameterJs.types.diff | 10 +- .../exportDefaultWithJSDoc2.types.diff | 1 - .../jsFileFunctionOverloads.types.diff | 10 +- .../jsFileFunctionOverloads2.types.diff | 10 -- .../jsdocImportTypeNodeNamespace.types.diff | 1 - .../compiler/jsdocTypeCast.types.diff | 10 +- ...sizedJSDocCastAtReturnStatement.types.diff | 10 -- ...nthesizedJSDocCastDoesNotNarrow.types.diff | 10 -- ...nConditionalExpressionJSDocCast.types.diff | 4 +- .../strictOptionalProperties4.types.diff | 9 +- .../assertionTypePredicates2.types.diff | 3 +- .../checkJsdocSatisfiesTag1.types.diff | 57 +-------- .../checkJsdocSatisfiesTag10.types.diff | 10 -- .../checkJsdocSatisfiesTag11.types.diff | 7 -- .../checkJsdocSatisfiesTag14.types.diff | 9 -- .../checkJsdocSatisfiesTag2.types.diff | 1 - .../checkJsdocSatisfiesTag3.types.diff | 11 +- .../checkJsdocSatisfiesTag4.types.diff | 18 --- .../checkJsdocSatisfiesTag5.types.diff | 10 -- .../checkJsdocSatisfiesTag6.types.diff | 9 -- .../checkJsdocSatisfiesTag7.types.diff | 10 -- .../checkJsdocSatisfiesTag8.types.diff | 1 - .../checkJsdocSatisfiesTag9.types.diff | 10 -- .../conformance/importTypeInJSDoc.types.diff | 13 +- .../jsDeclarationsClasses.types.diff | 28 +---- .../jsDeclarationsDefault.types.diff | 18 --- ...rationsExportDefinePropertyEmit.types.diff | 12 +- .../jsDeclarationsFunctions.types.diff | 17 +-- .../jsDeclarationsFunctionsCjs.types.diff | 9 +- ...sdocSignatureOnReturnedFunction.types.diff | 18 --- .../conformance/jsdocTypeTagCast.types.diff | 119 +----------------- .../templateInsideCallback.types.diff | 10 +- 73 files changed, 32 insertions(+), 563 deletions(-) delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.types.diff delete mode 100644 testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.types.diff diff --git a/internal/testutil/tsbaseline/type_symbol_baseline.go b/internal/testutil/tsbaseline/type_symbol_baseline.go index 4c37e852af..a8ee81afaf 100644 --- a/internal/testutil/tsbaseline/type_symbol_baseline.go +++ b/internal/testutil/tsbaseline/type_symbol_baseline.go @@ -327,14 +327,15 @@ func forEachASTNode(node *ast.Node) []*ast.Node { for len(work) > 0 { elem := work[len(work)-1] work = work[:len(work)-1] - if elem.Flags&ast.NodeFlagsReparsed != 0 && elem.Kind != ast.KindAsExpression && elem.Kind != ast.KindSatisfiesExpression { - continue + if elem.Flags&ast.NodeFlagsReparsed == 0 || elem.Kind == ast.KindAsExpression || elem.Kind == ast.KindSatisfiesExpression { + if elem.Flags&ast.NodeFlagsReparsed == 0 { + result = append(result, elem) + } + elem.ForEachChild(addChild) + slices.Reverse(resChildren) + work = append(work, resChildren...) + resChildren = resChildren[:0] } - result = append(result, elem) - elem.ForEachChild(addChild) - slices.Reverse(resChildren) - work = append(work, resChildren...) - resChildren = resChildren[:0] } return result } diff --git a/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.types b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.types index 2595c45c86..73169f527c 100644 --- a/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.types +++ b/testdata/baselines/reference/submodule/compiler/arrowExpressionBodyJSDoc.types @@ -11,7 +11,6 @@ const foo1 = value => /** @type {string} */({ ...value }); >value => /** @type {string} */({ ...value }) : (value: T | undefined) => T >value : T | undefined >({ ...value }) : string ->{ ...value } : string >{ ...value } : {} >value : T | undefined @@ -25,9 +24,7 @@ const foo2 = value => /** @type {string} */(/** @type {T} */({ ...value })); >value => /** @type {string} */(/** @type {T} */({ ...value })) : (value: T | undefined) => T >value : T | undefined >(/** @type {T} */({ ...value })) : string ->({ ...value }) : string >({ ...value }) : T ->{ ...value } : T >{ ...value } : {} >value : T | undefined diff --git a/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.types b/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.types index 26c9070949..7e11bdc400 100644 --- a/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.types +++ b/testdata/baselines/reference/submodule/compiler/arrowExpressionJs.types @@ -11,7 +11,6 @@ const cloneObjectGood = value => /** @type {T} */({ ...value }); >value => /** @type {T} */({ ...value }) : (value: T | undefined) => T >value : T | undefined >({ ...value }) : T ->{ ...value } : T >{ ...value } : {} >value : T | undefined diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types index c50e2500bd..3494d23bc9 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.types @@ -29,7 +29,6 @@ module.exports = /** @type {FooFun} */(void 0); >module : { "export=": (foo: typeof import("./file")) => string; } >exports : (foo: typeof import("./file")) => string >(void 0) : (foo: typeof import("./file")) => string ->void 0 : (foo: typeof import("./file")) => string >void 0 : undefined >0 : 0 diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types index 0a096ac73a..8f199e3acd 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types @@ -19,7 +19,6 @@ function foo(fns) { return /** @type {any} */ (null); >(null) : any ->null : any } const result = foo({ diff --git a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types index 87ac4ac308..7c43485ae5 100644 --- a/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types +++ b/testdata/baselines/reference/submodule/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types @@ -12,7 +12,6 @@ function filter(predicate) { return /** @type {any} */ (null); >(null) : any ->null : any } const a = filter( diff --git a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types index cf343ba62c..f20c6945f4 100644 --- a/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types +++ b/testdata/baselines/reference/submodule/compiler/exportDefaultWithJSDoc2.types @@ -8,7 +8,6 @@ export default /** @type {NumberLike[]} */([ ]); >([ ]) : (string | number)[] ->[ ] : (string | number)[] >[ ] : undefined[] === b.ts === diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types index c09db52c41..928989838d 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads.types @@ -89,7 +89,6 @@ function flatMap(array, iterable = identity) { >push : (...items: unknown[]) => number >.../** @type {unknown[]} */(iterable(array[i])) : unknown >(iterable(array[i])) : unknown[] ->iterable(array[i]) : unknown[] >iterable(array[i]) : unknown >iterable : (x: unknown) => unknown >array[i] : unknown diff --git a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types index 8afa9b0633..7932e4b495 100644 --- a/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types +++ b/testdata/baselines/reference/submodule/compiler/jsFileFunctionOverloads2.types @@ -84,7 +84,6 @@ function flatMap(array, iterable = identity) { >push : (...items: unknown[]) => number >.../** @type {unknown[]} */(iterable(array[i])) : unknown >(iterable(array[i])) : unknown[] ->iterable(array[i]) : unknown[] >iterable(array[i]) : unknown >iterable : (x: unknown) => unknown >array[i] : unknown diff --git a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types index c851fa7232..c494efff24 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocImportTypeNodeNamespace.types @@ -14,7 +14,6 @@ export default _default; export default function () { return /** @type {import('./GeometryType.js').default} */ ('Point'); >('Point') : any ->'Point' : any >'Point' : "Point" } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types index 1ba298ee22..c74d7f74b8 100644 --- a/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types +++ b/testdata/baselines/reference/submodule/compiler/jsdocTypeCast.types @@ -32,7 +32,6 @@ let c = /** @type {'a' | 'b'} */ (x); // Ok >c : "a" | "b" >(x) : "a" | "b" ->x : "a" | "b" >x : string c; diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.types b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.types index ad819605f9..cc1d5a66f9 100644 --- a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.types +++ b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastAtReturnStatement.types @@ -21,7 +21,6 @@ const getStringGetter = (key) => { return /** @type {string} */ (cache.get(key)) >(cache.get(key)) : string ->cache.get(key) : string >cache.get(key) : string | Set | undefined >cache.get : (key: string) => string | Set | undefined >cache : Map> diff --git a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.types b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.types index fd2f5c031c..812d848ed2 100644 --- a/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.types +++ b/testdata/baselines/reference/submodule/compiler/parenthesizedJSDocCastDoesNotNarrow.types @@ -7,7 +7,6 @@ let value = ""; switch (/** @type {"foo" | "bar"} */ (value)) { >(value) : "bar" | "foo" ->value : "bar" | "foo" >value : string case "bar": diff --git a/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.types b/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.types index d2016ed057..555fe6553f 100644 --- a/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.types +++ b/testdata/baselines/reference/submodule/compiler/returnConditionalExpressionJSDocCast.types @@ -22,7 +22,6 @@ function source(type = "javascript") { >( type ? sources.get(type) : sources.get("some other thing") ) : String type ->type ? sources.get(type) : sources.get("some other thing") : String >type ? sources.get(type) : sources.get("some other thing") : string | undefined >type : string diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types index 1773918b3c..d7b145897d 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types @@ -9,7 +9,6 @@ const x = /** @type {Foo} */ ({}); >x : Foo >({}) : Foo ->{} : Foo >{} : {} x.foo; // number | undefined @@ -20,7 +19,6 @@ x.foo; // number | undefined const y = /** @type {Required} */ ({}); >y : Required >({}) : Required ->{} : Required >{} : {} y.foo; // number diff --git a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types index 8aaa0c1341..6acd8d393f 100644 --- a/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types +++ b/testdata/baselines/reference/submodule/conformance/assertionTypePredicates2.types @@ -22,7 +22,6 @@ const foo = (a) => { >(a).y !== 0 : boolean >(a).y : number >(a) : { x: number; } & { y: number; } ->a : { x: number; } & { y: number; } >a : { x: number; } >y : number >0 : 0 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types index 4dfa52b4aa..4923bf3f9c 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types @@ -24,7 +24,6 @@ const t1 = /** @satisfies {T1} */ ({ a: 1 }); >t1 : { a: number; } >({ a: 1 }) : { a: number; } >{ a: 1 } : { a: number; } ->{ a: 1 } : { a: number; } >a : number >1 : 1 @@ -32,7 +31,6 @@ const t2 = /** @satisfies {T1} */ ({ a: 1, b: 1 }); >t2 : { a: number; b: number; } >({ a: 1, b: 1 }) : { a: number; b: number; } >{ a: 1, b: 1 } : { a: number; b: number; } ->{ a: 1, b: 1 } : { a: number; b: number; } >a : number >1 : 1 >b : number @@ -42,14 +40,12 @@ const t3 = /** @satisfies {T1} */ ({}); >t3 : {} >({}) : {} >{} : {} ->{} : {} /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : T2 >({ a: "a" }) : { a: string; } >{ a: "a" } : { a: string; } ->{ a: "a" } : { a: string; } >a : string >"a" : "a" @@ -58,7 +54,6 @@ const t5 = /** @satisfies {T3} */((m) => m.substring(0)); >t5 : (m: string) => string >((m) => m.substring(0)) : (m: string) => string >(m) => m.substring(0) : (m: string) => string ->(m) => m.substring(0) : (m: string) => string >m : string >m.substring(0) : string >m.substring : (start: number, end?: number) => string @@ -70,7 +65,6 @@ const t6 = /** @satisfies {[number, number]} */ ([1, 2]); >t6 : [number, number] >([1, 2]) : [number, number] >[1, 2] : [number, number] ->[1, 2] : [number, number] >1 : 1 >2 : 2 @@ -78,7 +72,6 @@ const t7 = /** @satisfies {T4} */ ({ a: 'test' }); >t7 : { a: string; } >({ a: 'test' }) : { a: string; } >{ a: 'test' } : { a: string; } ->{ a: 'test' } : { a: string; } >a : string >'test' : "test" @@ -86,7 +79,6 @@ const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); >t8 : { a: string; b: string; } >({ a: 'test', b: 'test' }) : { a: string; b: string; } >{ a: 'test', b: 'test' } : { a: string; b: string; } ->{ a: 'test', b: 'test' } : { a: string; b: string; } >a : string >'test' : "test" >b : string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types index 36f1c2160f..19bb42f761 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag10.types @@ -6,7 +6,6 @@ const p = /** @satisfies {Partial>} */ ({ >p : { a: number; b: string; x: number; } >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } ->{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } >{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } a: 0, diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types index c08a8555b1..a9dfcaf190 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag11.types @@ -28,5 +28,4 @@ const t2 = /** @satisfies {number} */ (1); >t2 : 1 >(1) : 1 >1 : 1 ->1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types index 5469de3f90..be25ed76fd 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag14.types @@ -19,7 +19,6 @@ const t2 = /** @satisfies T1 */ ({ a: 1 }); >t2 : { a: number; } >({ a: 1 }) : { a: number; } >{ a: 1 } : { a: number; } ->{ a: 1 } : { a: number; } >a : number >1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types index 5d108c5b86..77582f6470 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag2.types @@ -6,7 +6,6 @@ const p = /** @satisfies {Predicates} */ ({ >p : any >({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : any ->{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : any >{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } isEven: n => n % 2 === 0, diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types index 9233704bbf..a8e506648b 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag3.types @@ -5,7 +5,6 @@ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ({ >obj : { f(s: string): void; } & Record >({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: any): void; g(s: string): void; } ->{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } >{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } f(s) { }, // "incorrect" implicit any on 's' @@ -22,7 +21,6 @@ let obj = /** @satisfies {{ g(s: string): void } & Record} */ ( /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) >({ f(x) { } }) : { f(x: string): void; } >{ f(x) { } } : { f(x: string): void; } ->{ f(x) { } } : { f(x: string): void; } >f : (x: string) => void >x : string diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types index e25cf2934b..0d01dd7d19 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag4.types @@ -8,7 +8,6 @@ export default /** @satisfies {Foo} */ ({}); >({}) : {} >{} : {} ->{} : {} === /b.js === /** @@ -19,7 +18,6 @@ export default /** @satisfies {Foo} */ ({}); export default /** @satisfies {Foo} */ ({ a: 1 }); >({ a: 1 }) : { a: number; } >{ a: 1 } : { a: number; } ->{ a: 1 } : { a: number; } >a : number >1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types index 45a70bcd6b..d11b05dedb 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag5.types @@ -6,7 +6,6 @@ const car = /** @satisfies {Movable & Record} */ ({ >car : { start(): void; move(d: number): void; stop(): void; } >({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: number): void; stop(): void; } ->{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } >{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } start() { }, diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types index 3d1dea524e..27731e2ff5 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag6.types @@ -12,7 +12,6 @@ const a = /** @satisfies {Partial} */ ({ x: 10 }); >a : { x: number; } >({ x: 10 }) : { x: number; } >{ x: 10 } : { x: number; } ->{ x: 10 } : { x: number; } >x : number >10 : 10 diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types index 7946899b26..e5a245e579 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag7.types @@ -6,7 +6,6 @@ const p = /** @satisfies {Record} */ ({ >p : { a: number; b: string; x: number; } >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } ->{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } >{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } a: 0, diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types index c1c663fa30..99ad5b50a5 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag8.types @@ -7,7 +7,6 @@ const x = /** @satisfies {Facts} */ ({ >x : any >({ m: true, s: "false"}) : any ->{ m: true, s: "false"} : any >{ m: true, s: "false"} : { m: boolean; s: string; } m: true, diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types index b363b74b1d..98fe398fad 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag9.types @@ -12,7 +12,6 @@ export const Palette = /** @satisfies {Record} */ ({ >Palette : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } >({ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },}) : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } ->{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } >{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } white: { r: 255, g: 255, b: 255 }, diff --git a/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.types b/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.types index f57a8e5ea1..5521333f39 100644 --- a/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.types +++ b/testdata/baselines/reference/submodule/conformance/importTypeInJSDoc.types @@ -41,9 +41,7 @@ export = MyClass; let a = /** @type {Foo} */(/** @type {*} */(undefined)); >a : import("./externs") >(/** @type {*} */(undefined)) : import("./externs") ->(undefined) : import("./externs") >(undefined) : any ->undefined : any >undefined : undefined a = new Foo({doer: Foo.Bar}); @@ -60,7 +58,6 @@ a = new Foo({doer: Foo.Bar}); const q = /** @type {import("./externs").Bar} */({ doer: q => q }); >q : import("./externs").Bar >({ doer: q => q }) : import("./externs").Bar ->{ doer: q => q } : import("./externs").Bar >{ doer: q => q } : { doer: (q: string) => string; } >doer : (q: string) => string >q => q : (q: string) => string @@ -70,7 +67,6 @@ const q = /** @type {import("./externs").Bar} */({ doer: q => q }); const r = /** @type {typeof import("./externs").Bar} */(r => r); >r : (x: string, y?: number) => void >(r => r) : (x: string, y?: number) => void ->r => r : (x: string, y?: number) => void >r => r : (r: string) => string >r : string >r : string diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.types index 29e702a072..6fc9270168 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsClasses.types @@ -62,7 +62,6 @@ export class E { get f1() { return /** @type {*} */(null); } >f1 : U >(null) : any ->null : any /** * @param {U} _p @@ -77,7 +76,6 @@ export class E { get f2() { return /** @type {*} */(null); } >f2 : U >(null) : any ->null : any /** * @param {U} _p @@ -309,7 +307,6 @@ export class O extends N { var x = /** @type {*} */(null); >x : any >(null) : any ->null : any export class VariableBase extends x {} >VariableBase : VariableBase diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.types index 403e527ca3..e394ef665d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsDefault.types @@ -26,7 +26,6 @@ export default class Foo { a = /** @type {Foo} */(null); >a : Foo >(null) : Foo ->null : Foo }; export const X = Foo; @@ -48,7 +47,6 @@ class Bar extends Fab { x = /** @type {Bar} */(null); >x : Bar >(null) : Bar ->null : Bar } export default Bar; >Bar : Bar diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.types index 6006082d96..10150973c1 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsExportDefinePropertyEmit.types @@ -54,7 +54,6 @@ function d(a, b) { return /** @type {*} */(null); } >a : number >b : number >(null) : any ->null : any Object.defineProperty(module.exports, "d", { value: d }); >Object.defineProperty(module.exports, "d", { value: d }) : any @@ -81,7 +80,6 @@ function e(a, b) { return /** @type {*} */(null); } >a : T >b : U >(null) : any ->null : any Object.defineProperty(module.exports, "e", { value: e }); >Object.defineProperty(module.exports, "e", { value: e }) : any diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.types index ec9469e48d..35ff520d78 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctions.types @@ -34,7 +34,6 @@ export function d(a, b) { return /** @type {*} */(null); } >a : number >b : number >(null) : any ->null : any /** * @template T,U @@ -47,7 +46,6 @@ export function e(a, b) { return /** @type {*} */(null); } >a : T >b : U >(null) : any ->null : any /** * @template T diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types index a178b06c90..9da702ec33 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionsCjs.types @@ -70,7 +70,6 @@ module.exports.d = function d(a, b) { return /** @type {*} */(null); } >a : any >b : any >(null) : any ->null : any /** * @template T,U @@ -90,7 +89,6 @@ module.exports.e = function e(a, b) { return /** @type {*} */(null); } >a : any >b : any >(null) : any ->null : any /** * @template T diff --git a/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.types b/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.types index d496efe380..46dfc2effb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocSignatureOnReturnedFunction.types @@ -47,7 +47,6 @@ function f3() { /** @type {(a: number, b: number) => number} */ return (a, b) => { >(a, b) => { return a + b; } : (a: number, b: number) => number ->(a, b) => { return a + b; } : (a: number, b: number) => number >a : number >b : number @@ -64,7 +63,6 @@ function f4() { /** @type {(a: number, b: number) => number} */ return function (a, b){ >function (a, b){ return a + b; } : (a: number, b: number) => number ->function (a, b){ return a + b; } : (a: number, b: number) => number >a : number >b : number diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types index 868c12ce17..c006a8ea72 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeTagCast.types @@ -9,15 +9,12 @@ var W: string; var W = /** @type {string} */(/** @type {*} */ (4)); >W : string >(/** @type {*} */ (4)) : string ->(4) : string >(4) : any ->4 : any >4 : 4 var W = /** @type {string} */(4); // Error >W : string >(4) : string ->4 : string >4 : 4 /** @type {*} */ @@ -31,7 +28,6 @@ var s; var a = /** @type {*} */("" + 4); >a : any >("" + 4) : any ->"" + 4 : any >"" + 4 : string >"" : "" >4 : 4 @@ -41,7 +37,6 @@ var s = "" + /** @type {*} */(4); >"" + /** @type {*} */(4) : string >"" : "" >(4) : any ->4 : any >4 : 4 class SomeBase { @@ -123,7 +118,6 @@ someBase = /** @type {SomeBase} */(someDerived); >someBase = /** @type {SomeBase} */(someDerived) : SomeBase >someBase : SomeBase >(someDerived) : SomeBase ->someDerived : SomeBase >someDerived : SomeDerived someBase = /** @type {SomeBase} */(someBase); @@ -131,13 +125,11 @@ someBase = /** @type {SomeBase} */(someBase); >someBase : SomeBase >(someBase) : SomeBase >someBase : SomeBase ->someBase : SomeBase someBase = /** @type {SomeBase} */(someOther); // Error >someBase = /** @type {SomeBase} */(someOther) : SomeBase >someBase : SomeBase >(someOther) : SomeBase ->someOther : SomeBase >someOther : SomeOther someDerived = /** @type {SomeDerived} */(someDerived); @@ -145,34 +137,29 @@ someDerived = /** @type {SomeDerived} */(someDerived); >someDerived : SomeDerived >(someDerived) : SomeDerived >someDerived : SomeDerived ->someDerived : SomeDerived someDerived = /** @type {SomeDerived} */(someBase); >someDerived = /** @type {SomeDerived} */(someBase) : SomeDerived >someDerived : SomeDerived >(someBase) : SomeDerived ->someBase : SomeDerived >someBase : SomeBase someDerived = /** @type {SomeDerived} */(someOther); // Error >someDerived = /** @type {SomeDerived} */(someOther) : SomeDerived >someDerived : SomeDerived >(someOther) : SomeDerived ->someOther : SomeDerived >someOther : SomeOther someOther = /** @type {SomeOther} */(someDerived); // Error >someOther = /** @type {SomeOther} */(someDerived) : SomeOther >someOther : SomeOther >(someDerived) : SomeOther ->someDerived : SomeOther >someDerived : SomeDerived someOther = /** @type {SomeOther} */(someBase); // Error >someOther = /** @type {SomeOther} */(someBase) : SomeOther >someOther : SomeOther >(someBase) : SomeOther ->someBase : SomeOther >someBase : SomeBase someOther = /** @type {SomeOther} */(someOther); @@ -180,7 +167,6 @@ someOther = /** @type {SomeOther} */(someOther); >someOther : SomeOther >(someOther) : SomeOther >someOther : SomeOther ->someOther : SomeOther someFakeClass = someBase; >someFakeClass = someBase : SomeBase @@ -201,7 +187,6 @@ someBase = /** @type {SomeBase} */(someFakeClass); >someBase = /** @type {SomeBase} */(someFakeClass) : SomeBase >someBase : SomeBase >(someFakeClass) : SomeBase ->someFakeClass : SomeBase >someFakeClass : any // Type assertion cannot be a type-predicate type @@ -216,7 +201,6 @@ var str; if(/** @type {numOrStr is string} */(numOrStr === undefined)) { // Error >(numOrStr === undefined) : boolean >numOrStr === undefined : boolean ->numOrStr === undefined : boolean >numOrStr : string | number >undefined : undefined @@ -231,12 +215,10 @@ var asConst1 = /** @type {const} */(1); >asConst1 : 1 >(1) : 1 >1 : 1 ->1 : 1 var asConst2 = /** @type {const} */({ >asConst2 : { readonly x: 1; } >({ x: 1}) : { readonly x: 1; } ->{ x: 1} : { readonly x: 1; } >{ x: 1} : { readonly x: 1; } x: 1 diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types index 75beb25f20..ad48fc800f 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.types @@ -81,7 +81,6 @@ function flatMap(array, iterable = identity) { >push : (...items: unknown[]) => number >.../** @type {unknown[]} */(iterable(array[i])) : unknown >(iterable(array[i])) : unknown[] ->iterable(array[i]) : unknown[] >iterable(array[i]) : unknown >iterable : (x: unknown) => unknown >array[i] : unknown diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.types.diff deleted file mode 100644 index fa44d8649d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionBodyJSDoc.types.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.arrowExpressionBodyJSDoc.types -+++ new.arrowExpressionBodyJSDoc.types -@@= skipped -10, +10 lines =@@ - >value => /** @type {string} */({ ...value }) : (value: T | undefined) => T - >value : T | undefined - >({ ...value }) : string -+>{ ...value } : string - >{ ...value } : {} - >value : T | undefined - -@@= skipped -13, +14 lines =@@ - >value => /** @type {string} */(/** @type {T} */({ ...value })) : (value: T | undefined) => T - >value : T | undefined - >(/** @type {T} */({ ...value })) : string -+>({ ...value }) : string - >({ ...value }) : T -+>{ ...value } : T - >{ ...value } : {} - >value : T | undefined diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.types.diff deleted file mode 100644 index 4402005973..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/arrowExpressionJs.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.arrowExpressionJs.types -+++ new.arrowExpressionJs.types -@@= skipped -10, +10 lines =@@ - >value => /** @type {T} */({ ...value }) : (value: T | undefined) => T - >value : T | undefined - >({ ...value }) : T -+>{ ...value } : T - >{ ...value } : {} - >value : T | undefined diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff index fbb01ace50..0e87eff864 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.types.diff @@ -14,6 +14,5 @@ +>module : { "export=": (foo: typeof import("./file")) => string; } +>exports : (foo: typeof import("./file")) => string +>(void 0) : (foo: typeof import("./file")) => string -+>void 0 : (foo: typeof import("./file")) => string >void 0 : undefined >0 : 0 diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff index 25edfbd20f..e1e77fd2e1 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceFromAnnotatedFunctionJs.types.diff @@ -11,7 +11,6 @@ return /** @type {any} */ (null); >(null) : any -+>null : any } const result = foo({ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff index da70d9ceea..f76fbfc7c6 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types.diff @@ -1,14 +1,6 @@ --- old.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types +++ new.contravariantOnlyInferenceWithAnnotatedOptionalParameterJs.types -@@= skipped -11, +11 lines =@@ - - return /** @type {any} */ (null); - >(null) : any -+>null : any - } - - const a = filter( -@@= skipped -11, +12 lines =@@ +@@= skipped -22, +22 lines =@@ * @param {number} [pose] */ (pose) => true diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff index e6dae4d90f..c6a8e0dac4 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/exportDefaultWithJSDoc2.types.diff @@ -6,7 +6,6 @@ export default /** @type {NumberLike[]} */([ ]); ->([ ]) : NumberLike[] +>([ ]) : (string | number)[] -+>[ ] : (string | number)[] >[ ] : undefined[] === b.ts === diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff index 2f895cd1d5..ff629280db 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads.types.diff @@ -8,12 +8,4 @@ +>identity : (x: T) => T /** @type {unknown[]} */ - const result = []; -@@= skipped -26, +26 lines =@@ - >push : (...items: unknown[]) => number - >.../** @type {unknown[]} */(iterable(array[i])) : unknown - >(iterable(array[i])) : unknown[] -+>iterable(array[i]) : unknown[] - >iterable(array[i]) : unknown - >iterable : (x: unknown) => unknown - >array[i] : unknown \ No newline at end of file + const result = []; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff deleted file mode 100644 index 70cf65b1a4..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsFileFunctionOverloads2.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.jsFileFunctionOverloads2.types -+++ new.jsFileFunctionOverloads2.types -@@= skipped -83, +83 lines =@@ - >push : (...items: unknown[]) => number - >.../** @type {unknown[]} */(iterable(array[i])) : unknown - >(iterable(array[i])) : unknown[] -+>iterable(array[i]) : unknown[] - >iterable(array[i]) : unknown - >iterable : (x: unknown) => unknown - >array[i] : unknown \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff index b94ada8080..35e05e0049 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocImportTypeNodeNamespace.types.diff @@ -6,6 +6,5 @@ return /** @type {import('./GeometryType.js').default} */ ('Point'); ->('Point') : typeof import("GeometryType").default +>('Point') : any -+>'Point' : any >'Point' : "Point" } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff index 6a17e72a6c..de2785dd99 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocTypeCast.types.diff @@ -17,12 +17,4 @@ +>(((x))) : string >((x)) : string >(x) : string - >x : string -@@= skipped -12, +12 lines =@@ - let c = /** @type {'a' | 'b'} */ (x); // Ok - >c : "a" | "b" - >(x) : "a" | "b" -+>x : "a" | "b" - >x : string - - c; \ No newline at end of file + >x : string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.types.diff deleted file mode 100644 index 74485511ec..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastAtReturnStatement.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.parenthesizedJSDocCastAtReturnStatement.types -+++ new.parenthesizedJSDocCastAtReturnStatement.types -@@= skipped -20, +20 lines =@@ - - return /** @type {string} */ (cache.get(key)) - >(cache.get(key)) : string -+>cache.get(key) : string - >cache.get(key) : string | Set | undefined - >cache.get : (key: string) => string | Set | undefined - >cache : Map> \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.types.diff deleted file mode 100644 index 0345ce8f18..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/parenthesizedJSDocCastDoesNotNarrow.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.parenthesizedJSDocCastDoesNotNarrow.types -+++ new.parenthesizedJSDocCastDoesNotNarrow.types -@@= skipped -6, +6 lines =@@ - - switch (/** @type {"foo" | "bar"} */ (value)) { - >(value) : "bar" | "foo" -+>value : "bar" | "foo" - >value : string - - case "bar": \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.types.diff index 6972e384cb..ab7c432482 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/returnConditionalExpressionJSDocCast.types.diff @@ -14,6 +14,4 @@ +>( type ? sources.get(type) : sources.get("some other thing") ) : String type -+>type ? sources.get(type) : sources.get("some other thing") : String - >type ? sources.get(type) : sources.get("some other thing") : string | undefined - >type : string + >type ? sources.get(type) : sources.get("some other thing") : string | undefined \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff index 4f3480caeb..cac358c0b7 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff @@ -1,10 +1,6 @@ --- old.strictOptionalProperties4.types +++ new.strictOptionalProperties4.types -@@= skipped -8, +8 lines =@@ - const x = /** @type {Foo} */ ({}); - >x : Foo - >({}) : Foo -+>{} : Foo +@@= skipped -11, +11 lines =@@ >{} : {} x.foo; // number | undefined @@ -16,8 +12,7 @@ const y = /** @type {Required} */ ({}); >y : Required - >({}) : Required -+>{} : Required +@@= skipped -10, +10 lines =@@ >{} : {} y.foo; // number diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff index aca2a4e69b..d46ad406b3 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/assertionTypePredicates2.types.diff @@ -17,12 +17,11 @@ ->(a) : B ->a : A +>(a) : { x: number; } & { y: number; } -+>a : { x: number; } & { y: number; } +>a : { x: number; } >y : number >0 : 0 >TypeError() : TypeError -@@= skipped -25, +26 lines =@@ +@@= skipped -25, +25 lines =@@ /** @type { A } */ const a = { x: 1 }; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff index 3fb1359cf8..b10614b61d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff @@ -1,27 +1,6 @@ --- old.checkJsdocSatisfiesTag1.types +++ new.checkJsdocSatisfiesTag1.types -@@= skipped -23, +23 lines =@@ - >t1 : { a: number; } - >({ a: 1 }) : { a: number; } - >{ a: 1 } : { a: number; } -+>{ a: 1 } : { a: number; } - >a : number - >1 : 1 - -@@= skipped -7, +8 lines =@@ - >t2 : { a: number; b: number; } - >({ a: 1, b: 1 }) : { a: number; b: number; } - >{ a: 1, b: 1 } : { a: number; b: number; } -+>{ a: 1, b: 1 } : { a: number; b: number; } - >a : number - >1 : 1 - >b : number -@@= skipped -9, +10 lines =@@ - >t3 : {} - >({}) : {} - >{} : {} -+>{} : {} - +@@= skipped -43, +43 lines =@@ /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : T2 @@ -30,39 +9,7 @@ ->a : "a" +>({ a: "a" }) : { a: string; } +>{ a: "a" } : { a: string; } -+>{ a: "a" } : { a: string; } +>a : string >"a" : "a" - /** @type {(m: string) => string} */ -@@= skipped -14, +16 lines =@@ - >t5 : (m: string) => string - >((m) => m.substring(0)) : (m: string) => string - >(m) => m.substring(0) : (m: string) => string -+>(m) => m.substring(0) : (m: string) => string - >m : string - >m.substring(0) : string - >m.substring : (start: number, end?: number) => string -@@= skipped -11, +12 lines =@@ - >t6 : [number, number] - >([1, 2]) : [number, number] - >[1, 2] : [number, number] -+>[1, 2] : [number, number] - >1 : 1 - >2 : 2 - -@@= skipped -7, +8 lines =@@ - >t7 : { a: string; } - >({ a: 'test' }) : { a: string; } - >{ a: 'test' } : { a: string; } -+>{ a: 'test' } : { a: string; } - >a : string - >'test' : "test" - - const t8 = /** @satisfies {T4} */ ({ a: 'test', b: 'test' }); - >t8 : { a: string; b: string; } - >({ a: 'test', b: 'test' }) : { a: string; b: string; } -+>{ a: 'test', b: 'test' } : { a: string; b: string; } - >{ a: 'test', b: 'test' } : { a: string; b: string; } - >a : string - >'test' : "test" \ No newline at end of file + /** @type {(m: string) => string} */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff deleted file mode 100644 index 3c326a0343..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag10.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.checkJsdocSatisfiesTag10.types -+++ new.checkJsdocSatisfiesTag10.types -@@= skipped -6, +6 lines =@@ - >p : { a: number; b: string; x: number; } - >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } - >{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } -+>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } - - a: 0, - >a : number \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff deleted file mode 100644 index cca4442bd9..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag11.types.diff +++ /dev/null @@ -1,7 +0,0 @@ ---- old.checkJsdocSatisfiesTag11.types -+++ new.checkJsdocSatisfiesTag11.types -@@= skipped -27, +27 lines =@@ - >t2 : 1 - >(1) : 1 - >1 : 1 -+>1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff deleted file mode 100644 index e73bc78a83..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag14.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.checkJsdocSatisfiesTag14.types -+++ new.checkJsdocSatisfiesTag14.types -@@= skipped -18, +18 lines =@@ - >t2 : { a: number; } - >({ a: 1 }) : { a: number; } - >{ a: 1 } : { a: number; } -+>{ a: 1 } : { a: number; } - >a : number - >1 : 1 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff index a0a5949aef..364707ca58 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag2.types.diff @@ -9,7 +9,6 @@ ->{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: number) => boolean; isOdd: (n: number) => boolean; } +>p : any +>({ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1}) : any -+>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : any +>{ isEven: n => n % 2 === 0, isOdd: n => n % 2 === 1} : { isEven: (n: any) => boolean; isOdd: (n: any) => boolean; } isEven: n => n % 2 === 0, diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff index 6adbf80a98..1740c8c61a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag3.types.diff @@ -6,15 +6,6 @@ >obj : { f(s: string): void; } & Record ->({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: string): void; } & Record +>({ f(s) { }, // "incorrect" implicit any on 's' g(s) { }}) : { f(s: any): void; g(s: string): void; } -+>{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } >{ f(s) { }, // "incorrect" implicit any on 's' g(s) { }} : { f(s: any): void; g(s: string): void; } - f(s) { }, // "incorrect" implicit any on 's' -@@= skipped -16, +17 lines =@@ - // This needs to not crash (outer node is not expression) - /** @satisfies {{ f(s: string): void }} */ ({ f(x) { } }) - >({ f(x) { } }) : { f(x: string): void; } -+>{ f(x) { } } : { f(x: string): void; } - >{ f(x) { } } : { f(x: string): void; } - >f : (x: string) => void - >x : string \ No newline at end of file + f(s) { }, // "incorrect" implicit any on 's' \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff deleted file mode 100644 index 5e521f2220..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag4.types.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.checkJsdocSatisfiesTag4.types -+++ new.checkJsdocSatisfiesTag4.types -@@= skipped -7, +7 lines =@@ - export default /** @satisfies {Foo} */ ({}); - >({}) : {} - >{} : {} -+>{} : {} - - === /b.js === - /** -@@= skipped -9, +10 lines =@@ - - export default /** @satisfies {Foo} */ ({ a: 1 }); - >({ a: 1 }) : { a: number; } -+>{ a: 1 } : { a: number; } - >{ a: 1 } : { a: number; } - >a : number - >1 : 1 \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff deleted file mode 100644 index 44287a7788..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag5.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.checkJsdocSatisfiesTag5.types -+++ new.checkJsdocSatisfiesTag5.types -@@= skipped -6, +6 lines =@@ - >car : { start(): void; move(d: number): void; stop(): void; } - >({ start() { }, move(d) { // d should be number }, stop() { }}) : { start(): void; move(d: number): void; stop(): void; } - >{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } -+>{ start() { }, move(d) { // d should be number }, stop() { }} : { start(): void; move(d: number): void; stop(): void; } - - start() { }, - >start : () => void \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff deleted file mode 100644 index fa530537ab..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag6.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.checkJsdocSatisfiesTag6.types -+++ new.checkJsdocSatisfiesTag6.types -@@= skipped -11, +11 lines =@@ - >a : { x: number; } - >({ x: 10 }) : { x: number; } - >{ x: 10 } : { x: number; } -+>{ x: 10 } : { x: number; } - >x : number - >10 : 10 diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff deleted file mode 100644 index 26bb173a50..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag7.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.checkJsdocSatisfiesTag7.types -+++ new.checkJsdocSatisfiesTag7.types -@@= skipped -6, +6 lines =@@ - >p : { a: number; b: string; x: number; } - >({ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'}) : { a: number; b: string; x: number; } - >{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } -+>{ a: 0, b: "hello", x: 8 // Should error, 'x' isn't in 'Keys'} : { a: number; b: string; x: number; } - - a: 0, - >a : number \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff index 3df2d3f790..d621c57253 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag8.types.diff @@ -9,7 +9,6 @@ ->{ m: true, s: "false"} : { m: true; s: string; } +>x : any +>({ m: true, s: "false"}) : any -+>{ m: true, s: "false"} : any +>{ m: true, s: "false"} : { m: boolean; s: string; } m: true, diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff deleted file mode 100644 index 72ad0f80c6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag9.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.checkJsdocSatisfiesTag9.types -+++ new.checkJsdocSatisfiesTag9.types -@@= skipped -12, +12 lines =@@ - >Palette : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } - >({ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },}) : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } - >{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } -+>{ white: { r: 255, g: 255, b: 255 }, black: { r: 0, g: 0, d: 0 }, // <- oops! 'd' in place of 'b' blue: { r: 0, g: 0, b: 255 },} : { white: { r: number; g: number; b: number; }; black: { r: number; g: number; d: number; }; blue: { r: number; g: number; b: number; }; } - - white: { r: 255, g: 255, b: 255 }, - >white : { r: number; g: number; b: number; } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.types.diff index 3c4417e952..8f10713cda 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/importTypeInJSDoc.types.diff @@ -17,9 +17,7 @@ ->(/** @type {*} */(undefined)) : import("externs") +>a : import("./externs") +>(/** @type {*} */(undefined)) : import("./externs") -+>(undefined) : import("./externs") >(undefined) : any -+>undefined : any >undefined : undefined a = new Foo({doer: Foo.Bar}); @@ -43,15 +41,6 @@ ->({ doer: q => q }) : import("externs").Bar +>q : import("./externs").Bar +>({ doer: q => q }) : import("./externs").Bar -+>{ doer: q => q } : import("./externs").Bar >{ doer: q => q } : { doer: (q: string) => string; } >doer : (q: string) => string - >q => q : (q: string) => string -@@= skipped -28, +31 lines =@@ - const r = /** @type {typeof import("./externs").Bar} */(r => r); - >r : (x: string, y?: number) => void - >(r => r) : (x: string, y?: number) => void -+>r => r : (x: string, y?: number) => void - >r => r : (r: string) => string - >r : string - >r : string \ No newline at end of file + >q => q : (q: string) => string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.types.diff index 94bd748104..cbf12334aa 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsClasses.types.diff @@ -1,22 +1,6 @@ --- old.jsDeclarationsClasses.types +++ new.jsDeclarationsClasses.types -@@= skipped -61, +61 lines =@@ - get f1() { return /** @type {*} */(null); } - >f1 : U - >(null) : any -+>null : any - - /** - * @param {U} _p -@@= skipped -14, +15 lines =@@ - get f2() { return /** @type {*} */(null); } - >f2 : U - >(null) : any -+>null : any - - /** - * @param {U} _p -@@= skipped -133, +134 lines =@@ +@@= skipped -208, +208 lines =@@ constructor() { this.p1 = 12; >this.p1 = 12 : 12 @@ -72,12 +56,4 @@ +>another2 : U >param : U } - } -@@= skipped -10, +10 lines =@@ - var x = /** @type {*} */(null); - >x : any - >(null) : any -+>null : any - - export class VariableBase extends x {} - >VariableBase : VariableBase \ No newline at end of file + } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.types.diff deleted file mode 100644 index e299c94b8b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsDefault.types.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.jsDeclarationsDefault.types -+++ new.jsDeclarationsDefault.types -@@= skipped -25, +25 lines =@@ - a = /** @type {Foo} */(null); - >a : Foo - >(null) : Foo -+>null : Foo - - }; - export const X = Foo; -@@= skipped -21, +22 lines =@@ - x = /** @type {Bar} */(null); - >x : Bar - >(null) : Bar -+>null : Bar - } - export default Bar; - >Bar : Bar \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.types.diff index d54bfb6dd1..8cb7f93473 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsExportDefinePropertyEmit.types.diff @@ -58,11 +58,8 @@ >"cat" : "cat" >{ value: "cat" } : { value: string; } >value : string -@@= skipped -24, +24 lines =@@ - >a : number - >b : number +@@= skipped -26, +26 lines =@@ >(null) : any -+>null : any Object.defineProperty(module.exports, "d", { value: d }); ->Object.defineProperty(module.exports, "d", { value: d }) : typeof module.exports @@ -79,11 +76,8 @@ >"d" : "d" >{ value: d } : { value: (a: number, b: number) => string; } >value : (a: number, b: number) => string -@@= skipped -26, +27 lines =@@ - >a : T - >b : U +@@= skipped -26, +26 lines =@@ >(null) : any -+>null : any Object.defineProperty(module.exports, "e", { value: e }); ->Object.defineProperty(module.exports, "e", { value: e }) : typeof module.exports @@ -100,7 +94,7 @@ >"e" : "e" >{ value: e } : { value: (a: T, b: U) => T & U; } >value : (a: T, b: U) => T & U -@@= skipped -26, +27 lines =@@ +@@= skipped -24, +24 lines =@@ >a : T } Object.defineProperty(module.exports, "f", { value: f }); diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.types.diff index fe29654427..73305d22e1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctions.types.diff @@ -27,22 +27,7 @@ >Cls : typeof Cls >class {} : typeof Cls -@@= skipped -29, +29 lines =@@ - >a : number - >b : number - >(null) : any -+>null : any - - /** - * @template T,U -@@= skipped -12, +13 lines =@@ - >a : T - >b : U - >(null) : any -+>null : any - - /** - * @template T +@@= skipped -47, +47 lines =@@ * @param {T} a */ export function f(a) { diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff index a5dbd352ca..dd52e4e4ea 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionsCjs.types.diff @@ -112,11 +112,9 @@ +>a : any +>b : any >(null) : any -+>null : any /** - * @template T,U -@@= skipped -19, +20 lines =@@ +@@= skipped -19, +19 lines =@@ * @return {T & U} */ module.exports.e = function e(a, b) { return /** @type {*} */(null); } @@ -141,10 +139,9 @@ +>a : any +>b : any >(null) : any -+>null : any /** - * @template T +@@= skipped -17, +17 lines =@@ * @param {T} a */ module.exports.f = function f(a) { @@ -297,7 +294,7 @@ >i : () => void >function i() {} : () => void >i : () => void -@@= skipped -116, +117 lines =@@ +@@= skipped -99, +99 lines =@@ module.exports.ii = module.exports.i; >module.exports.ii = module.exports.i : () => void >module.exports.ii : () => void diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.types.diff deleted file mode 100644 index daa0a2cd3d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocSignatureOnReturnedFunction.types.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.jsdocSignatureOnReturnedFunction.types -+++ new.jsdocSignatureOnReturnedFunction.types -@@= skipped -46, +46 lines =@@ - /** @type {(a: number, b: number) => number} */ - return (a, b) => { - >(a, b) => { return a + b; } : (a: number, b: number) => number -+>(a, b) => { return a + b; } : (a: number, b: number) => number - >a : number - >b : number - -@@= skipped -15, +16 lines =@@ - - /** @type {(a: number, b: number) => number} */ - return function (a, b){ -+>function (a, b){ return a + b; } : (a: number, b: number) => number - >function (a, b){ return a + b; } : (a: number, b: number) => number - >a : number - >b : number \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff index 9160d47fcf..63cda728c4 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeTagCast.types.diff @@ -1,38 +1,6 @@ --- old.jsdocTypeTagCast.types +++ new.jsdocTypeTagCast.types -@@= skipped -8, +8 lines =@@ - var W = /** @type {string} */(/** @type {*} */ (4)); - >W : string - >(/** @type {*} */ (4)) : string -+>(4) : string - >(4) : any -+>4 : any - >4 : 4 - - var W = /** @type {string} */(4); // Error - >W : string - >(4) : string -+>4 : string - >4 : 4 - - /** @type {*} */ -@@= skipped -19, +22 lines =@@ - var a = /** @type {*} */("" + 4); - >a : any - >("" + 4) : any -+>"" + 4 : any - >"" + 4 : string - >"" : "" - >4 : 4 -@@= skipped -9, +10 lines =@@ - >"" + /** @type {*} */(4) : string - >"" : "" - >(4) : any -+>4 : any - >4 : 4 - - class SomeBase { -@@= skipped -8, +9 lines =@@ +@@= skipped -44, +44 lines =@@ constructor() { this.p = 42; >this.p = 42 : 42 @@ -98,66 +66,7 @@ someBase = /** @type {SomeBase} */(someDerived); >someBase = /** @type {SomeBase} */(someDerived) : SomeBase - >someBase : SomeBase - >(someDerived) : SomeBase -+>someDerived : SomeBase - >someDerived : SomeDerived - - someBase = /** @type {SomeBase} */(someBase); -@@= skipped -15, +16 lines =@@ - >someBase : SomeBase - >(someBase) : SomeBase - >someBase : SomeBase -+>someBase : SomeBase - - someBase = /** @type {SomeBase} */(someOther); // Error - >someBase = /** @type {SomeBase} */(someOther) : SomeBase - >someBase : SomeBase - >(someOther) : SomeBase -+>someOther : SomeBase - >someOther : SomeOther - - someDerived = /** @type {SomeDerived} */(someDerived); -@@= skipped -12, +14 lines =@@ - >someDerived : SomeDerived - >(someDerived) : SomeDerived - >someDerived : SomeDerived -+>someDerived : SomeDerived - - someDerived = /** @type {SomeDerived} */(someBase); - >someDerived = /** @type {SomeDerived} */(someBase) : SomeDerived - >someDerived : SomeDerived - >(someBase) : SomeDerived -+>someBase : SomeDerived - >someBase : SomeBase - - someDerived = /** @type {SomeDerived} */(someOther); // Error - >someDerived = /** @type {SomeDerived} */(someOther) : SomeDerived - >someDerived : SomeDerived - >(someOther) : SomeDerived -+>someOther : SomeDerived - >someOther : SomeOther - - someOther = /** @type {SomeOther} */(someDerived); // Error - >someOther = /** @type {SomeOther} */(someDerived) : SomeOther - >someOther : SomeOther - >(someDerived) : SomeOther -+>someDerived : SomeOther - >someDerived : SomeDerived - - someOther = /** @type {SomeOther} */(someBase); // Error - >someOther = /** @type {SomeOther} */(someBase) : SomeOther - >someOther : SomeOther - >(someBase) : SomeOther -+>someBase : SomeOther - >someBase : SomeBase - - someOther = /** @type {SomeOther} */(someOther); -@@= skipped -30, +35 lines =@@ - >someOther : SomeOther - >(someOther) : SomeOther - >someOther : SomeOther -+>someOther : SomeOther +@@= skipped -60, +60 lines =@@ someFakeClass = someBase; >someFakeClass = someBase : SomeBase @@ -183,29 +92,7 @@ >someBase : SomeBase >(someFakeClass) : SomeBase ->someFakeClass : SomeFakeClass -+>someFakeClass : SomeBase +>someFakeClass : any // Type assertion cannot be a type-predicate type - /** @type {number | string} */ -@@= skipped -34, +36 lines =@@ - if(/** @type {numOrStr is string} */(numOrStr === undefined)) { // Error - >(numOrStr === undefined) : boolean - >numOrStr === undefined : boolean -+>numOrStr === undefined : boolean - >numOrStr : string | number - >undefined : undefined - -@@= skipped -14, +15 lines =@@ - >asConst1 : 1 - >(1) : 1 - >1 : 1 -+>1 : 1 - - var asConst2 = /** @type {const} */({ - >asConst2 : { readonly x: 1; } - >({ x: 1}) : { readonly x: 1; } -+>{ x: 1} : { readonly x: 1; } - >{ x: 1} : { readonly x: 1; } - - x: 1 \ No newline at end of file + /** @type {number | string} */ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff index db407bb60f..ce416d86d6 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/templateInsideCallback.types.diff @@ -17,12 +17,4 @@ +>identity : Call /** @type {unknown[]} */ - const result = []; -@@= skipped -26, +26 lines =@@ - >push : (...items: unknown[]) => number - >.../** @type {unknown[]} */(iterable(array[i])) : unknown - >(iterable(array[i])) : unknown[] -+>iterable(array[i]) : unknown[] - >iterable(array[i]) : unknown - >iterable : (x: unknown) => unknown - >array[i] : unknown \ No newline at end of file + const result = []; \ No newline at end of file