Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2618,7 +2618,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void {
if (inStrictMode && isLeftHandSideExpression(node.left) && isAssignmentOperator(node.operatorToken.kind)) {
// ECMA 262 (Annex C) The identifier eval or arguments may not appear as the LeftHandSideExpression of an
// Assignment operator(11.13) or of a PostfixExpression(11.3)
checkStrictModeEvalOrArguments(node, node.left as Identifier);
checkStrictModeEvalOrArguments(node, node.left);
}
}

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

function checkStrictModePrefixUnaryExpression(node: PrefixUnaryExpression) {
// Grammar checking
if (inStrictMode) {
if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) {
checkStrictModeEvalOrArguments(node, node.operand as Identifier);
checkStrictModeEvalOrArguments(node, node.operand);
}
}
}
Expand Down
98 changes: 49 additions & 49 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ import {
DeleteExpression,
directorySeparator,
DoStatement,
DotToken,
ElementAccessExpression,
emitDetachedComments,
EmitFileNames,
Expand Down Expand Up @@ -2620,7 +2619,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri

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

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

if (every(modifiers, isDecorator)) {
if (allowDecorators) {
// if all modifier-likes are `Decorator`, simply emit the array as decorators.
return emitDecoratorList(node, modifiers as NodeArray<Decorator>);
return emitDecoratorList(node, modifiers);
}
return node.pos;
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10109,7 +10109,7 @@ namespace IncrementalParser {
Debug.assert(text === newText.substring(node.pos, node.end));
}

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

// Adjust the pos or end (or both) of the intersecting element accordingly.
adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
forEachChild(child, visitNode as (node: Node) => void, visitArray as (nodes: NodeArray<Node>) => void);
forEachChild(child, visitNode, visitArray);
if (hasJSDocNodes(child)) {
for (const jsDocComment of child.jsDoc!) {
visitNode(jsDocComment);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/symbolWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function createGetSymbolWalker(
}
}
if (type.flags & TypeFlags.TypeParameter) {
visitTypeParameter(type as TypeParameter);
visitTypeParameter(type);
}
if (type.flags & TypeFlags.UnionOrIntersection) {
visitUnionOrIntersectionType(type as UnionOrIntersectionType);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/es2018.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
// Disable substitution in the generated super accessor itself.
else if (enabledSubstitutions && substitutedSuperAccessors[getNodeId(node)]) {
const savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
enclosingSuperContainerFlags = 0 as NodeCheckFlags;
enclosingSuperContainerFlags = 0;
previousOnEmitNode(hint, node, emitCallback);
enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
return;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ export function transformTypeScript(context: TransformationContext): Transformer
function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration: ModuleDeclaration): ModuleDeclaration | undefined {
if (moduleDeclaration.body!.kind === SyntaxKind.ModuleDeclaration) {
const recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body as ModuleDeclaration);
return recursiveInnerModule || moduleDeclaration.body as ModuleDeclaration;
return recursiveInnerModule || moduleDeclaration.body;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/tsbuildPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ function createSolutionBuilderState<T extends BuilderProgram>(watch: boolean, ho

// State of the solution
const baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions) as CompilerHost & ReadBuildProgramHost;
const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions);
setGetSourceFileAsHashVersioned(compilerHost);
compilerHost.getParsedCommandLine = fileName => parseConfigFile(state, fileName as ResolvedConfigFileName, toResolvedConfigFilePath(state, fileName as ResolvedConfigFileName));
compilerHost.resolveModuleNameLiterals = maybeBind(host, host.resolveModuleNameLiterals);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12269,7 +12269,7 @@ export function getSynthesizedDeepCloneWithReplacements<T extends Node>(
setOriginalNode(clone, node);
}
else {
clone = getSynthesizedDeepCloneWorker(node as NonNullable<T>, replaceNode);
clone = getSynthesizedDeepCloneWorker(node, replaceNode);
}

if (clone && !includeTrivia) suppressLeadingAndTrailingTrivia(clone);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/utilitiesPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ function getDeclarationIdentifier(node: Declaration | Expression): Identifier |

/** @internal */
export function nodeHasName(statement: Node, name: Identifier): boolean {
if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name as Identifier) === idText(name)) {
if (isNamedDeclaration(statement) && isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
return true;
}
if (isVariableStatement(statement) && some(statement.declarationList.declarations, d => nodeHasName(d, name))) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2063,7 +2063,7 @@ export class ProjectService {
if (this.openFiles.has(fileOrDirectoryPath)) {
const info = Debug.checkDefined(this.getScriptInfoForPath(fileOrDirectoryPath));
if (info.isAttached(project)) {
const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || ProgramUpdateLevel.Update) as ProgramUpdateLevel;
const loadLevelToSet = Math.max(updateLevel, project.openFileWatchTriggered.get(fileOrDirectoryPath) || ProgramUpdateLevel.Update);
project.openFileWatchTriggered.set(fileOrDirectoryPath, loadLevelToSet);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/server/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,7 @@ export abstract class Project implements LanguageServiceHost, ModuleResolutionHo
this.moduleSpecifierCache.clear();
}

const oldExternalFiles = this.externalFiles || emptyArray as SortedReadonlyArray<string>;
const oldExternalFiles = this.externalFiles || emptyArray;
this.externalFiles = this.getExternalFiles();
enumerateInsertsAndDeletes<string, string>(
this.externalFiles,
Expand Down
2 changes: 1 addition & 1 deletion src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ function getPerProjectReferences<TResult>(
symlinkedProjectsMap.forEach((symlinkedProjects, symlinkedPath) => {
for (const symlinkedProject of symlinkedProjects) {
if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
queue.enqueue({ project: symlinkedProject, location: { fileName: symlinkedPath as string, pos: originalLocation.pos } });
queue.enqueue({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/server/utilitiesPublic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export enum Msg {
export function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings {
return {
projectName: project.getProjectName(),
fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles() as NormalizedPath[]),
fileNames: project.getFileNames(/*excludeFilesFromExternalLibraries*/ true, /*excludeConfigFiles*/ true).concat(project.getExcludedFiles()),
compilerOptions: project.getCompilationSettings(),
typeAcquisition,
unresolvedImports,
Expand Down
2 changes: 1 addition & 1 deletion src/services/classifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ function convertClassificationsToResult(classifications: Classifications, text:
for (let i = 0; i < dense.length; i += 3) {
const start = dense[i];
const length = dense[i + 1];
const type = dense[i + 2] as ClassificationType;
const type = dense[i + 2];

// Make a whitespace entry between the last item and this one.
if (lastEnd >= 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
isImportClause,
isImportEqualsDeclaration,
isImportSpecifier,
Node,
or,
Program,
refactor,
Expand Down Expand Up @@ -57,7 +56,7 @@ function getImportDeclaration(sourceFile: SourceFile, program: Program, start: n

const checker = program.getTypeChecker();
const symbol = checker.getSymbolAtLocation(identifier);
return find(symbol?.declarations || emptyArray, or(isImportClause, isImportSpecifier, isImportEqualsDeclaration) as (n: Node) => n is ImportClause | ImportSpecifier | ImportEqualsDeclaration);
return find(symbol?.declarations || emptyArray, or(isImportClause, isImportSpecifier, isImportEqualsDeclaration));
}

// Converts the import declaration of the offending import to a type-only import,
Expand Down
2 changes: 1 addition & 1 deletion src/services/codefixes/generateAccessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export function getAccessorConvertiblePropertyAtPosition(file: SourceFile, progr
isReadonly: hasEffectiveReadonlyModifier(declaration),
type: getDeclarationType(declaration, program),
container: declaration.kind === SyntaxKind.Parameter ? declaration.parent.parent : declaration.parent,
originalName: (declaration.name as AcceptedNameType).text,
originalName: declaration.name.text,
declaration,
fieldName,
accessorName,
Expand Down
2 changes: 1 addition & 1 deletion src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5714,7 +5714,7 @@ function tryGetObjectTypeDeclarationCompletionContainer(sourceFile: SourceFile,
// class C { blah \n constructor/**/ }
|| (isIdentifier(contextToken) && isPropertyDeclaration(contextToken.parent) && isClassLike(location))
) {
return findAncestor(contextToken, isClassLike) as ObjectTypeDeclaration;
return findAncestor(contextToken, isClassLike);
}

switch (contextToken.kind) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/findAllReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ export function getContextNode(node: NamedDeclaration | BinaryExpression | ForIn
case SyntaxKind.ShorthandPropertyAssignment:
return isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent) ?
getContextNode(
findAncestor(node.parent, node => isBinaryExpression(node) || isForInOrOfStatement(node)) as BinaryExpression | ForInOrOfStatement,
findAncestor(node.parent, node => isBinaryExpression(node) || isForInOrOfStatement(node)),
) :
node;
case SyntaxKind.SwitchStatement:
Expand Down
3 changes: 1 addition & 2 deletions src/services/getEditsForFileRename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
LanguageServiceHost,
last,
mapDefined,
ModuleResolutionHost,
moduleSpecifiers,
normalizePath,
pathIsRelative,
Expand Down Expand Up @@ -207,7 +206,7 @@ function updateImports(
const toImport = oldFromNew !== undefined
// If we're at the new location (file was already renamed), need to redo module resolution starting from the old location.
// TODO:GH#18217
? getSourceFileToImportFromResolved(importLiteral, resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host as ModuleResolutionHost), oldToNew, allFiles)
? getSourceFileToImportFromResolved(importLiteral, resolveModuleName(importLiteral.text, oldImportFromPath, program.getCompilerOptions(), host), oldToNew, allFiles)
: getSourceFileToImport(importedModuleSymbol, importLiteral, sourceFile, program, host, oldToNew);

// Need an update if the imported file moved, or the importing file moved and was using a relative path.
Expand Down
2 changes: 1 addition & 1 deletion src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2631,7 +2631,7 @@ export function createLanguageService(
[SyntaxKind.OpenBracketToken]: SyntaxKind.CloseBracketToken,
[SyntaxKind.GreaterThanToken]: SyntaxKind.LessThanToken,
}));
braceMatching.forEach((value, key) => braceMatching.set(value.toString(), Number(key) as SyntaxKind));
braceMatching.forEach((value, key) => braceMatching.set(value.toString(), Number(key)));

function getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] {
const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName);
Expand Down
4 changes: 2 additions & 2 deletions src/services/stringCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ function getCompletionEntriesForDirectoryFragment(
// check for a version redirect
const packageJsonPath = findPackageJson(baseDirectory, host);
if (packageJsonPath) {
const packageJson = readJson(packageJsonPath, host as { readFile: (filename: string) => string | undefined; });
const packageJson = readJson(packageJsonPath, host);
const typesVersions = (packageJson as any).typesVersions;
if (typeof typesVersions === "object") {
const versionPaths = getPackageJsonTypesVersionsPaths(typesVersions)?.paths;
Expand Down Expand Up @@ -1385,7 +1385,7 @@ function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPa

const result: string[] = [];
for (const packageJson of findPackageJsons(scriptPath, host)) {
const contents = readJson(packageJson, host as { readFile: (filename: string) => string | undefined; }); // Cast to assert that readFile is defined
const contents = readJson(packageJson, host); // Cast to assert that readFile is defined
// Provide completions for all non @types dependencies
for (const key of nodeModulesDependencyKeys) {
const dependencies: object | undefined = (contents as any)[key];
Expand Down
3 changes: 1 addition & 2 deletions src/services/symbolDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ import {
Type,
TypeChecker,
TypeFormatFlags,
TypeParameter,
typeToDisplayParts,
VariableDeclaration,
WriterContextOut,
Expand Down Expand Up @@ -699,7 +698,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
if (type.symbol && type.symbol.flags & SymbolFlags.TypeParameter && symbolKind !== ScriptElementKind.indexSignatureElement) {
const typeParameterParts = mapToDisplayParts(writer => {
const param = typeChecker.typeParameterToDeclaration(
type as TypeParameter,
type,
enclosingDeclaration,
symbolDisplayNodeBuilderFlags,
/*internalFlags*/ undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/projectsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class ProjectTestCase {
}

const content = Utils.removeTestPathPrefixes(output.text, /*retainTrailingDirectorySeparator*/ true);
Harness.Baseline.runBaseline(this.getBaselineFolder(this.compilerResult.moduleKind) + diskRelativeName, content as string | null); // eslint-disable-line no-restricted-syntax
Harness.Baseline.runBaseline(this.getBaselineFolder(this.compilerResult.moduleKind) + diskRelativeName, content);
}
catch (e) {
errs.push(e);
Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsserver/inlayHints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("unittests:: tsserver:: inlayHints::", () => {
arguments: {
preferences: {
includeInlayParameterNameHints: "all",
} as ts.UserPreferences,
},
},
});
verifyInlayHintResponse(session);
Expand Down
6 changes: 3 additions & 3 deletions src/testRunner/unittests/tsserver/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -927,20 +927,20 @@ describe("unittests:: tsserver:: projects::", () => {
arguments: {
file: f1.path,
},
} as ts.server.protocol.OpenRequest);
});
session.executeCommandSeq({
command: ts.server.protocol.CommandTypes.Close,
arguments: {
file: f1.path,
},
} as ts.server.protocol.CloseRequest);
});
session.executeCommandSeq({
command: ts.server.protocol.CommandTypes.Geterr,
arguments: {
delay: 0,
files: [f1.path],
},
} as ts.server.protocol.GeterrRequest);
});
baselineTsserverLogs("projects", "getting errors from closed script info does not throw exception because of getting project from orphan script info", session);
});

Expand Down
2 changes: 1 addition & 1 deletion src/testRunner/unittests/tsserver/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe("unittests:: tsserver:: Session:: General functionality", () => {
newLine: ts.NewLineKind.LineFeed,
moduleResolution: ts.ModuleResolutionKind.Node10,
allowNonTsExtensions: true, // injected by tsserver
} as ts.CompilerOptions,
},
);
});

Expand Down