diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 20113b6888..2fe9fd720b 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -171,7 +171,11 @@ func (p *Parser) reparseJSDocSignature(jsSignature *ast.Node, fun *ast.Node, jsD } func (p *Parser) reparseJSDocTypeLiteral(t *ast.TypeNode, host *ast.Node) *ast.Node { - if t != nil && t.Kind == ast.KindJSDocTypeLiteral { + if t == nil { + return nil + } + if t.Kind == ast.KindJSDocTypeLiteral { + isArrayType := t.AsJSDocTypeLiteral().IsArrayType properties := p.nodeSlicePool.NewSlice(0) for _, prop := range t.AsJSDocTypeLiteral().JSDocPropertyTags { jsprop := prop.AsJSDocParameterOrPropertyTag() @@ -180,7 +184,9 @@ func (p *Parser) reparseJSDocTypeLiteral(t *ast.TypeNode, host *ast.Node) *ast.N name = name.AsQualifiedName().Right } property := p.factory.NewPropertySignatureDeclaration(nil, name, p.makeQuestionIfOptional(jsprop), nil, nil) - property.AsPropertySignatureDeclaration().Type = p.reparseJSDocTypeLiteral(jsprop.TypeExpression, property) + if jsprop.TypeExpression != nil { + property.AsPropertySignatureDeclaration().Type = p.reparseJSDocTypeLiteral(jsprop.TypeExpression.Type(), property) + } property.Loc = prop.Loc property.Flags = p.contextFlags | ast.NodeFlagsReparsed properties = append(properties, property) @@ -189,6 +195,11 @@ func (p *Parser) reparseJSDocTypeLiteral(t *ast.TypeNode, host *ast.Node) *ast.N t = p.factory.NewTypeLiteralNode(p.newNodeList(loc, properties)) t.Loc = loc t.Flags = p.contextFlags | ast.NodeFlagsReparsed + if isArrayType { + t = p.factory.NewArrayTypeNode(t) + t.Flags = p.contextFlags | ast.NodeFlagsReparsed + t.Loc = loc + } } return t } @@ -327,13 +338,17 @@ func (p *Parser) reparseHosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) } case ast.KindJSDocParameterTag: if fun, ok := getFunctionLikeHost(parent); ok { - jsparam := tag.AsJSDocParameterOrPropertyTag() - if param, ok := findMatchingParameter(fun, jsparam); ok { + parameterTag := tag.AsJSDocParameterOrPropertyTag() + if param, ok := findMatchingParameter(fun, parameterTag, jsDoc); ok { if param.Type == nil { - param.Type = setHost(jsparam.TypeExpression, param.AsNode()) + paramType := setHost(parameterTag.TypeExpression, param.AsNode()) + if parameterTag.IsNameFirst && parameterTag.TypeExpression != nil && parameterTag.TypeExpression.Type().Kind == ast.KindJSDocTypeLiteral { + paramType = p.reparseJSDocTypeLiteral(parameterTag.TypeExpression.Type(), param.AsNode()) + } + param.AsParameterDeclaration().Type = paramType } if param.QuestionToken == nil && param.Initializer == nil { - if question := p.makeQuestionIfOptional(jsparam); question != nil { + if question := p.makeQuestionIfOptional(parameterTag); question != nil { param.QuestionToken = question } } @@ -461,11 +476,19 @@ func (p *Parser) makeQuestionIfOptional(parameter *ast.JSDocParameterTag) *ast.N return questionToken } -func findMatchingParameter(fun *ast.Node, tag *ast.JSDocParameterTag) (*ast.ParameterDeclaration, bool) { - for _, parameter := range fun.Parameters() { - if parameter.Name().Kind == ast.KindIdentifier && tag.Name().Kind == ast.KindIdentifier && - parameter.Name().Text() == tag.Name().Text() { - return parameter.AsParameterDeclaration(), true +func findMatchingParameter(fun *ast.Node, tag *ast.JSDocParameterTag, jsDoc *ast.Node) (*ast.ParameterDeclaration, bool) { + tagIndex := core.FindIndex(jsDoc.AsJSDoc().Tags.Nodes, func(n *ast.Node) bool { + return n.Kind == ast.KindJSDocParameterTag && n.AsJSDocParameterOrPropertyTag() == tag + }) + for parameterIndex, parameter := range fun.Parameters() { + if parameter.Name().Kind == ast.KindIdentifier { + if tag.Name().Kind == ast.KindIdentifier && parameter.Name().Text() == tag.Name().Text() { + return parameter.AsParameterDeclaration(), true + } + } else { + if parameterIndex == tagIndex { + return parameter.AsParameterDeclaration(), true + } } } return nil, false diff --git a/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.js b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.js new file mode 100644 index 0000000000..b664e9573d --- /dev/null +++ b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.js @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/jsdoc/jsdocDestructuringParameterDeclaration.ts] //// + +//// [a.js] +/** + * @param {{ a: number; b: string }} args + */ +function f({ a, b }) {} + + + + +//// [a.d.ts] +/** + * @param {{ a: number; b: string }} args + */ +declare function f({ a, b }: { + a: number; + b: string; +}): void; diff --git a/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.symbols b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.symbols new file mode 100644 index 0000000000..1af730ca75 --- /dev/null +++ b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.symbols @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/jsdoc/jsdocDestructuringParameterDeclaration.ts] //// + +=== /a.js === +/** + * @param {{ a: number; b: string }} args + */ +function f({ a, b }) {} +>f : Symbol(f, Decl(a.js, 0, 0)) +>a : Symbol(a, Decl(a.js, 3, 12)) +>b : Symbol(b, Decl(a.js, 3, 15)) + diff --git a/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.types b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.types new file mode 100644 index 0000000000..c48f2e6f8c --- /dev/null +++ b/testdata/baselines/reference/conformance/jsdocDestructuringParameterDeclaration.types @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/jsdoc/jsdocDestructuringParameterDeclaration.ts] //// + +=== /a.js === +/** + * @param {{ a: number; b: string }} args + */ +function f({ a, b }) {} +>f : ({ a, b }: { a: number; b: string; }) => void +>a : number +>b : string + diff --git a/testdata/baselines/reference/conformance/jsdocParseAwait.types b/testdata/baselines/reference/conformance/jsdocParseAwait.types index 0c3998fe86..2017fe0be0 100644 --- a/testdata/baselines/reference/conformance/jsdocParseAwait.types +++ b/testdata/baselines/reference/conformance/jsdocParseAwait.types @@ -14,10 +14,10 @@ const a = 1; /** @type {T} */ const b = { >b : T ->{ await: false,} : { await: boolean; } +>{ await: false,} : { await: false; } await: false, ->await : boolean +>await : false >false : false }; diff --git a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types index b8c62e6b5f..645e035f17 100644 --- a/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types +++ b/testdata/baselines/reference/submodule/compiler/checkJsdocTypeTagOnExportAssignment8.types @@ -11,14 +11,14 @@ /** @type {Foo} */ export default { ->{ a: 'a', b: 'b'} : { a: string; b: string; } +>{ a: 'a', b: 'b'} : { a: string; b: "b"; } a: 'a', >a : string >'a' : "a" b: 'b' ->b : string +>b : "b" >'b' : "b" } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.js b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.js index 1ffac68391..6ac27fe54b 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.js @@ -20,5 +20,7 @@ export declare class Foo { * * @param {{ prop: string }} baz Baz. */ - set bar({}: {}); + set bar({}: { + prop: string; + }); } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.js.diff index 11204c7a73..20c3d02b09 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.js.diff @@ -8,11 +8,4 @@ +export declare class Foo { /** * Bar. - * - * @param {{ prop: string }} baz Baz. - */ -- set bar({}: { -- prop: string; -- }); -+ set bar({}: {}); - } \ No newline at end of file + * \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.types b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.types index ccc2cbbb20..f362340211 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.types +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs2.types @@ -10,6 +10,6 @@ export class Foo { * @param {{ prop: string }} baz Baz. */ set bar({}) {} ->bar : any +>bar : { prop: string; } } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.js b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.js index cf8fc54afd..cdc092bf0f 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.js +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.js @@ -21,6 +21,6 @@ export declare class Foo { * @param {{ prop: string | undefined }} baz Baz. */ set bar({ prop }: { - prop?: string; + prop: string | undefined; }); } diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.js.diff b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.js.diff index fb69b41ff0..3ea23571a4 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.js.diff +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.js.diff @@ -8,11 +8,4 @@ +export declare class Foo { /** * Bar. - * - * @param {{ prop: string | undefined }} baz Baz. - */ - set bar({ prop }: { -- prop: string | undefined; -+ prop?: string; - }); - } \ No newline at end of file + * \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.types b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.types index 1a8be0b7ee..6dfe773d4f 100644 --- a/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.types +++ b/testdata/baselines/reference/submodule/compiler/declarationEmitClassSetAccessorParamNameInJs3.types @@ -10,7 +10,7 @@ export class Foo { * @param {{ prop: string | undefined }} baz Baz. */ set bar({ prop = 'foo' }) {} ->bar : any +>bar : { prop: string; } >prop : string >'foo' : "foo" } diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.types b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.types index 7153b102ef..f71c8687de 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.types +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitDoesNotRenameImport.types @@ -40,19 +40,19 @@ class X extends Test { >super : typeof Test if (options.test) { ->options.test : any +>options.test : typeof import("./Test.js").default | undefined >options : Options ->test : any +>test : typeof import("./Test.js").default | undefined this.test = new options.test(); ->this.test = new options.test() : any +>this.test = new options.test() : import("./Test.js").default >this.test : any >this : this >test : any ->new options.test() : any ->options.test : any +>new options.test() : import("./Test.js").default +>options.test : typeof import("./Test.js").default >options : Options ->test : any +>test : typeof import("./Test.js").default } } } diff --git a/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt new file mode 100644 index 0000000000..e265271517 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/jsdocPropertyTagInvalid.errors.txt @@ -0,0 +1,18 @@ +/a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'string'? + + +==== /a.js (1 errors) ==== + /** + * @typedef MyType + * @property {sting} [x] + ~~~~~ +!!! error TS2552: Cannot find name 'sting'. Did you mean 'string'? + */ + + /** @param {MyType} p */ + export function f(p) { } + +==== /b.js (0 errors) ==== + import { f } from "./a.js" + f({ x: 42 }) + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt index ae46bda792..600683bbdf 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties3.errors.txt @@ -1,9 +1,12 @@ +a.js(7,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'A' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. + Types of property 'value' are incompatible. + Type 'undefined' is not assignable to type 'number'. a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. Types of property 'value' are incompatible. Type 'undefined' is not assignable to type 'number'. -==== a.js (1 errors) ==== +==== a.js (2 errors) ==== /** * @typedef {object} A * @property {number} [value] @@ -11,6 +14,10 @@ a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type /** @type {A} */ const a = { value: undefined }; // error + ~ +!!! error TS2375: Type '{ value: undefined; }' is not assignable to type 'A' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. +!!! error TS2375: Types of property 'value' are incompatible. +!!! error TS2375: Type 'undefined' is not assignable to type 'number'. /** * @typedef {{ value?: number }} B diff --git a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types index d7b145897d..15012647cf 100644 --- a/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types +++ b/testdata/baselines/reference/submodule/compiler/strictOptionalProperties4.types @@ -12,9 +12,9 @@ const x = /** @type {Foo} */ ({}); >{} : {} x.foo; // number | undefined ->x.foo : any +>x.foo : number | undefined >x : Foo ->foo : any +>foo : number | undefined const y = /** @type {Required} */ ({}); >y : Required @@ -22,7 +22,7 @@ const y = /** @type {Required} */ ({}); >{} : {} y.foo; // number ->y.foo : any +>y.foo : number >y : Required ->foo : any +>foo : number diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types index 4923bf3f9c..b66080b5f5 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocSatisfiesTag1.types @@ -44,9 +44,9 @@ const t3 = /** @satisfies {T1} */ ({}); /** @type {T2} */ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : T2 ->({ a: "a" }) : { a: string; } ->{ a: "a" } : { a: string; } ->a : string +>({ a: "a" }) : { a: "a"; } +>{ a: "a" } : { a: "a"; } +>a : "a" >"a" : "a" /** @type {(m: string) => string} */ diff --git a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.types b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.types index 1f9d8338ed..72342ed3d0 100644 --- a/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.types +++ b/testdata/baselines/reference/submodule/conformance/checkJsdocTypedefInParamTag1.types @@ -16,9 +16,9 @@ function foo(opts) { >opts : Opts opts.x; ->opts.x : any +>opts.x : string >opts : Opts ->x : any +>x : string } foo({x: 'abc'}); @@ -40,9 +40,9 @@ function foo1(opts) { >opts : AnotherOpts opts.anotherX; ->opts.anotherX : any +>opts.anotherX : string >opts : AnotherOpts ->anotherX : any +>anotherX : string } foo1({anotherX: "world"}); @@ -66,9 +66,9 @@ function foo2(opts) { >opts : Opts1 opts.x; ->opts.x : any +>opts.x : string >opts : Opts1 ->x : any +>x : string } foo2({x: 'abc'}); >foo2({x: 'abc'}) : void diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).symbols b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).symbols index c6a88f9745..da7a5cc68b 100644 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).symbols +++ b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).symbols @@ -9,7 +9,7 @@ export function prepareConfig({ >prepareConfig : Symbol(prepareConfig, Decl(index.js, 0, 0)) additionalFiles: { ->additionalFiles : Symbol(additionalFiles) +>additionalFiles : Symbol(additionalFiles, Decl(index.js, 2, 3)) json = [] >json : Symbol(json, Decl(index.js, 5, 22)) @@ -60,7 +60,7 @@ export const prepareConfigWithContextualSignature = ({ */ function f1({ a: { json = [] } = {} } = {}) { return json } >f1 : Symbol(f1, Decl(index.js, 29, 1)) ->a : Symbol(a) +>a : Symbol(a, Decl(index.js, 34, 12)) >json : Symbol(json, Decl(index.js, 36, 18)) >json : Symbol(json, Decl(index.js, 36, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).symbols.diff b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).symbols.diff deleted file mode 100644 index c01a32638a..0000000000 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).symbols.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.destructuringParameterDeclaration9(strict=false).symbols -+++ new.destructuringParameterDeclaration9(strict=false).symbols -@@= skipped -8, +8 lines =@@ - >prepareConfig : Symbol(prepareConfig, Decl(index.js, 0, 0)) - - additionalFiles: { -->additionalFiles : Symbol(additionalFiles, Decl(index.js, 2, 3)) -+>additionalFiles : Symbol(additionalFiles) - - json = [] - >json : Symbol(json, Decl(index.js, 5, 22)) -@@= skipped -51, +51 lines =@@ - */ - function f1({ a: { json = [] } = {} } = {}) { return json } - >f1 : Symbol(f1, Decl(index.js, 29, 1)) -->a : Symbol(a, Decl(index.js, 34, 12)) -+>a : Symbol(a) - >json : Symbol(json, Decl(index.js, 36, 18)) - >json : Symbol(json, Decl(index.js, 36, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).types b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).types index 36ac06a198..0815c2fcd8 100644 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).types +++ b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=false).types @@ -6,13 +6,13 @@ * @param {Partial>} [config.additionalFiles] */ export function prepareConfig({ ->prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: { json?: any[]; }; }) => void +>prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: Partial>; }) => void additionalFiles: { >additionalFiles : any json = [] ->json : any[] +>json : string[] >[] : undefined[] } = {} @@ -22,7 +22,7 @@ export function prepareConfig({ >{} : {} json // string[] ->json : any[] +>json : string[] } export function prepareConfigWithoutAnnotation({ @@ -75,22 +75,22 @@ export const prepareConfigWithContextualSignature = ({ * @param {{ a?: { json?: string[] }}} [config] */ function f1({ a: { json = [] } = {} } = {}) { return json } ->f1 : ({ a: { json } }?: { a?: { json?: any[]; }; }) => any[] +>f1 : ({ a: { json } }?: { a?: { json?: string[]; }; }) => string[] >a : any ->json : any[] +>json : string[] >[] : undefined[] >{} : {} >{} : {} ->json : any[] +>json : string[] /** * @param {[[string[]?]?]} [x] */ function f2([[json = []] = []] = []) { return json } ->f2 : ([[json]]?: [[any[]?]?]) => any[] ->json : any[] +>f2 : ([[json]]?: [[string[]?]?]) => string[] +>json : string[] >[] : undefined[] >[] : [] >[] : [] ->json : any[] +>json : string[] diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).symbols b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).symbols index c6a88f9745..da7a5cc68b 100644 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).symbols +++ b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).symbols @@ -9,7 +9,7 @@ export function prepareConfig({ >prepareConfig : Symbol(prepareConfig, Decl(index.js, 0, 0)) additionalFiles: { ->additionalFiles : Symbol(additionalFiles) +>additionalFiles : Symbol(additionalFiles, Decl(index.js, 2, 3)) json = [] >json : Symbol(json, Decl(index.js, 5, 22)) @@ -60,7 +60,7 @@ export const prepareConfigWithContextualSignature = ({ */ function f1({ a: { json = [] } = {} } = {}) { return json } >f1 : Symbol(f1, Decl(index.js, 29, 1)) ->a : Symbol(a) +>a : Symbol(a, Decl(index.js, 34, 12)) >json : Symbol(json, Decl(index.js, 36, 18)) >json : Symbol(json, Decl(index.js, 36, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).symbols.diff b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).symbols.diff index a6c41bc009..4ffbde456a 100644 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).symbols.diff @@ -4,7 +4,7 @@ >prepareConfig : Symbol(prepareConfig, Decl(index.js, 0, 0)) additionalFiles: { -+>additionalFiles : Symbol(additionalFiles) ++>additionalFiles : Symbol(additionalFiles, Decl(index.js, 2, 3)) + json = [] >json : Symbol(json, Decl(index.js, 5, 22)) @@ -13,6 +13,6 @@ */ function f1({ a: { json = [] } = {} } = {}) { return json } >f1 : Symbol(f1, Decl(index.js, 29, 1)) -+>a : Symbol(a) ++>a : Symbol(a, Decl(index.js, 34, 12)) >json : Symbol(json, Decl(index.js, 36, 18)) >json : Symbol(json, Decl(index.js, 36, 18)) diff --git a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).types b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).types index d91371d03a..be0248f5ee 100644 --- a/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).types +++ b/testdata/baselines/reference/submodule/conformance/destructuringParameterDeclaration9(strict=true).types @@ -6,13 +6,13 @@ * @param {Partial>} [config.additionalFiles] */ export function prepareConfig({ ->prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: { json?: never[] | undefined; } | undefined; }) => void +>prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: Partial> | undefined; }) => void additionalFiles: { >additionalFiles : any json = [] ->json : never[] +>json : string[] >[] : never[] } = {} @@ -22,7 +22,7 @@ export function prepareConfig({ >{} : {} json // string[] ->json : never[] +>json : string[] } export function prepareConfigWithoutAnnotation({ @@ -75,22 +75,22 @@ export const prepareConfigWithContextualSignature = ({ * @param {{ a?: { json?: string[] }}} [config] */ function f1({ a: { json = [] } = {} } = {}) { return json } ->f1 : ({ a: { json } }?: { a?: { json?: never[] | undefined; } | undefined; }) => never[] +>f1 : ({ a: { json } }?: { a?: { json?: string[] | undefined; } | undefined; }) => string[] >a : any ->json : never[] +>json : string[] >[] : never[] >{} : {} >{} : {} ->json : never[] +>json : string[] /** * @param {[[string[]?]?]} [x] */ function f2([[json = []] = []] = []) { return json } ->f2 : ([[json]]?: [([(never[] | undefined)?] | undefined)?]) => never[] ->json : never[] +>f2 : ([[json]]?: [([(string[] | undefined)?] | undefined)?]) => string[] +>json : string[] >[] : never[] >[] : [] >[] : [] ->json : never[] +>json : string[] diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt index 339f44b69d..4fca94994d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt @@ -1,6 +1,7 @@ file.js(4,11): error TS2315: Type 'Object' is not generic. file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. file2.js(6,11): error TS2315: Type 'Object' is not generic. @@ -8,7 +9,7 @@ file2.js(12,23): error TS2702: 'myTypes' only refers to a type, but is being use file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. -==== file.js (5 errors) ==== +==== file.js (6 errors) ==== /** * @namespace myTypes * @global @@ -29,6 +30,8 @@ file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being ~~~~~~~ !!! error TS2300: Duplicate identifier 'myTypes'. * @property {myTypes.typeA} prop1 - Prop 1. + ~~~~~~~ +!!! error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. * @property {string} prop2 - Prop 2. */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt index b12f06b6fa..e25ccebe0d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt @@ -1,6 +1,7 @@ file.js(4,11): error TS2315: Type 'Object' is not generic. file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. file2.js(6,11): error TS2315: Type 'Object' is not generic. @@ -46,7 +47,7 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi module.exports = {testFn, testFnTypes}; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== file.js (5 errors) ==== +==== file.js (6 errors) ==== /** * @namespace myTypes * @global @@ -67,6 +68,8 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi ~~~~~~~ !!! error TS2300: Duplicate identifier 'myTypes'. * @property {myTypes.typeA} prop1 - Prop 1. + ~~~~~~~ +!!! error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. * @property {string} prop2 - Prop 2. */ diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.js index 84169804ec..7dc2cad00f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.js @@ -61,8 +61,8 @@ declare class X { * @returns {Promise.<*>} resolves when the event has been sent. */ cancel({ reason, code }: { - code: any; - reason: any; + reason: string | null; + code: string | null; }): Promise; } declare class Y { @@ -76,7 +76,10 @@ declare class Y { * @returns {Promise.<*>} resolves when the event has been sent. */ cancel({ reason, suberr }: { - reason: any; - suberr: any; + reason: string | null; + suberr: { + reason: string | null; + code: string | null; + }; }): Promise; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.js.diff index 5468e255b7..f3c9975f4b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.js.diff @@ -37,28 +37,3 @@ + async cancel({ reason, suberr }) { } } - -@@= skipped -16, +14 lines =@@ - * @returns {Promise.<*>} resolves when the event has been sent. - */ - cancel({ reason, code }: { -- reason: string | null; -- code: string | null; -+ code: any; -+ reason: any; - }): Promise; - } - declare class Y { -@@= skipped -15, +15 lines =@@ - * @returns {Promise.<*>} resolves when the event has been sent. - */ - cancel({ reason, suberr }: { -- reason: string | null; -- suberr: { -- reason: string | null; -- code: string | null; -- }; -+ reason: any; -+ suberr: any; - }): Promise; - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.types index 8e95a7f497..b474a6afe5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsNestedParams.types @@ -12,9 +12,9 @@ class X { * @returns {Promise.<*>} resolves when the event has been sent. */ async cancel({reason, code}) {} ->cancel : ({ reason, code }: { code: any; reason: any; }) => Promise ->reason : any ->code : any +>cancel : ({ reason, code }: { reason: string; code: string; }) => Promise +>reason : string +>code : string } class Y { @@ -30,8 +30,8 @@ class Y { * @returns {Promise.<*>} resolves when the event has been sent. */ async cancel({reason, suberr}) {} ->cancel : ({ reason, suberr }: { reason: any; suberr: any; }) => Promise ->reason : any ->suberr : any +>cancel : ({ reason, suberr }: { reason: string; suberr: { reason: string; code: string; }; }) => Promise +>reason : string +>suberr : { reason: string; code: string; } } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.types b/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.types index d8e70218a5..d73c0d2bdc 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTag2.types @@ -7,9 +7,9 @@ * @param {string} x */ function good1({a, b}, x) {} ->good1 : ({ a, b }: { a: any; b: any; }, x: string) => void ->a : any ->b : any +>good1 : ({ a, b }: { a: string; b: string; }, x: string) => void +>a : string +>b : string >x : string /** @@ -17,11 +17,11 @@ function good1({a, b}, x) {} * @param {{c: number, d: number}} OBJECTION */ function good2({a, b}, {c, d}) {} ->good2 : ({ a, b }: { a: any; b: any; }, { c, d }: { c: any; d: any; }) => void ->a : any ->b : any ->c : any ->d : any +>good2 : ({ a, b }: { a: string; b: string; }, { c, d }: { c: number; d: number; }) => void +>a : string +>b : string +>c : number +>d : number /** * @param {number} x @@ -29,19 +29,19 @@ function good2({a, b}, {c, d}) {} * @param {string} y */ function good3(x, {a, b}, y) {} ->good3 : (x: number, { a, b }: { a: any; b: any; }, y: string) => void +>good3 : (x: number, { a, b }: { a: string; b: string; }, y: string) => void >x : number ->a : any ->b : any +>a : string +>b : string >y : string /** * @param {{a: string, b: string}} obj */ function good4({a, b}) {} ->good4 : ({ a, b }: { a: any; b: any; }) => void ->a : any ->b : any +>good4 : ({ a, b }: { a: string; b: string; }) => void +>a : string +>b : string // nested object syntax /** @@ -51,9 +51,9 @@ function good4({a, b}) {} * @param {string} x */ function good5({a, b}, x) {} ->good5 : ({ a, b }: { a: any; b: any; }, x: string) => void ->a : any ->b : any +>good5 : ({ a, b }: { a: string; b: string; }, x: string) => void +>a : string +>b : string >x : string /** @@ -65,11 +65,11 @@ function good5({a, b}, x) {} * @param {string} OBJECTION.d - meh */ function good6({a, b}, {c, d}) {} ->good6 : ({ a, b }: { a: any; b: any; }, { c, d }: { c: any; d: any; }) => void ->a : any ->b : any ->c : any ->d : any +>good6 : ({ a, b }: { a: string; b: string; }, { c, d }: { c: string; d: string; }) => void +>a : string +>b : string +>c : string +>d : string /** * @param {number} x @@ -79,10 +79,10 @@ function good6({a, b}, {c, d}) {} * @param {string} y */ function good7(x, {a, b}, y) {} ->good7 : (x: number, { a, b }: { a: any; b: any; }, y: string) => void +>good7 : (x: number, { a, b }: { a: string; b: string; }, y: string) => void >x : number ->a : any ->b : any +>a : string +>b : string >y : string /** @@ -91,16 +91,16 @@ function good7(x, {a, b}, y) {} * @param {string} obj.b */ function good8({a, b}) {} ->good8 : ({ a, b }: { a: any; b: any; }) => void ->a : any ->b : any +>good8 : ({ a, b }: { a: string; b: string; }) => void +>a : string +>b : string /** * @param {{ a: string }} argument */ function good9({ a }) { ->good9 : ({ a }: { a: any; }) => void ->a : any +>good9 : ({ a }: { a: string; }) => void +>a : string console.log(arguments, a); >console.log(arguments, a) : void @@ -108,7 +108,7 @@ function good9({ a }) { >console : Console >log : (...data: any[]) => void >arguments : IArguments ->a : any +>a : string } /** @@ -128,8 +128,8 @@ function bad1(x, {a, b}) {} * @param {{a: string, b: string}} obj */ function bad2(x, {a, b}) {} ->bad2 : (x: any, { a, b }: { a: any; b: any; }) => void +>bad2 : (x: any, { a, b }: { a: string; b: string; }) => void >x : any ->a : any ->b : any +>a : string +>b : string diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.symbols b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.symbols index 2df591726e..bc2e050fb7 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.symbols @@ -27,7 +27,9 @@ function foo1(opts1) { >opts1 : Symbol(opts1, Decl(0.js, 16, 14)) opts1.x; +>opts1.x : Symbol(x, Decl(0.js, 11, 3)) >opts1 : Symbol(opts1, Decl(0.js, 16, 14)) +>x : Symbol(x, Decl(0.js, 11, 3)) } foo1({x: 'abc'}); @@ -44,7 +46,9 @@ function foo2(/** @param opts2 bad idea theatre! */opts2) { >opts2 : Symbol(opts2, Decl(0.js, 27, 14)) opts2[0].anotherX; +>opts2[0].anotherX : Symbol(anotherX, Decl(0.js, 24, 3)) >opts2 : Symbol(opts2, Decl(0.js, 27, 14)) +>anotherX : Symbol(anotherX, Decl(0.js, 24, 3)) } foo2([{anotherX: "world"}]); @@ -60,7 +64,9 @@ function foo3(opts3) { >opts3 : Symbol(opts3, Decl(0.js, 37, 14)) opts3.x; +>opts3.x : Symbol(x, Decl(0.js, 35, 3)) >opts3 : Symbol(opts3, Decl(0.js, 37, 14)) +>x : Symbol(x, Decl(0.js, 35, 3)) } foo3({x: 'abc'}); >foo3 : Symbol(foo3, Decl(0.js, 31, 28)) @@ -78,7 +84,9 @@ function foo4(opts4) { >opts4 : Symbol(opts4, Decl(0.js, 49, 14)) opts4[0].x; +>opts4[0].x : Symbol(x, Decl(0.js, 44, 3)) >opts4 : Symbol(opts4, Decl(0.js, 49, 14)) +>x : Symbol(x, Decl(0.js, 44, 3)) } foo4([{ x: 'hi' }]); @@ -100,10 +108,18 @@ function foo5(opts5) { >opts5 : Symbol(opts5, Decl(0.js, 65, 14)) opts5[0].what.bad[0].idea; +>opts5[0].what.bad[0].idea : Symbol(idea, Decl(0.js, 61, 3)) +>opts5[0].what.bad : Symbol(bad, Decl(0.js, 60, 3)) +>opts5[0].what : Symbol(what, Decl(0.js, 58, 3)) >opts5 : Symbol(opts5, Decl(0.js, 65, 14)) +>what : Symbol(what, Decl(0.js, 58, 3)) +>bad : Symbol(bad, Decl(0.js, 60, 3)) +>idea : Symbol(idea, Decl(0.js, 61, 3)) opts5[0].unnest; +>opts5[0].unnest : Symbol(unnest, Decl(0.js, 63, 3)) >opts5 : Symbol(opts5, Decl(0.js, 65, 14)) +>unnest : Symbol(unnest, Decl(0.js, 63, 3)) } foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]); diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.symbols.diff deleted file mode 100644 index 1d4642f2e5..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.symbols.diff +++ /dev/null @@ -1,61 +0,0 @@ ---- old.jsdocParamTagTypeLiteral.symbols -+++ new.jsdocParamTagTypeLiteral.symbols -@@= skipped -26, +26 lines =@@ - >opts1 : Symbol(opts1, Decl(0.js, 16, 14)) - - opts1.x; -->opts1.x : Symbol(x, Decl(0.js, 11, 3)) - >opts1 : Symbol(opts1, Decl(0.js, 16, 14)) -->x : Symbol(x, Decl(0.js, 11, 3)) - } - - foo1({x: 'abc'}); -@@= skipped -19, +17 lines =@@ - >opts2 : Symbol(opts2, Decl(0.js, 27, 14)) - - opts2[0].anotherX; -->opts2[0].anotherX : Symbol(anotherX, Decl(0.js, 24, 3)) - >opts2 : Symbol(opts2, Decl(0.js, 27, 14)) -->anotherX : Symbol(anotherX, Decl(0.js, 24, 3)) - } - - foo2([{anotherX: "world"}]); -@@= skipped -18, +16 lines =@@ - >opts3 : Symbol(opts3, Decl(0.js, 37, 14)) - - opts3.x; -->opts3.x : Symbol(x, Decl(0.js, 35, 3)) - >opts3 : Symbol(opts3, Decl(0.js, 37, 14)) -->x : Symbol(x, Decl(0.js, 35, 3)) - } - foo3({x: 'abc'}); - >foo3 : Symbol(foo3, Decl(0.js, 31, 28)) -@@= skipped -20, +18 lines =@@ - >opts4 : Symbol(opts4, Decl(0.js, 49, 14)) - - opts4[0].x; -->opts4[0].x : Symbol(x, Decl(0.js, 44, 3)) - >opts4 : Symbol(opts4, Decl(0.js, 49, 14)) -->x : Symbol(x, Decl(0.js, 44, 3)) - } - - foo4([{ x: 'hi' }]); -@@= skipped -24, +22 lines =@@ - >opts5 : Symbol(opts5, Decl(0.js, 65, 14)) - - opts5[0].what.bad[0].idea; -->opts5[0].what.bad[0].idea : Symbol(idea, Decl(0.js, 61, 3)) -->opts5[0].what.bad : Symbol(bad, Decl(0.js, 60, 3)) -->opts5[0].what : Symbol(what, Decl(0.js, 58, 3)) - >opts5 : Symbol(opts5, Decl(0.js, 65, 14)) -->what : Symbol(what, Decl(0.js, 58, 3)) -->bad : Symbol(bad, Decl(0.js, 60, 3)) -->idea : Symbol(idea, Decl(0.js, 61, 3)) - - opts5[0].unnest; -->opts5[0].unnest : Symbol(unnest, Decl(0.js, 63, 3)) - >opts5 : Symbol(opts5, Decl(0.js, 65, 14)) -->unnest : Symbol(unnest, Decl(0.js, 63, 3)) - } - - foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.types b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.types index 470a8300aa..04400feb42 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocParamTagTypeLiteral.types @@ -25,18 +25,18 @@ normal(12); * @param {string} [opts1.w="hi"] doc5 */ function foo1(opts1) { ->foo1 : (opts1: any) => void ->opts1 : any +>foo1 : (opts1: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }) => void +>opts1 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; } opts1.x; ->opts1.x : any ->opts1 : any ->x : any +>opts1.x : string +>opts1 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; } +>x : string } foo1({x: 'abc'}); >foo1({x: 'abc'}) : void ->foo1 : (opts1: any) => void +>foo1 : (opts1: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" @@ -47,20 +47,20 @@ foo1({x: 'abc'}); * @param {string=} opts2[].anotherY */ function foo2(/** @param opts2 bad idea theatre! */opts2) { ->foo2 : (opts2: any) => void ->opts2 : any +>foo2 : (opts2: { anotherX: string; anotherY?: string | undefined; }[]) => void +>opts2 : { anotherX: string; anotherY?: string | undefined; }[] opts2[0].anotherX; ->opts2[0].anotherX : any ->opts2[0] : any ->opts2 : any +>opts2[0].anotherX : string +>opts2[0] : { anotherX: string; anotherY?: string | undefined; } +>opts2 : { anotherX: string; anotherY?: string | undefined; }[] >0 : 0 ->anotherX : any +>anotherX : string } foo2([{anotherX: "world"}]); >foo2([{anotherX: "world"}]) : void ->foo2 : (opts2: any) => void +>foo2 : (opts2: { anotherX: string; anotherY?: string | undefined; }[]) => void >[{anotherX: "world"}] : { anotherX: string; }[] >{anotherX: "world"} : { anotherX: string; } >anotherX : string @@ -71,17 +71,17 @@ foo2([{anotherX: "world"}]); * @param {string} opts3.x */ function foo3(opts3) { ->foo3 : (opts3: any) => void ->opts3 : any +>foo3 : (opts3: { x: string; }) => void +>opts3 : { x: string; } opts3.x; ->opts3.x : any ->opts3 : any ->x : any +>opts3.x : string +>opts3 : { x: string; } +>x : string } foo3({x: 'abc'}); >foo3({x: 'abc'}) : void ->foo3 : (opts3: any) => void +>foo3 : (opts3: { x: string; }) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" @@ -94,20 +94,20 @@ foo3({x: 'abc'}); * @param {string} [opts4[].w="hi"] */ function foo4(opts4) { ->foo4 : (opts4: any) => void ->opts4 : any +>foo4 : (opts4: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[]) => void +>opts4 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[] opts4[0].x; ->opts4[0].x : any ->opts4[0] : any ->opts4 : any +>opts4[0].x : string +>opts4[0] : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; } +>opts4 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[] >0 : 0 ->x : any +>x : string } foo4([{ x: 'hi' }]); >foo4([{ x: 'hi' }]) : void ->foo4 : (opts4: any) => void +>foo4 : (opts4: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[]) => void >[{ x: 'hi' }] : { x: string; }[] >{ x: 'hi' } : { x: string; } >x : string @@ -124,47 +124,47 @@ foo4([{ x: 'hi' }]); * @param {number} opts5[].unnest - Here we are almost all the way back at the beginning. */ function foo5(opts5) { ->foo5 : (opts5: any) => void ->opts5 : any +>foo5 : (opts5: { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[]) => void +>opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[] opts5[0].what.bad[0].idea; ->opts5[0].what.bad[0].idea : any ->opts5[0].what.bad[0] : any ->opts5[0].what.bad : any ->opts5[0].what : any ->opts5[0] : any ->opts5 : any +>opts5[0].what.bad[0].idea : string +>opts5[0].what.bad[0] : { idea: string; oh: boolean; } +>opts5[0].what.bad : { idea: string; oh: boolean; }[] +>opts5[0].what : { a: string; bad: { idea: string; oh: boolean; }[]; } +>opts5[0] : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; } +>opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[] >0 : 0 ->what : any ->bad : any +>what : { a: string; bad: { idea: string; oh: boolean; }[]; } +>bad : { idea: string; oh: boolean; }[] >0 : 0 ->idea : any +>idea : string opts5[0].unnest; ->opts5[0].unnest : any ->opts5[0] : any ->opts5 : any +>opts5[0].unnest : number +>opts5[0] : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; } +>opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[] >0 : 0 ->unnest : any +>unnest : number } foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]); >foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]) : void ->foo5 : (opts5: any) => void ->[{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }] : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[] ->{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 } : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; } +>foo5 : (opts5: { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[]) => void +>[{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }] : { help: string; what: { a: string; bad: { idea: string; oh: false; }[]; }; unnest: number; }[] +>{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 } : { help: string; what: { a: string; bad: { idea: string; oh: false; }[]; }; unnest: number; } >help : string >"help" : "help" ->what : { a: string; bad: { idea: string; oh: boolean; }[]; } ->{ a: 'a', bad: [{ idea: 'idea', oh: false }] } : { a: string; bad: { idea: string; oh: boolean; }[]; } +>what : { a: string; bad: { idea: string; oh: false; }[]; } +>{ a: 'a', bad: [{ idea: 'idea', oh: false }] } : { a: string; bad: { idea: string; oh: false; }[]; } >a : string >'a' : "a" ->bad : { idea: string; oh: boolean; }[] ->[{ idea: 'idea', oh: false }] : { idea: string; oh: boolean; }[] ->{ idea: 'idea', oh: false } : { idea: string; oh: boolean; } +>bad : { idea: string; oh: false; }[] +>[{ idea: 'idea', oh: false }] : { idea: string; oh: false; }[] +>{ idea: 'idea', oh: false } : { idea: string; oh: false; } >idea : string >'idea' : "idea" ->oh : boolean +>oh : false >false : false >unnest : number >1 : 1 diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt new file mode 100644 index 0000000000..db4a9a3064 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateConstructorFunction2.errors.txt @@ -0,0 +1,38 @@ +templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. + + +==== templateTagWithNestedTypeLiteral.js (1 errors) ==== + /** + * @param {T} t + * @template T + */ + function Zet(t) { + /** @type {T} */ + this.u + this.t = t + } + /** + * @param {T} v + * @param {object} o + * @param {T} o.nested + */ + Zet.prototype.add = function(v, o) { + this.u = v || o.nested + return this.u + } + var z = new Zet(1) + z.t = 2 + z.u = false + /** @type {number} */ + let answer = z.add(3, { nested: 4 }) + + // lookup in typedef should not crash the compiler, even when the type is unknown + /** + * @typedef {Object} A + * @property {T} value + ~ +!!! error TS2304: Cannot find name 'T'. + */ + /** @type {A} */ + const options = { value: null }; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt index 348848a9e7..7d3cba7e4f 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.errors.txt @@ -1,14 +1,14 @@ a.js(2,14): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias +a.js(4,15): error TS2304: Cannot find name 'T'. a.js(18,1): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. Type 'unknown' is not assignable to type 'string'. a.js(21,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -a.js(29,33): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(34,31): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(23,19): error TS2304: Cannot find name 'T'. a.js(36,1): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. Type 'unknown' is not assignable to type 'string'. a.js(40,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -a.js(48,29): error TS7006: Parameter 'x' implicitly has an 'any' type. -a.js(53,27): error TS7006: Parameter 'x' implicitly has an 'any' type. +a.js(42,19): error TS2304: Cannot find name 'T'. +a.js(42,25): error TS2304: Cannot find name 'T'. a.js(55,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Type 'unknown' is not assignable to type 'string'. a.js(56,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. @@ -23,6 +23,8 @@ a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of !!! error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Covariant * @property {T} x + ~ +!!! error TS2304: Cannot find name 'T'. */ /** @@ -47,21 +49,19 @@ a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of !!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Contravariant * @property {(x: T) => void} f + ~ +!!! error TS2304: Cannot find name 'T'. */ /** * @type {Contravariant} */ let super_contravariant = { f: (x) => {} }; - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. /** * @type {Contravariant} */ let sub_contravariant = { f: (x) => {} }; - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. super_contravariant = sub_contravariant; // Error ~~~~~~~~~~~~~~~~~~~ @@ -75,21 +75,21 @@ a.js(59,14): error TS1274: 'in' modifier can only appear on a type parameter of !!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Invariant * @property {(x: T) => T} f + ~ +!!! error TS2304: Cannot find name 'T'. + ~ +!!! error TS2304: Cannot find name 'T'. */ /** * @type {Invariant} */ let super_invariant = { f: (x) => {} }; - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. /** * @type {Invariant} */ let sub_invariant = { f: (x) => { return "" } }; - ~ -!!! error TS7006: Parameter 'x' implicitly has an 'any' type. super_invariant = sub_invariant; // Error ~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.types b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.types index 4180ca750d..535be9edb4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.types +++ b/testdata/baselines/reference/submodule/conformance/jsdocTemplateTag8.types @@ -46,20 +46,20 @@ sub_covariant = super_covariant; // Error */ let super_contravariant = { f: (x) => {} }; >super_contravariant : Contravariant ->{ f: (x) => {} } : { f: (x: any) => void; } ->f : (x: any) => void ->(x) => {} : (x: any) => void ->x : any +>{ f: (x) => {} } : { f: (x: T) => void; } +>f : (x: T) => void +>(x) => {} : (x: T) => void +>x : T /** * @type {Contravariant} */ let sub_contravariant = { f: (x) => {} }; >sub_contravariant : Contravariant ->{ f: (x) => {} } : { f: (x: any) => void; } ->f : (x: any) => void ->(x) => {} : (x: any) => void ->x : any +>{ f: (x) => {} } : { f: (x: T) => void; } +>f : (x: T) => void +>(x) => {} : (x: T) => void +>x : T super_contravariant = sub_contravariant; // Error >super_contravariant = sub_contravariant : Contravariant @@ -82,20 +82,20 @@ sub_contravariant = super_contravariant; */ let super_invariant = { f: (x) => {} }; >super_invariant : Invariant ->{ f: (x) => {} } : { f: (x: any) => void; } ->f : (x: any) => void ->(x) => {} : (x: any) => void ->x : any +>{ f: (x) => {} } : { f: (x: T) => void; } +>f : (x: T) => void +>(x) => {} : (x: T) => void +>x : T /** * @type {Invariant} */ let sub_invariant = { f: (x) => { return "" } }; >sub_invariant : Invariant ->{ f: (x) => { return "" } } : { f: (x: any) => string; } ->f : (x: any) => string ->(x) => { return "" } : (x: any) => string ->x : any +>{ f: (x) => { return "" } } : { f: (x: T) => string; } +>f : (x: T) => string +>(x) => { return "" } : (x: T) => string +>x : T >"" : "" super_invariant = sub_invariant; // Error diff --git a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt new file mode 100644 index 0000000000..3e8e002141 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.errors.txt @@ -0,0 +1,16 @@ +/a.js(9,12): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + + +==== /a.js (1 errors) ==== + /** + * @typedef Foo + * @property {string} a + */ + + /** + * @param {Foo} [options] + */ + function f({ a = "a" }) {} + ~~~~~~~~~~~ +!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.types b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.types index 5c712385af..dbd40ac8fd 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.types +++ b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters3.types @@ -10,7 +10,7 @@ * @param {Foo} [options] */ function f({ a = "a" }) {} ->f : ({ a }: { a?: string; }) => void +>f : ({ a }?: Foo) => void >a : string >"a" : "a" diff --git a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt deleted file mode 100644 index e7895a18fa..0000000000 --- a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.errors.txt +++ /dev/null @@ -1,13 +0,0 @@ -/a.js(4,16): error TS2339: Property 'cause' does not exist on type '{}'. - - -==== /a.js (1 errors) ==== - /** - * @param {{ cause?: string }} [options] - */ - function foo({ cause } = {}) { - ~~~~~ -!!! error TS2339: Property 'cause' does not exist on type '{}'. - return cause; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.types b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.types index f257ebc365..12012d1d6d 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.types +++ b/testdata/baselines/reference/submodule/conformance/optionalBindingParameters4.types @@ -5,11 +5,11 @@ * @param {{ cause?: string }} [options] */ function foo({ cause } = {}) { ->foo : ({ cause }?: {}) => any ->cause : any +>foo : ({ cause }?: { cause?: string; }) => string +>cause : string >{} : {} return cause; ->cause : any +>cause : string } diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js index fa74820076..9b384afd88 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js @@ -117,7 +117,7 @@ function flatMap(array, iterable = identity) { export type Call = () ; export type Nested = { oh: { - property: number; - property: string; + no: number; + noooooo: string; }; }; diff --git a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff index e998ad68d9..6c9be2b1a2 100644 --- a/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff +++ b/testdata/baselines/reference/submodule/conformance/templateInsideCallback.js.diff @@ -57,10 +57,8 @@ +export type Call = () ; +export type Nested = { oh: { -- no: number; -- noooooo: string; -+ property: number; -+ property: string; + no: number; + noooooo: string; }; }; -type Oops = any; diff --git a/testdata/baselines/reference/submodule/conformance/typedefTagNested.types b/testdata/baselines/reference/submodule/conformance/typedefTagNested.types index 7077cb580a..3cc590bdc9 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefTagNested.types +++ b/testdata/baselines/reference/submodule/conformance/typedefTagNested.types @@ -65,17 +65,17 @@ var sala = { name: 'uppsala', not: 0, nested: "ok" }; >"ok" : "ok" sala.name ->sala.name : any +>sala.name : string >sala : Upp ->name : any +>name : string sala.not ->sala.not : any +>sala.not : Object >sala : Upp ->not : any +>not : Object sala.nested ->sala.nested : any +>sala.nested : string >sala : Upp ->nested : any +>nested : string diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff deleted file mode 100644 index c3b3f96792..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsdocTypeTagOnExportAssignment8.types.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.checkJsdocTypeTagOnExportAssignment8.types -+++ new.checkJsdocTypeTagOnExportAssignment8.types -@@= skipped -10, +10 lines =@@ - - /** @type {Foo} */ - export default { -->{ a: 'a', b: 'b'} : { a: string; b: "b"; } -+>{ a: 'a', b: 'b'} : { a: string; b: string; } - - a: 'a', - >a : string - >'a' : "a" - - b: 'b' -->b : "b" -+>b : string - >'b' : "b" - } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.types.diff deleted file mode 100644 index 91d9d2693a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs2.types.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.declarationEmitClassSetAccessorParamNameInJs2.types -+++ new.declarationEmitClassSetAccessorParamNameInJs2.types -@@= skipped -9, +9 lines =@@ - * @param {{ prop: string }} baz Baz. - */ - set bar({}) {} -->bar : { prop: string; } -+>bar : any - } diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.types.diff index d751ea0e02..2cb5606c82 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/declarationEmitClassSetAccessorParamNameInJs3.types.diff @@ -5,7 +5,7 @@ */ set bar({ prop = 'foo' }) {} ->bar : { prop: string | undefined; } -+>bar : any ++>bar : { prop: string; } >prop : string >'foo' : "foo" } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.types.diff index 654d365ee1..7a35ded200 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitDoesNotRenameImport.types.diff @@ -5,24 +5,24 @@ if (options.test) { ->options.test : typeof import("Test").default | undefined -+>options.test : any ++>options.test : typeof import("./Test.js").default | undefined >options : Options ->test : typeof import("Test").default | undefined -+>test : any ++>test : typeof import("./Test.js").default | undefined this.test = new options.test(); ->this.test = new options.test() : import("Test").default -+>this.test = new options.test() : any ++>this.test = new options.test() : import("./Test.js").default >this.test : any >this : this >test : any ->new options.test() : import("Test").default ->options.test : typeof import("Test").default -+>new options.test() : any -+>options.test : any ++>new options.test() : import("./Test.js").default ++>options.test : typeof import("./Test.js").default >options : Options ->test : typeof import("Test").default -+>test : any ++>test : typeof import("./Test.js").default } } } \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff deleted file mode 100644 index 8d6ef41aa0..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsdocPropertyTagInvalid.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.jsdocPropertyTagInvalid.errors.txt -+++ new.jsdocPropertyTagInvalid.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(3,15): error TS2552: Cannot find name 'sting'. Did you mean 'string'? -- -- --==== /a.js (1 errors) ==== -- /** -- * @typedef MyType -- * @property {sting} [x] -- ~~~~~ --!!! error TS2552: Cannot find name 'sting'. Did you mean 'string'? -- */ -- -- /** @param {MyType} p */ -- export function f(p) { } -- --==== /b.js (0 errors) ==== -- import { f } from "./a.js" -- f({ x: 42 }) -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff index 08ec916107..7172ded6dd 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties3.errors.txt.diff @@ -1,36 +1,15 @@ --- old.strictOptionalProperties3.errors.txt +++ new.strictOptionalProperties3.errors.txt @@= skipped -0, +0 lines =@@ --a.js(7,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'A' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. -- Types of property 'value' are incompatible. -- Type 'undefined' is not assignable to type 'number'. + a.js(7,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'A' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. + Types of property 'value' are incompatible. + Type 'undefined' is not assignable to type 'number'. -a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type 'B' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. -- Types of property 'value' are incompatible. -- Type 'undefined' is not assignable to type 'number'. -- -- --==== a.js (2 errors) ==== +a.js(14,7): error TS2375: Type '{ value: undefined; }' is not assignable to type '{ value?: number; }' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. -+ Types of property 'value' are incompatible. -+ Type 'undefined' is not assignable to type 'number'. -+ -+ -+==== a.js (1 errors) ==== - /** - * @typedef {object} A - * @property {number} [value] -@@= skipped -13, +10 lines =@@ - - /** @type {A} */ - const a = { value: undefined }; // error -- ~ --!!! error TS2375: Type '{ value: undefined; }' is not assignable to type 'A' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties. --!!! error TS2375: Types of property 'value' are incompatible. --!!! error TS2375: Type 'undefined' is not assignable to type 'number'. - - /** - * @typedef {{ value?: number }} B -@@= skipped -12, +8 lines =@@ + Types of property 'value' are incompatible. + Type 'undefined' is not assignable to type 'number'. + +@@= skipped -25, +25 lines =@@ /** @type {B} */ const b = { value: undefined }; // error ~ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff deleted file mode 100644 index cac358c0b7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/strictOptionalProperties4.types.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.strictOptionalProperties4.types -+++ new.strictOptionalProperties4.types -@@= skipped -11, +11 lines =@@ - >{} : {} - - x.foo; // number | undefined -->x.foo : number | undefined -+>x.foo : any - >x : Foo -->foo : number | undefined -+>foo : any - - const y = /** @type {Required} */ ({}); - >y : Required -@@= skipped -10, +10 lines =@@ - >{} : {} - - y.foo; // number -->y.foo : number -+>y.foo : any - >y : Required -->foo : number -+>foo : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff index b10614b61d..b63a4f8b53 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocSatisfiesTag1.types.diff @@ -5,11 +5,7 @@ const t4 = /** @satisfies {T2} */ ({ a: "a" }); >t4 : T2 ->({ a: "a" }) : T2 -->{ a: "a" } : { a: "a"; } -->a : "a" -+>({ a: "a" }) : { a: string; } -+>{ a: "a" } : { a: string; } -+>a : string - >"a" : "a" - - /** @type {(m: string) => string} */ \ No newline at end of file ++>({ a: "a" }) : { a: "a"; } + >{ a: "a" } : { a: "a"; } + >a : "a" + >"a" : "a" \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.types.diff deleted file mode 100644 index 6ef59befbf..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/checkJsdocTypedefInParamTag1.types.diff +++ /dev/null @@ -1,38 +0,0 @@ ---- old.checkJsdocTypedefInParamTag1.types -+++ new.checkJsdocTypedefInParamTag1.types -@@= skipped -15, +15 lines =@@ - >opts : Opts - - opts.x; -->opts.x : string -+>opts.x : any - >opts : Opts -->x : string -+>x : any - } - - foo({x: 'abc'}); -@@= skipped -24, +24 lines =@@ - >opts : AnotherOpts - - opts.anotherX; -->opts.anotherX : string -+>opts.anotherX : any - >opts : AnotherOpts -->anotherX : string -+>anotherX : any - } - - foo1({anotherX: "world"}); -@@= skipped -26, +26 lines =@@ - >opts : Opts1 - - opts.x; -->opts.x : string -+>opts.x : any - >opts : Opts1 -->x : string -+>x : any - } - foo2({x: 'abc'}); - >foo2({x: 'abc'}) : void \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).types.diff index 98b53f2fe9..b7dca7fe81 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=false).types.diff @@ -5,27 +5,11 @@ */ export function prepareConfig({ ->prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: Partial>;}) => void -+>prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: { json?: any[]; }; }) => void ++>prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: Partial>; }) => void additionalFiles: { >additionalFiles : any - - json = [] -->json : string[] -+>json : any[] - >[] : undefined[] - - } = {} -@@= skipped -16, +16 lines =@@ - >{} : {} - - json // string[] -->json : string[] -+>json : any[] - } - - export function prepareConfigWithoutAnnotation({ -@@= skipped -27, +27 lines =@@ +@@= skipped -43, +43 lines =@@ additionalFiles?: Partial>; }) => void} */ export const prepareConfigWithContextualSignature = ({ @@ -35,32 +19,4 @@ +>({ additionalFiles: { json = [] } = {}} = {})=> { json // string[]} : ({ additionalFiles: { json } }?: { additionalFiles?: Partial>; }) => void additionalFiles: { - >additionalFiles : any -@@= skipped -26, +26 lines =@@ - * @param {{ a?: { json?: string[] }}} [config] - */ - function f1({ a: { json = [] } = {} } = {}) { return json } -->f1 : ({ a: { json } }?: { a?: { json?: string[]; }; }) => string[] -+>f1 : ({ a: { json } }?: { a?: { json?: any[]; }; }) => any[] - >a : any -->json : string[] -+>json : any[] - >[] : undefined[] - >{} : {} - >{} : {} -->json : string[] -+>json : any[] - - /** - * @param {[[string[]?]?]} [x] - */ - function f2([[json = []] = []] = []) { return json } -->f2 : ([[json]]?: [[string[]?]?]) => string[] -->json : string[] -+>f2 : ([[json]]?: [[any[]?]?]) => any[] -+>json : any[] - >[] : undefined[] - >[] : [] - >[] : [] -->json : string[] -+>json : any[] + >additionalFiles : any \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).types.diff index fad06a430c..23b183f260 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/destructuringParameterDeclaration9(strict=true).types.diff @@ -5,27 +5,11 @@ */ export function prepareConfig({ ->prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: Partial> | undefined;}) => void -+>prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: { json?: never[] | undefined; } | undefined; }) => void ++>prepareConfig : ({ additionalFiles: { json } }?: { additionalFiles?: Partial> | undefined; }) => void additionalFiles: { >additionalFiles : any - - json = [] -->json : string[] -+>json : never[] - >[] : never[] - - } = {} -@@= skipped -16, +16 lines =@@ - >{} : {} - - json // string[] -->json : string[] -+>json : never[] - } - - export function prepareConfigWithoutAnnotation({ -@@= skipped -10, +10 lines =@@ +@@= skipped -26, +26 lines =@@ >additionalFiles : any json = [] @@ -58,26 +42,16 @@ */ function f1({ a: { json = [] } = {} } = {}) { return json } ->f1 : ({ a: { json } }?: { a?: { json?: string[]; }; }) => string[] -+>f1 : ({ a: { json } }?: { a?: { json?: never[] | undefined; } | undefined; }) => never[] ++>f1 : ({ a: { json } }?: { a?: { json?: string[] | undefined; } | undefined; }) => string[] >a : any -->json : string[] -+>json : never[] + >json : string[] >[] : never[] - >{} : {} - >{} : {} -->json : string[] -+>json : never[] - - /** +@@= skipped -12, +12 lines =@@ * @param {[[string[]?]?]} [x] */ function f2([[json = []] = []] = []) { return json } ->f2 : ([[json]]?: [[string[]?]?]) => string[] -->json : string[] -+>f2 : ([[json]]?: [([(never[] | undefined)?] | undefined)?]) => never[] -+>json : never[] ++>f2 : ([[json]]?: [([(string[] | undefined)?] | undefined)?]) => string[] + >json : string[] >[] : never[] - >[] : [] - >[] : [] -->json : string[] -+>json : never[] + >[] : [] \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff index 50bab13dde..44269de68f 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff @@ -8,6 +8,7 @@ +file.js(4,11): error TS2315: Type 'Object' is not generic. +file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. ++file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. +file2.js(6,11): error TS2315: Type 'Object' is not generic. @@ -15,7 +16,7 @@ +file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. + + -+==== file.js (5 errors) ==== ++==== file.js (6 errors) ==== /** * @namespace myTypes * @global @@ -36,6 +37,8 @@ + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'myTypes'. * @property {myTypes.typeA} prop1 - Prop 1. ++ ~~~~~~~ ++!!! error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. * @property {string} prop2 - Prop 2. */ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff index feefca22a3..516be88695 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff @@ -5,6 +5,7 @@ +file.js(4,11): error TS2315: Type 'Object' is not generic. +file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. ++file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. +file2.js(6,11): error TS2315: Type 'Object' is not generic. @@ -50,7 +51,7 @@ + module.exports = {testFn, testFnTypes}; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== file.js (5 errors) ==== ++==== file.js (6 errors) ==== + /** + * @namespace myTypes + * @global @@ -71,6 +72,8 @@ + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'myTypes'. + * @property {myTypes.typeA} prop1 - Prop 1. ++ ~~~~~~~ ++!!! error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. + * @property {string} prop2 - Prop 2. + */ + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.types.diff index 58ea682e15..2001c4d3d2 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsNestedParams.types.diff @@ -5,22 +5,17 @@ */ async cancel({reason, code}) {} ->cancel : ({ reason, code }: { reason: string | null; code: string | null;}) => Promise -->reason : string -->code : string -+>cancel : ({ reason, code }: { code: any; reason: any; }) => Promise -+>reason : any -+>code : any ++>cancel : ({ reason, code }: { reason: string; code: string; }) => Promise + >reason : string + >code : string } - - class Y { @@= skipped -18, +18 lines =@@ * @returns {Promise.<*>} resolves when the event has been sent. */ async cancel({reason, suberr}) {} ->cancel : ({ reason, suberr }: { reason: string | null; suberr: { reason: string | null; code: string | null; };}) => Promise -->reason : string ++>cancel : ({ reason, suberr }: { reason: string; suberr: { reason: string; code: string; }; }) => Promise + >reason : string ->suberr : { reason: string | null; code: string | null; } -+>cancel : ({ reason, suberr }: { reason: any; suberr: any; }) => Promise -+>reason : any -+>suberr : any ++>suberr : { reason: string; code: string; } } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.types.diff index aac04ba90f..2f5558f93d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTag2.types.diff @@ -1,137 +1,51 @@ --- old.jsdocParamTag2.types +++ new.jsdocParamTag2.types -@@= skipped -6, +6 lines =@@ - * @param {string} x - */ - function good1({a, b}, x) {} -->good1 : ({ a, b }: { a: string; b: string; }, x: string) => void -->a : string -->b : string -+>good1 : ({ a, b }: { a: any; b: any; }, x: string) => void -+>a : any -+>b : any - >x : string - - /** -@@= skipped -10, +10 lines =@@ - * @param {{c: number, d: number}} OBJECTION - */ - function good2({a, b}, {c, d}) {} -->good2 : ({ a, b }: { a: string; b: string; }, { c, d }: { c: number; d: number; }) => void -->a : string -->b : string -->c : number -->d : number -+>good2 : ({ a, b }: { a: any; b: any; }, { c, d }: { c: any; d: any; }) => void -+>a : any -+>b : any -+>c : any -+>d : any - - /** - * @param {number} x -@@= skipped -12, +12 lines =@@ - * @param {string} y - */ - function good3(x, {a, b}, y) {} -->good3 : (x: number, { a, b }: { a: string; b: string; }, y: string) => void -+>good3 : (x: number, { a, b }: { a: any; b: any; }, y: string) => void - >x : number -->a : string -->b : string -+>a : any -+>b : any - >y : string - - /** - * @param {{a: string, b: string}} obj - */ - function good4({a, b}) {} -->good4 : ({ a, b }: { a: string; b: string; }) => void -->a : string -->b : string -+>good4 : ({ a, b }: { a: any; b: any; }) => void -+>a : any -+>b : any - - // nested object syntax - /** -@@= skipped -22, +22 lines =@@ +@@= skipped -50, +50 lines =@@ * @param {string} x */ function good5({a, b}, x) {} ->good5 : ({ a, b }: { a: string; b: string;}, x: string) => void -->a : string -->b : string -+>good5 : ({ a, b }: { a: any; b: any; }, x: string) => void -+>a : any -+>b : any ++>good5 : ({ a, b }: { a: string; b: string; }, x: string) => void + >a : string + >b : string >x : string - - /** @@= skipped -14, +14 lines =@@ * @param {string} OBJECTION.d - meh */ function good6({a, b}, {c, d}) {} ->good6 : ({ a, b }: { a: string; b: string;}, { c, d }: { c: string; d: string;}) => void -->a : string -->b : string -->c : string -->d : string -+>good6 : ({ a, b }: { a: any; b: any; }, { c, d }: { c: any; d: any; }) => void -+>a : any -+>b : any -+>c : any -+>d : any - - /** - * @param {number} x ++>good6 : ({ a, b }: { a: string; b: string; }, { c, d }: { c: string; d: string; }) => void + >a : string + >b : string + >c : string @@= skipped -14, +14 lines =@@ * @param {string} y */ function good7(x, {a, b}, y) {} ->good7 : (x: number, { a, b }: { a: string; b: string;}, y: string) => void -+>good7 : (x: number, { a, b }: { a: any; b: any; }, y: string) => void ++>good7 : (x: number, { a, b }: { a: string; b: string; }, y: string) => void >x : number -->a : string -->b : string -+>a : any -+>b : any - >y : string - - /** + >a : string + >b : string @@= skipped -12, +12 lines =@@ * @param {string} obj.b */ function good8({a, b}) {} ->good8 : ({ a, b }: { a: string; b: string;}) => void -->a : string -->b : string -+>good8 : ({ a, b }: { a: any; b: any; }) => void -+>a : any -+>b : any ++>good8 : ({ a, b }: { a: string; b: string; }) => void + >a : string + >b : string - /** +@@= skipped -8, +8 lines =@@ * @param {{ a: string }} argument */ function good9({ a }) { ->good9 : ({ a }: { a: string; }, ...args: any[]) => void -->a : string -+>good9 : ({ a }: { a: any; }) => void -+>a : any ++>good9 : ({ a }: { a: string; }) => void + >a : string console.log(arguments, a); - >console.log(arguments, a) : void -@@= skipped -17, +17 lines =@@ - >console : Console - >log : (...data: any[]) => void - >arguments : IArguments -->a : string -+>a : any - } - - /** -@@= skipped -10, +10 lines =@@ +@@= skipped -19, +19 lines =@@ * @param {string} x */ function bad1(x, {a, b}) {} @@ -139,15 +53,4 @@ +>bad1 : (x: string, { a, b }: { a: any; b: any; }) => void >x : string >a : any - >b : any -@@= skipped -10, +10 lines =@@ - * @param {{a: string, b: string}} obj - */ - function bad2(x, {a, b}) {} -->bad2 : (x: any, { a, b }: { a: string; b: string; }) => void -+>bad2 : (x: any, { a, b }: { a: any; b: any; }) => void - >x : any -->a : string -->b : string -+>a : any -+>b : any + >b : any \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.types.diff index 01fa44947d..d654a9ad84 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocParamTagTypeLiteral.types.diff @@ -5,177 +5,113 @@ */ function foo1(opts1) { ->foo1 : (opts1: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined;}) => void -->opts1 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; } -+>foo1 : (opts1: any) => void -+>opts1 : any ++>foo1 : (opts1: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }) => void + >opts1 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; } opts1.x; -->opts1.x : string -->opts1 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; } -->x : string -+>opts1.x : any -+>opts1 : any -+>x : any - } +@@= skipped -11, +11 lines =@@ foo1({x: 'abc'}); >foo1({x: 'abc'}) : void ->foo1 : (opts1: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined;}) => void -+>foo1 : (opts1: any) => void ++>foo1 : (opts1: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" -@@= skipped -22, +22 lines =@@ +@@= skipped -11, +11 lines =@@ * @param {string=} opts2[].anotherY */ function foo2(/** @param opts2 bad idea theatre! */opts2) { ->foo2 : (opts2: { anotherX: string; anotherY?: string | undefined;}) => void -->opts2 : { anotherX: string; anotherY?: string | undefined; }[] -+>foo2 : (opts2: any) => void -+>opts2 : any ++>foo2 : (opts2: { anotherX: string; anotherY?: string | undefined; }[]) => void + >opts2 : { anotherX: string; anotherY?: string | undefined; }[] opts2[0].anotherX; -->opts2[0].anotherX : string -->opts2[0] : { anotherX: string; anotherY?: string | undefined; } -->opts2 : { anotherX: string; anotherY?: string | undefined; }[] -+>opts2[0].anotherX : any -+>opts2[0] : any -+>opts2 : any - >0 : 0 -->anotherX : string -+>anotherX : any - } +@@= skipped -13, +13 lines =@@ foo2([{anotherX: "world"}]); >foo2([{anotherX: "world"}]) : void ->foo2 : (opts2: { anotherX: string; anotherY?: string | undefined;}) => void -+>foo2 : (opts2: any) => void ++>foo2 : (opts2: { anotherX: string; anotherY?: string | undefined; }[]) => void >[{anotherX: "world"}] : { anotherX: string; }[] >{anotherX: "world"} : { anotherX: string; } >anotherX : string -@@= skipped -24, +24 lines =@@ +@@= skipped -11, +11 lines =@@ * @param {string} opts3.x */ function foo3(opts3) { ->foo3 : (opts3: { x: string;}) => void -->opts3 : { x: string; } -+>foo3 : (opts3: any) => void -+>opts3 : any ++>foo3 : (opts3: { x: string; }) => void + >opts3 : { x: string; } opts3.x; -->opts3.x : string -->opts3 : { x: string; } -->x : string -+>opts3.x : any -+>opts3 : any -+>x : any +@@= skipped -10, +10 lines =@@ } foo3({x: 'abc'}); >foo3({x: 'abc'}) : void ->foo3 : (opts3: { x: string;}) => void -+>foo3 : (opts3: any) => void ++>foo3 : (opts3: { x: string; }) => void >{x: 'abc'} : { x: string; } >x : string >'abc' : "abc" -@@= skipped -23, +23 lines =@@ +@@= skipped -13, +13 lines =@@ * @param {string} [opts4[].w="hi"] */ function foo4(opts4) { ->foo4 : (opts4: { x: string; y?: string | undefined; z?: string; w?: string;}) => void -->opts4 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[] -+>foo4 : (opts4: any) => void -+>opts4 : any ++>foo4 : (opts4: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[]) => void + >opts4 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[] opts4[0].x; -->opts4[0].x : string -->opts4[0] : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; } -->opts4 : { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[] -+>opts4[0].x : any -+>opts4[0] : any -+>opts4 : any - >0 : 0 -->x : string -+>x : any - } +@@= skipped -13, +13 lines =@@ foo4([{ x: 'hi' }]); >foo4([{ x: 'hi' }]) : void ->foo4 : (opts4: { x: string; y?: string | undefined; z?: string; w?: string;}) => void -+>foo4 : (opts4: any) => void ++>foo4 : (opts4: { x: string; y?: string | undefined; z?: string | undefined; w?: string | undefined; }[]) => void >[{ x: 'hi' }] : { x: string; }[] >{ x: 'hi' } : { x: string; } >x : string -@@= skipped -30, +30 lines =@@ +@@= skipped -17, +17 lines =@@ * @param {number} opts5[].unnest - Here we are almost all the way back at the beginning. */ function foo5(opts5) { ->foo5 : (opts5: { help: string; what: { a: string; bad: { idea: string; oh: boolean; }; }; unnest: number;}) => void ->opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; };}; unnest: number; }[] -+>foo5 : (opts5: any) => void -+>opts5 : any ++>foo5 : (opts5: { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[]) => void ++>opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[] opts5[0].what.bad[0].idea; -->opts5[0].what.bad[0].idea : string -->opts5[0].what.bad[0] : { idea: string; oh: boolean; } -->opts5[0].what.bad : { idea: string; oh: boolean; }[] + >opts5[0].what.bad[0].idea : string + >opts5[0].what.bad[0] : { idea: string; oh: boolean; } + >opts5[0].what.bad : { idea: string; oh: boolean; }[] ->opts5[0].what : { a: string; bad: { idea: string; oh: boolean;}; } ->opts5[0] : { help: string; what: { a: string; bad: { idea: string; oh: boolean; };}; unnest: number; } ->opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; };}; unnest: number; }[] -->0 : 0 ++>opts5[0].what : { a: string; bad: { idea: string; oh: boolean; }[]; } ++>opts5[0] : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; } ++>opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[] + >0 : 0 ->what : { a: string; bad: { idea: string; oh: boolean;}; } -->bad : { idea: string; oh: boolean; }[] -->0 : 0 -->idea : string -+>opts5[0].what.bad[0].idea : any -+>opts5[0].what.bad[0] : any -+>opts5[0].what.bad : any -+>opts5[0].what : any -+>opts5[0] : any -+>opts5 : any -+>0 : 0 -+>what : any -+>bad : any -+>0 : 0 -+>idea : any ++>what : { a: string; bad: { idea: string; oh: boolean; }[]; } + >bad : { idea: string; oh: boolean; }[] + >0 : 0 + >idea : string opts5[0].unnest; -->opts5[0].unnest : number + >opts5[0].unnest : number ->opts5[0] : { help: string; what: { a: string; bad: { idea: string; oh: boolean; };}; unnest: number; } ->opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; };}; unnest: number; }[] -+>opts5[0].unnest : any -+>opts5[0] : any -+>opts5 : any ++>opts5[0] : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; } ++>opts5 : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[] >0 : 0 -->unnest : number -+>unnest : any + >unnest : number } foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]); >foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]) : void ->foo5 : (opts5: { help: string; what: { a: string; bad: { idea: string; oh: boolean; }; }; unnest: number;}) => void -->[{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }] : { help: string; what: { a: string; bad: { idea: string; oh: false; }[]; }; unnest: number; }[] -->{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 } : { help: string; what: { a: string; bad: { idea: string; oh: false; }[]; }; unnest: number; } -+>foo5 : (opts5: any) => void -+>[{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }] : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[] -+>{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 } : { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; } - >help : string - >"help" : "help" -->what : { a: string; bad: { idea: string; oh: false; }[]; } -->{ a: 'a', bad: [{ idea: 'idea', oh: false }] } : { a: string; bad: { idea: string; oh: false; }[]; } -+>what : { a: string; bad: { idea: string; oh: boolean; }[]; } -+>{ a: 'a', bad: [{ idea: 'idea', oh: false }] } : { a: string; bad: { idea: string; oh: boolean; }[]; } - >a : string - >'a' : "a" -->bad : { idea: string; oh: false; }[] -->[{ idea: 'idea', oh: false }] : { idea: string; oh: false; }[] -->{ idea: 'idea', oh: false } : { idea: string; oh: false; } -+>bad : { idea: string; oh: boolean; }[] -+>[{ idea: 'idea', oh: false }] : { idea: string; oh: boolean; }[] -+>{ idea: 'idea', oh: false } : { idea: string; oh: boolean; } - >idea : string - >'idea' : "idea" -->oh : false -+>oh : boolean - >false : false - >unnest : number - >1 : 1 \ No newline at end of file ++>foo5 : (opts5: { help: string; what: { a: string; bad: { idea: string; oh: boolean; }[]; }; unnest: number; }[]) => void + >[{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }] : { help: string; what: { a: string; bad: { idea: string; oh: false; }[]; }; unnest: number; }[] + >{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 } : { help: string; what: { a: string; bad: { idea: string; oh: false; }[]; }; unnest: number; } + >help : string \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff index 8307262019..1de308f13e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateConstructorFunction2.errors.txt.diff @@ -2,44 +2,20 @@ +++ new.jsdocTemplateConstructorFunction2.errors.txt @@= skipped -0, +0 lines =@@ -templateTagWithNestedTypeLiteral.js(21,1): error TS2322: Type 'boolean' is not assignable to type 'number'. --templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. -- -- + templateTagWithNestedTypeLiteral.js(28,15): error TS2304: Cannot find name 'T'. + + -==== templateTagWithNestedTypeLiteral.js (2 errors) ==== -- /** -- * @param {T} t -- * @template T -- */ -- function Zet(t) { -- /** @type {T} */ -- this.u -- this.t = t -- } -- /** -- * @param {T} v -- * @param {object} o -- * @param {T} o.nested -- */ -- Zet.prototype.add = function(v, o) { -- this.u = v || o.nested -- return this.u -- } -- var z = new Zet(1) -- z.t = 2 -- z.u = false ++==== templateTagWithNestedTypeLiteral.js (1 errors) ==== + /** + * @param {T} t + * @template T +@@= skipped -23, +22 lines =@@ + var z = new Zet(1) + z.t = 2 + z.u = false - ~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. -- /** @type {number} */ -- let answer = z.add(3, { nested: 4 }) -- -- // lookup in typedef should not crash the compiler, even when the type is unknown -- /** -- * @typedef {Object} A -- * @property {T} value -- ~ --!!! error TS2304: Cannot find name 'T'. -- */ -- /** @type {A} */ -- const options = { value: null }; -- -+ \ No newline at end of file + /** @type {number} */ + let answer = z.add(3, { nested: 4 }) + \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff index a9cdebd0f2..989f7fbd7d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.errors.txt.diff @@ -2,16 +2,16 @@ +++ new.jsdocTemplateTag8.errors.txt @@= skipped -0, +0 lines =@@ +a.js(2,14): error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias ++a.js(4,15): error TS2304: Cannot find name 'T'. a.js(18,1): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. Type 'unknown' is not assignable to type 'string'. +a.js(21,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -+a.js(29,33): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(34,31): error TS7006: Parameter 'x' implicitly has an 'any' type. ++a.js(23,19): error TS2304: Cannot find name 'T'. a.js(36,1): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. Type 'unknown' is not assignable to type 'string'. +a.js(40,14): error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias -+a.js(48,29): error TS7006: Parameter 'x' implicitly has an 'any' type. -+a.js(53,27): error TS7006: Parameter 'x' implicitly has an 'any' type. ++a.js(42,19): error TS2304: Cannot find name 'T'. ++a.js(42,25): error TS2304: Cannot find name 'T'. a.js(55,1): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. - Types of property 'f' are incompatible. - Type '(x: string) => string' is not assignable to type '(x: unknown) => unknown'. @@ -33,8 +33,12 @@ +!!! error TS1274: 'out' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Covariant * @property {T} x ++ ~ ++!!! error TS2304: Cannot find name 'T'. */ -@@= skipped -37, +42 lines =@@ + + /** +@@= skipped -37, +44 lines =@@ /** * @template in T @@ -42,24 +46,12 @@ +!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Contravariant * @property {(x: T) => void} f ++ ~ ++!!! error TS2304: Cannot find name 'T'. */ -@@= skipped -8, +10 lines =@@ - * @type {Contravariant} - */ - let super_contravariant = { f: (x) => {} }; -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. /** - * @type {Contravariant} - */ - let sub_contravariant = { f: (x) => {} }; -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - - super_contravariant = sub_contravariant; // Error - ~~~~~~~~~~~~~~~~~~~ -@@= skipped -14, +18 lines =@@ +@@= skipped -22, +26 lines =@@ /** * @template in out T @@ -67,21 +59,14 @@ +!!! error TS1274: 'in' modifier can only appear on a type parameter of a class, interface or type alias * @typedef {Object} Invariant * @property {(x: T) => T} f ++ ~ ++!!! error TS2304: Cannot find name 'T'. ++ ~ ++!!! error TS2304: Cannot find name 'T'. */ -@@= skipped -8, +10 lines =@@ - * @type {Invariant} - */ - let super_invariant = { f: (x) => {} }; -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. /** - * @type {Invariant} - */ - let sub_invariant = { f: (x) => { return "" } }; -+ ~ -+!!! error TS7006: Parameter 'x' implicitly has an 'any' type. - +@@= skipped -17, +23 lines =@@ super_invariant = sub_invariant; // Error ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.types.diff index f72a8667ff..1d65a74dcf 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTemplateTag8.types.diff @@ -8,10 +8,10 @@ ->f : (x: unknown) => void ->(x) => {} : (x: unknown) => void ->x : unknown -+>{ f: (x) => {} } : { f: (x: any) => void; } -+>f : (x: any) => void -+>(x) => {} : (x: any) => void -+>x : any ++>{ f: (x) => {} } : { f: (x: T) => void; } ++>f : (x: T) => void ++>(x) => {} : (x: T) => void ++>x : T /** * @type {Contravariant} @@ -22,10 +22,10 @@ ->f : (x: string) => void ->(x) => {} : (x: string) => void ->x : string -+>{ f: (x) => {} } : { f: (x: any) => void; } -+>f : (x: any) => void -+>(x) => {} : (x: any) => void -+>x : any ++>{ f: (x) => {} } : { f: (x: T) => void; } ++>f : (x: T) => void ++>(x) => {} : (x: T) => void ++>x : T super_contravariant = sub_contravariant; // Error >super_contravariant = sub_contravariant : Contravariant @@ -37,10 +37,10 @@ ->f : (x: unknown) => void ->(x) => {} : (x: unknown) => void ->x : unknown -+>{ f: (x) => {} } : { f: (x: any) => void; } -+>f : (x: any) => void -+>(x) => {} : (x: any) => void -+>x : any ++>{ f: (x) => {} } : { f: (x: T) => void; } ++>f : (x: T) => void ++>(x) => {} : (x: T) => void ++>x : T /** * @type {Invariant} @@ -51,10 +51,10 @@ ->f : (x: string) => string ->(x) => { return "" } : (x: string) => string ->x : string -+>{ f: (x) => { return "" } } : { f: (x: any) => string; } -+>f : (x: any) => string -+>(x) => { return "" } : (x: any) => string -+>x : any ++>{ f: (x) => { return "" } } : { f: (x: T) => string; } ++>f : (x: T) => string ++>(x) => { return "" } : (x: T) => string ++>x : T >"" : "" super_invariant = sub_invariant; // Error \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff deleted file mode 100644 index f7800589ed..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.optionalBindingParameters3.errors.txt -+++ new.optionalBindingParameters3.errors.txt -@@= skipped -0, +0 lines =@@ --/a.js(9,12): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -- -- --==== /a.js (1 errors) ==== -- /** -- * @typedef Foo -- * @property {string} a -- */ -- -- /** -- * @param {Foo} [options] -- */ -- function f({ a = "a" }) {} -- ~~~~~~~~~~~ --!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.types.diff deleted file mode 100644 index c05f17d5b2..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters3.types.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.optionalBindingParameters3.types -+++ new.optionalBindingParameters3.types -@@= skipped -9, +9 lines =@@ - * @param {Foo} [options] - */ - function f({ a = "a" }) {} -->f : ({ a }?: Foo) => void -+>f : ({ a }: { a?: string; }) => void - >a : string - >"a" : "a" diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff deleted file mode 100644 index 60b5f6731e..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.errors.txt.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.optionalBindingParameters4.errors.txt -+++ new.optionalBindingParameters4.errors.txt -@@= skipped -0, +0 lines =@@ -- -+/a.js(4,16): error TS2339: Property 'cause' does not exist on type '{}'. -+ -+ -+==== /a.js (1 errors) ==== -+ /** -+ * @param {{ cause?: string }} [options] -+ */ -+ function foo({ cause } = {}) { -+ ~~~~~ -+!!! error TS2339: Property 'cause' does not exist on type '{}'. -+ return cause; -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.types.diff deleted file mode 100644 index 5d3003f106..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/optionalBindingParameters4.types.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.optionalBindingParameters4.types -+++ new.optionalBindingParameters4.types -@@= skipped -4, +4 lines =@@ - * @param {{ cause?: string }} [options] - */ - function foo({ cause } = {}) { -->foo : ({ cause }?: { cause?: string; }) => string -->cause : string -+>foo : ({ cause }?: {}) => any -+>cause : any - >{} : {} - - return cause; -->cause : string -+>cause : any - } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.types.diff deleted file mode 100644 index 8318329c5a..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefTagNested.types.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.typedefTagNested.types -+++ new.typedefTagNested.types -@@= skipped -64, +64 lines =@@ - >"ok" : "ok" - - sala.name -->sala.name : string -+>sala.name : any - >sala : Upp -->name : string -+>name : any - - sala.not -->sala.not : Object -+>sala.not : any - >sala : Upp -->not : Object -+>not : any - - sala.nested -->sala.nested : string -+>sala.nested : any - >sala : Upp -->nested : string -+>nested : any diff --git a/testdata/tests/cases/conformance/jsdoc/jsdocDestructuringParameterDeclaration.ts b/testdata/tests/cases/conformance/jsdoc/jsdocDestructuringParameterDeclaration.ts new file mode 100644 index 0000000000..694b17889d --- /dev/null +++ b/testdata/tests/cases/conformance/jsdoc/jsdocDestructuringParameterDeclaration.ts @@ -0,0 +1,10 @@ +// @allowJs: true +// @checkJs: true +// @declaration: true +// @emitDeclarationOnly: true + +// @Filename: /a.js +/** + * @param {{ a: number; b: string }} args + */ +function f({ a, b }) {}