From fce33f1b8f185ed5fd339a9b52cbfa43c13c5712 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 8 Dec 2020 09:28:48 -0800 Subject: [PATCH] remove some done TODOs --- src/services/codefixes/inferFromUsage.ts | 6 ++-- src/services/jsDoc.ts | 1 - src/services/services.ts | 1 - .../reference/api/tsserverlibrary.d.ts | 29 +++++++++---------- tests/baselines/reference/api/typescript.d.ts | 18 ++++++------ 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/services/codefixes/inferFromUsage.ts b/src/services/codefixes/inferFromUsage.ts index dc030fce72c34..76e37f339303e 100644 --- a/src/services/codefixes/inferFromUsage.ts +++ b/src/services/codefixes/inferFromUsage.ts @@ -128,7 +128,7 @@ namespace ts.codefix { const typeNode = getTypeNodeIfAccessible(type, parent, program, host); if (typeNode) { // Note that the codefix will never fire with an existing `@type` tag, so there is no need to merge tags - const typeTag = factory.createJSDocTypeTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode), /*comment*/ { text: "" }); + const typeTag = factory.createJSDocTypeTag(/*tagName*/ undefined, factory.createJSDocTypeExpression(typeNode), /*comment*/ undefined); addJSDocTags(changes, sourceFile, cast(parent.parent.parent, isExpressionStatement), [typeTag]); } importAdder.writeFixes(changes); @@ -307,7 +307,7 @@ namespace ts.codefix { return; } const typeExpression = factory.createJSDocTypeExpression(typeNode); - const typeTag = isGetAccessorDeclaration(declaration) ? factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, { text: "" }) : factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, { text: "" }); + const typeTag = isGetAccessorDeclaration(declaration) ? factory.createJSDocReturnTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined) : factory.createJSDocTypeTag(/*tagName*/ undefined, typeExpression, /*comment*/ undefined); addJSDocTags(changes, sourceFile, parent, [typeTag]); } else if (!tryReplaceImportTypeNodeWithAutoImport(typeNode, declaration, sourceFile, changes, importAdder, getEmitScriptTarget(program.getCompilerOptions()))) { @@ -374,7 +374,7 @@ namespace ts.codefix { } else { const paramTags = map(inferences, ({ name, typeNode, isOptional }) => - factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, { text: "" })); + factory.createJSDocParameterTag(/*tagName*/ undefined, name, /*isBracketed*/ !!isOptional, factory.createJSDocTypeExpression(typeNode), /* isNameFirst */ false, /*comment*/ undefined)); addJSDocTags(changes, sourceFile, signature, paramTags); } } diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 53e1fe95417f2..a6da4bc20075c 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -128,7 +128,6 @@ namespace ts.JsDoc { if (links) { return mapDefined(links, link => { if (!link.name) return; - // TODO: Test this, I think getSymbolAtLocation eventually calls checkQualifiedName and then returns resolvedSymbol, but it's hard to be sure const symbol = checker.getSymbolAtLocation(link.name); if (!symbol || !symbol.valueDeclaration) return; return { diff --git a/src/services/services.ts b/src/services/services.ts index cb2848859f7fb..7d0c16a184480 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -359,7 +359,6 @@ namespace ts { } } - // TODO: Maybe link symbol resolution should be lazy so this function doesn't need to provide a checker getJsDocTags(checker: TypeChecker): JSDocTagInfo[] { if (this.tags === undefined) { this.tags = JsDoc.getJsDocTagsFromDeclarations(checker, this.declarations); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 6063ddd6bf5e6..e95cf865dfa5c 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -1750,13 +1750,13 @@ declare namespace ts { readonly tagName: Identifier; readonly comment?: JSDocComment; } - export interface JSDocLinkNode extends Node { + export interface JSDocLink extends Node { readonly kind: SyntaxKind.JSDocLink; readonly name?: EntityName; } export interface JSDocComment { text: string; - links?: JSDocLinkNode[]; + links?: JSDocLink[]; } export interface JSDocUnknownTag extends JSDocTag { readonly kind: SyntaxKind.JSDocTag; @@ -3462,8 +3462,8 @@ declare namespace ts { updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression; createJSDocNameReference(name: EntityName): JSDocNameReference; updateJSDocNameReference(node: JSDocNameReference, name: EntityName): JSDocNameReference; - createJSDocLinkNode(name: EntityName): JSDocLinkNode; - updateJSDocLinkNode(node: JSDocLinkNode, name: EntityName): JSDocLinkNode; + createJSDocLinkNode(name: EntityName): JSDocLink; + updateJSDocLinkNode(node: JSDocLink, name: EntityName): JSDocLink; createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral; updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral; createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature; @@ -5992,9 +5992,9 @@ declare namespace ts { interface JSDocTagInfo { name: string; text?: string; - links?: readonly JSDocLink[]; + links?: readonly JSDocLinkInfo[]; } - interface JSDocLink extends DocumentSpan { + interface JSDocLinkInfo extends DocumentSpan { target: DocumentSpan; } interface QuickInfo { @@ -6003,7 +6003,7 @@ declare namespace ts { textSpan: TextSpan; displayParts?: SymbolDisplayPart[]; documentation?: SymbolDisplayPart[]; - tags?: readonly JSDocTagInfo[]; + tags?: JSDocTagInfo[]; } type RenameInfo = RenameInfoSuccess | RenameInfoFailure; interface RenameInfoSuccess { @@ -6050,7 +6050,7 @@ declare namespace ts { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; - tags: readonly JSDocTagInfo[]; + tags: JSDocTagInfo[]; } /** * Represents a set of signature help items, and the preferred item that should be selected. @@ -6102,7 +6102,7 @@ declare namespace ts { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation?: SymbolDisplayPart[]; - tags?: readonly JSDocTagInfo[]; + tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; source?: SymbolDisplayPart[]; } @@ -7204,9 +7204,9 @@ declare namespace ts.server.protocol { interface JSDocTagInfo { name: string; text?: string; - links?: readonly JSDocLink[]; + links?: JSDocLinkInfo[]; } - interface JSDocLink extends DocumentSpan { + interface JSDocLinkInfo extends DocumentSpan { target: FileSpan; } interface TextSpanWithContext extends TextSpan { @@ -7936,7 +7936,7 @@ declare namespace ts.server.protocol { /** * JSDoc tags associated with symbol. */ - tags: readonly JSDocTagInfo[]; + tags: JSDocTagInfo[]; } /** * Quickinfo response message. @@ -8208,7 +8208,7 @@ declare namespace ts.server.protocol { /** * JSDoc tags for the symbol. */ - tags?: readonly JSDocTagInfo[]; + tags?: JSDocTagInfo[]; /** * The associated code actions for this entry */ @@ -8291,9 +8291,8 @@ declare namespace ts.server.protocol { documentation: SymbolDisplayPart[]; /** * The signature's JSDoc tags - * TODO: Changing this doesn't cause the build to fail! Need tests and probably a scan of session.ts */ - tags: readonly JSDocTagInfo[]; + tags: JSDocTagInfo[]; } /** * Signature help items found in the response of a signature help request. diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 93e74d5201e79..0d3eab806c749 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1750,13 +1750,13 @@ declare namespace ts { readonly tagName: Identifier; readonly comment?: JSDocComment; } - export interface JSDocLinkNode extends Node { + export interface JSDocLink extends Node { readonly kind: SyntaxKind.JSDocLink; readonly name?: EntityName; } export interface JSDocComment { text: string; - links?: JSDocLinkNode[]; + links?: JSDocLink[]; } export interface JSDocUnknownTag extends JSDocTag { readonly kind: SyntaxKind.JSDocTag; @@ -3462,8 +3462,8 @@ declare namespace ts { updateJSDocTypeExpression(node: JSDocTypeExpression, type: TypeNode): JSDocTypeExpression; createJSDocNameReference(name: EntityName): JSDocNameReference; updateJSDocNameReference(node: JSDocNameReference, name: EntityName): JSDocNameReference; - createJSDocLinkNode(name: EntityName): JSDocLinkNode; - updateJSDocLinkNode(node: JSDocLinkNode, name: EntityName): JSDocLinkNode; + createJSDocLinkNode(name: EntityName): JSDocLink; + updateJSDocLinkNode(node: JSDocLink, name: EntityName): JSDocLink; createJSDocTypeLiteral(jsDocPropertyTags?: readonly JSDocPropertyLikeTag[], isArrayType?: boolean): JSDocTypeLiteral; updateJSDocTypeLiteral(node: JSDocTypeLiteral, jsDocPropertyTags: readonly JSDocPropertyLikeTag[] | undefined, isArrayType: boolean | undefined): JSDocTypeLiteral; createJSDocSignature(typeParameters: readonly JSDocTemplateTag[] | undefined, parameters: readonly JSDocParameterTag[], type?: JSDocReturnTag): JSDocSignature; @@ -5992,9 +5992,9 @@ declare namespace ts { interface JSDocTagInfo { name: string; text?: string; - links?: readonly JSDocLink[]; + links?: readonly JSDocLinkInfo[]; } - interface JSDocLink extends DocumentSpan { + interface JSDocLinkInfo extends DocumentSpan { target: DocumentSpan; } interface QuickInfo { @@ -6003,7 +6003,7 @@ declare namespace ts { textSpan: TextSpan; displayParts?: SymbolDisplayPart[]; documentation?: SymbolDisplayPart[]; - tags?: readonly JSDocTagInfo[]; + tags?: JSDocTagInfo[]; } type RenameInfo = RenameInfoSuccess | RenameInfoFailure; interface RenameInfoSuccess { @@ -6050,7 +6050,7 @@ declare namespace ts { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; - tags: readonly JSDocTagInfo[]; + tags: JSDocTagInfo[]; } /** * Represents a set of signature help items, and the preferred item that should be selected. @@ -6102,7 +6102,7 @@ declare namespace ts { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation?: SymbolDisplayPart[]; - tags?: readonly JSDocTagInfo[]; + tags?: JSDocTagInfo[]; codeActions?: CodeAction[]; source?: SymbolDisplayPart[]; }