Skip to content

Commit 92c09c0

Browse files
committed
Remove unnecessary type assertions
1 parent c574e40 commit 92c09c0

25 files changed

+79
-79
lines changed

src/compiler/binder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2618,7 +2618,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
26182618
if (inStrictMode && isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operatorToken.kind)) {
26192619
// ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an
26202620
// Assignment operator(11.13) or of a PostfixExpression(11.3)
2621-
checkStrictModeEvalOrArguments(node, node.left as Identifier);
2621+
checkStrictModeEvalOrArguments(node, node.left);
26222622
}
26232623
}
26242624

@@ -2713,15 +2713,15 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
27132713
// Assignment operator(11.13) or of a PostfixExpression(11.3) or as the UnaryExpression
27142714
// operated upon by a Prefix Increment(11.4.4) or a Prefix Decrement(11.4.5) operator.
27152715
if (inStrictMode) {
2716-
checkStrictModeEvalOrArguments(node, node.operand as Identifier);
2716+
checkStrictModeEvalOrArguments(node, node.operand);
27172717
}
27182718
}
27192719

27202720
function checkStrictModePrefixUnaryExpression(node: PrefixUnaryExpression) {
27212721
// Grammar checking
27222722
if (inStrictMode) {
27232723
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
2724-
checkStrictModeEvalOrArguments(node, node.operand as Identifier);
2724+
checkStrictModeEvalOrArguments(node, node.operand);
27252725
}
27262726
}
27272727
}

src/compiler/checker.ts

Lines changed: 49 additions & 49 deletions
Large diffs are not rendered by default.

src/compiler/emitter.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
26202620

26212621
function emitPropertyAccessExpression(node: PropertyAccessExpression) {
26222622
emitExpression(node.expression, parenthesizer.parenthesizeLeftSideOfAccess);
2623-
const token = node.questionDotToken || setTextRangePosEnd(factory.createToken(SyntaxKind.DotToken) as DotToken, node.expression.end, node.name.pos);
2623+
const token = node.questionDotToken || setTextRangePosEnd(factory.createToken(SyntaxKind.DotToken), node.expression.end, node.name.pos);
26242624
const linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
26252625
const linesAfterDot = getLinesBetweenNodes(node, token, node.name);
26262626

@@ -4433,13 +4433,13 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
44334433
if (modifiers?.length) {
44344434
if (every(modifiers, isModifier)) {
44354435
// if all modifier-likes are `Modifier`, simply emit the array as modifiers.
4436-
return emitModifierList(node, modifiers as NodeArray<Modifier>);
4436+
return emitModifierList(node, modifiers);
44374437
}
44384438

44394439
if (every(modifiers, isDecorator)) {
44404440
if (allowDecorators) {
44414441
// if all modifier-likes are `Decorator`, simply emit the array as decorators.
4442-
return emitDecoratorList(node, modifiers as NodeArray<Decorator>);
4442+
return emitDecoratorList(node, modifiers);
44434443
}
44444444
return node.pos;
44454445
}

src/compiler/parser.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10109,7 +10109,7 @@ namespace IncrementalParser {
1010910109
Debug.assert(text === newText.substring(node.pos, node.end));
1011010110
}
1011110111

10112-
forEachChild(node, visitNode as (node: Node) => void, visitArray as (nodes: NodeArray<Node>) => void);
10112+
forEachChild(node, visitNode, visitArray);
1011310113
if (hasJSDocNodes(node)) {
1011410114
for (const jsDocComment of node.jsDoc!) {
1011510115
visitNode(jsDocComment);
@@ -10262,7 +10262,7 @@ namespace IncrementalParser {
1026210262

1026310263
// Adjust the pos or end (or both) of the intersecting element accordingly.
1026410264
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
10265-
forEachChild(child, visitNode as (node: Node) => void, visitArray as (nodes: NodeArray<Node>) => void);
10265+
forEachChild(child, visitNode, visitArray);
1026610266
if (hasJSDocNodes(child)) {
1026710267
for (const jsDocComment of child.jsDoc!) {
1026810268
visitNode(jsDocComment);

src/compiler/symbolWalker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function createGetSymbolWalker(
101101
}
102102
}
103103
if (type.flags & TypeFlags.TypeParameter) {
104-
visitTypeParameter(type as TypeParameter);
104+
visitTypeParameter(type);
105105
}
106106
if (type.flags & TypeFlags.UnionOrIntersection) {
107107
visitUnionOrIntersectionType(type as UnionOrIntersectionType);

src/compiler/transformers/es2018.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
13731373
// Disable substitution in the generated super accessor itself.
13741374
else if (enabledSubstitutions && substitutedSuperAccessors[getNodeId(node)]) {
13751375
const savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
1376-
enclosingSuperContainerFlags = 0 as NodeCheckFlags;
1376+
enclosingSuperContainerFlags = 0;
13771377
previousOnEmitNode(hint, node, emitCallback);
13781378
enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
13791379
return;

src/compiler/transformers/ts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2243,7 +2243,7 @@ export function transformTypeScript(context: TransformationContext): Transformer
22432243
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration: ModuleDeclaration): ModuleDeclaration | undefined {
22442244
if (moduleDeclaration.body!.kind === SyntaxKind.ModuleDeclaration) {
22452245
const recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body as ModuleDeclaration);
2246-
return recursiveInnerModule || moduleDeclaration.body as ModuleDeclaration;
2246+
return recursiveInnerModule || moduleDeclaration.body;
22472247
}
22482248
}
22492249

src/compiler/tsbuildPublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ function createSolutionBuilderState<T extends BuilderProgram>(watch: boolean, ho
432432

433433
// State of the solution
434434
const baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
435-
const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions) as CompilerHost & ReadBuildProgramHost;
435+
const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions);
436436
setGetSourceFileAsHashVersioned(compilerHost);
437437
compilerHost.getParsedCommandLine = fileName => parseConfigFile(state, fileName as ResolvedConfigFileName, toResolvedConfigFilePath(state, fileName as ResolvedConfigFileName));
438438
compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12269,7 +12269,7 @@ export function getSynthesizedDeepCloneWithReplacements<T extends Node>(
1226912269
setOriginalNode(clone, node);
1227012270
}
1227112271
else {
12272-
clone = getSynthesizedDeepCloneWorker(node as NonNullable<T>, replaceNode);
12272+
clone = getSynthesizedDeepCloneWorker(node, replaceNode);
1227312273
}
1227412274

1227512275
if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);

src/compiler/utilitiesPublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ function getDeclarationIdentifier(node: Declaration | Expression): Identifier |
927927

928928
/** @internal */
929929
export function nodeHasName(statement: Node, name: Identifier): boolean {
930-
if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name as Identifier) === idText(name)) {
930+
if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
931931
return true;
932932
}
933933
if (isVariableStatement(statement) && some(statement.declarationList.declarations, d => nodeHasName(d, name))) {

0 commit comments

Comments
 (0)