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:
Wesley Wigham
2017-09-07 10:28:58 -07:00
committed by GitHub
parent 39d0590869
commit c1f2afd645
17 changed files with 279 additions and 91 deletions

View File

@@ -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;
}

View File

@@ -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) {

View File

@@ -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);
}

View File

@@ -2111,7 +2111,7 @@ namespace ts {
}
forEachChild(node, walk);
if (node.jsDoc) {
if (hasJSDocNodes(node)) {
for (const jsDoc of node.jsDoc) {
forEachChild(jsDoc, walk);
}