From e16be71c08f13d61adf24bd55a15ebd51104b44c Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Wed, 9 Jan 2019 15:52:05 -0800 Subject: [PATCH 1/6] Add diagnostic message for JSDoc qualified param name without top level param --- src/compiler/diagnosticMessages.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 57f4c4c561..58ec73c3ca 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -4266,6 +4266,10 @@ "category": "Error", "code": 8031 }, + "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'.": { + "category": "Error", + "code": 8032 + }, "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": { "category": "Error", "code": 9002 From dd0a612cc9317034c87e2cf6ddec1370ef0e0ddb Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Wed, 9 Jan 2019 16:08:14 -0800 Subject: [PATCH 2/6] Use specific error message for qualified param name without leading top level param name --- src/compiler/checker.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index de44e8bb37..68ad0afaf5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24757,9 +24757,17 @@ namespace ts { return; } if (!containsArgumentsReference(decl)) { - error(node.name, - Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, - idText(node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name)); + if (isQualifiedName(node.name)) { + error(node.name, + Diagnostics.Qualified_name_0_is_not_allowed_without_a_leading_param_object_1, + entityNameToString(node.name), + entityNameToString(node.name.left)); + } + else { + error(node.name, + Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, + idText(node.name)); + } } else if (findLast(getJSDocTags(decl), isJSDocParameterTag) === node && node.typeExpression && node.typeExpression.type && From e2524e375029d49de5de8c1393b8d362381aa6c4 Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 10 Jan 2019 09:55:06 -0800 Subject: [PATCH 3/6] Add test for qualified name param without top level object error --- .../paramTagNestedWithoutTopLevelObject.errors.txt | 12 ++++++++++++ .../paramTagNestedWithoutTopLevelObject.symbols | 11 +++++++++++ .../paramTagNestedWithoutTopLevelObject.types | 13 +++++++++++++ .../jsdoc/paramTagNestedWithoutTopLevelObject.ts | 11 +++++++++++ 4 files changed, 47 insertions(+) create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types create mode 100644 tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt new file mode 100644 index 0000000000..7cfe6e0367 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js(2,20): error TS8032: Qualified name 'xyz.p' is not allowed without a leading '@param {object} xyz'. + + +==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js (1 errors) ==== + /** + * @param {number} xyz.p + ~~~~~ +!!! error TS8032: Qualified name 'xyz.p' is not allowed without a leading '@param {object} xyz'. + */ + function g(xyz) { + xyz.x; + } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols new file mode 100644 index 0000000000..63e7e4980b --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js === +/** + * @param {number} xyz.p + */ +function g(xyz) { +>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject.js, 0, 0)) +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11)) + + xyz.x; +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11)) +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types new file mode 100644 index 0000000000..d65efd8678 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js === +/** + * @param {number} xyz.p + */ +function g(xyz) { +>g : (xyz: any) => void +>xyz : any + + xyz.x; +>xyz.x : any +>xyz : any +>x : any +} diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts new file mode 100644 index 0000000000..2285ae623f --- /dev/null +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts @@ -0,0 +1,11 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: paramTagNestedWithoutTopLevelObject.js + +/** + * @param {number} xyz.p + */ +function g(xyz) { + xyz.x; +} \ No newline at end of file From ebe193c6d7757ecfe998634823beb2045f63aec1 Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 10 Jan 2019 14:05:10 -0800 Subject: [PATCH 4/6] Minor refactor in paramTagNestedWithoutTopLevelObject.ts --- .../paramTagNestedWithoutTopLevelObject.errors.txt | 2 +- .../reference/paramTagNestedWithoutTopLevelObject.symbols | 2 +- .../reference/paramTagNestedWithoutTopLevelObject.types | 8 ++++---- .../jsdoc/paramTagNestedWithoutTopLevelObject.ts | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt index 7cfe6e0367..8ee7b3ba98 100644 --- a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.errors.txt @@ -8,5 +8,5 @@ tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.js(2,20): erro !!! error TS8032: Qualified name 'xyz.p' is not allowed without a leading '@param {object} xyz'. */ function g(xyz) { - xyz.x; + return xyz.p; } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols index 63e7e4980b..d8a28a638f 100644 --- a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.symbols @@ -6,6 +6,6 @@ function g(xyz) { >g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject.js, 0, 0)) >xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11)) - xyz.x; + return xyz.p; >xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject.js, 3, 11)) } diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types index d65efd8678..cc339b84b3 100644 --- a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject.types @@ -3,11 +3,11 @@ * @param {number} xyz.p */ function g(xyz) { ->g : (xyz: any) => void +>g : (xyz: any) => any >xyz : any - xyz.x; ->xyz.x : any + return xyz.p; +>xyz.p : any >xyz : any ->x : any +>p : any } diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts index 2285ae623f..03c79ce9e1 100644 --- a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject.ts @@ -7,5 +7,5 @@ * @param {number} xyz.p */ function g(xyz) { - xyz.x; + return xyz.p; } \ No newline at end of file From b3633fab5275f2a3b2c29e2b9f4ba5106e002dfa Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 10 Jan 2019 15:04:16 -0800 Subject: [PATCH 5/6] Add more tests for qualified name param without top level object error --- ...aramTagNestedWithoutTopLevelObject4.errors.txt | 12 ++++++++++++ .../paramTagNestedWithoutTopLevelObject4.symbols | 11 +++++++++++ .../paramTagNestedWithoutTopLevelObject4.types | 15 +++++++++++++++ .../jsdoc/paramTagNestedWithoutTopLevelObject2.ts | 12 ++++++++++++ .../jsdoc/paramTagNestedWithoutTopLevelObject3.ts | 12 ++++++++++++ .../jsdoc/paramTagNestedWithoutTopLevelObject4.ts | 11 +++++++++++ 6 files changed, 73 insertions(+) create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.errors.txt create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.symbols create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.types create mode 100644 tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.ts create mode 100644 tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.ts create mode 100644 tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.ts diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.errors.txt new file mode 100644 index 0000000000..74ca02ef00 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.js(2,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. + + +==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.js (1 errors) ==== + /** + * @param {number} xyz.bar.p + ~~~~~~~~~ +!!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. + */ + function g(xyz) { + return xyz.bar.p; + } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.symbols new file mode 100644 index 0000000000..6f8e1ffa64 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.js === +/** + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject4.js, 0, 0)) +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject4.js, 3, 11)) + + return xyz.bar.p; +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject4.js, 3, 11)) +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.types new file mode 100644 index 0000000000..8b9843bdbe --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject4.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.js === +/** + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : (xyz: any) => any +>xyz : any + + return xyz.bar.p; +>xyz.bar.p : any +>xyz.bar : any +>xyz : any +>bar : any +>p : any +} diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.ts new file mode 100644 index 0000000000..a6a68aa086 --- /dev/null +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.ts @@ -0,0 +1,12 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: paramTagNestedWithoutTopLevelObject2.js + +/** + * @param {object} xyz.bar + * @param {number} xyz.bar.p + */ +function g(xyz) { + return xyz.bar.p; +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.ts new file mode 100644 index 0000000000..8307688a0c --- /dev/null +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.ts @@ -0,0 +1,12 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: paramTagNestedWithoutTopLevelObject3.js + +/** + * @param {object} xyz + * @param {number} xyz.bar.p + */ +function g(xyz) { + return xyz.bar.p; +} \ No newline at end of file diff --git a/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.ts b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.ts new file mode 100644 index 0000000000..5840308fa0 --- /dev/null +++ b/tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject4.ts @@ -0,0 +1,11 @@ +// @noEmit: true +// @allowJs: true +// @checkJs: true +// @Filename: paramTagNestedWithoutTopLevelObject4.js + +/** + * @param {number} xyz.bar.p + */ +function g(xyz) { + return xyz.bar.p; +} \ No newline at end of file From ed5775865a971b74bbbd0f430214e5fb96beed5b Mon Sep 17 00:00:00 2001 From: Gabriela Britto Date: Thu, 10 Jan 2019 15:45:00 -0800 Subject: [PATCH 6/6] Add missing baseline references --- ...ramTagNestedWithoutTopLevelObject2.errors.txt | 13 +++++++++++++ .../paramTagNestedWithoutTopLevelObject2.symbols | 12 ++++++++++++ .../paramTagNestedWithoutTopLevelObject2.types | 16 ++++++++++++++++ ...ramTagNestedWithoutTopLevelObject3.errors.txt | 13 +++++++++++++ .../paramTagNestedWithoutTopLevelObject3.symbols | 12 ++++++++++++ .../paramTagNestedWithoutTopLevelObject3.types | 16 ++++++++++++++++ 6 files changed, 82 insertions(+) create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.errors.txt create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.symbols create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.types create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.errors.txt create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.symbols create mode 100644 tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.types diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.errors.txt new file mode 100644 index 0000000000..d3e94e1cff --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js(2,20): error TS8032: Qualified name 'xyz.bar' is not allowed without a leading '@param {object} xyz'. + + +==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js (1 errors) ==== + /** + * @param {object} xyz.bar + ~~~~~~~ +!!! error TS8032: Qualified name 'xyz.bar' is not allowed without a leading '@param {object} xyz'. + * @param {number} xyz.bar.p + */ + function g(xyz) { + return xyz.bar.p; + } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.symbols new file mode 100644 index 0000000000..e6acfb7cbc --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js === +/** + * @param {object} xyz.bar + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject2.js, 0, 0)) +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject2.js, 4, 11)) + + return xyz.bar.p; +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject2.js, 4, 11)) +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.types new file mode 100644 index 0000000000..2f6598ffa2 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject2.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject2.js === +/** + * @param {object} xyz.bar + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : (xyz: any) => any +>xyz : any + + return xyz.bar.p; +>xyz.bar.p : any +>xyz.bar : any +>xyz : any +>bar : any +>p : any +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.errors.txt b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.errors.txt new file mode 100644 index 0000000000..d73f35cfcb --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js(3,20): error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. + + +==== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js (1 errors) ==== + /** + * @param {object} xyz + * @param {number} xyz.bar.p + ~~~~~~~~~ +!!! error TS8032: Qualified name 'xyz.bar.p' is not allowed without a leading '@param {object} xyz.bar'. + */ + function g(xyz) { + return xyz.bar.p; + } \ No newline at end of file diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.symbols b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.symbols new file mode 100644 index 0000000000..a350edded9 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js === +/** + * @param {object} xyz + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : Symbol(g, Decl(paramTagNestedWithoutTopLevelObject3.js, 0, 0)) +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject3.js, 4, 11)) + + return xyz.bar.p; +>xyz : Symbol(xyz, Decl(paramTagNestedWithoutTopLevelObject3.js, 4, 11)) +} diff --git a/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.types b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.types new file mode 100644 index 0000000000..a2bb9ddf32 --- /dev/null +++ b/tests/baselines/reference/paramTagNestedWithoutTopLevelObject3.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/jsdoc/paramTagNestedWithoutTopLevelObject3.js === +/** + * @param {object} xyz + * @param {number} xyz.bar.p + */ +function g(xyz) { +>g : (xyz: any) => any +>xyz : any + + return xyz.bar.p; +>xyz.bar.p : any +>xyz.bar : any +>xyz : any +>bar : any +>p : any +}