mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-07 18:25:51 -05:00
Add typedef declaration space, unify typedef name gathering (#18172)
* Add typedef declaration space, unify typedef name gathering, strengthen errorUnusedLocal * Bonus round: make jsdoc presence way mroe typesafe * Be exhaustive in nameForNamelessJSDocTypedef * Remove nonrequired casts * Replace more casts with guards * Cannot be internal * Debug.fail returns never, assert never no longer needs unreachable throw to satisfy checker * Rename type * Add replacement message as in 18287
This commit is contained in:
@@ -699,7 +699,8 @@ namespace ts {
|
||||
// specially.
|
||||
const docCommentAndDiagnostics = parseIsolatedJSDocComment(sourceFile.text, start, width);
|
||||
if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) {
|
||||
docCommentAndDiagnostics.jsDoc.parent = token;
|
||||
// TODO: This should be predicated on `token["kind"]` being compatible with `HasJSDoc["kind"]`
|
||||
docCommentAndDiagnostics.jsDoc.parent = token as HasJSDoc;
|
||||
classifyJSDocComment(docCommentAndDiagnostics.jsDoc);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1739,7 +1739,7 @@ namespace ts.Completions {
|
||||
|
||||
/** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
|
||||
function getJsDocTagAtPosition(node: Node, position: number): JSDocTag | undefined {
|
||||
const { jsDoc } = getJsDocHavingNode(node);
|
||||
const { jsDoc } = getJsDocHavingNode(node) as JSDocContainer;
|
||||
if (!jsDoc) return undefined;
|
||||
|
||||
for (const { pos, end, tags } of jsDoc) {
|
||||
|
||||
@@ -263,13 +263,15 @@ namespace ts.NavigationBar {
|
||||
break;
|
||||
|
||||
default:
|
||||
forEach(node.jsDoc, jsDoc => {
|
||||
forEach(jsDoc.tags, tag => {
|
||||
if (tag.kind === SyntaxKind.JSDocTypedefTag) {
|
||||
addLeafNode(tag);
|
||||
}
|
||||
if (hasJSDocNodes(node)) {
|
||||
forEach(node.jsDoc, jsDoc => {
|
||||
forEach(jsDoc.tags, tag => {
|
||||
if (tag.kind === SyntaxKind.JSDocTypedefTag) {
|
||||
addLeafNode(tag);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
forEachChild(node, addChildrenRecursively);
|
||||
}
|
||||
|
||||
@@ -2111,7 +2111,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
forEachChild(node, walk);
|
||||
if (node.jsDoc) {
|
||||
if (hasJSDocNodes(node)) {
|
||||
for (const jsDoc of node.jsDoc) {
|
||||
forEachChild(jsDoc, walk);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user