mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 11:35:42 -06:00
fix(50303): Using @linkcode in combination with private methods causes TS1003 in JavaScript files. (#56338)
This commit is contained in:
parent
c250aed310
commit
4eae150282
@ -9210,18 +9210,7 @@ namespace Parser {
|
||||
}
|
||||
nextTokenJSDoc(); // start at token after link, then skip any whitespace
|
||||
skipWhitespace();
|
||||
// parseEntityName logs an error for non-identifier, so create a MissingNode ourselves to avoid the error
|
||||
const p2 = getNodePos();
|
||||
let name: EntityName | JSDocMemberName | undefined = tokenIsIdentifierOrKeyword(token())
|
||||
? parseEntityName(/*allowReservedWords*/ true)
|
||||
: undefined;
|
||||
if (name) {
|
||||
while (token() === SyntaxKind.PrivateIdentifier) {
|
||||
reScanHashToken(); // rescan #id as # id
|
||||
nextTokenJSDoc(); // then skip the #
|
||||
name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), p2);
|
||||
}
|
||||
}
|
||||
const name = parseJSDocLinkName();
|
||||
const text = [];
|
||||
while (token() !== SyntaxKind.CloseBraceToken && token() !== SyntaxKind.NewLineTrivia && token() !== SyntaxKind.EndOfFileToken) {
|
||||
text.push(scanner.getTokenText());
|
||||
@ -9233,6 +9222,24 @@ namespace Parser {
|
||||
return finishNode(create(name, text.join("")), start, scanner.getTokenEnd());
|
||||
}
|
||||
|
||||
function parseJSDocLinkName() {
|
||||
if (tokenIsIdentifierOrKeyword(token())) {
|
||||
const pos = getNodePos();
|
||||
|
||||
let name: EntityName | JSDocMemberName = parseIdentifierName();
|
||||
while (parseOptional(SyntaxKind.DotToken)) {
|
||||
name = finishNode(factory.createQualifiedName(name, token() === SyntaxKind.PrivateIdentifier ? createMissingNode<Identifier>(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false) : parseIdentifier()), pos);
|
||||
}
|
||||
while (token() === SyntaxKind.PrivateIdentifier) {
|
||||
reScanHashToken();
|
||||
nextTokenJSDoc();
|
||||
name = finishNode(factory.createJSDocMemberName(name, parseIdentifier()), pos);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function parseJSDocLinkPrefix() {
|
||||
skipWhitespaceOrAsterisk();
|
||||
if (
|
||||
|
||||
26
tests/baselines/reference/jsdocLinkTag7.symbols
Normal file
26
tests/baselines/reference/jsdocLinkTag7.symbols
Normal file
@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/jsdoc/jsdocLinkTag7.ts] ////
|
||||
|
||||
=== /a.js ===
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(a.js, 0, 0))
|
||||
|
||||
/**
|
||||
* {@linkcode this.a}
|
||||
* {@linkcode this.#c}
|
||||
*
|
||||
* {@link this.a}
|
||||
* {@link this.#c}
|
||||
*
|
||||
* {@linkplain this.a}
|
||||
* {@linkplain this.#c}
|
||||
*/
|
||||
a() { }
|
||||
>a : Symbol(Foo.a, Decl(a.js, 0, 11))
|
||||
|
||||
b() { }
|
||||
>b : Symbol(Foo.b, Decl(a.js, 11, 11))
|
||||
|
||||
#c() { }
|
||||
>#c : Symbol(Foo.#c, Decl(a.js, 12, 11))
|
||||
}
|
||||
|
||||
26
tests/baselines/reference/jsdocLinkTag7.types
Normal file
26
tests/baselines/reference/jsdocLinkTag7.types
Normal file
@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/jsdoc/jsdocLinkTag7.ts] ////
|
||||
|
||||
=== /a.js ===
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
/**
|
||||
* {@linkcode this.a}
|
||||
* {@linkcode this.#c}
|
||||
*
|
||||
* {@link this.a}
|
||||
* {@link this.#c}
|
||||
*
|
||||
* {@linkplain this.a}
|
||||
* {@linkplain this.#c}
|
||||
*/
|
||||
a() { }
|
||||
>a : () => void
|
||||
|
||||
b() { }
|
||||
>b : () => void
|
||||
|
||||
#c() { }
|
||||
>#c : () => void
|
||||
}
|
||||
|
||||
20
tests/cases/conformance/jsdoc/jsdocLinkTag7.ts
Normal file
20
tests/cases/conformance/jsdoc/jsdocLinkTag7.ts
Normal file
@ -0,0 +1,20 @@
|
||||
// @checkJs: true
|
||||
// @allowJs: true
|
||||
// @target: esnext
|
||||
// @noEmit: true
|
||||
// @filename: /a.js
|
||||
class Foo {
|
||||
/**
|
||||
* {@linkcode this.a}
|
||||
* {@linkcode this.#c}
|
||||
*
|
||||
* {@link this.a}
|
||||
* {@link this.#c}
|
||||
*
|
||||
* {@linkplain this.a}
|
||||
* {@linkplain this.#c}
|
||||
*/
|
||||
a() { }
|
||||
b() { }
|
||||
#c() { }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user