From 5170645f4e4b395891fad823bfe03ac628411afb Mon Sep 17 00:00:00 2001 From: "Oleksandr T." Date: Fri, 17 Jan 2025 22:12:12 +0200 Subject: [PATCH] fix(60592): JSDoc implements space sensetive (#60640) --- src/compiler/parser.ts | 1 + tests/baselines/reference/extendsTag3.js | 19 +++++++++++ tests/baselines/reference/extendsTag3.symbols | 14 ++++++++ tests/baselines/reference/extendsTag3.types | 19 +++++++++++ tests/baselines/reference/extendsTag6.symbols | 26 +++++++++++++++ tests/baselines/reference/extendsTag6.types | 32 +++++++++++++++++++ .../reference/jsdocImplementsTag.symbols | 17 ++++++++++ .../reference/jsdocImplementsTag.types | 21 ++++++++++++ tests/cases/conformance/jsdoc/extendsTag3.ts | 10 ++++++ tests/cases/conformance/jsdoc/extendsTag6.ts | 22 +++++++++++++ .../conformance/jsdoc/jsdocImplementsTag.ts | 15 +++++++++ 11 files changed, 196 insertions(+) create mode 100644 tests/baselines/reference/extendsTag6.symbols create mode 100644 tests/baselines/reference/extendsTag6.types create mode 100644 tests/baselines/reference/jsdocImplementsTag.symbols create mode 100644 tests/baselines/reference/jsdocImplementsTag.types create mode 100644 tests/cases/conformance/jsdoc/extendsTag6.ts create mode 100644 tests/cases/conformance/jsdoc/jsdocImplementsTag.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 59ad1f030220f..8c69cccba1282 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -9536,6 +9536,7 @@ namespace Parser { const node = factory.createExpressionWithTypeArguments(expression, typeArguments) as ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression; }; const res = finishNode(node, pos); if (usedBrace) { + skipWhitespace(); parseExpected(SyntaxKind.CloseBraceToken); } return res; diff --git a/tests/baselines/reference/extendsTag3.js b/tests/baselines/reference/extendsTag3.js index 999982f3289b1..68180aa6214fb 100644 --- a/tests/baselines/reference/extendsTag3.js +++ b/tests/baselines/reference/extendsTag3.js @@ -17,6 +17,16 @@ class B extends A { super(); } } + +/** + * @extends { A } + * @constructor + */ +class C extends A { + constructor() { + super(); + } +} //// [foo.js] @@ -35,3 +45,12 @@ class B extends A { super(); } } +/** + * @extends { A } + * @constructor + */ +class C extends A { + constructor() { + super(); + } +} diff --git a/tests/baselines/reference/extendsTag3.symbols b/tests/baselines/reference/extendsTag3.symbols index 4fa623c2649ce..265cd1313f900 100644 --- a/tests/baselines/reference/extendsTag3.symbols +++ b/tests/baselines/reference/extendsTag3.symbols @@ -24,3 +24,17 @@ class B extends A { } } +/** + * @extends { A } + * @constructor + */ +class C extends A { +>C : Symbol(C, Decl(foo.js, 15, 1)) +>A : Symbol(A, Decl(foo.js, 0, 0)) + + constructor() { + super(); +>super : Symbol(A, Decl(foo.js, 0, 0)) + } +} + diff --git a/tests/baselines/reference/extendsTag3.types b/tests/baselines/reference/extendsTag3.types index c9f7a76260cdd..04a08d0f32ce2 100644 --- a/tests/baselines/reference/extendsTag3.types +++ b/tests/baselines/reference/extendsTag3.types @@ -30,3 +30,22 @@ class B extends A { } } +/** + * @extends { A } + * @constructor + */ +class C extends A { +>C : C +> : ^ +>A : A +> : ^ + + constructor() { + super(); +>super() : void +> : ^^^^ +>super : typeof A +> : ^^^^^^^^ + } +} + diff --git a/tests/baselines/reference/extendsTag6.symbols b/tests/baselines/reference/extendsTag6.symbols new file mode 100644 index 0000000000000..c0e9f051ce49f --- /dev/null +++ b/tests/baselines/reference/extendsTag6.symbols @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/jsdoc/extendsTag6.ts] //// + +=== foo.js === +/** + * @constructor + */ +class A { +>A : Symbol(A, Decl(foo.js, 0, 0)) + + constructor() {} +} + +/** + * @extends { A } + * @constructor + */ +class B extends A { +>B : Symbol(B, Decl(foo.js, 5, 1)) +>A : Symbol(A, Decl(foo.js, 0, 0)) + + constructor() { + super(); +>super : Symbol(A, Decl(foo.js, 0, 0)) + } +} + diff --git a/tests/baselines/reference/extendsTag6.types b/tests/baselines/reference/extendsTag6.types new file mode 100644 index 0000000000000..886b33328eae3 --- /dev/null +++ b/tests/baselines/reference/extendsTag6.types @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/jsdoc/extendsTag6.ts] //// + +=== foo.js === +/** + * @constructor + */ +class A { +>A : A +> : ^ + + constructor() {} +} + +/** + * @extends { A } + * @constructor + */ +class B extends A { +>B : B +> : ^ +>A : A +> : ^ + + constructor() { + super(); +>super() : void +> : ^^^^ +>super : typeof A +> : ^^^^^^^^ + } +} + diff --git a/tests/baselines/reference/jsdocImplementsTag.symbols b/tests/baselines/reference/jsdocImplementsTag.symbols new file mode 100644 index 0000000000000..e582dae1d074a --- /dev/null +++ b/tests/baselines/reference/jsdocImplementsTag.symbols @@ -0,0 +1,17 @@ +//// [tests/cases/conformance/jsdoc/jsdocImplementsTag.ts] //// + +=== /a.js === +/** + * @typedef { { foo: string } } A + */ + +/** + * @implements { A } + */ +class B { +>B : Symbol(B, Decl(a.js, 0, 0)) + + foo = '' +>foo : Symbol(B.foo, Decl(a.js, 7, 9)) +} + diff --git a/tests/baselines/reference/jsdocImplementsTag.types b/tests/baselines/reference/jsdocImplementsTag.types new file mode 100644 index 0000000000000..496e4b1fcbfe7 --- /dev/null +++ b/tests/baselines/reference/jsdocImplementsTag.types @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/jsdoc/jsdocImplementsTag.ts] //// + +=== /a.js === +/** + * @typedef { { foo: string } } A + */ + +/** + * @implements { A } + */ +class B { +>B : B +> : ^ + + foo = '' +>foo : string +> : ^^^^^^ +>'' : "" +> : ^^ +} + diff --git a/tests/cases/conformance/jsdoc/extendsTag3.ts b/tests/cases/conformance/jsdoc/extendsTag3.ts index 81ac1e68843d3..28ca684ac71d8 100644 --- a/tests/cases/conformance/jsdoc/extendsTag3.ts +++ b/tests/cases/conformance/jsdoc/extendsTag3.ts @@ -20,3 +20,13 @@ class B extends A { super(); } } + +/** + * @extends { A } + * @constructor + */ +class C extends A { + constructor() { + super(); + } +} diff --git a/tests/cases/conformance/jsdoc/extendsTag6.ts b/tests/cases/conformance/jsdoc/extendsTag6.ts new file mode 100644 index 0000000000000..e7eee6ec8cdf9 --- /dev/null +++ b/tests/cases/conformance/jsdoc/extendsTag6.ts @@ -0,0 +1,22 @@ +// @allowJs: true +// @checkJs: true +// @target: esnext +// @noEmit: true +// @Filename: foo.js + +/** + * @constructor + */ +class A { + constructor() {} +} + +/** + * @extends { A } + * @constructor + */ +class B extends A { + constructor() { + super(); + } +} diff --git a/tests/cases/conformance/jsdoc/jsdocImplementsTag.ts b/tests/cases/conformance/jsdoc/jsdocImplementsTag.ts new file mode 100644 index 0000000000000..355ac8ca43af3 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocImplementsTag.ts @@ -0,0 +1,15 @@ +// @allowJs: true +// @checkJs: true +// @noEmit: true + +// @Filename: /a.js +/** + * @typedef { { foo: string } } A + */ + +/** + * @implements { A } + */ +class B { + foo = '' +}