Skip to content

Commit

Permalink
fix(60592): JSDoc implements space sensetive (#60640)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-tarasyuk authored Jan 17, 2025
1 parent f99803d commit 5170645
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 19 additions & 0 deletions tests/baselines/reference/extendsTag3.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ class B extends A {
super();
}
}

/**
* @extends { A }
* @constructor
*/
class C extends A {
constructor() {
super();
}
}


//// [foo.js]
Expand All @@ -35,3 +45,12 @@ class B extends A {
super();
}
}
/**
* @extends { A }
* @constructor
*/
class C extends A {
constructor() {
super();
}
}
14 changes: 14 additions & 0 deletions tests/baselines/reference/extendsTag3.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

19 changes: 19 additions & 0 deletions tests/baselines/reference/extendsTag3.types
Original file line number Diff line number Diff line change
Expand Up @@ -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
> : ^^^^^^^^
}
}

26 changes: 26 additions & 0 deletions tests/baselines/reference/extendsTag6.symbols
Original file line number Diff line number Diff line change
@@ -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))
}
}

32 changes: 32 additions & 0 deletions tests/baselines/reference/extendsTag6.types
Original file line number Diff line number Diff line change
@@ -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
> : ^^^^^^^^
}
}

17 changes: 17 additions & 0 deletions tests/baselines/reference/jsdocImplementsTag.symbols
Original file line number Diff line number Diff line change
@@ -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))
}

21 changes: 21 additions & 0 deletions tests/baselines/reference/jsdocImplementsTag.types
Original file line number Diff line number Diff line change
@@ -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
> : ^^^^^^
>'' : ""
> : ^^
}

10 changes: 10 additions & 0 deletions tests/cases/conformance/jsdoc/extendsTag3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ class B extends A {
super();
}
}

/**
* @extends { A }
* @constructor
*/
class C extends A {
constructor() {
super();
}
}
22 changes: 22 additions & 0 deletions tests/cases/conformance/jsdoc/extendsTag6.ts
Original file line number Diff line number Diff line change
@@ -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();
}
}
15 changes: 15 additions & 0 deletions tests/cases/conformance/jsdoc/jsdocImplementsTag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// @allowJs: true
// @checkJs: true
// @noEmit: true

// @Filename: /a.js
/**
* @typedef { { foo: string } } A
*/

/**
* @implements { A }
*/
class B {
foo = ''
}

0 comments on commit 5170645

Please sign in to comment.