Fix many no-object-literal-type-assertion lint errors (#17278) · WebReflection/TypeScript@08fbcd8 · GitHub
Skip to content

Commit 08fbcd8

Browse files
author
Andy
authored
Fix many no-object-literal-type-assertion lint errors (microsoft#17278)
* Fix many no-object-literal-type-assertion lint errors * Simple fixes * Use a union for FlowNode * PR feedback and remove remaining `id()` uses * Use a union for CodeBlock * Discriminate CodeBlock by CodeBlockKind
1 parent fe3a05e commit 08fbcd8

17 files changed

Lines changed: 140 additions & 148 deletions

src/compiler/binder.ts

Lines changed: 5 additions & 22 deletions

src/compiler/checker.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,7 +2172,7 @@ namespace ts {
21722172
if (accessibleSymbolChain) {
21732173
const hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
21742174
if (!hasAccessibleDeclarations) {
2175-
return <SymbolAccessibilityResult>{
2175+
return {
21762176
accessibility: SymbolAccessibility.NotAccessible,
21772177
errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
21782178
errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, SymbolFlags.Namespace) : undefined,
@@ -2294,7 +2294,7 @@ namespace ts {
22942294
const symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined);
22952295

22962296
// Verify if the symbol is accessible
2297-
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || <SymbolVisibilityResult>{
2297+
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
22982298
accessibility: SymbolAccessibility.NotAccessible,
22992299
errorSymbolName: getTextOfNode(firstIdentifier),
23002300
errorNode: firstIdentifier
@@ -6300,7 +6300,7 @@ namespace ts {
63006300
return {
63016301
kind: TypePredicateKind.This,
63026302
type: getTypeFromTypeNode(node.type)
6303-
} as ThisTypePredicate;
6303+
};
63046304
}
63056305
}
63066306

@@ -8109,13 +8109,13 @@ namespace ts {
81098109
parameterName: predicate.parameterName,
81108110
parameterIndex: predicate.parameterIndex,
81118111
type: instantiateType(predicate.type, mapper)
8112-
} as IdentifierTypePredicate;
8112+
};
81138113
}
81148114
else {
81158115
return {
81168116
kind: TypePredicateKind.This,
81178117
type: instantiateType(predicate.type, mapper)
8118-
} as ThisTypePredicate;
8118+
};
81198119
}
81208120
}
81218121

src/compiler/emitter.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,9 @@ namespace ts {
11951195
if (!(getEmitFlags(node) & EmitFlags.NoIndentation)) {
11961196
const dotRangeStart = node.expression.end;
11971197
const dotRangeEnd = skipTrivia(currentSourceFile.text, node.expression.end) + 1;
1198-
const dotToken = <Node>{ kind: SyntaxKind.DotToken, pos: dotRangeStart, end: dotRangeEnd };
1198+
const dotToken = createToken(SyntaxKind.DotToken);
1199+
dotToken.pos = dotRangeStart;
1200+
dotToken.end = dotRangeEnd;
11991201
indentBeforeDot = needsIndentation(node, node.expression, dotToken);
12001202
indentAfterDot = needsIndentation(node, dotToken, node.name);
12011203
}

src/compiler/factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,7 +2586,7 @@ namespace ts {
25862586
}
25872587

25882588
export function addSyntheticLeadingComment<T extends Node>(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean) {
2589-
return setSyntheticLeadingComments(node, append(getSyntheticLeadingComments(node), <SynthesizedComment>{ kind, pos: -1, end: -1, hasTrailingNewLine, text }));
2589+
return setSyntheticLeadingComments(node, append<SynthesizedComment>(getSyntheticLeadingComments(node), { kind, pos: -1, end: -1, hasTrailingNewLine, text }));
25902590
}
25912591

25922592
export function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined {
@@ -2600,7 +2600,7 @@ namespace ts {
26002600
}
26012601

26022602
export function addSyntheticTrailingComment<T extends Node>(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean) {
2603-
return setSyntheticTrailingComments(node, append(getSyntheticTrailingComments(node), <SynthesizedComment>{ kind, pos: -1, end: -1, hasTrailingNewLine, text }));
2603+
return setSyntheticTrailingComments(node, append<SynthesizedComment>(getSyntheticTrailingComments(node), { kind, pos: -1, end: -1, hasTrailingNewLine, text }));
26042604
}
26052605

26062606
/**

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6169,7 +6169,7 @@ namespace ts {
61696169

61706170
export function parseIsolatedJSDocComment(content: string, start: number, length: number): { jsDoc: JSDoc, diagnostics: Diagnostic[] } | undefined {
61716171
initializeState(content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS);
6172-
sourceFile = <SourceFile>{ languageVariant: LanguageVariant.Standard, text: content };
6172+
sourceFile = <SourceFile>{ languageVariant: LanguageVariant.Standard, text: content }; // tslint:disable-line no-object-literal-type-assertion
61736173
const jsDoc = parseJSDocCommentWorker(start, length);
61746174
const diagnostics = parseDiagnostics;
61756175
clearState();

src/compiler/transformers/generators.ts

Lines changed: 46 additions & 48 deletions

0 commit comments

Comments
 (0)