diff --git a/tests/baselines/reference/jsdocParamTagTypeLiteral.symbols b/tests/baselines/reference/jsdocParamTagTypeLiteral.symbols new file mode 100644 index 00000000000..6add9c77cde --- /dev/null +++ b/tests/baselines/reference/jsdocParamTagTypeLiteral.symbols @@ -0,0 +1,134 @@ +=== tests/cases/conformance/jsdoc/0.js === +/** + * @param {Object} notSpecial + * @param {string} unrelated - not actually related because it's not notSpecial.unrelated + */ +function normal(notSpecial) { +>normal : Symbol(normal, Decl(0.js, 0, 0)) +>notSpecial : Symbol(notSpecial, Decl(0.js, 4, 16)) + + notSpecial; // should just be 'any' +>notSpecial : Symbol(notSpecial, Decl(0.js, 4, 16)) +} +normal(12); +>normal : Symbol(normal, Decl(0.js, 0, 0)) + +/** + * @param {Object} opts1 doc1 + * @param {string} opts1.x doc2 + * @param {string=} opts1.y doc3 + * @param {string} [opts1.z] doc4 + * @param {string} [opts1.w="hi"] doc5 + */ +function foo1(opts1) { +>foo1 : Symbol(foo1, Decl(0.js, 7, 11)) +>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'}); +>foo1 : Symbol(foo1, Decl(0.js, 7, 11)) +>x : Symbol(x, Decl(0.js, 20, 6)) + +/** + * @param {Object[]} opts2 + * @param {string} opts2[].anotherX + * @param {string=} opts2[].anotherY + */ +function foo2(/** @param opts2 bad idea theatre! */opts2) { +>foo2 : Symbol(foo2, Decl(0.js, 20, 17)) +>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"}]); +>foo2 : Symbol(foo2, Decl(0.js, 20, 17)) +>anotherX : Symbol(anotherX, Decl(0.js, 31, 7)) + +/** + * @param {object} opts3 + * @param {string} opts3.x + */ +function foo3(opts3) { +>foo3 : Symbol(foo3, Decl(0.js, 31, 28)) +>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)) +>x : Symbol(x, Decl(0.js, 40, 6)) + +/** + * @param {object[]} opts4 + * @param {string} opts4[].x + * @param {string=} opts4[].y + * @param {string} [opts4[].z] + * @param {string} [opts4[].w="hi"] + */ +function foo4(opts4) { +>foo4 : Symbol(foo4, Decl(0.js, 40, 17)) +>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' }]); +>foo4 : Symbol(foo4, Decl(0.js, 40, 17)) +>x : Symbol(x, Decl(0.js, 53, 7)) + +/** + * @param {object[]} opts5 - Let's test out some multiple nesting levels + * @param {string} opts5[].help - (This one is just normal) + * @param {object} opts5[].what - Look at us go! Here's the first nest! + * @param {string} opts5[].what.a - (Another normal one) + * @param {Object[]} opts5[].what.bad - Now we're nesting inside a nested type + * @param {string} opts5[].what.bad[].idea - I don't think you can get back out of this level... + * @param {boolean} opts5[].what.bad[].oh - Oh ... that's how you do it. + * @param {number} opts5[].unnest - Here we are almost all the way back at the beginning. + */ +function foo5(opts5) { +>foo5 : Symbol(foo5, Decl(0.js, 53, 20)) +>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 }]); +>foo5 : Symbol(foo5, Decl(0.js, 53, 20)) +>help : Symbol(help, Decl(0.js, 70, 7)) +>what : Symbol(what, Decl(0.js, 70, 21)) +>a : Symbol(a, Decl(0.js, 70, 29)) +>bad : Symbol(bad, Decl(0.js, 70, 37)) +>idea : Symbol(idea, Decl(0.js, 70, 45)) +>oh : Symbol(oh, Decl(0.js, 70, 59)) +>unnest : Symbol(unnest, Decl(0.js, 70, 75)) + +// TODO: Also write these ridiculous object[] / nested tests for @typedef as well + diff --git a/tests/baselines/reference/jsdocParamTagTypeLiteral.types b/tests/baselines/reference/jsdocParamTagTypeLiteral.types new file mode 100644 index 00000000000..80ec6edf7b0 --- /dev/null +++ b/tests/baselines/reference/jsdocParamTagTypeLiteral.types @@ -0,0 +1,171 @@ +=== tests/cases/conformance/jsdoc/0.js === +/** + * @param {Object} notSpecial + * @param {string} unrelated - not actually related because it's not notSpecial.unrelated + */ +function normal(notSpecial) { +>normal : (notSpecial: any) => void +>notSpecial : any + + notSpecial; // should just be 'any' +>notSpecial : any +} +normal(12); +>normal(12) : void +>normal : (notSpecial: any) => void +>12 : 12 + +/** + * @param {Object} opts1 doc1 + * @param {string} opts1.x doc2 + * @param {string=} opts1.y doc3 + * @param {string} [opts1.z] doc4 + * @param {string} [opts1.w="hi"] doc5 + */ +function foo1(opts1) { +>foo1 : (opts1: { x: string; y?: string; z?: string; w?: string; }) => void +>opts1 : { x: string; y?: string; z?: string; w?: string; } + + opts1.x; +>opts1.x : string +>opts1 : { x: string; y?: string; z?: string; w?: string; } +>x : string +} + +foo1({x: 'abc'}); +>foo1({x: 'abc'}) : void +>foo1 : (opts1: { x: string; y?: string; z?: string; w?: string; }) => void +>{x: 'abc'} : { x: string; } +>x : string +>'abc' : "abc" + +/** + * @param {Object[]} opts2 + * @param {string} opts2[].anotherX + * @param {string=} opts2[].anotherY + */ +function foo2(/** @param opts2 bad idea theatre! */opts2) { +>foo2 : (opts2: { anotherX: string; anotherY?: string; }[]) => void +>opts2 : { anotherX: string; anotherY?: string; }[] + + opts2[0].anotherX; +>opts2[0].anotherX : string +>opts2[0] : { anotherX: string; anotherY?: string; } +>opts2 : { anotherX: string; anotherY?: string; }[] +>0 : 0 +>anotherX : string +} + +foo2([{anotherX: "world"}]); +>foo2([{anotherX: "world"}]) : void +>foo2 : (opts2: { anotherX: string; anotherY?: string; }[]) => void +>[{anotherX: "world"}] : { anotherX: string; }[] +>{anotherX: "world"} : { anotherX: string; } +>anotherX : string +>"world" : "world" + +/** + * @param {object} opts3 + * @param {string} opts3.x + */ +function foo3(opts3) { +>foo3 : (opts3: { x: string; }) => void +>opts3 : { x: string; } + + opts3.x; +>opts3.x : string +>opts3 : { x: string; } +>x : string +} +foo3({x: 'abc'}); +>foo3({x: 'abc'}) : void +>foo3 : (opts3: { x: string; }) => void +>{x: 'abc'} : { x: string; } +>x : string +>'abc' : "abc" + +/** + * @param {object[]} opts4 + * @param {string} opts4[].x + * @param {string=} opts4[].y + * @param {string} [opts4[].z] + * @param {string} [opts4[].w="hi"] + */ +function foo4(opts4) { +>foo4 : (opts4: { x: string; y?: string; z?: string; w?: string; }[]) => void +>opts4 : { x: string; y?: string; z?: string; w?: string; }[] + + opts4[0].x; +>opts4[0].x : string +>opts4[0] : { x: string; y?: string; z?: string; w?: string; } +>opts4 : { x: string; y?: string; z?: string; w?: string; }[] +>0 : 0 +>x : string +} + +foo4([{ x: 'hi' }]); +>foo4([{ x: 'hi' }]) : void +>foo4 : (opts4: { x: string; y?: string; z?: string; w?: string; }[]) => void +>[{ x: 'hi' }] : { x: string; }[] +>{ x: 'hi' } : { x: string; } +>x : string +>'hi' : "hi" + +/** + * @param {object[]} opts5 - Let's test out some multiple nesting levels + * @param {string} opts5[].help - (This one is just normal) + * @param {object} opts5[].what - Look at us go! Here's the first nest! + * @param {string} opts5[].what.a - (Another normal one) + * @param {Object[]} opts5[].what.bad - Now we're nesting inside a nested type + * @param {string} opts5[].what.bad[].idea - I don't think you can get back out of this level... + * @param {boolean} opts5[].what.bad[].oh - Oh ... that's how you do it. + * @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; }[] + + 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 : { 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].unnest; +>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 : 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; } +>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; }[]; } +>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; } +>idea : string +>'idea' : "idea" +>oh : boolean +>false : false +>unnest : number +>1 : 1 + +// TODO: Also write these ridiculous object[] / nested tests for @typedef as well + diff --git a/tests/cases/conformance/jsdoc/jsdocParamTagTypeLiteral.ts b/tests/cases/conformance/jsdoc/jsdocParamTagTypeLiteral.ts new file mode 100644 index 00000000000..2c8d4cbafb6 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocParamTagTypeLiteral.ts @@ -0,0 +1,80 @@ +// @allowJS: true +// @checkJs: true +// @noEmit: true +// @strict: true +// @suppressOutputPathCheck: true + +// @Filename: 0.js +/** + * @param {Object} notSpecial + * @param {string} unrelated - not actually related because it's not notSpecial.unrelated + */ +function normal(notSpecial) { + notSpecial; // should just be 'any' +} +normal(12); + +/** + * @param {Object} opts1 doc1 + * @param {string} opts1.x doc2 + * @param {string=} opts1.y doc3 + * @param {string} [opts1.z] doc4 + * @param {string} [opts1.w="hi"] doc5 + */ +function foo1(opts1) { + opts1.x; +} + +foo1({x: 'abc'}); + +/** + * @param {Object[]} opts2 + * @param {string} opts2[].anotherX + * @param {string=} opts2[].anotherY + */ +function foo2(/** @param opts2 bad idea theatre! */opts2) { + opts2[0].anotherX; +} + +foo2([{anotherX: "world"}]); + +/** + * @param {object} opts3 + * @param {string} opts3.x + */ +function foo3(opts3) { + opts3.x; +} +foo3({x: 'abc'}); + +/** + * @param {object[]} opts4 + * @param {string} opts4[].x + * @param {string=} opts4[].y + * @param {string} [opts4[].z] + * @param {string} [opts4[].w="hi"] + */ +function foo4(opts4) { + opts4[0].x; +} + +foo4([{ x: 'hi' }]); + +/** + * @param {object[]} opts5 - Let's test out some multiple nesting levels + * @param {string} opts5[].help - (This one is just normal) + * @param {object} opts5[].what - Look at us go! Here's the first nest! + * @param {string} opts5[].what.a - (Another normal one) + * @param {Object[]} opts5[].what.bad - Now we're nesting inside a nested type + * @param {string} opts5[].what.bad[].idea - I don't think you can get back out of this level... + * @param {boolean} opts5[].what.bad[].oh - Oh ... that's how you do it. + * @param {number} opts5[].unnest - Here we are almost all the way back at the beginning. + */ +function foo5(opts5) { + opts5[0].what.bad[0].idea; + opts5[0].unnest; +} + +foo5([{ help: "help", what: { a: 'a', bad: [{ idea: 'idea', oh: false }] }, unnest: 1 }]); + +// TODO: Also write these ridiculous object[] / nested tests for @typedef as well