Skip to content
Merged
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
12 changes: 6 additions & 6 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3200,7 +3200,7 @@ namespace ts {
}
}

let entityName: EntityName = undefined;
let entityName: EntityName;
const nameIdentifier = symbolToTypeReferenceName(type.symbol);
if (qualifiedName) {
Debug.assert(!qualifiedName.right);
Expand Down Expand Up @@ -5689,7 +5689,7 @@ namespace ts {
}
return [signature];
}
let result: Signature[] = undefined;
let result: Signature[];
for (let i = 0; i < signatureLists.length; i++) {
// Allow matching non-generic signatures to have excess parameters and different return types
const match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, /*partialMatch*/ true, /*ignoreThisTypes*/ true, /*ignoreReturnTypes*/ true);
Expand All @@ -5707,7 +5707,7 @@ namespace ts {
// type is the union of the constituent return types.
function getUnionSignatures(types: Type[], kind: SignatureKind): Signature[] {
const signatureLists = map(types, t => getSignaturesOfType(t, kind));
let result: Signature[] = undefined;
let result: Signature[];
for (let i = 0; i < signatureLists.length; i++) {
for (const signature of signatureLists[i]) {
// Only process signatures with parameter lists that aren't already in the result list
Expand Down Expand Up @@ -5843,7 +5843,7 @@ namespace ts {
else {
// Combinations of function, class, enum and module
let members = emptySymbols;
let stringIndexInfo: IndexInfo = undefined;
let stringIndexInfo: IndexInfo;
if (symbol.exports) {
members = getExportsOfSymbol(symbol);
}
Expand Down Expand Up @@ -6395,7 +6395,7 @@ namespace ts {
}
const propTypes: Type[] = [];
const declarations: Declaration[] = [];
let commonType: Type = undefined;
let commonType: Type;
for (const prop of props) {
if (prop.declarations) {
addRange(declarations, prop.declarations);
Expand Down Expand Up @@ -6676,7 +6676,7 @@ namespace ts {
const parameters: Symbol[] = [];
let hasLiteralTypes = false;
let minArgumentCount = 0;
let thisParameter: Symbol = undefined;
let thisParameter: Symbol;
let hasThisParameter: boolean;
const iife = getImmediatelyInvokedFunctionExpression(declaration);
const isJSConstructSignature = isJSDocConstructSignature(declaration);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ namespace ts {
return text.replace(/{(\d+)}/g, (_match, index?) => args[+index + baseIndex]);
}

export let localizedDiagnosticMessages: MapLike<string> = undefined;
export let localizedDiagnosticMessages: MapLike<string>;

export function getLocaleSpecificMessage(message: DiagnosticMessage) {
return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message;
Expand Down Expand Up @@ -3049,7 +3049,7 @@ namespace ts {

/** Return the object corresponding to the best pattern to match `candidate`. */
export function findBestPatternMatch<T>(values: ReadonlyArray<T>, getPattern: (value: T) => Pattern, candidate: string): T | undefined {
let matchedValue: T | undefined = undefined;
let matchedValue: T | undefined;
// use length of prefix as betterness criteria
let longestMatchPrefixLength = -1;

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ namespace ts {
}

// string is for exact match
let matchedPattern: Pattern | string | undefined = undefined;
let matchedPattern: Pattern | string | undefined;
if (state.compilerOptions.paths) {
if (state.traceEnabled) {
trace(state.host, Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4770,7 +4770,7 @@ namespace ts {
const awaitToken = parseOptionalToken(SyntaxKind.AwaitKeyword);
parseExpected(SyntaxKind.OpenParenToken);

let initializer: VariableDeclarationList | Expression = undefined;
let initializer: VariableDeclarationList | Expression;
if (token() !== SyntaxKind.SemicolonToken) {
if (token() === SyntaxKind.VarKeyword || token() === SyntaxKind.LetKeyword || token() === SyntaxKind.ConstKeyword) {
initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true);
Expand Down Expand Up @@ -6232,7 +6232,7 @@ namespace ts {
// Initially we can parse out a tag. We also have seen a starting asterisk.
// This is so that /** * @type */ doesn't parse.
let state = JSDocState.SawAsterisk;
let margin: number | undefined = undefined;
let margin: number | undefined;
// + 4 for leading '/** '
let indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4;
function pushComment(text: string) {
Expand Down Expand Up @@ -7256,7 +7256,7 @@ namespace ts {
}

function getLastChildWorker(node: Node): Node | undefined {
let last: Node = undefined;
let last: Node;
forEachChild(node, child => {
if (nodeIsPresent(child)) {
last = child;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/transformers/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace ts {
const uniqueExports = createMap<boolean>();
let exportedNames: Identifier[];
let hasExportDefault = false;
let exportEquals: ExportAssignment = undefined;
let exportEquals: ExportAssignment;
let hasExportStarsToExportValues = false;
let hasImportStarOrImportDefault = false;

Expand Down
6 changes: 3 additions & 3 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3329,7 +3329,7 @@ ${code}
const ranges: Range[] = [];

// Stuff related to the subfile we're parsing
let currentFileContent: string = undefined;
let currentFileContent: string;
let currentFileName = fileName;
let currentFileSymlinks: string[] | undefined;
let currentFileOptions: { [s: string]: string } = {};
Expand Down Expand Up @@ -3464,7 +3464,7 @@ ${code}
}

function recordObjectMarker(fileName: string, location: LocationInformation, text: string, markerMap: ts.Map<Marker>, markers: Marker[]): Marker {
let markerValue: any = undefined;
let markerValue: any;
try {
// Attempt to parse the marker value as JSON
markerValue = JSON.parse("{ " + text + " }");
Expand Down Expand Up @@ -3523,7 +3523,7 @@ ${code}
let output = "";

/// The current marker (or maybe multi-line comment?) we're parsing, possibly
let openMarker: LocationInformation = undefined;
let openMarker: LocationInformation;

/// A stack of the open range markers that are still unclosed
const openRanges: RangeLocationInformation[] = [];
Expand Down
6 changes: 3 additions & 3 deletions src/harness/harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ namespace Utils {
path = "tests/" + path;
}

let content: string = undefined;
let content: string;
try {
content = Harness.IO.readFile(Harness.userSpecifiedRoot + path);
}
Expand Down Expand Up @@ -1891,9 +1891,9 @@ namespace Harness {
const lines = Utils.splitContentByNewlines(code);

// Stuff related to the subfile we're parsing
let currentFileContent: string = undefined;
let currentFileContent: string;
let currentFileOptions: any = {};
let currentFileName: any = undefined;
let currentFileName: any;
let refs: string[] = [];

for (const line of lines) {
Expand Down
6 changes: 3 additions & 3 deletions src/harness/loggedIO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ interface PlaybackControl {
}

namespace Playback {
let recordLog: IoLog = undefined;
let replayLog: IoLog = undefined;
let replayFilesRead: ts.Map<IoLogFile> | undefined = undefined;
let recordLog: IoLog;
let replayLog: IoLog;
let replayFilesRead: ts.Map<IoLogFile> | undefined;
let recordLogFileNameBase = "";

interface Memoized<T> {
Expand Down
8 changes: 4 additions & 4 deletions src/harness/parallel/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ namespace Harness.Parallel.Worker {
const fakeContext: Mocha.ISuiteCallbackContext = {
retries() { return this; },
slow() { return this; },
timeout(n) {
timeout = n as number;
timeout(n: number) {
timeout = n;
return this;
},
};
Expand Down Expand Up @@ -126,8 +126,8 @@ namespace Harness.Parallel.Worker {
let timeout: number;
const fakeContext: Mocha.ITestCallbackContext = {
skip() { return this; },
timeout(n) {
timeout = n as number;
timeout(n: number) {
timeout = n;
const timeoutMsg: ParallelTimeoutChangeMessage = { type: "timeout", payload: { duration: timeout } };
process.send(timeoutMsg);
return this;
Expand Down
6 changes: 3 additions & 3 deletions src/harness/projectsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class ProjectRunner extends RunnerBase {
}

function getSourceFile(fileName: string, languageVersion: ts.ScriptTarget): ts.SourceFile {
let sourceFile: ts.SourceFile = undefined;
let sourceFile: ts.SourceFile;
if (fileName === Harness.Compiler.defaultLibFileName) {
sourceFile = Harness.Compiler.getDefaultLibrarySourceFile(Harness.Compiler.getDefaultLibFileName(compilerOptions));
}
Expand Down Expand Up @@ -294,7 +294,7 @@ class ProjectRunner extends RunnerBase {
}

function getSourceFileText(fileName: string): string {
let text: string = undefined;
let text: string;
try {
text = Harness.IO.readFile(getFileNameInTheProjectTest(fileName));
}
Expand Down Expand Up @@ -370,7 +370,7 @@ class ProjectRunner extends RunnerBase {
allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text });
}
else if (!(compilerOptions.outFile || compilerOptions.out)) {
let emitOutputFilePathWithoutExtension: string = undefined;
let emitOutputFilePathWithoutExtension: string;
if (compilerOptions.outDir) {
let sourceFilePath = ts.getNormalizedAbsolutePath(sourceFile.fileName, compilerResult.program.getCurrentDirectory());
sourceFilePath = sourceFilePath.replace(compilerResult.program.getCommonSourceDirectory(), "");
Expand Down
2 changes: 1 addition & 1 deletion src/server/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ namespace ts.server {
const edits: FileTextChanges[] = this.convertCodeEditsToTextChanges(response.body.edits);

const renameFilename: string | undefined = response.body.renameFilename;
let renameLocation: number | undefined = undefined;
let renameLocation: number | undefined;
if (renameFilename !== undefined) {
renameLocation = this.lineOffsetToPosition(renameFilename, response.body.renameLocation);
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1560,7 +1560,7 @@ namespace ts.server {
}

private extractPositionAndRange(args: protocol.FileLocationOrRangeRequestArgs, scriptInfo: ScriptInfo): { position: number, textRange: TextRange } {
let position: number = undefined;
let position: number;
let textRange: TextRange;
if (this.isLocation(args)) {
position = getPosition(args);
Expand Down Expand Up @@ -1676,7 +1676,7 @@ namespace ts.server {
}

private getStartAndEndPosition(args: protocol.FileRangeRequestArgs, scriptInfo: ScriptInfo) {
let startPosition: number = undefined, endPosition: number = undefined;
let startPosition: number, endPosition: number;
if (args.startPosition !== undefined) {
startPosition = args.startPosition;
}
Expand Down
4 changes: 2 additions & 2 deletions src/services/findAllReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ namespace ts.FindAllReferences.Core {
// here appears to be intentional).
const {
text = stripQuotes(unescapeLeadingUnderscores((getLocalSymbolForExportDefault(symbol) || symbol).escapedName)),
allSearchSymbols = undefined,
allSearchSymbols,
} = searchOptions;
const escapedText = escapeLeadingUnderscores(text);
const parents = this.options.implementations && getParentSymbolsOfPropertyAccess(location, symbol, this.checker);
Expand Down Expand Up @@ -1146,7 +1146,7 @@ namespace ts.FindAllReferences.Core {
}

function getContainingTypeReference(node: Node): Node {
let topLevelTypeReference: Node = undefined;
let topLevelTypeReference: Node;

while (node) {
if (isTypeNode(node)) {
Expand Down
6 changes: 3 additions & 3 deletions src/services/patternMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ namespace ts {
// Only if all words have some sort of match is the pattern considered matched.

const subWordTextChunks = segment.subWordTextChunks;
let matches: PatternMatch[] = undefined;
let matches: PatternMatch[];

for (const subWordTextChunk of subWordTextChunks) {
// Try to match the candidate with this word
Expand Down Expand Up @@ -393,8 +393,8 @@ namespace ts {

let currentCandidate = 0;
let currentChunkSpan = 0;
let firstMatch: number = undefined;
let contiguous: boolean = undefined;
let firstMatch: number;
let contiguous: boolean;

while (true) {
// Let's consider our termination cases
Expand Down
22 changes: 11 additions & 11 deletions src/services/refactors/extractSymbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ namespace ts.refactor.extractSymbol {
}
else if (isVariableStatement(node)) {
let numInitializers = 0;
let lastInitializer: Expression | undefined = undefined;
let lastInitializer: Expression | undefined;
for (const declaration of node.declarationList.declarations) {
if (declaration.initializer) {
numInitializers++;
Expand Down Expand Up @@ -730,12 +730,12 @@ namespace ts.refactor.extractSymbol {

const functionName = createIdentifier(functionNameText);

let returnType: TypeNode = undefined;
let returnType: TypeNode;
const parameters: ParameterDeclaration[] = [];
const callArguments: Identifier[] = [];
let writes: UsageEntry[];
usagesInScope.forEach((usage, name) => {
let typeNode: TypeNode = undefined;
let typeNode: TypeNode;
if (!isJS) {
let type = checker.getTypeOfSymbolAtLocation(usage.symbol, usage.node);
// Widen the type so we don't emit nonsense annotations like "function fn(x: 3) {"
Expand Down Expand Up @@ -1114,7 +1114,7 @@ namespace ts.refactor.extractSymbol {
}

function getContainingVariableDeclarationIfInList(node: Node, scope: Scope) {
let prevNode = undefined;
let prevNode;
while (node !== undefined && node !== scope) {
if (isVariableDeclaration(node) &&
node.initializer === prevNode &&
Expand Down Expand Up @@ -1161,7 +1161,7 @@ namespace ts.refactor.extractSymbol {
}

function getFirstDeclaration(type: Type): Declaration | undefined {
let firstDeclaration = undefined;
let firstDeclaration;

const symbol = type.symbol;
if (symbol && symbol.declarations) {
Expand Down Expand Up @@ -1297,7 +1297,7 @@ namespace ts.refactor.extractSymbol {
const members = scope.members;
Debug.assert(members.length > 0); // There must be at least one child, since we extracted from one.

let prevMember: ClassElement | undefined = undefined;
let prevMember: ClassElement | undefined;
let allProperties = true;
for (const member of members) {
if (member.pos > maxPos) {
Expand All @@ -1322,7 +1322,7 @@ namespace ts.refactor.extractSymbol {
function getNodeToInsertConstantBefore(node: Node, scope: Scope): Statement {
Debug.assert(!isClassLike(scope));

let prevScope: Scope | undefined = undefined;
let prevScope: Scope | undefined;
for (let curr = node; curr !== scope; curr = curr.parent) {
if (isScope(curr)) {
prevScope = curr;
Expand All @@ -1331,7 +1331,7 @@ namespace ts.refactor.extractSymbol {

for (let curr = (prevScope || node).parent; ; curr = curr.parent) {
if (isBlockLike(curr)) {
let prevStatement = undefined;
let prevStatement;
for (const statement of curr.statements) {
if (statement.pos > node.pos) {
break;
Expand Down Expand Up @@ -1432,15 +1432,15 @@ namespace ts.refactor.extractSymbol {
const visibleDeclarationsInExtractedRange: NamedDeclaration[] = [];
const exposedVariableSymbolSet = createMap<true>(); // Key is symbol ID
const exposedVariableDeclarations: VariableDeclaration[] = [];
let firstExposedNonVariableDeclaration: NamedDeclaration | undefined = undefined;
let firstExposedNonVariableDeclaration: NamedDeclaration | undefined;

const expression = !isReadonlyArray(targetRange.range)
? targetRange.range
: targetRange.range.length === 1 && isExpressionStatement(targetRange.range[0])
? (targetRange.range[0] as ExpressionStatement).expression
: undefined;

let expressionDiagnostic: Diagnostic | undefined = undefined;
let expressionDiagnostic: Diagnostic | undefined;
if (expression === undefined) {
const statements = targetRange.range as ReadonlyArray<Statement>;
const start = first(statements).getStart();
Expand Down Expand Up @@ -1542,7 +1542,7 @@ namespace ts.refactor.extractSymbol {
}

let hasWrite = false;
let readonlyClassPropertyWrite: Declaration | undefined = undefined;
let readonlyClassPropertyWrite: Declaration | undefined;
usagesPerScope[i].usages.forEach(value => {
if (value.usage === Usage.Write) {
hasWrite = true;
Expand Down
2 changes: 1 addition & 1 deletion src/services/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1971,7 +1971,7 @@ namespace ts {
continue;
}

let descriptor: TodoCommentDescriptor = undefined;
let descriptor: TodoCommentDescriptor;
for (let i = 0; i < descriptors.length; i++) {
if (matchArray[i + firstDescriptorCaptureIndex]) {
descriptor = descriptors[i];
Expand Down
Loading