diff --git a/packages/compiler-cli/src/ngtsc/typecheck/src/comments.ts b/packages/compiler-cli/src/ngtsc/typecheck/src/comments.ts index 10b6c59dda..7007b1a33c 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/src/comments.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/src/comments.ts @@ -53,7 +53,7 @@ export function addExpressionIdentifier(node: ts.Node, identifier: ExpressionIde /* hasTrailingNewLine */ false); } -const IGNORE_MARKER = `${CommentTriviaType.DIAGNOSTIC}:ignore`; +const IGNORE_FOR_DIAGNOSTICS_MARKER = `${CommentTriviaType.DIAGNOSTIC}:ignore`; /** * Tag the `ts.Node` with an indication that any errors arising from the evaluation of the node @@ -61,17 +61,18 @@ const IGNORE_MARKER = `${CommentTriviaType.DIAGNOSTIC}:ignore`; */ export function markIgnoreDiagnostics(node: ts.Node): void { ts.addSyntheticTrailingComment( - node, ts.SyntaxKind.MultiLineCommentTrivia, IGNORE_MARKER, /* hasTrailingNewLine */ false); + node, ts.SyntaxKind.MultiLineCommentTrivia, IGNORE_FOR_DIAGNOSTICS_MARKER, + /* hasTrailingNewLine */ false); } /** Returns true if the node has a marker that indicates diagnostics errors should be ignored. */ -export function hasIgnoreMarker(node: ts.Node, sourceFile: ts.SourceFile): boolean { +export function hasIgnoreForDiagnosticsMarker(node: ts.Node, sourceFile: ts.SourceFile): boolean { return ts.forEachTrailingCommentRange(sourceFile.text, node.getEnd(), (pos, end, kind) => { if (kind !== ts.SyntaxKind.MultiLineCommentTrivia) { return null; } const commentText = sourceFile.text.substring(pos + 2, end - 2); - return commentText === IGNORE_MARKER; + return commentText === IGNORE_FOR_DIAGNOSTICS_MARKER; }) === true; } diff --git a/packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.ts b/packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.ts index b7d56a00a5..7bdc189dcb 100644 --- a/packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.ts +++ b/packages/compiler-cli/src/ngtsc/typecheck/src/tcb_util.ts @@ -13,7 +13,7 @@ import * as ts from 'typescript'; import {getTokenAtPosition} from '../../util/src/typescript'; import {FullTemplateMapping, SourceLocation, TemplateId, TemplateSourceMapping} from '../api'; -import {hasIgnoreMarker, readSpanComment} from './comments'; +import {hasIgnoreForDiagnosticsMarker, readSpanComment} from './comments'; import {checkIfClassIsExported, checkIfGenericTypesAreUnbound} from './ts_util'; /** @@ -89,7 +89,7 @@ export function findTypeCheckBlock(file: ts.SourceFile, id: TemplateId): ts.Node export function findSourceLocation(node: ts.Node, sourceFile: ts.SourceFile): SourceLocation|null { // Search for comments until the TCB's function declaration is encountered. while (node !== undefined && !ts.isFunctionDeclaration(node)) { - if (hasIgnoreMarker(node, sourceFile)) { + if (hasIgnoreForDiagnosticsMarker(node, sourceFile)) { // There's an ignore marker on this node, so the diagnostic should not be reported. return null; } @@ -114,7 +114,7 @@ export function findSourceLocation(node: ts.Node, sourceFile: ts.SourceFile): So function getTemplateId(node: ts.Node, sourceFile: ts.SourceFile): TemplateId|null { // Walk up to the function declaration of the TCB, the file information is attached there. while (!ts.isFunctionDeclaration(node)) { - if (hasIgnoreMarker(node, sourceFile)) { + if (hasIgnoreForDiagnosticsMarker(node, sourceFile)) { // There's an ignore marker on this node, so the diagnostic should not be reported. return null; }