From 49ac6e4d44a73996640d00dc19fae45f88e6510c Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 25 May 2016 15:19:47 -0700 Subject: [PATCH 01/90] Initial work to get CodeFixes and make them work in fourslash --- src/harness/fourslash.ts | 14 +++++++- src/harness/harnessLanguageService.ts | 3 ++ src/server/client.ts | 4 +++ src/services/services.ts | 46 +++++++++++++++++++++++++-- src/services/shims.ts | 16 ++++++++++ tests/cases/fourslash/fourslash.ts | 1 + tests/cases/fourslash/superFix1.ts | 11 +++++++ 7 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 tests/cases/fourslash/superFix1.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d6035aaa026d2..8f03f17201c58 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -637,7 +637,6 @@ namespace FourSlash { } } - public verifyCompletionListAllowsNewIdentifier(negative: boolean) { const completions = this.getCompletionListAtCaret(); @@ -1817,6 +1816,15 @@ namespace FourSlash { } } + public verifyCodeFixAtPosition(expectedChange: { span: ts.TextSpan, newText: string }) { + const position = this.currentCaretPosition; + const actual = this.languageService.getCodeFixAtPosition(this.activeFile.fileName, position, position, ["TS2377"]); + + if (actual[0].newText !== expectedChange.newText) { + this.raiseError(`Not the expected text change.`); + } + } + public verifyDocCommentTemplate(expected?: ts.TextInsertion) { const name = "verifyDocCommentTemplate"; const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition); @@ -3029,6 +3037,10 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } + public codeFixAtPosition(expectedChange: { span: ts.TextSpan, newText: string }) { + this.state.verifyCodeFixAtPosition(expectedChange); + } + public getScriptLexicalStructureListCount(count: number) { this.state.verifyGetScriptLexicalStructureListCount(count); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8aaff65febcca..ad7c2a1aa50ac 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -440,6 +440,9 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPostion(fileName, position, openingBrace)); } + getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.TextChange[] { + return unwrapJSONCallResult(this.shim.getCodeFixAtPosition(fileName, start, end, errorCodes)); + } getEmitOutput(fileName: string): ts.EmitOutput { return unwrapJSONCallResult(this.shim.getEmitOutput(fileName)); } diff --git a/src/server/client.ts b/src/server/client.ts index caeab6e3f3cf5..6988781872838 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -572,6 +572,10 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } + getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.TextChange[] { + throw new Error("Not Implemented Yet."); + } + getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] { var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.FileLocationRequestArgs = { diff --git a/src/services/services.ts b/src/services/services.ts index b2f7eb4bdbaaf..2907502d8e4d7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1115,6 +1115,8 @@ namespace ts { isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean; + getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): TextChange[]; + getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; @@ -1753,9 +1755,18 @@ namespace ts { }; } - // Cache host information about scrip Should be refreshed + export function getSupportedCodeFixes() { + return { + // TODO: get this from the actual language service + codeFixes: [ + "TS2377" /* Constructors for derived classes must contain a 'super' call. */ + ] + }; + } + + // Cache host information about script Should be refreshed // at each language service public entry point, since we don't know when - // set of scripts handled by the host changes. + // the set of scripts handled by the host changes. class HostCache { private fileNameToEntry: FileMap; private _compilationSettings: CompilerOptions; @@ -7477,6 +7488,36 @@ namespace ts { return []; } + // TODO (pvanbren): move the codefixes to a separate file + + function getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): TextChange[] { + synchronizeHostData(); + + interface CodeFix { (fileName: string, start: number, end: number): TextChange[] } + + // errorCodes should contain TS2377 + const codeFixMap: Map = { + "TS2377": fixMissingSuper + }; + + return codeFixMap[errorCodes[0]](fileName, start, end); + + function fixMissingSuper(fileName: string, start: number, end: number) { + + const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + const token = getTokenAtPosition(sourceFile, start); + if (token.kind !== SyntaxKind.ConstructorKeyword) { + // wait why are we not a on a constructor? + return []; + } + + const openCurly = (token.parent).body.getChildren(sourceFile)[0]; // assume this is the open curly + const position = openCurly.getEnd(); // want to position directly after open curly, we'll format using the formatting service in the host + + return [{ newText: "super();", span: { start: position, length: 0 } }]; + } + } + /** * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. @@ -7947,6 +7988,7 @@ namespace ts { getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, isValidBraceCompletionAtPostion, + getCodeFixAtPosition, getEmitOutput, getNonBoundSourceFile, getProgram diff --git a/src/services/shims.ts b/src/services/shims.ts index a515f32d1691c..be959bdb4878a 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -228,6 +228,8 @@ namespace ts { */ isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string; + getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): string; + getEmitOutput(fileName: string): string; } @@ -241,6 +243,7 @@ namespace ts { getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getDefaultCompilationSettings(): string; discoverTypings(discoverTypingsJson: string): string; + getSupportedCodeFixes(): string; } function logInternalError(logger: Logger, err: Error) { @@ -851,6 +854,13 @@ namespace ts { ); } + public getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): string { + return this.forwardJSONCall( + `getCodeFixAtPosition( '${fileName}', ${start}, ${end}, '[${errorCodes.join(",")}]')`, + () => this.languageService.getCodeFixAtPosition(fileName, start, end, errorCodes) + ); + } + /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -1040,6 +1050,12 @@ namespace ts { info.compilerOptions); }); } + + public getSupportedCodeFixes(): string { + return this.forwardJSONCall("getSupportedCodeFixes()", + () => getSupportedCodeFixes() + ); + } } export class TypeScriptServicesFactory implements ShimFactory { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 48d69f0a85eb8..16211609671a4 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -174,6 +174,7 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; + codeFixAtPosition(expectedChange: { span: TextSpan, newText: string }); getScriptLexicalStructureListCount(count: number): void; getScriptLexicalStructureListContains(name: string, kind: string, fileName?: string, parentName?: string, isAdditionalSpan?: boolean, markerPosition?: number): void; diff --git a/tests/cases/fourslash/superFix1.ts b/tests/cases/fourslash/superFix1.ts new file mode 100644 index 0000000000000..352f8a8e3bb1a --- /dev/null +++ b/tests/cases/fourslash/superFix1.ts @@ -0,0 +1,11 @@ +/// + +////class Base{ +////} +////class C extends Base{ +//// /*0*/constructor() { +//// } +////} + +goTo.marker('0'); +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "super();" }); From a985041b066adbe5e7a57a6a0cbe0f844e0c783c Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Wed, 25 May 2016 15:19:47 -0700 Subject: [PATCH 02/90] Initial work to get CodeFixes and make them work in fourslash --- src/harness/fourslash.ts | 23 ++++++++++++- src/harness/harnessLanguageService.ts | 3 ++ src/server/client.ts | 4 +++ src/services/quickfixes/quickFixProvider.ts | 37 +++++++++++++++++++++ src/services/quickfixes/superFixes.ts | 31 +++++++++++++++++ src/services/services.ts | 20 +++++++++-- src/services/shims.ts | 16 +++++++++ tests/cases/fourslash/fourslash.ts | 1 + tests/cases/fourslash/superFix1.ts | 10 ++++++ tests/cases/fourslash/superFix2.ts | 13 ++++++++ 10 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 src/services/quickfixes/quickFixProvider.ts create mode 100644 src/services/quickfixes/superFixes.ts create mode 100644 tests/cases/fourslash/superFix1.ts create mode 100644 tests/cases/fourslash/superFix2.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index d6035aaa026d2..93fe8c22d3233 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -637,7 +637,6 @@ namespace FourSlash { } } - public verifyCompletionListAllowsNewIdentifier(negative: boolean) { const completions = this.getCompletionListAtCaret(); @@ -1817,6 +1816,24 @@ namespace FourSlash { } } + public verifyCodeFixAtPosition(expectedChange: { span: ts.TextSpan, newText: string }) { + const position = this.currentCaretPosition; + const diagnostics = this.getDiagnostics(this.activeFile.fileName); + + if (diagnostics.length === 0) { + this.raiseError("Errors expected"); + } + + // we expect a single error per file + const errorCode = diagnostics[0].code; + + const actual = this.languageService.getCodeFixAtPosition(this.activeFile.fileName, position, position, [`TS${errorCode}`]); + + if (actual.textChanges[0].newText !== expectedChange.newText) { + this.raiseError(`Not the expected text change.`); + } + } + public verifyDocCommentTemplate(expected?: ts.TextInsertion) { const name = "verifyDocCommentTemplate"; const actual = this.languageService.getDocCommentTemplateAtPosition(this.activeFile.fileName, this.currentCaretPosition); @@ -3029,6 +3046,10 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } + public codeFixAtPosition(expectedChange: { span: ts.TextSpan, newText: string }) { + this.state.verifyCodeFixAtPosition(expectedChange); + } + public getScriptLexicalStructureListCount(count: number) { this.state.verifyGetScriptLexicalStructureListCount(count); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8aaff65febcca..c48f0b1b4d1ae 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -440,6 +440,9 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPostion(fileName, position, openingBrace)); } + getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): { name: string, textChanges: ts.TextChange[] } { + return unwrapJSONCallResult(this.shim.getCodeFixAtPosition(fileName, start, end, errorCodes)); + } getEmitOutput(fileName: string): ts.EmitOutput { return unwrapJSONCallResult(this.shim.getEmitOutput(fileName)); } diff --git a/src/server/client.ts b/src/server/client.ts index caeab6e3f3cf5..90c21c3e98012 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -572,6 +572,10 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } + getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): { name: string, textChanges: ts.TextChange[] } { + throw new Error("Not Implemented Yet."); + } + getBraceMatchingAtPosition(fileName: string, position: number): TextSpan[] { var lineOffset = this.positionToOneBasedLineOffset(fileName, position); var args: protocol.FileLocationRequestArgs = { diff --git a/src/services/quickfixes/quickFixProvider.ts b/src/services/quickfixes/quickFixProvider.ts new file mode 100644 index 0000000000000..3d123d52a5359 --- /dev/null +++ b/src/services/quickfixes/quickFixProvider.ts @@ -0,0 +1,37 @@ +/// +/// + +/* @internal */ +namespace ts.quickFix { + + export interface QuickFix { + name: string; + errorCode: string; + getFix(sourceFile: SourceFile, start: number, end: number): TextChange[]; + } + + export class QuickFixProvider { + // TODO: + // Make the provider query the fixes for all the errorcodes they can fix + // and allow multiple fixes to fix the same error + + private static quickFixes: Map = { + [MissingSuperFix.errorCode]: MissingSuperFix, + [SuperOrderFix.errorCode]: SuperOrderFix, + }; + + public static getSupportedErrorCodes() { + return getKeys(QuickFixProvider.quickFixes); + } + + public fix(errorCode: string, sourceFile: SourceFile, start: number, end: number) { + const fix = QuickFixProvider.quickFixes[errorCode]; + + if (!fix) { + throw new Error(`No fix found for error: '${errorCode}'`); + } + + return { name: fix.name, textChanges: fix.getFix(sourceFile, start, end) }; + } + } +} \ No newline at end of file diff --git a/src/services/quickfixes/superFixes.ts b/src/services/quickfixes/superFixes.ts new file mode 100644 index 0000000000000..490323d8d2451 --- /dev/null +++ b/src/services/quickfixes/superFixes.ts @@ -0,0 +1,31 @@ +/// +/// + +/* @internal */ +namespace ts.quickFix { + export const MissingSuperFix: QuickFix = { + name: `Add missing 'super()' call.`, + errorCode: "TS2377", + getFix: (sourceFile: SourceFile, start: number, end: number) => { + const token = getTokenAtPosition(sourceFile, start); + if (token.kind !== SyntaxKind.ConstructorKeyword) { + // wait why are we not a on a constructor? + return []; + } + + const openCurly = (token.parent).body.getChildren(sourceFile)[0]; // assume this is the open curly + const position = openCurly.getEnd(); // want to position directly after open curly, we'll format using the formatting service in the host + + return [{ newText: "super();", span: { start: position, length: 0 } }]; + } + } + + export const SuperOrderFix: QuickFix = { + name: `Make super call the first statement in the constructor.`, + errorCode: "TS17009", + getFix: (SourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { + + throw new Error("Not implemented"); + } + } +} \ No newline at end of file diff --git a/src/services/services.ts b/src/services/services.ts index b2f7eb4bdbaaf..5afb33a194d69 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -10,6 +10,7 @@ /// /// /// +/// namespace ts { /** The version of the language service API */ @@ -1115,6 +1116,8 @@ namespace ts { isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean; + getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): { name: string, textChanges: TextChange[] }; + getEmitOutput(fileName: string): EmitOutput; getProgram(): Program; @@ -1753,9 +1756,13 @@ namespace ts { }; } - // Cache host information about scrip Should be refreshed + export function getSupportedCodeFixes() { + return quickFix.QuickFixProvider.getSupportedErrorCodes(); + } + + // Cache host information about script Should be refreshed // at each language service public entry point, since we don't know when - // set of scripts handled by the host changes. + // the set of scripts handled by the host changes. class HostCache { private fileNameToEntry: FileMap; private _compilationSettings: CompilerOptions; @@ -2825,6 +2832,7 @@ namespace ts { documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { const syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); + const quickFixProvider: quickFix.QuickFixProvider = new quickFix.QuickFixProvider(); let ruleProvider: formatting.RulesProvider; let program: Program; let lastProjectVersion: string; @@ -7477,6 +7485,13 @@ namespace ts { return []; } + function getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): { name: string, textChanges: TextChange[] } { + synchronizeHostData(); + const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + + return quickFixProvider.fix(errorCodes[0], sourceFile, start, end); + } + /** * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. @@ -7947,6 +7962,7 @@ namespace ts { getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, isValidBraceCompletionAtPostion, + getCodeFixAtPosition, getEmitOutput, getNonBoundSourceFile, getProgram diff --git a/src/services/shims.ts b/src/services/shims.ts index a515f32d1691c..be959bdb4878a 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -228,6 +228,8 @@ namespace ts { */ isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string; + getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): string; + getEmitOutput(fileName: string): string; } @@ -241,6 +243,7 @@ namespace ts { getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getDefaultCompilationSettings(): string; discoverTypings(discoverTypingsJson: string): string; + getSupportedCodeFixes(): string; } function logInternalError(logger: Logger, err: Error) { @@ -851,6 +854,13 @@ namespace ts { ); } + public getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): string { + return this.forwardJSONCall( + `getCodeFixAtPosition( '${fileName}', ${start}, ${end}, '[${errorCodes.join(",")}]')`, + () => this.languageService.getCodeFixAtPosition(fileName, start, end, errorCodes) + ); + } + /// NAVIGATE TO /** Return a list of symbols that are interesting to navigate to */ @@ -1040,6 +1050,12 @@ namespace ts { info.compilerOptions); }); } + + public getSupportedCodeFixes(): string { + return this.forwardJSONCall("getSupportedCodeFixes()", + () => getSupportedCodeFixes() + ); + } } export class TypeScriptServicesFactory implements ShimFactory { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 48d69f0a85eb8..16211609671a4 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -174,6 +174,7 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; + codeFixAtPosition(expectedChange: { span: TextSpan, newText: string }); getScriptLexicalStructureListCount(count: number): void; getScriptLexicalStructureListContains(name: string, kind: string, fileName?: string, parentName?: string, isAdditionalSpan?: boolean, markerPosition?: number): void; diff --git a/tests/cases/fourslash/superFix1.ts b/tests/cases/fourslash/superFix1.ts new file mode 100644 index 0000000000000..5f4646f2bddc0 --- /dev/null +++ b/tests/cases/fourslash/superFix1.ts @@ -0,0 +1,10 @@ +/// + +////class Base{ +////} +////class C extends Base{ +//// /*0*/constructor() { +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "super();" }); diff --git a/tests/cases/fourslash/superFix2.ts b/tests/cases/fourslash/superFix2.ts new file mode 100644 index 0000000000000..71ec52cfde360 --- /dev/null +++ b/tests/cases/fourslash/superFix2.ts @@ -0,0 +1,13 @@ +/// + +////class Base{ +////} +////class C extends Base{ +//// private a:number; +//// /*0*/constructor() { +//// this.a = 12; +//// super(); +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "super();" }); From 617b81916964a28f2eac7bd23e2a8c14232fc8d0 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 24 May 2016 12:54:32 -0700 Subject: [PATCH 03/90] Code changes to update references of the Identifiers --- src/compiler/checker.ts | 8 ++++++++ src/compiler/types.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 06ef246340252..ef45612f48837 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8100,8 +8100,16 @@ namespace ts { return container === declarationContainer; } + function updateReferences(node: Identifier): void { + const symbol = getReferencedValueSymbol(node); + if (symbol) { + symbol.hasReference = true; + } + } + function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); + updateReferences(node); // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c7e14a1003108..21eafc2d282f8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2108,6 +2108,7 @@ namespace ts { /* @internal */ parent?: Symbol; // Parent symbol /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums + hasReference?: boolean; } /* @internal */ From a8bc8b4bd5ae89d370e77bd3a619d2357dc33bf0 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 26 May 2016 10:06:01 -0700 Subject: [PATCH 04/90] Added code for handling function, method and coonstructor level local variables and parameters --- src/compiler/checker.ts | 30 +++++++++++++++++++++++++--- src/compiler/commandLineParser.ts | 10 ++++++++++ src/compiler/diagnosticMessages.json | 8 ++++++++ src/compiler/types.ts | 4 +++- 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ef45612f48837..21cf2f7c5518c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8101,9 +8101,11 @@ namespace ts { } function updateReferences(node: Identifier): void { - const symbol = getReferencedValueSymbol(node); - if (symbol) { - symbol.hasReference = true; + if (!isSourceFileADefinitionFile(node)) { + const symbol = getReferencedValueSymbol(node); + if (symbol) { + symbol.hasReference = true; + } } } @@ -13128,6 +13130,7 @@ namespace ts { checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); + checkUnusedIdentifiers(node); const symbol = getSymbolOfNode(node); const firstDeclaration = getDeclarationOfKind(symbol, node.kind); @@ -14170,6 +14173,7 @@ namespace ts { } checkSourceElement(node.body); + checkUnusedIdentifiers(node); if (!node.asteriskToken) { const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -14191,6 +14195,26 @@ namespace ts { } } + function isSourceFileADefinitionFile(node: Node): boolean { + return getSourceFileOfNode(node).fileName.indexOf(".d.ts") > 0; + } + + function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { + if (!isSourceFileADefinitionFile(node)) { + for (const key in node.locals) { + if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { + if (compilerOptions.noUnusedLocals && node.locals[key].valueDeclaration.kind === SyntaxKind.VariableDeclaration) { + error(node, Diagnostics.Variable_0_has_never_been_used, key); + } + + if (compilerOptions.noUnusedParameters && node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter) { + error(node, Diagnostics.Parameter_0_has_never_been_used, key); + } + } + } + } + } + function checkBlock(node: Block) { // Grammar checking for SyntaxKind.Block if (node.kind === SyntaxKind.Block) { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 506a2d5bee42d..f5b1fe3b48358 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -132,6 +132,16 @@ namespace ts { type: "boolean", description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, }, + { + name: "noUnusedLocals", + type: "boolean", + description: Diagnostics.Variable_0_has_never_been_used, + }, + { + name: "noUnusedParameters", + type: "boolean", + description: Diagnostics.Parameter_0_has_never_been_used + }, { name: "noLib", type: "boolean", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 034bd27b1472a..4462e2b3832fb 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2772,6 +2772,14 @@ "category": "Error", "code": 6131 }, + "Variable '{0}' has never been used.": { + "category": "Message", + "code": 6132 + }, + "Parameter '{0}' has never been used.": { + "category": "Message", + "code": 6133 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 21eafc2d282f8..e36c0a488557d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2108,7 +2108,7 @@ namespace ts { /* @internal */ parent?: Symbol; // Parent symbol /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums - hasReference?: boolean; + /* @internal */ hasReference?: boolean; // True if the symbol is referenced elsewhere } /* @internal */ @@ -2505,6 +2505,8 @@ namespace ts { noErrorTruncation?: boolean; noImplicitAny?: boolean; noImplicitThis?: boolean; + noUnusedLocals?: boolean; + noUnusedParameters?: boolean; noLib?: boolean; noResolve?: boolean; out?: string; From 01966bad69a61c1cd4b9e8f79dba625f0be5fefb Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 26 May 2016 10:07:04 -0700 Subject: [PATCH 05/90] Rebased with origin master --- lib/lib.scripthost.d.ts | 294 ---------------------------------------- 1 file changed, 294 deletions(-) delete mode 100644 lib/lib.scripthost.d.ts diff --git a/lib/lib.scripthost.d.ts b/lib/lib.scripthost.d.ts deleted file mode 100644 index d4c6131fd93ba..0000000000000 --- a/lib/lib.scripthost.d.ts +++ /dev/null @@ -1,294 +0,0 @@ -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. -Licensed under the Apache License, Version 2.0 (the "License"); you may not use -this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - -THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - -See the Apache Version 2.0 License for specific language governing permissions -and limitations under the License. -***************************************************************************** */ - -/// - - -///////////////////////////// -/// Windows Script Host APIS -///////////////////////////// - - -interface ActiveXObject { - new (s: string): any; -} -declare var ActiveXObject: ActiveXObject; - -interface ITextWriter { - Write(s: string): void; - WriteLine(s: string): void; - Close(): void; -} - -interface TextStreamBase { - /** - * The column number of the current character position in an input stream. - */ - Column: number; - - /** - * The current line number in an input stream. - */ - Line: number; - - /** - * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If - * you close a standard stream, be aware that any other pointers to that standard stream become invalid. - */ - Close(): void; -} - -interface TextStreamWriter extends TextStreamBase { - /** - * Sends a string to an output stream. - */ - Write(s: string): void; - - /** - * Sends a specified number of blank lines (newline characters) to an output stream. - */ - WriteBlankLines(intLines: number): void; - - /** - * Sends a string followed by a newline character to an output stream. - */ - WriteLine(s: string): void; -} - -interface TextStreamReader extends TextStreamBase { - /** - * Returns a specified number of characters from an input stream, starting at the current pointer position. - * Does not return until the ENTER key is pressed. - * Can only be used on a stream in reading mode; causes an error in writing or appending mode. - */ - Read(characters: number): string; - - /** - * Returns all characters from an input stream. - * Can only be used on a stream in reading mode; causes an error in writing or appending mode. - */ - ReadAll(): string; - - /** - * Returns an entire line from an input stream. - * Although this method extracts the newline character, it does not add it to the returned string. - * Can only be used on a stream in reading mode; causes an error in writing or appending mode. - */ - ReadLine(): string; - - /** - * Skips a specified number of characters when reading from an input text stream. - * Can only be used on a stream in reading mode; causes an error in writing or appending mode. - * @param characters Positive number of characters to skip forward. (Backward skipping is not supported.) - */ - Skip(characters: number): void; - - /** - * Skips the next line when reading from an input text stream. - * Can only be used on a stream in reading mode, not writing or appending mode. - */ - SkipLine(): void; - - /** - * Indicates whether the stream pointer position is at the end of a line. - */ - AtEndOfLine: boolean; - - /** - * Indicates whether the stream pointer position is at the end of a stream. - */ - AtEndOfStream: boolean; -} - -declare var WScript: { - /** - * Outputs text to either a message box (under WScript.exe) or the command console window followed by - * a newline (under CScript.exe). - */ - Echo(s: any): void; - - /** - * Exposes the write-only error output stream for the current script. - * Can be accessed only while using CScript.exe. - */ - StdErr: TextStreamWriter; - - /** - * Exposes the write-only output stream for the current script. - * Can be accessed only while using CScript.exe. - */ - StdOut: TextStreamWriter; - Arguments: { length: number; Item(n: number): string; }; - - /** - * The full path of the currently running script. - */ - ScriptFullName: string; - - /** - * Forces the script to stop immediately, with an optional exit code. - */ - Quit(exitCode?: number): number; - - /** - * The Windows Script Host build version number. - */ - BuildVersion: number; - - /** - * Fully qualified path of the host executable. - */ - FullName: string; - - /** - * Gets/sets the script mode - interactive(true) or batch(false). - */ - Interactive: boolean; - - /** - * The name of the host executable (WScript.exe or CScript.exe). - */ - Name: string; - - /** - * Path of the directory containing the host executable. - */ - Path: string; - - /** - * The filename of the currently running script. - */ - ScriptName: string; - - /** - * Exposes the read-only input stream for the current script. - * Can be accessed only while using CScript.exe. - */ - StdIn: TextStreamReader; - - /** - * Windows Script Host version - */ - Version: string; - - /** - * Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event. - */ - ConnectObject(objEventSource: any, strPrefix: string): void; - - /** - * Creates a COM object. - * @param strProgiID - * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events. - */ - CreateObject(strProgID: string, strPrefix?: string): any; - - /** - * Disconnects a COM object from its event sources. - */ - DisconnectObject(obj: any): void; - - /** - * Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file. - * @param strPathname Fully qualified path to the file containing the object persisted to disk. - * For objects in memory, pass a zero-length string. - * @param strProgID - * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events. - */ - GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any; - - /** - * Suspends script execution for a specified length of time, then continues execution. - * @param intTime Interval (in milliseconds) to suspend script execution. - */ - Sleep(intTime: number): void; -}; - -/** - * Allows enumerating over a COM collection, which may not have indexed item access. - */ -interface Enumerator { - /** - * Returns true if the current item is the last one in the collection, or the collection is empty, - * or the current item is undefined. - */ - atEnd(): boolean; - - /** - * Returns the current item in the collection - */ - item(): T; - - /** - * Resets the current item in the collection to the first item. If there are no items in the collection, - * the current item is set to undefined. - */ - moveFirst(): void; - - /** - * Moves the current item to the next item in the collection. If the enumerator is at the end of - * the collection or the collection is empty, the current item is set to undefined. - */ - moveNext(): void; -} - -interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; -} - -declare var Enumerator: EnumeratorConstructor; - -/** - * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. - */ -interface VBArray { - /** - * Returns the number of dimensions (1-based). - */ - dimensions(): number; - - /** - * Takes an index for each dimension in the array, and returns the item at the corresponding location. - */ - getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T; - - /** - * Returns the smallest available index for a given dimension. - * @param dimension 1-based dimension (defaults to 1) - */ - lbound(dimension?: number): number; - - /** - * Returns the largest available index for a given dimension. - * @param dimension 1-based dimension (defaults to 1) - */ - ubound(dimension?: number): number; - - /** - * Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions, - * each successive dimension is appended to the end of the array. - * Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6] - */ - toArray(): T[]; -} - -interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; -} - -declare var VBArray: VBArrayConstructor; From 1e5ca92010a0bec2281bb7b1a2722171c0e8063b Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 27 May 2016 10:08:19 -0700 Subject: [PATCH 06/90] Code changes to handle unused private variables, private methods and typed parameters --- src/compiler/checker.ts | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 21cf2f7c5518c..4e072c67aeaa4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8109,6 +8109,13 @@ namespace ts { } } + function updateReferencesForTypedParameters(node: TypeNode): void { + const symbol = getNodeLinks(node).resolvedSymbol; + if (symbol) { + symbol.hasReference = true; + } + } + function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); updateReferences(node); @@ -9992,6 +9999,7 @@ namespace ts { return unknownType; } + prop.hasReference = true; getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & SymbolFlags.Class) { @@ -13107,6 +13115,9 @@ namespace ts { checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); + if (node.type && node.type.kind === SyntaxKind.TypeReference) { + updateReferencesForTypedParameters(node.type); + } } function checkMethodDeclaration(node: MethodDeclaration) { @@ -14207,7 +14218,9 @@ namespace ts { error(node, Diagnostics.Variable_0_has_never_been_used, key); } - if (compilerOptions.noUnusedParameters && node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter) { + if (compilerOptions.noUnusedParameters + && node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter + && node.parent.kind === SyntaxKind.FunctionDeclaration) { error(node, Diagnostics.Parameter_0_has_never_been_used, key); } } @@ -14215,6 +14228,39 @@ namespace ts { } } + function checkUnusedPrivates(node: ClassDeclaration): void { + if (!isSourceFileADefinitionFile(node)) { + for (let i = 0; i < node.members.length; i++) { + switch (node.members[i].kind) { + case SyntaxKind.MethodDeclaration: + case SyntaxKind.PropertyDeclaration: + if (compilerOptions.noUnusedLocals && isPrivateClassElement(node.members[i]) && !node.members[i].symbol.hasReference) { + error(node, Diagnostics.Variable_0_has_never_been_used, node.members[i].symbol.name); + } + break; + default: + break; + } + } + + //var typeParametersLength = (node.typeParameters) ? node.typeParameters.length : 0; + for (let i = 0; node.typeParameters && i < node.typeParameters.length; i++) { + if (compilerOptions.noUnusedLocals && !node.typeParameters[i].symbol.hasReference) { + error(node, Diagnostics.Variable_0_has_never_been_used, node.typeParameters[i].symbol.name); + } + } + } + } + + function isPrivateClassElement(node: ClassElement): boolean { + for (let i = 0; node.modifiers && i < node.modifiers.length; i++) { + if (node.modifiers[i].kind === SyntaxKind.PrivateKeyword) + return true; + } + return false; + } + + function checkBlock(node: Block) { // Grammar checking for SyntaxKind.Block if (node.kind === SyntaxKind.Block) { @@ -15372,6 +15418,7 @@ namespace ts { } checkClassLikeDeclaration(node); forEach(node.members, checkSourceElement); + checkUnusedPrivates(node); } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { From 890d178a742663b0df75d962fb988f10f9e52e07 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 1 Jun 2016 11:08:17 -0700 Subject: [PATCH 07/90] Code changes to handle namespace level elements --- src/compiler/checker.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4e072c67aeaa4..fc9e03e7ce6b5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14228,9 +14228,21 @@ namespace ts { } } + function checkUnusedModulePrivates(node: ModuleDeclaration): void { + if (!isSourceFileADefinitionFile(node)) { + for (const key in node.locals) { + if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { + if (compilerOptions.noUnusedLocals && !node.locals[key].exportSymbol) { + error(node, Diagnostics.Variable_0_has_never_been_used, key); + } + } + } + } + } + function checkUnusedPrivates(node: ClassDeclaration): void { if (!isSourceFileADefinitionFile(node)) { - for (let i = 0; i < node.members.length; i++) { + for (let i = 0; node.members && i < node.members.length; i++) { switch (node.members[i].kind) { case SyntaxKind.MethodDeclaration: case SyntaxKind.PropertyDeclaration: @@ -14243,7 +14255,6 @@ namespace ts { } } - //var typeParametersLength = (node.typeParameters) ? node.typeParameters.length : 0; for (let i = 0; node.typeParameters && i < node.typeParameters.length; i++) { if (compilerOptions.noUnusedLocals && !node.typeParameters[i].symbol.hasReference) { error(node, Diagnostics.Variable_0_has_never_been_used, node.typeParameters[i].symbol.name); @@ -16117,6 +16128,7 @@ namespace ts { } } checkSourceElement(node.body); + checkUnusedModulePrivates(node); } function checkModuleAugmentationElement(node: Node, isGlobalAugmentation: boolean): void { From 69dbeea93612fcede78d0c470b17257716bbb3e6 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 1 Jun 2016 16:08:12 -0700 Subject: [PATCH 08/90] Code changes to handle unimplemented interfaces --- src/compiler/checker.ts | 42 +++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fc9e03e7ce6b5..eb979933a8d81 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13141,7 +13141,7 @@ namespace ts { checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); - checkUnusedIdentifiers(node); + checkUnusedLocals(node); const symbol = getSymbolOfNode(node); const firstDeclaration = getDeclarationOfKind(symbol, node.kind); @@ -14184,7 +14184,7 @@ namespace ts { } checkSourceElement(node.body); - checkUnusedIdentifiers(node); + checkUnusedLocals(node); if (!node.asteriskToken) { const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -14210,17 +14210,28 @@ namespace ts { return getSourceFileOfNode(node).fileName.indexOf(".d.ts") > 0; } + function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { + checkUnusedIdentifiers(node); + checkUnusedParameters(node); + } + function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { - if (!isSourceFileADefinitionFile(node)) { + if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile(node)) { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { - if (compilerOptions.noUnusedLocals && node.locals[key].valueDeclaration.kind === SyntaxKind.VariableDeclaration) { + if (node.locals[key].valueDeclaration.kind === SyntaxKind.VariableDeclaration) { error(node, Diagnostics.Variable_0_has_never_been_used, key); } + } + } + } + } - if (compilerOptions.noUnusedParameters - && node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter - && node.parent.kind === SyntaxKind.FunctionDeclaration) { + function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { + if (compilerOptions.noUnusedParameters && !isSourceFileADefinitionFile(node)) { + for (const key in node.locals) { + if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { + if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter) { error(node, Diagnostics.Parameter_0_has_never_been_used, key); } } @@ -14229,10 +14240,11 @@ namespace ts { } function checkUnusedModulePrivates(node: ModuleDeclaration): void { - if (!isSourceFileADefinitionFile(node)) { + if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile(node)) { for (const key in node.locals) { - if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { - if (compilerOptions.noUnusedLocals && !node.locals[key].exportSymbol) { + if (!node.locals[key].hasReference && !node.locals[key].exportSymbol) { + if ((node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) + || (node.locals[key].declarations && node.locals[key].declarations[0].kind === SyntaxKind.InterfaceDeclaration)) { error(node, Diagnostics.Variable_0_has_never_been_used, key); } } @@ -14241,12 +14253,12 @@ namespace ts { } function checkUnusedPrivates(node: ClassDeclaration): void { - if (!isSourceFileADefinitionFile(node)) { + if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile(node)) { for (let i = 0; node.members && i < node.members.length; i++) { switch (node.members[i].kind) { case SyntaxKind.MethodDeclaration: case SyntaxKind.PropertyDeclaration: - if (compilerOptions.noUnusedLocals && isPrivateClassElement(node.members[i]) && !node.members[i].symbol.hasReference) { + if (isPrivateClassElement(node.members[i]) && !node.members[i].symbol.hasReference) { error(node, Diagnostics.Variable_0_has_never_been_used, node.members[i].symbol.name); } break; @@ -14256,7 +14268,7 @@ namespace ts { } for (let i = 0; node.typeParameters && i < node.typeParameters.length; i++) { - if (compilerOptions.noUnusedLocals && !node.typeParameters[i].symbol.hasReference) { + if (!node.typeParameters[i].symbol.hasReference) { error(node, Diagnostics.Variable_0_has_never_been_used, node.typeParameters[i].symbol.name); } } @@ -14271,7 +14283,6 @@ namespace ts { return false; } - function checkBlock(node: Block) { // Grammar checking for SyntaxKind.Block if (node.kind === SyntaxKind.Block) { @@ -15494,6 +15505,9 @@ namespace ts { if (produceDiagnostics) { const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { + if (t.symbol) { + t.symbol.hasReference = true; + } const declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); From c78d0e277ffd4f514c48adccd62f4efbcc9241b3 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 1 Jun 2016 16:15:47 -0700 Subject: [PATCH 09/90] Code to optimize the d.ts check --- src/compiler/checker.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index eb979933a8d81..8407d4835ee0d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -44,6 +44,7 @@ namespace ts { let typeCount = 0; let symbolCount = 0; + let isSourceFileADefinitionFile: boolean = false; const emptyArray: any[] = []; const emptySymbols: SymbolTable = {}; @@ -8101,7 +8102,7 @@ namespace ts { } function updateReferences(node: Identifier): void { - if (!isSourceFileADefinitionFile(node)) { + if (!isSourceFileADefinitionFile) { const symbol = getReferencedValueSymbol(node); if (symbol) { symbol.hasReference = true; @@ -14206,7 +14207,7 @@ namespace ts { } } - function isSourceFileADefinitionFile(node: Node): boolean { + function checkSourceFileADefinitionFile(node: Node): boolean { return getSourceFileOfNode(node).fileName.indexOf(".d.ts") > 0; } @@ -14216,7 +14217,7 @@ namespace ts { } function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { - if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile(node)) { + if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind === SyntaxKind.VariableDeclaration) { @@ -14228,7 +14229,7 @@ namespace ts { } function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { - if (compilerOptions.noUnusedParameters && !isSourceFileADefinitionFile(node)) { + if (compilerOptions.noUnusedParameters && !isSourceFileADefinitionFile) { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter) { @@ -14240,7 +14241,7 @@ namespace ts { } function checkUnusedModulePrivates(node: ModuleDeclaration): void { - if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile(node)) { + if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { for (const key in node.locals) { if (!node.locals[key].hasReference && !node.locals[key].exportSymbol) { if ((node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) @@ -14253,7 +14254,7 @@ namespace ts { } function checkUnusedPrivates(node: ClassDeclaration): void { - if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile(node)) { + if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { for (let i = 0; node.members && i < node.members.length; i++) { switch (node.members[i].kind) { case SyntaxKind.MethodDeclaration: @@ -16641,6 +16642,7 @@ namespace ts { function checkSourceFile(node: SourceFile) { const start = new Date().getTime(); + isSourceFileADefinitionFile = checkSourceFileADefinitionFile(node); checkSourceFileWorker(node); checkTime += new Date().getTime() - start; From 107b36991a1486a7d4e8c123b012b7d3eb4ef7e2 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 1 Jun 2016 16:38:24 -0700 Subject: [PATCH 10/90] Correct Code change to handle the parameters for methods inside interfaces --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8407d4835ee0d..a9ef955f5a6ff 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14232,7 +14232,7 @@ namespace ts { if (compilerOptions.noUnusedParameters && !isSourceFileADefinitionFile) { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { - if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter) { + if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter && node.parent.kind !== SyntaxKind.InterfaceDeclaration) { error(node, Diagnostics.Parameter_0_has_never_been_used, key); } } From 481baa3cb164d564e0a397cea3ebf9a8e35daaae Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 1 Jun 2016 18:07:50 -0700 Subject: [PATCH 11/90] Fix for lint error --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a9ef955f5a6ff..4f6370a434b2f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -44,7 +44,7 @@ namespace ts { let typeCount = 0; let symbolCount = 0; - let isSourceFileADefinitionFile: boolean = false; + let isSourceFileADefinitionFile = false; const emptyArray: any[] = []; const emptySymbols: SymbolTable = {}; From cd1ce0f7a84cd6a1ceb09ee94fc2c6c66ef7bea2 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 2 Jun 2016 09:41:41 -0700 Subject: [PATCH 12/90] Remove Trailing whitespace --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4f6370a434b2f..e89d64539eb3e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14225,7 +14225,7 @@ namespace ts { } } } - } + } } function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { @@ -14248,7 +14248,7 @@ namespace ts { || (node.locals[key].declarations && node.locals[key].declarations[0].kind === SyntaxKind.InterfaceDeclaration)) { error(node, Diagnostics.Variable_0_has_never_been_used, key); } - } + } } } } @@ -14273,7 +14273,7 @@ namespace ts { error(node, Diagnostics.Variable_0_has_never_been_used, node.typeParameters[i].symbol.name); } } - } + } } function isPrivateClassElement(node: ClassElement): boolean { From 4e36addd573071ca5c5fda18ddbbfbbc7b5783c6 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 2 Jun 2016 13:15:08 -0700 Subject: [PATCH 13/90] Support multiple errorcodes per fix --- src/services/quickfixes/quickFixProvider.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/services/quickfixes/quickFixProvider.ts b/src/services/quickfixes/quickFixProvider.ts index 3f77125457a93..1528c08819c31 100644 --- a/src/services/quickfixes/quickFixProvider.ts +++ b/src/services/quickfixes/quickFixProvider.ts @@ -1,9 +1,8 @@ /* @internal */ namespace ts { - export interface QuickFix { name: string; - errorCode: string; + errorCodes: string[]; getFix(sourceFile: SourceFile, start: number, end: number): TextChange[]; } @@ -13,7 +12,6 @@ namespace ts { } export namespace quickFix { - export const enum FixPriority { AboveNormal, Normal, @@ -22,25 +20,21 @@ namespace ts { var quickFixes: Map = {}; - export function registerQuickFix(fix: QuickFix){ - quickFixes[fix.errorCode] = fix; + export function registerQuickFix(fix: QuickFix) { + fix.errorCodes.forEach(error => quickFixes[error] = fix); } export class QuickFixProvider { - // TODO: - // Make the provider query the fixes for all the errorcodes they can fix - // and allow multiple fixes to fix the same error public static getSupportedErrorCodes() { - return getKeys(quickFixes); } - public fix(errorCode: string, sourceFile: SourceFile, start: number, end: number): SuggestedFix{ + public fix(errorCode: string, sourceFile: SourceFile, start: number, end: number): SuggestedFix { const fix = quickFixes[errorCode]; if (!fix) { - throw new Error(`No fix found for error: '${errorCode}'`); + throw new Error(`No fix found for error: '${errorCode}'.`); } return { name: fix.name, textChanges: fix.getFix(sourceFile, start, end) }; From 3994bfc5b5d7db28e7e4c75058b63e162f762712 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 2 Jun 2016 13:15:34 -0700 Subject: [PATCH 14/90] Implement making making super call the first call fix. --- src/services/quickfixes/superFixes.ts | 50 ++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/src/services/quickfixes/superFixes.ts b/src/services/quickfixes/superFixes.ts index 5eb4bb2645785..94614f5c06719 100644 --- a/src/services/quickfixes/superFixes.ts +++ b/src/services/quickfixes/superFixes.ts @@ -1,11 +1,9 @@ - - -/* @internal */ +/* @internal */ namespace ts.quickFix { registerQuickFix({ name: `Add missing 'super()' call.`, - errorCode: "TS2377", + errorCodes: ["TS2377"], getFix: (sourceFile: SourceFile, start: number, end: number) => { const token = getTokenAtPosition(sourceFile, start); if (token.kind !== SyntaxKind.ConstructorKeyword) { @@ -22,17 +20,51 @@ namespace ts.quickFix { registerQuickFix({ name: `Make super call the first statement in the constructor.`, - errorCode: "TS17009", - getFix: (SourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { + errorCodes: ["TS17009"], + getFix: (sourceFile: SourceFile, start: number, end: number): TextChange[] => { + const token = getTokenAtPosition(sourceFile, start); + const constructor = getContainingFunction(token); - throw new Error("Not implemented"); + if (constructor.kind !== SyntaxKind.Constructor) { + // wait why are we not a on a constructor? + throw new Error("Failed to find the constructor."); + } + const superCall = findSuperCall((constructor).body); + + const children = (constructor).body.getChildren(sourceFile); + + // first child is the open curly, this is where we want to put the 'super' call. + const newPosition = children[0].getEnd(); + + if (!superCall) { + throw new Error(`Failed to find super call.`); + } + + return [{ + newText: superCall.getText(sourceFile), + span: { start: newPosition, length: 0 } + }, + { + newText: "", + span: { start: superCall.getStart(sourceFile), length: superCall.getFullWidth() } + }] + + function findSuperCall(n: Node): Node { + if (isSuperCallExpression(n)) { + return n; + } + if (isFunctionLike(n)) { + return undefined; + } + return forEachChild(n, findSuperCall); + } } }); registerQuickFix({ name: `Add Type to static member access.`, - errorCode: "TS2662", - getFix: (SourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { + errorCodes: ["TS2662"], + getFix: (sourceFile: SourceFile, start: number, end: number): TextChange[] => { throw new Error("Not implemented"); } From a38149d83cc8096e9f18e6c0a3755b99fd8a767f Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 3 Jun 2016 12:19:16 -0700 Subject: [PATCH 15/90] Code changes to handle interface implementations --- src/compiler/checker.ts | 39 ++++++++++++++++++++++++++++----------- src/compiler/utilities.ts | 2 +- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e89d64539eb3e..7ecb1e4867284 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8117,6 +8117,16 @@ namespace ts { } } + function updateReferencesForInterfaceImplementations(node: InterfaceDeclaration): void { + const extendedTypeNode = getClassExtendsHeritageClauseElement(node); + if (extendedTypeNode) { + const t = getTypeFromTypeNode(extendedTypeNode); + if (t !== unknownType && t.symbol) { + t.symbol.hasReference = true; + } + } + } + function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); updateReferences(node); @@ -11899,6 +11909,7 @@ namespace ts { if (node.body.kind === SyntaxKind.Block) { checkSourceElement(node.body); + checkUnusedLocals(node); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -13335,13 +13346,18 @@ namespace ts { function checkTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments) { checkGrammarTypeArguments(node, node.typeArguments); const type = getTypeFromTypeReference(node); - if (type !== unknownType && node.typeArguments) { - // Do type argument local checks only if referenced type is successfully resolved - forEach(node.typeArguments, checkSourceElement); - if (produceDiagnostics) { - const symbol = getNodeLinks(node).resolvedSymbol; - const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; - checkTypeArgumentConstraints(typeParameters, node.typeArguments); + if (type !== unknownType) { + if (type.symbol) { + type.symbol.hasReference = true; + } + if (node.typeArguments) { + // Do type argument local checks only if referenced type is successfully resolved + forEach(node.typeArguments, checkSourceElement); + if (produceDiagnostics) { + const symbol = getNodeLinks(node).resolvedSymbol; + const typeParameters = symbol.flags & SymbolFlags.TypeAlias ? getSymbolLinks(symbol).typeParameters : (type).target.localTypeParameters; + checkTypeArgumentConstraints(typeParameters, node.typeArguments); + } } } } @@ -14211,16 +14227,16 @@ namespace ts { return getSourceFileOfNode(node).fileName.indexOf(".d.ts") > 0; } - function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { + function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { checkUnusedIdentifiers(node); checkUnusedParameters(node); } - function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { + function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { - if (node.locals[key].valueDeclaration.kind === SyntaxKind.VariableDeclaration) { + if (node.locals[key].valueDeclaration.kind !== SyntaxKind.Parameter) { error(node, Diagnostics.Variable_0_has_never_been_used, key); } } @@ -14228,7 +14244,7 @@ namespace ts { } } - function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration): void { + function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { if (compilerOptions.noUnusedParameters && !isSourceFileADefinitionFile) { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { @@ -15727,6 +15743,7 @@ namespace ts { checkExportsOnMergedDeclarations(node); const symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); + updateReferencesForInterfaceImplementations(node); // Only check this symbol once const firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 74ea3459b2359..834d599790fbb 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1690,7 +1690,7 @@ namespace ts { node.kind === SyntaxKind.ExportAssignment && (node).expression.kind === SyntaxKind.Identifier; } - export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration) { + export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration) { const heritageClause = getHeritageClause(node.heritageClauses, SyntaxKind.ExtendsKeyword); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } From 0571c1989b6bc5d3cbce8ca474dad17b5674fae1 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 3 Jun 2016 15:07:20 -0700 Subject: [PATCH 16/90] Changes to display the error position correctly --- src/compiler/checker.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7ecb1e4867284..a88504c65cff2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14237,7 +14237,7 @@ namespace ts { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind !== SyntaxKind.Parameter) { - error(node, Diagnostics.Variable_0_has_never_been_used, key); + error(node.locals[key].valueDeclaration, Diagnostics.Variable_0_has_never_been_used, key); } } } @@ -14249,7 +14249,7 @@ namespace ts { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter && node.parent.kind !== SyntaxKind.InterfaceDeclaration) { - error(node, Diagnostics.Parameter_0_has_never_been_used, key); + error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); } } } @@ -14260,9 +14260,11 @@ namespace ts { if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { for (const key in node.locals) { if (!node.locals[key].hasReference && !node.locals[key].exportSymbol) { - if ((node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) - || (node.locals[key].declarations && node.locals[key].declarations[0].kind === SyntaxKind.InterfaceDeclaration)) { - error(node, Diagnostics.Variable_0_has_never_been_used, key); + if ((node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind)) { + error(node.locals[key].valueDeclaration, Diagnostics.Variable_0_has_never_been_used, key); + } + else if (node.locals[key].declarations && node.locals[key].declarations[0].kind === SyntaxKind.InterfaceDeclaration) { + error(node.locals[key].declarations[0], Diagnostics.Variable_0_has_never_been_used, key); } } } @@ -14276,7 +14278,7 @@ namespace ts { case SyntaxKind.MethodDeclaration: case SyntaxKind.PropertyDeclaration: if (isPrivateClassElement(node.members[i]) && !node.members[i].symbol.hasReference) { - error(node, Diagnostics.Variable_0_has_never_been_used, node.members[i].symbol.name); + error(node.members[i], Diagnostics.Variable_0_has_never_been_used, node.members[i].symbol.name); } break; default: @@ -14286,7 +14288,7 @@ namespace ts { for (let i = 0; node.typeParameters && i < node.typeParameters.length; i++) { if (!node.typeParameters[i].symbol.hasReference) { - error(node, Diagnostics.Variable_0_has_never_been_used, node.typeParameters[i].symbol.name); + error(node.typeParameters[i], Diagnostics.Variable_0_has_never_been_used, node.typeParameters[i].symbol.name); } } } From e17ed58a27bcd16516273c4eb981cef546bb4e59 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 3 Jun 2016 15:07:58 -0700 Subject: [PATCH 17/90] Compiler Test Cases --- .../unusedClassesinNamespace1.errors.txt | 12 ++ .../reference/unusedClassesinNamespace1.js | 17 ++ .../unusedClassesinNamespace2.errors.txt | 16 ++ .../reference/unusedClassesinNamespace2.js | 27 +++ .../reference/unusedClassesinNamespace3.js | 30 +++ .../unusedClassesinNamespace3.symbols | 19 ++ .../reference/unusedClassesinNamespace3.types | 20 ++ .../unusedClassesinNamespace4.errors.txt | 20 ++ .../reference/unusedClassesinNamespace4.js | 43 ++++ .../unusedClassesinNamespace5.errors.txt | 20 ++ .../reference/unusedClassesinNamespace5.js | 36 ++++ .../unusedFunctionsinNamespaces1.errors.txt | 11 ++ .../reference/unusedFunctionsinNamespaces1.js | 13 ++ .../unusedFunctionsinNamespaces2.errors.txt | 11 ++ .../reference/unusedFunctionsinNamespaces2.js | 13 ++ .../unusedFunctionsinNamespaces3.errors.txt | 14 ++ .../reference/unusedFunctionsinNamespaces3.js | 13 ++ .../unusedFunctionsinNamespaces4.errors.txt | 15 ++ .../reference/unusedFunctionsinNamespaces4.js | 20 ++ .../unusedFunctionsinNamespaces5.errors.txt | 26 +++ .../reference/unusedFunctionsinNamespaces5.js | 33 ++++ .../unusedFunctionsinNamespaces6.errors.txt | 25 +++ .../reference/unusedFunctionsinNamespaces6.js | 36 ++++ .../unusedIdentifiersConsolidated1.errors.txt | 153 ++++++++++++++ .../unusedIdentifiersConsolidated1.js | 187 ++++++++++++++++++ .../unusedInterfaceinNamespace1.errors.txt | 12 ++ .../reference/unusedInterfaceinNamespace1.js | 9 + .../unusedInterfaceinNamespace2.errors.txt | 16 ++ .../reference/unusedInterfaceinNamespace2.js | 13 ++ .../unusedInterfaceinNamespace3.errors.txt | 20 ++ .../reference/unusedInterfaceinNamespace3.js | 17 ++ .../reference/unusedInterfaceinNamespace4.js | 30 +++ .../unusedInterfaceinNamespace4.symbols | 27 +++ .../unusedInterfaceinNamespace4.types | 27 +++ .../reference/unusedInterfaceinNamespace5.js | 36 ++++ .../unusedInterfaceinNamespace5.symbols | 36 ++++ .../unusedInterfaceinNamespace5.types | 36 ++++ .../unusedLocalsInMethod1.errors.txt | 12 ++ .../reference/unusedLocalsInMethod1.js | 17 ++ .../unusedLocalsInMethod2.errors.txt | 13 ++ .../reference/unusedLocalsInMethod2.js | 19 ++ .../unusedLocalsInMethod3.errors.txt | 13 ++ .../reference/unusedLocalsInMethod3.js | 19 ++ ...ationWithinFunctionDeclaration1.errors.txt | 26 +++ ...onDeclarationWithinFunctionDeclaration1.js | 18 ++ ...ationWithinFunctionDeclaration2.errors.txt | 35 ++++ ...onDeclarationWithinFunctionDeclaration2.js | 24 +++ ...rationWithinFunctionExpression1.errors.txt | 26 +++ ...ionDeclarationWithinFunctionExpression1.js | 18 ++ ...rationWithinFunctionExpression2.errors.txt | 35 ++++ ...ionDeclarationWithinFunctionExpression2.js | 24 +++ ...ssionWithinFunctionDeclaration1.errors.txt | 26 +++ ...ionExpressionWithinFunctionDeclaration1.js | 18 ++ ...ssionWithinFunctionDeclaration2.errors.txt | 35 ++++ ...ionExpressionWithinFunctionDeclaration2.js | 24 +++ ...essionWithinFunctionExpression1.errors.txt | 26 +++ ...tionExpressionWithinFunctionExpression1.js | 18 ++ ...essionWithinFunctionExpression2.errors.txt | 35 ++++ ...tionExpressionWithinFunctionExpression2.js | 24 +++ .../unusedLocalsinConstructor1.errors.txt | 12 ++ .../reference/unusedLocalsinConstructor1.js | 15 ++ .../unusedLocalsinConstructor2.errors.txt | 14 ++ .../reference/unusedLocalsinConstructor2.js | 19 ++ ...dMultipleParameter1InContructor.errors.txt | 16 ++ .../unusedMultipleParameter1InContructor.js | 17 ++ ...eParameter1InFunctionExpression.errors.txt | 14 ++ ...dMultipleParameter1InFunctionExpression.js | 12 ++ ...dMultipleParameter2InContructor.errors.txt | 19 ++ .../unusedMultipleParameter2InContructor.js | 17 ++ ...eParameter2InFunctionExpression.errors.txt | 17 ++ ...dMultipleParameter2InFunctionExpression.js | 12 ++ ...arameters1InFunctionDeclaration.errors.txt | 14 ++ ...ultipleParameters1InFunctionDeclaration.js | 12 ++ ...eParameters1InMethodDeclaration.errors.txt | 16 ++ ...dMultipleParameters1InMethodDeclaration.js | 19 ++ ...arameters2InFunctionDeclaration.errors.txt | 17 ++ ...ultipleParameters2InFunctionDeclaration.js | 12 ++ ...eParameters2InMethodDeclaration.errors.txt | 19 ++ ...dMultipleParameters2InMethodDeclaration.js | 19 ++ .../unusedParametersinConstructor1.errors.txt | 11 ++ .../unusedParametersinConstructor1.js | 13 ++ .../unusedParametersinConstructor2.errors.txt | 12 ++ .../unusedParametersinConstructor2.js | 15 ++ .../unusedParametersinConstructor3.errors.txt | 15 ++ .../unusedParametersinConstructor3.js | 15 ++ .../unusedPrivateMethodInClass1.errors.txt | 13 ++ .../reference/unusedPrivateMethodInClass1.js | 19 ++ .../unusedPrivateMethodInClass2.errors.txt | 21 ++ .../reference/unusedPrivateMethodInClass2.js | 28 +++ .../unusedPrivateMethodInClass3.errors.txt | 26 +++ .../reference/unusedPrivateMethodInClass3.js | 37 ++++ .../unusedPrivateMethodInClass4.errors.txt | 24 +++ .../reference/unusedPrivateMethodInClass4.js | 39 ++++ .../unusedPrivateVariableInClass1.errors.txt | 10 + .../unusedPrivateVariableInClass1.js | 12 ++ .../unusedPrivateVariableInClass2.errors.txt | 14 ++ .../unusedPrivateVariableInClass2.js | 13 ++ .../unusedPrivateVariableInClass3.errors.txt | 15 ++ .../unusedPrivateVariableInClass3.js | 14 ++ .../unusedPrivateVariableInClass4.errors.txt | 16 ++ .../unusedPrivateVariableInClass4.js | 21 ++ .../unusedPrivateVariableInClass5.errors.txt | 16 ++ .../unusedPrivateVariableInClass5.js | 19 ++ ...usedSingleParameterInContructor.errors.txt | 15 ++ .../unusedSingleParameterInContructor.js | 15 ++ ...eParameterInFunctionDeclaration.errors.txt | 13 ++ ...sedSingleParameterInFunctionDeclaration.js | 10 + ...leParameterInFunctionExpression.errors.txt | 13 ++ ...usedSingleParameterInFunctionExpression.js | 10 + ...gleParameterInMethodDeclaration.errors.txt | 15 ++ ...nusedSingleParameterInMethodDeclaration.js | 17 ++ .../unusedTypeParameters1.errors.txt | 10 + .../reference/unusedTypeParameters1.js | 12 ++ .../unusedTypeParameters2.errors.txt | 14 ++ .../reference/unusedTypeParameters2.js | 19 ++ .../unusedTypeParameters3.errors.txt | 17 ++ .../reference/unusedTypeParameters3.js | 19 ++ .../unusedVariablesinNamespaces1.errors.txt | 10 + .../reference/unusedVariablesinNamespaces1.js | 11 ++ .../unusedVariablesinNamespaces2.errors.txt | 17 ++ .../reference/unusedVariablesinNamespaces2.js | 28 +++ .../unusedVariablesinNamespaces3.errors.txt | 18 ++ .../reference/unusedVariablesinNamespaces3.js | 30 +++ .../compiler/unusedClassesinNamespace1.ts | 8 + .../compiler/unusedClassesinNamespace2.ts | 12 ++ .../compiler/unusedClassesinNamespace3.ts | 14 ++ .../compiler/unusedClassesinNamespace4.ts | 16 ++ .../compiler/unusedClassesinNamespace5.ts | 16 ++ .../compiler/unusedFunctionsinNamespaces1.ts | 7 + .../compiler/unusedFunctionsinNamespaces2.ts | 7 + .../compiler/unusedFunctionsinNamespaces3.ts | 7 + .../compiler/unusedFunctionsinNamespaces4.ts | 11 ++ .../compiler/unusedFunctionsinNamespaces5.ts | 19 ++ .../compiler/unusedFunctionsinNamespaces6.ts | 21 ++ .../unusedIdentifiersConsolidated1.ts | 104 ++++++++++ .../compiler/unusedInterfaceinNamespace1.ts | 8 + .../compiler/unusedInterfaceinNamespace2.ts | 12 ++ .../compiler/unusedInterfaceinNamespace3.ts | 16 ++ .../compiler/unusedInterfaceinNamespace4.ts | 20 ++ .../compiler/unusedInterfaceinNamespace5.ts | 26 +++ tests/cases/compiler/unusedLocalsInMethod1.ts | 8 + tests/cases/compiler/unusedLocalsInMethod2.ts | 9 + tests/cases/compiler/unusedLocalsInMethod3.ts | 9 + ...onDeclarationWithinFunctionDeclaration1.ts | 10 + ...onDeclarationWithinFunctionDeclaration2.ts | 13 ++ ...ionDeclarationWithinFunctionExpression1.ts | 10 + ...ionDeclarationWithinFunctionExpression2.ts | 13 ++ ...ionExpressionWithinFunctionDeclaration1.ts | 10 + ...ionExpressionWithinFunctionDeclaration2.ts | 13 ++ ...tionExpressionWithinFunctionExpression1.ts | 10 + ...tionExpressionWithinFunctionExpression2.ts | 13 ++ .../compiler/unusedLocalsinConstructor1.ts | 8 + .../compiler/unusedLocalsinConstructor2.ts | 10 + .../unusedMultipleParameter1InContructor.ts | 9 + ...dMultipleParameter1InFunctionExpression.ts | 7 + .../unusedMultipleParameter2InContructor.ts | 9 + ...dMultipleParameter2InFunctionExpression.ts | 7 + ...ultipleParameters1InFunctionDeclaration.ts | 7 + ...dMultipleParameters1InMethodDeclaration.ts | 9 + ...ultipleParameters2InFunctionDeclaration.ts | 7 + ...dMultipleParameters2InMethodDeclaration.ts | 9 + .../unusedParametersinConstructor1.ts | 7 + .../unusedParametersinConstructor2.ts | 8 + .../unusedParametersinConstructor3.ts | 8 + .../compiler/unusedPrivateMethodInClass1.ts | 9 + .../compiler/unusedPrivateMethodInClass2.ts | 14 ++ .../compiler/unusedPrivateMethodInClass3.ts | 19 ++ .../compiler/unusedPrivateMethodInClass4.ts | 20 ++ .../compiler/unusedPrivateVariableInClass1.ts | 6 + .../compiler/unusedPrivateVariableInClass2.ts | 7 + .../compiler/unusedPrivateVariableInClass3.ts | 8 + .../compiler/unusedPrivateVariableInClass4.ts | 12 ++ .../compiler/unusedPrivateVariableInClass5.ts | 12 ++ .../unusedSingleParameterInContructor.ts | 8 + ...sedSingleParameterInFunctionDeclaration.ts | 6 + ...usedSingleParameterInFunctionExpression.ts | 6 + ...nusedSingleParameterInMethodDeclaration.ts | 8 + tests/cases/compiler/unusedTypeParameters1.ts | 6 + tests/cases/compiler/unusedTypeParameters2.ts | 10 + tests/cases/compiler/unusedTypeParameters3.ts | 10 + .../compiler/unusedVariablesinNamespaces1.ts | 6 + .../compiler/unusedVariablesinNamespaces2.ts | 13 ++ .../compiler/unusedVariablesinNamespaces3.ts | 14 ++ 183 files changed, 3418 insertions(+) create mode 100644 tests/baselines/reference/unusedClassesinNamespace1.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinNamespace1.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace2.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinNamespace2.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace3.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace3.symbols create mode 100644 tests/baselines/reference/unusedClassesinNamespace3.types create mode 100644 tests/baselines/reference/unusedClassesinNamespace4.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinNamespace4.js create mode 100644 tests/baselines/reference/unusedClassesinNamespace5.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinNamespace5.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces1.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces2.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces3.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces4.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces5.js create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt create mode 100644 tests/baselines/reference/unusedFunctionsinNamespaces6.js create mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt create mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace1.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace2.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace3.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace4.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace4.symbols create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace4.types create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace5.js create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace5.symbols create mode 100644 tests/baselines/reference/unusedInterfaceinNamespace5.types create mode 100644 tests/baselines/reference/unusedLocalsInMethod1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsInMethod1.js create mode 100644 tests/baselines/reference/unusedLocalsInMethod2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsInMethod2.js create mode 100644 tests/baselines/reference/unusedLocalsInMethod3.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsInMethod3.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js create mode 100644 tests/baselines/reference/unusedLocalsinConstructor1.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsinConstructor1.js create mode 100644 tests/baselines/reference/unusedLocalsinConstructor2.errors.txt create mode 100644 tests/baselines/reference/unusedLocalsinConstructor2.js create mode 100644 tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter1InContructor.js create mode 100644 tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.js create mode 100644 tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter2InContructor.js create mode 100644 tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.js create mode 100644 tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.js create mode 100644 tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.js create mode 100644 tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.js create mode 100644 tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor1.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor1.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor2.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor2.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor3.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor3.js create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass1.js create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass2.js create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass3.js create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateMethodInClass4.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass1.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass2.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass3.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass4.js create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt create mode 100644 tests/baselines/reference/unusedPrivateVariableInClass5.js create mode 100644 tests/baselines/reference/unusedSingleParameterInContructor.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInContructor.js create mode 100644 tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.js create mode 100644 tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInFunctionExpression.js create mode 100644 tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInMethodDeclaration.js create mode 100644 tests/baselines/reference/unusedTypeParameters1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters1.js create mode 100644 tests/baselines/reference/unusedTypeParameters2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters2.js create mode 100644 tests/baselines/reference/unusedTypeParameters3.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters3.js create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces1.js create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces2.js create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinNamespaces3.js create mode 100644 tests/cases/compiler/unusedClassesinNamespace1.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace2.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace3.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace4.ts create mode 100644 tests/cases/compiler/unusedClassesinNamespace5.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces1.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces2.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces3.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces4.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces5.ts create mode 100644 tests/cases/compiler/unusedFunctionsinNamespaces6.ts create mode 100644 tests/cases/compiler/unusedIdentifiersConsolidated1.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace1.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace2.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace3.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace4.ts create mode 100644 tests/cases/compiler/unusedInterfaceinNamespace5.ts create mode 100644 tests/cases/compiler/unusedLocalsInMethod1.ts create mode 100644 tests/cases/compiler/unusedLocalsInMethod2.ts create mode 100644 tests/cases/compiler/unusedLocalsInMethod3.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts create mode 100644 tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts create mode 100644 tests/cases/compiler/unusedLocalsinConstructor1.ts create mode 100644 tests/cases/compiler/unusedLocalsinConstructor2.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter1InContructor.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter2InContructor.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts create mode 100644 tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts create mode 100644 tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts create mode 100644 tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts create mode 100644 tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor1.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor2.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor3.ts create mode 100644 tests/cases/compiler/unusedPrivateMethodInClass1.ts create mode 100644 tests/cases/compiler/unusedPrivateMethodInClass2.ts create mode 100644 tests/cases/compiler/unusedPrivateMethodInClass3.ts create mode 100644 tests/cases/compiler/unusedPrivateMethodInClass4.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass1.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass2.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass3.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass4.ts create mode 100644 tests/cases/compiler/unusedPrivateVariableInClass5.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInContructor.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts create mode 100644 tests/cases/compiler/unusedTypeParameters1.ts create mode 100644 tests/cases/compiler/unusedTypeParameters2.ts create mode 100644 tests/cases/compiler/unusedTypeParameters3.ts create mode 100644 tests/cases/compiler/unusedVariablesinNamespaces1.ts create mode 100644 tests/cases/compiler/unusedVariablesinNamespaces2.ts create mode 100644 tests/cases/compiler/unusedVariablesinNamespaces3.ts diff --git a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt new file mode 100644 index 0000000000000..eea58a29d7ff3 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): message TS6132: Variable 'c1' has never been used. + + +==== tests/cases/compiler/unusedClassesinNamespace1.ts (1 errors) ==== + + namespace Validation { + class c1 { + ~~ +!!! message TS6132: Variable 'c1' has never been used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace1.js b/tests/baselines/reference/unusedClassesinNamespace1.js new file mode 100644 index 0000000000000..e49b9019a2843 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace1.js @@ -0,0 +1,17 @@ +//// [unusedClassesinNamespace1.ts] + +namespace Validation { + class c1 { + + } +} + +//// [unusedClassesinNamespace1.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt new file mode 100644 index 0000000000000..b3520e3047395 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): message TS6132: Variable 'c1' has never been used. + + +==== tests/cases/compiler/unusedClassesinNamespace2.ts (1 errors) ==== + + namespace Validation { + class c1 { + ~~ +!!! message TS6132: Variable 'c1' has never been used. + + } + + export class c2 { + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace2.js b/tests/baselines/reference/unusedClassesinNamespace2.js new file mode 100644 index 0000000000000..03431e4fd0412 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace2.js @@ -0,0 +1,27 @@ +//// [unusedClassesinNamespace2.ts] + +namespace Validation { + class c1 { + + } + + export class c2 { + + } +} + +//// [unusedClassesinNamespace2.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + var c2 = (function () { + function c2() { + } + return c2; + }()); + Validation.c2 = c2; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace3.js b/tests/baselines/reference/unusedClassesinNamespace3.js new file mode 100644 index 0000000000000..bdb646e87b20a --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace3.js @@ -0,0 +1,30 @@ +//// [unusedClassesinNamespace3.ts] + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + export let a = new c1(); +} + +//// [unusedClassesinNamespace3.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + var c2 = (function () { + function c2() { + } + return c2; + }()); + Validation.c2 = c2; + Validation.a = new c1(); +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace3.symbols b/tests/baselines/reference/unusedClassesinNamespace3.symbols new file mode 100644 index 0000000000000..d8eeb0b54600e --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace3.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/unusedClassesinNamespace3.ts === + +namespace Validation { +>Validation : Symbol(Validation, Decl(unusedClassesinNamespace3.ts, 0, 0)) + + class c1 { +>c1 : Symbol(c1, Decl(unusedClassesinNamespace3.ts, 1, 22)) + + } + + export class c2 { +>c2 : Symbol(c2, Decl(unusedClassesinNamespace3.ts, 4, 5)) + + } + + export let a = new c1(); +>a : Symbol(a, Decl(unusedClassesinNamespace3.ts, 10, 14)) +>c1 : Symbol(c1, Decl(unusedClassesinNamespace3.ts, 1, 22)) +} diff --git a/tests/baselines/reference/unusedClassesinNamespace3.types b/tests/baselines/reference/unusedClassesinNamespace3.types new file mode 100644 index 0000000000000..cef64a4c4e3be --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace3.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/unusedClassesinNamespace3.ts === + +namespace Validation { +>Validation : typeof Validation + + class c1 { +>c1 : c1 + + } + + export class c2 { +>c2 : c2 + + } + + export let a = new c1(); +>a : c1 +>new c1() : c1 +>c1 : typeof c1 +} diff --git a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt new file mode 100644 index 0000000000000..bd4f46bbd6484 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): message TS6132: Variable 'c3' has never been used. + + +==== tests/cases/compiler/unusedClassesinNamespace4.ts (1 errors) ==== + + namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 extends c1 { + ~~ +!!! message TS6132: Variable 'c3' has never been used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace4.js b/tests/baselines/reference/unusedClassesinNamespace4.js new file mode 100644 index 0000000000000..65198c1c1aa7e --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace4.js @@ -0,0 +1,43 @@ +//// [unusedClassesinNamespace4.ts] + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 extends c1 { + + } +} + +//// [unusedClassesinNamespace4.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + var c2 = (function () { + function c2() { + } + return c2; + }()); + Validation.c2 = c2; + var c3 = (function (_super) { + __extends(c3, _super); + function c3() { + _super.apply(this, arguments); + } + return c3; + }(c1)); +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt new file mode 100644 index 0000000000000..81cbad6e11515 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): message TS6132: Variable 'c3' has never been used. + + +==== tests/cases/compiler/unusedClassesinNamespace5.ts (1 errors) ==== + + namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 { + ~~ +!!! message TS6132: Variable 'c3' has never been used. + public x: c1; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace5.js b/tests/baselines/reference/unusedClassesinNamespace5.js new file mode 100644 index 0000000000000..037a3564bd78c --- /dev/null +++ b/tests/baselines/reference/unusedClassesinNamespace5.js @@ -0,0 +1,36 @@ +//// [unusedClassesinNamespace5.ts] + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 { + public x: c1; + } +} + +//// [unusedClassesinNamespace5.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + var c2 = (function () { + function c2() { + } + return c2; + }()); + Validation.c2 = c2; + var c3 = (function () { + function c3() { + } + return c3; + }()); +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt new file mode 100644 index 0000000000000..6f02e5c2f9f8c --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): message TS6132: Variable 'function1' has never been used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces1.ts (1 errors) ==== + + namespace Validation { + function function1() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function1' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.js b/tests/baselines/reference/unusedFunctionsinNamespaces1.js new file mode 100644 index 0000000000000..a6eec74b1f5ec --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.js @@ -0,0 +1,13 @@ +//// [unusedFunctionsinNamespaces1.ts] + +namespace Validation { + function function1() { + } +} + +//// [unusedFunctionsinNamespaces1.js] +var Validation; +(function (Validation) { + function function1() { + } +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt new file mode 100644 index 0000000000000..e956ea08a03c2 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): message TS6132: Variable 'function1' has never been used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces2.ts (1 errors) ==== + + namespace Validation { + var function1 = function() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function1' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.js b/tests/baselines/reference/unusedFunctionsinNamespaces2.js new file mode 100644 index 0000000000000..c908e38e7a64c --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.js @@ -0,0 +1,13 @@ +//// [unusedFunctionsinNamespaces2.ts] + +namespace Validation { + var function1 = function() { + } +} + +//// [unusedFunctionsinNamespaces2.js] +var Validation; +(function (Validation) { + var function1 = function () { + }; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt new file mode 100644 index 0000000000000..d375fb6026204 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,9): message TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): message TS6133: Parameter 'param1' has never been used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces3.ts (2 errors) ==== + + namespace Validation { + var function1 = function(param1:string) { + ~~~~~~~~~ +!!! message TS6132: Variable 'function1' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param1' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.js b/tests/baselines/reference/unusedFunctionsinNamespaces3.js new file mode 100644 index 0000000000000..5501ed62a6f27 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.js @@ -0,0 +1,13 @@ +//// [unusedFunctionsinNamespaces3.ts] + +namespace Validation { + var function1 = function(param1:string) { + } +} + +//// [unusedFunctionsinNamespaces3.js] +var Validation; +(function (Validation) { + var function1 = function (param1) { + }; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt new file mode 100644 index 0000000000000..f4bccdd6df609 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): message TS6132: Variable 'function1' has never been used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces4.ts (1 errors) ==== + + namespace Validation { + var function1 = function() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function1' has never been used. + } + + export function function2() { + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.js b/tests/baselines/reference/unusedFunctionsinNamespaces4.js new file mode 100644 index 0000000000000..41557a6204504 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.js @@ -0,0 +1,20 @@ +//// [unusedFunctionsinNamespaces4.ts] + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } +} + +//// [unusedFunctionsinNamespaces4.js] +var Validation; +(function (Validation) { + var function1 = function () { + }; + function function2() { + } + Validation.function2 = function2; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt new file mode 100644 index 0000000000000..5f76bec8356c8 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(10,14): message TS6132: Variable 'function3' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): message TS6132: Variable 'function4' has never been used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces5.ts (2 errors) ==== + + namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function3' has never been used. + function1(); + } + + function function4() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function4' has never been used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.js b/tests/baselines/reference/unusedFunctionsinNamespaces5.js new file mode 100644 index 0000000000000..4023876b359cc --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.js @@ -0,0 +1,33 @@ +//// [unusedFunctionsinNamespaces5.ts] + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + + } +} + +//// [unusedFunctionsinNamespaces5.js] +var Validation; +(function (Validation) { + var function1 = function () { + }; + function function2() { + } + Validation.function2 = function2; + function function3() { + function1(); + } + function function4() { + } +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt new file mode 100644 index 0000000000000..08dc040017d71 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): message TS6132: Variable 'function4' has never been used. + + +==== tests/cases/compiler/unusedFunctionsinNamespaces6.ts (1 errors) ==== + + namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function4' has never been used. + + } + + export let a = function3; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.js b/tests/baselines/reference/unusedFunctionsinNamespaces6.js new file mode 100644 index 0000000000000..81ff5d9ea54e5 --- /dev/null +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.js @@ -0,0 +1,36 @@ +//// [unusedFunctionsinNamespaces6.ts] + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + + } + + export let a = function3; +} + +//// [unusedFunctionsinNamespaces6.js] +var Validation; +(function (Validation) { + var function1 = function () { + }; + function function2() { + } + Validation.function2 = function2; + function function3() { + function1(); + } + function function4() { + } + Validation.a = function3; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt new file mode 100644 index 0000000000000..27ec7d90821da --- /dev/null +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -0,0 +1,153 @@ +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): message TS6132: Variable 'unusedtypeparameter' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): message TS6132: Variable 'unusedprivatevariable' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): message TS6133: Parameter 'message' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): message TS6132: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): message TS6132: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): message TS6132: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): message TS6132: Variable 'usedLocallyInterface2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): message TS6132: Variable 'dummy' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): message TS6132: Variable 'unusedInterface' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): message TS6132: Variable 'class3' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: Variable 'interface5' has never been used. + + +==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== + + function greeter(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } + + class Dummy { + ~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedtypeparameter' has never been used. + private unusedprivatevariable: string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedprivatevariable' has never been used. + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + ~~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'message' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. + } + } + + var user = "Jane User"; + var user2 = "Jane2 User2"; + + namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + ~~~~~~~~~~~~ +!!! message TS6132: Variable 'numberRegexp' has never been used. + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'usedLocallyInterface2' has never been used. + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + ~~~~~ +!!! message TS6132: Variable 'dummy' has never been used. + } + + interface unusedInterface { + ~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedInterface' has never been used. + } + } + + + namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + ~~~~~~ +!!! message TS6132: Variable 'class3' has never been used. + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + ~~~~~~~~~~ +!!! message TS6132: Variable 'interface5' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.js b/tests/baselines/reference/unusedIdentifiersConsolidated1.js new file mode 100644 index 0000000000000..521f17bf5ef7e --- /dev/null +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.js @@ -0,0 +1,187 @@ +//// [unusedIdentifiersConsolidated1.ts] + +function greeter(person: string) { + var unused = 20; +} + +class Dummy { + private unusedprivatevariable: string; + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + var unused = 20; + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + } +} + +var user = "Jane User"; +var user2 = "Jane2 User2"; + +namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + } + + interface unusedInterface { + } +} + + +namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + } +} + +//// [unusedIdentifiersConsolidated1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +function greeter(person) { + var unused = 20; +} +var Dummy = (function () { + function Dummy(message) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + Dummy.prototype.greeter = function (person) { + var unused = 20; + this.usedPrivateFunction(); + }; + Dummy.prototype.usedPrivateFunction = function () { + }; + Dummy.prototype.unUsedPrivateFunction = function () { + }; + return Dummy; +}()); +var user = "Jane User"; +var user2 = "Jane2 User2"; +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; + var numberRegexp = /^[0-9]+$/; + var LettersOnlyValidator = (function () { + function LettersOnlyValidator() { + } + LettersOnlyValidator.prototype.isAcceptable = function (s2) { + return lettersRegexp.test(s2); + }; + LettersOnlyValidator.prototype.unUsedPrivateFunction = function () { + }; + return LettersOnlyValidator; + }()); + Validation.LettersOnlyValidator = LettersOnlyValidator; + var ZipCodeValidator = (function () { + function ZipCodeValidator() { + } + ZipCodeValidator.prototype.isAcceptable = function (s3) { + return s3.length === 5; + }; + return ZipCodeValidator; + }()); + Validation.ZipCodeValidator = ZipCodeValidator; + var dummy = (function () { + function dummy() { + } + return dummy; + }()); +})(Validation || (Validation = {})); +var Greeter; +(function (Greeter) { + var class1 = (function () { + function class1() { + } + return class1; + }()); + var class2 = (function (_super) { + __extends(class2, _super); + function class2() { + _super.apply(this, arguments); + } + return class2; + }(class1)); + Greeter.class2 = class2; + var class3 = (function () { + function class3() { + } + return class3; + }()); + var class4 = (function () { + function class4() { + } + return class4; + }()); + Greeter.class4 = class4; +})(Greeter || (Greeter = {})); diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt new file mode 100644 index 0000000000000..fb56fe108ec3d --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): message TS6132: Variable 'i1' has never been used. + + +==== tests/cases/compiler/unusedInterfaceinNamespace1.ts (1 errors) ==== + + namespace Validation { + interface i1 { + ~~ +!!! message TS6132: Variable 'i1' has never been used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.js b/tests/baselines/reference/unusedInterfaceinNamespace1.js new file mode 100644 index 0000000000000..8b4334c13c798 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.js @@ -0,0 +1,9 @@ +//// [unusedInterfaceinNamespace1.ts] + +namespace Validation { + interface i1 { + + } +} + +//// [unusedInterfaceinNamespace1.js] diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt new file mode 100644 index 0000000000000..0ec233548818b --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): message TS6132: Variable 'i1' has never been used. + + +==== tests/cases/compiler/unusedInterfaceinNamespace2.ts (1 errors) ==== + + namespace Validation { + interface i1 { + ~~ +!!! message TS6132: Variable 'i1' has never been used. + + } + + export interface i2 { + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.js b/tests/baselines/reference/unusedInterfaceinNamespace2.js new file mode 100644 index 0000000000000..fbec39921d363 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.js @@ -0,0 +1,13 @@ +//// [unusedInterfaceinNamespace2.ts] + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } +} + +//// [unusedInterfaceinNamespace2.js] diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt new file mode 100644 index 0000000000000..7f6abaa11b070 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt @@ -0,0 +1,20 @@ +tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): message TS6132: Variable 'i3' has never been used. + + +==== tests/cases/compiler/unusedInterfaceinNamespace3.ts (1 errors) ==== + + namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + ~~ +!!! message TS6132: Variable 'i3' has never been used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.js b/tests/baselines/reference/unusedInterfaceinNamespace3.js new file mode 100644 index 0000000000000..7409a3d862398 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.js @@ -0,0 +1,17 @@ +//// [unusedInterfaceinNamespace3.ts] + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } +} + +//// [unusedInterfaceinNamespace3.js] diff --git a/tests/baselines/reference/unusedInterfaceinNamespace4.js b/tests/baselines/reference/unusedInterfaceinNamespace4.js new file mode 100644 index 0000000000000..51e09a1565bc8 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace4.js @@ -0,0 +1,30 @@ +//// [unusedInterfaceinNamespace4.ts] + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } + + export class c1 implements i3 { + + } +} + +//// [unusedInterfaceinNamespace4.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + Validation.c1 = c1; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedInterfaceinNamespace4.symbols b/tests/baselines/reference/unusedInterfaceinNamespace4.symbols new file mode 100644 index 0000000000000..90b2ff5df7028 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace4.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/unusedInterfaceinNamespace4.ts === + +namespace Validation { +>Validation : Symbol(Validation, Decl(unusedInterfaceinNamespace4.ts, 0, 0)) + + interface i1 { +>i1 : Symbol(i1, Decl(unusedInterfaceinNamespace4.ts, 1, 22)) + + } + + export interface i2 { +>i2 : Symbol(i2, Decl(unusedInterfaceinNamespace4.ts, 4, 5)) + + } + + interface i3 extends i1 { +>i3 : Symbol(i3, Decl(unusedInterfaceinNamespace4.ts, 8, 5)) +>i1 : Symbol(i1, Decl(unusedInterfaceinNamespace4.ts, 1, 22)) + + } + + export class c1 implements i3 { +>c1 : Symbol(c1, Decl(unusedInterfaceinNamespace4.ts, 12, 5)) +>i3 : Symbol(i3, Decl(unusedInterfaceinNamespace4.ts, 8, 5)) + + } +} diff --git a/tests/baselines/reference/unusedInterfaceinNamespace4.types b/tests/baselines/reference/unusedInterfaceinNamespace4.types new file mode 100644 index 0000000000000..1b1efebb299ae --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace4.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/unusedInterfaceinNamespace4.ts === + +namespace Validation { +>Validation : typeof Validation + + interface i1 { +>i1 : i1 + + } + + export interface i2 { +>i2 : i2 + + } + + interface i3 extends i1 { +>i3 : i3 +>i1 : i1 + + } + + export class c1 implements i3 { +>c1 : c1 +>i3 : i3 + + } +} diff --git a/tests/baselines/reference/unusedInterfaceinNamespace5.js b/tests/baselines/reference/unusedInterfaceinNamespace5.js new file mode 100644 index 0000000000000..bb29b33ebca2c --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace5.js @@ -0,0 +1,36 @@ +//// [unusedInterfaceinNamespace5.ts] + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } + + export class c1 implements i3 { + + } + + interface i4 { + + } + + export let c2:i4; +} + +//// [unusedInterfaceinNamespace5.js] +var Validation; +(function (Validation) { + var c1 = (function () { + function c1() { + } + return c1; + }()); + Validation.c1 = c1; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedInterfaceinNamespace5.symbols b/tests/baselines/reference/unusedInterfaceinNamespace5.symbols new file mode 100644 index 0000000000000..156dc9a3ef14a --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace5.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/unusedInterfaceinNamespace5.ts === + +namespace Validation { +>Validation : Symbol(Validation, Decl(unusedInterfaceinNamespace5.ts, 0, 0)) + + interface i1 { +>i1 : Symbol(i1, Decl(unusedInterfaceinNamespace5.ts, 1, 22)) + + } + + export interface i2 { +>i2 : Symbol(i2, Decl(unusedInterfaceinNamespace5.ts, 4, 5)) + + } + + interface i3 extends i1 { +>i3 : Symbol(i3, Decl(unusedInterfaceinNamespace5.ts, 8, 5)) +>i1 : Symbol(i1, Decl(unusedInterfaceinNamespace5.ts, 1, 22)) + + } + + export class c1 implements i3 { +>c1 : Symbol(c1, Decl(unusedInterfaceinNamespace5.ts, 12, 5)) +>i3 : Symbol(i3, Decl(unusedInterfaceinNamespace5.ts, 8, 5)) + + } + + interface i4 { +>i4 : Symbol(i4, Decl(unusedInterfaceinNamespace5.ts, 16, 5)) + + } + + export let c2:i4; +>c2 : Symbol(c2, Decl(unusedInterfaceinNamespace5.ts, 22, 14)) +>i4 : Symbol(i4, Decl(unusedInterfaceinNamespace5.ts, 16, 5)) +} diff --git a/tests/baselines/reference/unusedInterfaceinNamespace5.types b/tests/baselines/reference/unusedInterfaceinNamespace5.types new file mode 100644 index 0000000000000..db896be80ae72 --- /dev/null +++ b/tests/baselines/reference/unusedInterfaceinNamespace5.types @@ -0,0 +1,36 @@ +=== tests/cases/compiler/unusedInterfaceinNamespace5.ts === + +namespace Validation { +>Validation : typeof Validation + + interface i1 { +>i1 : i1 + + } + + export interface i2 { +>i2 : i2 + + } + + interface i3 extends i1 { +>i3 : i3 +>i1 : i1 + + } + + export class c1 implements i3 { +>c1 : c1 +>i3 : i3 + + } + + interface i4 { +>i4 : i4 + + } + + export let c2:i4; +>c2 : i4 +>i4 : i4 +} diff --git a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt new file mode 100644 index 0000000000000..2e6c31edd4ce1 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): message TS6132: Variable 'x' has never been used. + + +==== tests/cases/compiler/unusedLocalsInMethod1.ts (1 errors) ==== + + class greeter { + public function1() { + var x = 10; + ~ +!!! message TS6132: Variable 'x' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod1.js b/tests/baselines/reference/unusedLocalsInMethod1.js new file mode 100644 index 0000000000000..7f2e555ab62c1 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod1.js @@ -0,0 +1,17 @@ +//// [unusedLocalsInMethod1.ts] + +class greeter { + public function1() { + var x = 10; + } +} + +//// [unusedLocalsInMethod1.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var x = 10; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt new file mode 100644 index 0000000000000..104700882aa15 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): message TS6132: Variable 'x' has never been used. + + +==== tests/cases/compiler/unusedLocalsInMethod2.ts (1 errors) ==== + + class greeter { + public function1() { + var x, y = 10; + ~ +!!! message TS6132: Variable 'x' has never been used. + y++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod2.js b/tests/baselines/reference/unusedLocalsInMethod2.js new file mode 100644 index 0000000000000..b92de2497507c --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod2.js @@ -0,0 +1,19 @@ +//// [unusedLocalsInMethod2.ts] + +class greeter { + public function1() { + var x, y = 10; + y++; + } +} + +//// [unusedLocalsInMethod2.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var x, y = 10; + y++; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt new file mode 100644 index 0000000000000..4859b2256e00e --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): message TS6132: Variable 'x' has never been used. + + +==== tests/cases/compiler/unusedLocalsInMethod3.ts (1 errors) ==== + + class greeter { + public function1() { + var x, y; + ~ +!!! message TS6132: Variable 'x' has never been used. + y = 1; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod3.js b/tests/baselines/reference/unusedLocalsInMethod3.js new file mode 100644 index 0000000000000..ff148f7a78fff --- /dev/null +++ b/tests/baselines/reference/unusedLocalsInMethod3.js @@ -0,0 +1,19 @@ +//// [unusedLocalsInMethod3.ts] + +class greeter { + public function1() { + var x, y; + y = 1; + } +} + +//// [unusedLocalsInMethod3.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var x, y; + y = 1; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt new file mode 100644 index 0000000000000..36281a919089a --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,14): message TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,20): message TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(5,13): message TS6132: Variable 'unused2' has never been used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + function maker(child: string): void { + ~~~~~ +!!! message TS6132: Variable 'maker' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js new file mode 100644 index 0000000000000..a8da9dcfa8781 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js @@ -0,0 +1,18 @@ +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.js] +function greeter(person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + person2 = "dummy value"; +} diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt new file mode 100644 index 0000000000000..cb4521998e850 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,14): message TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,20): message TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(5,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,21): message TS6133: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(8,13): message TS6132: Variable 'unused3' has never been used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts (7 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + function maker(child: string): void { + ~~~~~ +!!! message TS6132: Variable 'maker' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + } + function maker2(child2: string): void { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child2' has never been used. + var unused3 = 23; + ~~~~~~~ +!!! message TS6132: Variable 'unused3' has never been used. + } + maker2(person2); + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js new file mode 100644 index 0000000000000..28b5057d6409a --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js @@ -0,0 +1,24 @@ +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + function maker2(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.js] +function greeter(person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + function maker2(child2) { + var unused3 = 23; + } + maker2(person2); +} diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt new file mode 100644 index 0000000000000..509e83e8c624d --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,25): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,14): message TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,20): message TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(5,13): message TS6132: Variable 'unused2' has never been used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (5 errors) ==== + + var greeter = function (person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + function maker(child: string): void { + ~~~~~ +!!! message TS6132: Variable 'maker' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js new file mode 100644 index 0000000000000..b9c7649323900 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js @@ -0,0 +1,18 @@ +//// [unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts] + +var greeter = function (person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.js] +var greeter = function (person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + person2 = "dummy value"; +}; diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt new file mode 100644 index 0000000000000..10610f397fc59 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,25): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,14): message TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,20): message TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(5,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,21): message TS6133: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(8,13): message TS6132: Variable 'unused3' has never been used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts (7 errors) ==== + + var greeter = function (person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + function maker(child: string): void { + ~~~~~ +!!! message TS6132: Variable 'maker' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + } + function maker2(child2: string): void { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child2' has never been used. + var unused3 = 23; + ~~~~~~~ +!!! message TS6132: Variable 'unused3' has never been used. + } + maker2(person2); + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js new file mode 100644 index 0000000000000..e7930da686c13 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js @@ -0,0 +1,24 @@ +//// [unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts] + +var greeter = function (person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + function maker2(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} + +//// [unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.js] +var greeter = function (person, person2) { + var unused = 20; + function maker(child) { + var unused2 = 22; + } + function maker2(child2) { + var unused3 = 23; + } + maker2(person2); +}; diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt new file mode 100644 index 0000000000000..4265702a17c05 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,9): message TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,27): message TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(5,13): message TS6132: Variable 'unused2' has never been used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (5 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + var maker = function (child: string): void { + ~~~~~ +!!! message TS6132: Variable 'maker' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js new file mode 100644 index 0000000000000..880053a8667b4 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js @@ -0,0 +1,18 @@ +//// [unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.js] +function greeter(person, person2) { + var unused = 20; + var maker = function (child) { + var unused2 = 22; + }; + person2 = "dummy value"; +} diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt new file mode 100644 index 0000000000000..586dab0eb0aed --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,9): message TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,26): message TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(5,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,27): message TS6133: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(8,13): message TS6132: Variable 'unused3' has never been used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts (7 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + var maker = function(child: string): void { + ~~~~~ +!!! message TS6132: Variable 'maker' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + } + var maker2 = function(child2: string): void { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child2' has never been used. + var unused3 = 23; + ~~~~~~~ +!!! message TS6132: Variable 'unused3' has never been used. + } + maker2(person2); + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js new file mode 100644 index 0000000000000..fb37bf9cb5a9b --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js @@ -0,0 +1,24 @@ +//// [unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + var maker = function(child: string): void { + var unused2 = 22; + } + var maker2 = function(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} + +//// [unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.js] +function greeter(person, person2) { + var unused = 20; + var maker = function (child) { + var unused2 = 22; + }; + var maker2 = function (child2) { + var unused3 = 23; + }; + maker2(person2); +} diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt new file mode 100644 index 0000000000000..86a461ce6c781 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,25): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,9): message TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,27): message TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(5,13): message TS6132: Variable 'unused2' has never been used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (5 errors) ==== + + var greeter = function (person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + var maker = function (child: string): void { + ~~~~~ +!!! message TS6132: Variable 'maker' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + } + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js new file mode 100644 index 0000000000000..299c0e97b94cd --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js @@ -0,0 +1,18 @@ +//// [unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts] + +var greeter = function (person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} + +//// [unusedLocalsOnFunctionExpressionWithinFunctionExpression1.js] +var greeter = function (person, person2) { + var unused = 20; + var maker = function (child) { + var unused2 = 22; + }; + person2 = "dummy value"; +}; diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt new file mode 100644 index 0000000000000..ce78a2fb1839e --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt @@ -0,0 +1,35 @@ +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,25): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,9): message TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,27): message TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(5,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,28): message TS6133: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(8,13): message TS6132: Variable 'unused3' has never been used. + + +==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts (7 errors) ==== + + var greeter = function (person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + var maker = function (child: string): void { + ~~~~~ +!!! message TS6132: Variable 'maker' has never been used. + ~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + } + var maker2 = function (child2: string): void { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'child2' has never been used. + var unused3 = 23; + ~~~~~~~ +!!! message TS6132: Variable 'unused3' has never been used. + } + maker2(person2); + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js new file mode 100644 index 0000000000000..00ba31b16d729 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js @@ -0,0 +1,24 @@ +//// [unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts] + +var greeter = function (person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + var maker2 = function (child2: string): void { + var unused3 = 23; + } + maker2(person2); +} + +//// [unusedLocalsOnFunctionExpressionWithinFunctionExpression2.js] +var greeter = function (person, person2) { + var unused = 20; + var maker = function (child) { + var unused2 = 22; + }; + var maker2 = function (child2) { + var unused3 = 23; + }; + maker2(person2); +}; diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt new file mode 100644 index 0000000000000..aea22dceeb356 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedLocalsinConstructor1.ts (1 errors) ==== + + class greeter { + constructor() { + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.js b/tests/baselines/reference/unusedLocalsinConstructor1.js new file mode 100644 index 0000000000000..28bd75730680f --- /dev/null +++ b/tests/baselines/reference/unusedLocalsinConstructor1.js @@ -0,0 +1,15 @@ +//// [unusedLocalsinConstructor1.ts] + +class greeter { + constructor() { + var unused = 20; + } +} + +//// [unusedLocalsinConstructor1.js] +var greeter = (function () { + function greeter() { + var unused = 20; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt new file mode 100644 index 0000000000000..7eced3493f7f3 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedLocalsinConstructor2.ts (1 errors) ==== + + class greeter { + constructor() { + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + var used = "dummy"; + used = used + "second part"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.js b/tests/baselines/reference/unusedLocalsinConstructor2.js new file mode 100644 index 0000000000000..2fda63d28a304 --- /dev/null +++ b/tests/baselines/reference/unusedLocalsinConstructor2.js @@ -0,0 +1,19 @@ +//// [unusedLocalsinConstructor2.ts] + +class greeter { + constructor() { + var unused = 20; + var used = "dummy"; + used = used + "second part"; + } +} + +//// [unusedLocalsinConstructor2.js] +var greeter = (function () { + function greeter() { + var unused = 20; + var used = "dummy"; + used = used + "second part"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt new file mode 100644 index 0000000000000..ad829ef8bcbbd --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== + + class Dummy { + constructor(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "Dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.js b/tests/baselines/reference/unusedMultipleParameter1InContructor.js new file mode 100644 index 0000000000000..e236ea3d26a09 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.js @@ -0,0 +1,17 @@ +//// [unusedMultipleParameter1InContructor.ts] + +class Dummy { + constructor(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; + } +} + +//// [unusedMultipleParameter1InContructor.js] +var Dummy = (function () { + function Dummy(person, person2) { + var unused = 20; + person2 = "Dummy value"; + } + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt new file mode 100644 index 0000000000000..97e152e96fe34 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,21): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (2 errors) ==== + + var func = function(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "Dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.js b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.js new file mode 100644 index 0000000000000..55a697cc3e028 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.js @@ -0,0 +1,12 @@ +//// [unusedMultipleParameter1InFunctionExpression.ts] + +var func = function(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; +} + +//// [unusedMultipleParameter1InFunctionExpression.js] +var func = function (person, person2) { + var unused = 20; + person2 = "Dummy value"; +}; diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt new file mode 100644 index 0000000000000..7196273a5c725 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): message TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== + + class Dummy { + constructor(person: string, person2: string, person3: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + ~~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person3' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "Dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.js b/tests/baselines/reference/unusedMultipleParameter2InContructor.js new file mode 100644 index 0000000000000..8ffd4c3659124 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.js @@ -0,0 +1,17 @@ +//// [unusedMultipleParameter2InContructor.ts] + +class Dummy { + constructor(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; + } +} + +//// [unusedMultipleParameter2InContructor.js] +var Dummy = (function () { + function Dummy(person, person2, person3) { + var unused = 20; + person2 = "Dummy value"; + } + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt new file mode 100644 index 0000000000000..ddf63a22146f8 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,21): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,54): message TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (3 errors) ==== + + var func = function(person: string, person2: string, person3: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + ~~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person3' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "Dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.js b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.js new file mode 100644 index 0000000000000..1c35c1762f34d --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.js @@ -0,0 +1,12 @@ +//// [unusedMultipleParameter2InFunctionExpression.ts] + +var func = function(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; +} + +//// [unusedMultipleParameter2InFunctionExpression.js] +var func = function (person, person2, person3) { + var unused = 20; + person2 = "Dummy value"; +}; diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt new file mode 100644 index 0000000000000..61a1864318235 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (2 errors) ==== + + function greeter(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.js b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.js new file mode 100644 index 0000000000000..caac12c873532 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.js @@ -0,0 +1,12 @@ +//// [unusedMultipleParameters1InFunctionDeclaration.ts] + +function greeter(person: string, person2: string) { + var unused = 20; + person2 = "dummy value"; +} + +//// [unusedMultipleParameters1InFunctionDeclaration.js] +function greeter(person, person2) { + var unused = 20; + person2 = "dummy value"; +} diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt new file mode 100644 index 0000000000000..7037ef6423a64 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,20): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (2 errors) ==== + + class Dummy { + public greeter(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.js b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.js new file mode 100644 index 0000000000000..bc78da7bd7594 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.js @@ -0,0 +1,19 @@ +//// [unusedMultipleParameters1InMethodDeclaration.ts] + +class Dummy { + public greeter(person: string, person2: string) { + var unused = 20; + person2 = "dummy value"; + } +} + +//// [unusedMultipleParameters1InMethodDeclaration.js] +var Dummy = (function () { + function Dummy() { + } + Dummy.prototype.greeter = function (person, person2) { + var unused = 20; + person2 = "dummy value"; + }; + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt new file mode 100644 index 0000000000000..83594231e532f --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,51): message TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (3 errors) ==== + + function greeter(person: string, person2: string, person3: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + ~~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person3' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "dummy value"; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.js b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.js new file mode 100644 index 0000000000000..1197cabf646c2 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.js @@ -0,0 +1,12 @@ +//// [unusedMultipleParameters2InFunctionDeclaration.ts] + +function greeter(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "dummy value"; +} + +//// [unusedMultipleParameters2InFunctionDeclaration.js] +function greeter(person, person2, person3) { + var unused = 20; + person2 = "dummy value"; +} diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt new file mode 100644 index 0000000000000..27f4db42d7c94 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,20): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,53): message TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (3 errors) ==== + + class Dummy { + public greeter(person: string, person2: string, person3: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + ~~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person3' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.js b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.js new file mode 100644 index 0000000000000..80f93990b5bca --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.js @@ -0,0 +1,19 @@ +//// [unusedMultipleParameters2InMethodDeclaration.ts] + +class Dummy { + public greeter(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "dummy value"; + } +} + +//// [unusedMultipleParameters2InMethodDeclaration.js] +var Dummy = (function () { + function Dummy() { + } + Dummy.prototype.greeter = function (person, person2, person3) { + var unused = 20; + person2 = "dummy value"; + }; + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt new file mode 100644 index 0000000000000..ca4bc497c7559 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): message TS6133: Parameter 'param1' has never been used. + + +==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== + + class greeter { + constructor(param1: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param1' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor1.js b/tests/baselines/reference/unusedParametersinConstructor1.js new file mode 100644 index 0000000000000..500d7a45eb2f5 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor1.js @@ -0,0 +1,13 @@ +//// [unusedParametersinConstructor1.ts] + +class greeter { + constructor(param1: string) { + } +} + +//// [unusedParametersinConstructor1.js] +var greeter = (function () { + function greeter(param1) { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt new file mode 100644 index 0000000000000..282e40b0f68da --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): message TS6133: Parameter 'param1' has never been used. + + +==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== + + class greeter { + constructor(param1: string, param2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param1' has never been used. + param2 = param2 + "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.js b/tests/baselines/reference/unusedParametersinConstructor2.js new file mode 100644 index 0000000000000..97bbf21ee0437 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor2.js @@ -0,0 +1,15 @@ +//// [unusedParametersinConstructor2.ts] + +class greeter { + constructor(param1: string, param2: string) { + param2 = param2 + "dummy value"; + } +} + +//// [unusedParametersinConstructor2.js] +var greeter = (function () { + function greeter(param1, param2) { + param2 = param2 + "dummy value"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt new file mode 100644 index 0000000000000..29f3685327190 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): message TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): message TS6133: Parameter 'param3' has never been used. + + +==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== + + class greeter { + constructor(param1: string, param2: string, param3: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param1' has never been used. + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param3' has never been used. + param2 = param2 + "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.js b/tests/baselines/reference/unusedParametersinConstructor3.js new file mode 100644 index 0000000000000..06ac99229ac94 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor3.js @@ -0,0 +1,15 @@ +//// [unusedParametersinConstructor3.ts] + +class greeter { + constructor(param1: string, param2: string, param3: string) { + param2 = param2 + "dummy value"; + } +} + +//// [unusedParametersinConstructor3.js] +var greeter = (function () { + function greeter(param1, param2, param3) { + param2 = param2 + "dummy value"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt new file mode 100644 index 0000000000000..f426aac6cc939 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): message TS6132: Variable 'function1' has never been used. + + +==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (1 errors) ==== + + class greeter { + private function1() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function1' has never been used. + var y = 10; + y++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.js b/tests/baselines/reference/unusedPrivateMethodInClass1.js new file mode 100644 index 0000000000000..18e6fc339c3fe --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.js @@ -0,0 +1,19 @@ +//// [unusedPrivateMethodInClass1.ts] + +class greeter { + private function1() { + var y = 10; + y++; + } +} + +//// [unusedPrivateMethodInClass1.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var y = 10; + y++; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt new file mode 100644 index 0000000000000..605458197d1da --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): message TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): message TS6132: Variable 'function2' has never been used. + + +==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (2 errors) ==== + + class greeter { + private function1() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function1' has never been used. + var y = 10; + y++; + } + + private function2() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function2' has never been used. + var y = 10; + y++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.js b/tests/baselines/reference/unusedPrivateMethodInClass2.js new file mode 100644 index 0000000000000..6a1dbd4df685b --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.js @@ -0,0 +1,28 @@ +//// [unusedPrivateMethodInClass2.ts] + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } +} + +//// [unusedPrivateMethodInClass2.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var y = 10; + y++; + }; + greeter.prototype.function2 = function () { + var y = 10; + y++; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt new file mode 100644 index 0000000000000..e25cd2b61bf56 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt @@ -0,0 +1,26 @@ +tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): message TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): message TS6132: Variable 'function2' has never been used. + + +==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (2 errors) ==== + + class greeter { + private function1() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function1' has never been used. + var y = 10; + y++; + } + + private function2() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function2' has never been used. + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.js b/tests/baselines/reference/unusedPrivateMethodInClass3.js new file mode 100644 index 0000000000000..0009a52f8b684 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.js @@ -0,0 +1,37 @@ +//// [unusedPrivateMethodInClass3.ts] + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + } +} + +//// [unusedPrivateMethodInClass3.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var y = 10; + y++; + }; + greeter.prototype.function2 = function () { + var y = 10; + y++; + }; + greeter.prototype.function3 = function () { + var y = 10; + y++; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt new file mode 100644 index 0000000000000..1c2796e37717d --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): message TS6132: Variable 'function1' has never been used. + + +==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (1 errors) ==== + + class greeter { + private function1() { + ~~~~~~~~~ +!!! message TS6132: Variable 'function1' has never been used. + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + this.function2(); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.js b/tests/baselines/reference/unusedPrivateMethodInClass4.js new file mode 100644 index 0000000000000..6bf2b928fa43e --- /dev/null +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.js @@ -0,0 +1,39 @@ +//// [unusedPrivateMethodInClass4.ts] + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + this.function2(); + } +} + +//// [unusedPrivateMethodInClass4.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + var y = 10; + y++; + }; + greeter.prototype.function2 = function () { + var y = 10; + y++; + }; + greeter.prototype.function3 = function () { + var y = 10; + y++; + this.function2(); + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt new file mode 100644 index 0000000000000..1be4db39e31d4 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): message TS6132: Variable 'x' has never been used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass1.ts (1 errors) ==== + + class greeter { + private x: string; + ~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'x' has never been used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.js b/tests/baselines/reference/unusedPrivateVariableInClass1.js new file mode 100644 index 0000000000000..464676490d89f --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.js @@ -0,0 +1,12 @@ +//// [unusedPrivateVariableInClass1.ts] + +class greeter { + private x: string; +} + +//// [unusedPrivateVariableInClass1.js] +var greeter = (function () { + function greeter() { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt new file mode 100644 index 0000000000000..bc5772507ef52 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,5): message TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): message TS6132: Variable 'y' has never been used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass2.ts (2 errors) ==== + + class greeter { + private x: string; + ~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'x' has never been used. + private y: string; + ~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'y' has never been used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.js b/tests/baselines/reference/unusedPrivateVariableInClass2.js new file mode 100644 index 0000000000000..329e2bbe2b6ef --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.js @@ -0,0 +1,13 @@ +//// [unusedPrivateVariableInClass2.ts] + +class greeter { + private x: string; + private y: string; +} + +//// [unusedPrivateVariableInClass2.js] +var greeter = (function () { + function greeter() { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt new file mode 100644 index 0000000000000..c63294bb6e12e --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,5): message TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): message TS6132: Variable 'y' has never been used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass3.ts (2 errors) ==== + + class greeter { + private x: string; + ~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'x' has never been used. + private y: string; + ~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'y' has never been used. + public z: string; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.js b/tests/baselines/reference/unusedPrivateVariableInClass3.js new file mode 100644 index 0000000000000..c72b9e61995c7 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.js @@ -0,0 +1,14 @@ +//// [unusedPrivateVariableInClass3.ts] + +class greeter { + private x: string; + private y: string; + public z: string; +} + +//// [unusedPrivateVariableInClass3.js] +var greeter = (function () { + function greeter() { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt new file mode 100644 index 0000000000000..65edb89ef0cf7 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): message TS6132: Variable 'y' has never been used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass4.ts (1 errors) ==== + + class greeter { + private x: string; + private y: string; + ~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'y' has never been used. + public z: string; + + public method1() { + this.x = "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.js b/tests/baselines/reference/unusedPrivateVariableInClass4.js new file mode 100644 index 0000000000000..878a7780e85c9 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.js @@ -0,0 +1,21 @@ +//// [unusedPrivateVariableInClass4.ts] + +class greeter { + private x: string; + private y: string; + public z: string; + + public method1() { + this.x = "dummy value"; + } +} + +//// [unusedPrivateVariableInClass4.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.method1 = function () { + this.x = "dummy value"; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt new file mode 100644 index 0000000000000..eb056fc446049 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): message TS6132: Variable 'y' has never been used. + + +==== tests/cases/compiler/unusedPrivateVariableInClass5.ts (1 errors) ==== + + class greeter { + private x: string; + private y: string; + ~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'y' has never been used. + public z: string; + + constructor() { + this.x = "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.js b/tests/baselines/reference/unusedPrivateVariableInClass5.js new file mode 100644 index 0000000000000..4d9b301722234 --- /dev/null +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.js @@ -0,0 +1,19 @@ +//// [unusedPrivateVariableInClass5.ts] + +class greeter { + private x: string; + private y: string; + public z: string; + + constructor() { + this.x = "dummy value"; + } +} + +//// [unusedPrivateVariableInClass5.js] +var greeter = (function () { + function greeter() { + this.x = "dummy value"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt new file mode 100644 index 0000000000000..923a743d224b8 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== + + class Dummy { + constructor(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.js b/tests/baselines/reference/unusedSingleParameterInContructor.js new file mode 100644 index 0000000000000..172f9e20ab860 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInContructor.js @@ -0,0 +1,15 @@ +//// [unusedSingleParameterInContructor.ts] + +class Dummy { + constructor(person: string) { + var unused = 20; + } +} + +//// [unusedSingleParameterInContructor.js] +var Dummy = (function () { + function Dummy(person) { + var unused = 20; + } + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt new file mode 100644 index 0000000000000..0e8e7598f122b --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts (2 errors) ==== + + function greeter(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.js b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.js new file mode 100644 index 0000000000000..0ee7c3d608a23 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.js @@ -0,0 +1,10 @@ +//// [unusedSingleParameterInFunctionDeclaration.ts] + +function greeter(person: string) { + var unused = 20; +} + +//// [unusedSingleParameterInFunctionDeclaration.js] +function greeter(person) { + var unused = 20; +} diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt new file mode 100644 index 0000000000000..a614b0058c8ce --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,21): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts (2 errors) ==== + + var func = function(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.js b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.js new file mode 100644 index 0000000000000..578707e43cc9e --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.js @@ -0,0 +1,10 @@ +//// [unusedSingleParameterInFunctionExpression.ts] + +var func = function(person: string) { + var unused = 20; +} + +//// [unusedSingleParameterInFunctionExpression.js] +var func = function (person) { + var unused = 20; +}; diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt new file mode 100644 index 0000000000000..b34d8a9bfc5db --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,20): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts (2 errors) ==== + + class Dummy { + public greeter(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.js b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.js new file mode 100644 index 0000000000000..993866086db0b --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.js @@ -0,0 +1,17 @@ +//// [unusedSingleParameterInMethodDeclaration.ts] + +class Dummy { + public greeter(person: string) { + var unused = 20; + } +} + +//// [unusedSingleParameterInMethodDeclaration.js] +var Dummy = (function () { + function Dummy() { + } + Dummy.prototype.greeter = function (person) { + var unused = 20; + }; + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedTypeParameters1.errors.txt b/tests/baselines/reference/unusedTypeParameters1.errors.txt new file mode 100644 index 0000000000000..c00d0b072e8b3 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedTypeParameters1.ts(2,15): message TS6132: Variable 'typeparameter1' has never been used. + + +==== tests/cases/compiler/unusedTypeParameters1.ts (1 errors) ==== + + class greeter { + ~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'typeparameter1' has never been used. + + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters1.js b/tests/baselines/reference/unusedTypeParameters1.js new file mode 100644 index 0000000000000..27de80a9ecc41 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters1.js @@ -0,0 +1,12 @@ +//// [unusedTypeParameters1.ts] + +class greeter { + +} + +//// [unusedTypeParameters1.js] +var greeter = (function () { + function greeter() { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedTypeParameters2.errors.txt b/tests/baselines/reference/unusedTypeParameters2.errors.txt new file mode 100644 index 0000000000000..af6192260c31f --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedTypeParameters2.ts(2,15): message TS6132: Variable 'typeparameter1' has never been used. + + +==== tests/cases/compiler/unusedTypeParameters2.ts (1 errors) ==== + + class greeter { + ~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'typeparameter1' has never been used. + private x: typeparameter2; + + public function1() { + this.x; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters2.js b/tests/baselines/reference/unusedTypeParameters2.js new file mode 100644 index 0000000000000..b28aa5074e774 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters2.js @@ -0,0 +1,19 @@ +//// [unusedTypeParameters2.ts] + +class greeter { + private x: typeparameter2; + + public function1() { + this.x; + } +} + +//// [unusedTypeParameters2.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + this.x; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedTypeParameters3.errors.txt b/tests/baselines/reference/unusedTypeParameters3.errors.txt new file mode 100644 index 0000000000000..2f74d3f53dfd4 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters3.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedTypeParameters3.ts(2,15): message TS6132: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters3.ts(2,47): message TS6132: Variable 'typeparameter3' has never been used. + + +==== tests/cases/compiler/unusedTypeParameters3.ts (2 errors) ==== + + class greeter { + ~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'typeparameter1' has never been used. + ~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'typeparameter3' has never been used. + private x: typeparameter2; + + public function1() { + this.x; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters3.js b/tests/baselines/reference/unusedTypeParameters3.js new file mode 100644 index 0000000000000..0552acaf54081 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters3.js @@ -0,0 +1,19 @@ +//// [unusedTypeParameters3.ts] + +class greeter { + private x: typeparameter2; + + public function1() { + this.x; + } +} + +//// [unusedTypeParameters3.js] +var greeter = (function () { + function greeter() { + } + greeter.prototype.function1 = function () { + this.x; + }; + return greeter; +}()); diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt new file mode 100644 index 0000000000000..460a06ef91558 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): message TS6132: Variable 'lettersRegexp' has never been used. + + +==== tests/cases/compiler/unusedVariablesinNamespaces1.ts (1 errors) ==== + + namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + ~~~~~~~~~~~~~ +!!! message TS6132: Variable 'lettersRegexp' has never been used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.js b/tests/baselines/reference/unusedVariablesinNamespaces1.js new file mode 100644 index 0000000000000..a6dca8e413f13 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.js @@ -0,0 +1,11 @@ +//// [unusedVariablesinNamespaces1.ts] + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; +} + +//// [unusedVariablesinNamespaces1.js] +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt new file mode 100644 index 0000000000000..f175e709bcd39 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): message TS6132: Variable 'numberRegexp' has never been used. + + +==== tests/cases/compiler/unusedVariablesinNamespaces2.ts (1 errors) ==== + + namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + ~~~~~~~~~~~~ +!!! message TS6132: Variable 'numberRegexp' has never been used. + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.js b/tests/baselines/reference/unusedVariablesinNamespaces2.js new file mode 100644 index 0000000000000..b0b64fa644d82 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.js @@ -0,0 +1,28 @@ +//// [unusedVariablesinNamespaces2.ts] + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } +} + +//// [unusedVariablesinNamespaces2.js] +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; + var numberRegexp = /^[0-9]+$/; + var LettersOnlyValidator = (function () { + function LettersOnlyValidator() { + } + LettersOnlyValidator.prototype.isAcceptable = function (s2) { + return lettersRegexp.test(s2); + }; + return LettersOnlyValidator; + }()); + Validation.LettersOnlyValidator = LettersOnlyValidator; +})(Validation || (Validation = {})); diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt new file mode 100644 index 0000000000000..e9ab2418904d8 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): message TS6132: Variable 'numberRegexp' has never been used. + + +==== tests/cases/compiler/unusedVariablesinNamespaces3.ts (1 errors) ==== + + namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + ~~~~~~~~~~~~ +!!! message TS6132: Variable 'numberRegexp' has never been used. + export const anotherUnusedVariable = "Dummy value"; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.js b/tests/baselines/reference/unusedVariablesinNamespaces3.js new file mode 100644 index 0000000000000..16a92a475d954 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.js @@ -0,0 +1,30 @@ +//// [unusedVariablesinNamespaces3.ts] + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + export const anotherUnusedVariable = "Dummy value"; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } +} + +//// [unusedVariablesinNamespaces3.js] +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; + var numberRegexp = /^[0-9]+$/; + Validation.anotherUnusedVariable = "Dummy value"; + var LettersOnlyValidator = (function () { + function LettersOnlyValidator() { + } + LettersOnlyValidator.prototype.isAcceptable = function (s2) { + return lettersRegexp.test(s2); + }; + return LettersOnlyValidator; + }()); + Validation.LettersOnlyValidator = LettersOnlyValidator; +})(Validation || (Validation = {})); diff --git a/tests/cases/compiler/unusedClassesinNamespace1.ts b/tests/cases/compiler/unusedClassesinNamespace1.ts new file mode 100644 index 0000000000000..da1feef919566 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace2.ts b/tests/cases/compiler/unusedClassesinNamespace2.ts new file mode 100644 index 0000000000000..83d60ff16280f --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace2.ts @@ -0,0 +1,12 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } + + export class c2 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace3.ts b/tests/cases/compiler/unusedClassesinNamespace3.ts new file mode 100644 index 0000000000000..9d39af37ea287 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace3.ts @@ -0,0 +1,14 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + export let a = new c1(); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace4.ts b/tests/cases/compiler/unusedClassesinNamespace4.ts new file mode 100644 index 0000000000000..390df8f72298c --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace4.ts @@ -0,0 +1,16 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 extends c1 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedClassesinNamespace5.ts b/tests/cases/compiler/unusedClassesinNamespace5.ts new file mode 100644 index 0000000000000..43265e8fc4072 --- /dev/null +++ b/tests/cases/compiler/unusedClassesinNamespace5.ts @@ -0,0 +1,16 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + class c1 { + + } + + export class c2 { + + } + + class c3 { + public x: c1; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces1.ts b/tests/cases/compiler/unusedFunctionsinNamespaces1.ts new file mode 100644 index 0000000000000..3e4a1814ba85a --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces1.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + function function1() { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces2.ts b/tests/cases/compiler/unusedFunctionsinNamespaces2.ts new file mode 100644 index 0000000000000..5f38bbaaaace6 --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces2.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function() { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces3.ts b/tests/cases/compiler/unusedFunctionsinNamespaces3.ts new file mode 100644 index 0000000000000..c20759494f640 --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces3.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function(param1:string) { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces4.ts b/tests/cases/compiler/unusedFunctionsinNamespaces4.ts new file mode 100644 index 0000000000000..b8855ba265040 --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces4.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces5.ts b/tests/cases/compiler/unusedFunctionsinNamespaces5.ts new file mode 100644 index 0000000000000..f1d516fa66f29 --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces5.ts @@ -0,0 +1,19 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedFunctionsinNamespaces6.ts b/tests/cases/compiler/unusedFunctionsinNamespaces6.ts new file mode 100644 index 0000000000000..19f1591249c4c --- /dev/null +++ b/tests/cases/compiler/unusedFunctionsinNamespaces6.ts @@ -0,0 +1,21 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + function function4() { + + } + + export let a = function3; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedIdentifiersConsolidated1.ts b/tests/cases/compiler/unusedIdentifiersConsolidated1.ts new file mode 100644 index 0000000000000..7c6e9b2e6957a --- /dev/null +++ b/tests/cases/compiler/unusedIdentifiersConsolidated1.ts @@ -0,0 +1,104 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string) { + var unused = 20; +} + +class Dummy { + private unusedprivatevariable: string; + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + var unused = 20; + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + } +} + +var user = "Jane User"; +var user2 = "Jane2 User2"; + +namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + } + + interface unusedInterface { + } +} + + +namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace1.ts b/tests/cases/compiler/unusedInterfaceinNamespace1.ts new file mode 100644 index 0000000000000..db50d0da2b6ac --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace2.ts b/tests/cases/compiler/unusedInterfaceinNamespace2.ts new file mode 100644 index 0000000000000..d0b6eb239ef5c --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace2.ts @@ -0,0 +1,12 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace3.ts b/tests/cases/compiler/unusedInterfaceinNamespace3.ts new file mode 100644 index 0000000000000..48c615be90348 --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace3.ts @@ -0,0 +1,16 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace4.ts b/tests/cases/compiler/unusedInterfaceinNamespace4.ts new file mode 100644 index 0000000000000..e643f8122277b --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace4.ts @@ -0,0 +1,20 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } + + export class c1 implements i3 { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedInterfaceinNamespace5.ts b/tests/cases/compiler/unusedInterfaceinNamespace5.ts new file mode 100644 index 0000000000000..901124e0f393a --- /dev/null +++ b/tests/cases/compiler/unusedInterfaceinNamespace5.ts @@ -0,0 +1,26 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + interface i1 { + + } + + export interface i2 { + + } + + interface i3 extends i1 { + + } + + export class c1 implements i3 { + + } + + interface i4 { + + } + + export let c2:i4; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsInMethod1.ts b/tests/cases/compiler/unusedLocalsInMethod1.ts new file mode 100644 index 0000000000000..7da21b2c1afba --- /dev/null +++ b/tests/cases/compiler/unusedLocalsInMethod1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + public function1() { + var x = 10; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsInMethod2.ts b/tests/cases/compiler/unusedLocalsInMethod2.ts new file mode 100644 index 0000000000000..a376e6de0acae --- /dev/null +++ b/tests/cases/compiler/unusedLocalsInMethod2.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + public function1() { + var x, y = 10; + y++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsInMethod3.ts b/tests/cases/compiler/unusedLocalsInMethod3.ts new file mode 100644 index 0000000000000..5d94911057369 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsInMethod3.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + public function1() { + var x, y; + y = 1; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts new file mode 100644 index 0000000000000..0c325f198fa9e --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts new file mode 100644 index 0000000000000..00615f034b7c2 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + function maker2(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts new file mode 100644 index 0000000000000..fd0e0f190e965 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var greeter = function (person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts new file mode 100644 index 0000000000000..73adf038564cc --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var greeter = function (person: string, person2: string) { + var unused = 20; + function maker(child: string): void { + var unused2 = 22; + } + function maker2(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts new file mode 100644 index 0000000000000..9417b13b65a49 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts new file mode 100644 index 0000000000000..7971ce5a30aae --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + var maker = function(child: string): void { + var unused2 = 22; + } + var maker2 = function(child2: string): void { + var unused3 = 23; + } + maker2(person2); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts new file mode 100644 index 0000000000000..edeb341ee7db9 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var greeter = function (person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts new file mode 100644 index 0000000000000..b407755c259e1 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var greeter = function (person: string, person2: string) { + var unused = 20; + var maker = function (child: string): void { + var unused2 = 22; + } + var maker2 = function (child2: string): void { + var unused3 = 23; + } + maker2(person2); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsinConstructor1.ts b/tests/cases/compiler/unusedLocalsinConstructor1.ts new file mode 100644 index 0000000000000..fca303d2b9f5d --- /dev/null +++ b/tests/cases/compiler/unusedLocalsinConstructor1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor() { + var unused = 20; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedLocalsinConstructor2.ts b/tests/cases/compiler/unusedLocalsinConstructor2.ts new file mode 100644 index 0000000000000..2e67d98d56e65 --- /dev/null +++ b/tests/cases/compiler/unusedLocalsinConstructor2.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor() { + var unused = 20; + var used = "dummy"; + used = used + "second part"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter1InContructor.ts b/tests/cases/compiler/unusedMultipleParameter1InContructor.ts new file mode 100644 index 0000000000000..b9565cafca62a --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter1InContructor.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts b/tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts new file mode 100644 index 0000000000000..3892db7e39d76 --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var func = function(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter2InContructor.ts b/tests/cases/compiler/unusedMultipleParameter2InContructor.ts new file mode 100644 index 0000000000000..34d54c714af6f --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter2InContructor.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts b/tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts new file mode 100644 index 0000000000000..4d5bb2a103b09 --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var func = function(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts b/tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts new file mode 100644 index 0000000000000..bc63d72f0150d --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string) { + var unused = 20; + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts b/tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts new file mode 100644 index 0000000000000..c74e702bbae36 --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + public greeter(person: string, person2: string) { + var unused = 20; + person2 = "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts b/tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts new file mode 100644 index 0000000000000..ad20d044eccdb --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "dummy value"; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts b/tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts new file mode 100644 index 0000000000000..4ede3cd47a409 --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + public greeter(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor1.ts b/tests/cases/compiler/unusedParametersinConstructor1.ts new file mode 100644 index 0000000000000..421636d661b74 --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor1.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string) { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor2.ts b/tests/cases/compiler/unusedParametersinConstructor2.ts new file mode 100644 index 0000000000000..d6812f438c598 --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor2.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string, param2: string) { + param2 = param2 + "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor3.ts b/tests/cases/compiler/unusedParametersinConstructor3.ts new file mode 100644 index 0000000000000..e6295cd49fadf --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor3.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string, param2: string, param3: string) { + param2 = param2 + "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateMethodInClass1.ts b/tests/cases/compiler/unusedPrivateMethodInClass1.ts new file mode 100644 index 0000000000000..e31dec6033b54 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMethodInClass1.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private function1() { + var y = 10; + y++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateMethodInClass2.ts b/tests/cases/compiler/unusedPrivateMethodInClass2.ts new file mode 100644 index 0000000000000..5039c26589033 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMethodInClass2.ts @@ -0,0 +1,14 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateMethodInClass3.ts b/tests/cases/compiler/unusedPrivateMethodInClass3.ts new file mode 100644 index 0000000000000..a35cd4512ecc2 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMethodInClass3.ts @@ -0,0 +1,19 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateMethodInClass4.ts b/tests/cases/compiler/unusedPrivateMethodInClass4.ts new file mode 100644 index 0000000000000..5e2741a12bc58 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateMethodInClass4.ts @@ -0,0 +1,20 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private function1() { + var y = 10; + y++; + } + + private function2() { + var y = 10; + y++; + } + + public function3() { + var y = 10; + y++; + this.function2(); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass1.ts b/tests/cases/compiler/unusedPrivateVariableInClass1.ts new file mode 100644 index 0000000000000..0877b7cd8685b --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass2.ts b/tests/cases/compiler/unusedPrivateVariableInClass2.ts new file mode 100644 index 0000000000000..acaf1e80412c3 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass2.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; + private y: string; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass3.ts b/tests/cases/compiler/unusedPrivateVariableInClass3.ts new file mode 100644 index 0000000000000..6cfa3184f44a7 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass3.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; + private y: string; + public z: string; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass4.ts b/tests/cases/compiler/unusedPrivateVariableInClass4.ts new file mode 100644 index 0000000000000..23598d5a491bd --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass4.ts @@ -0,0 +1,12 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; + private y: string; + public z: string; + + public method1() { + this.x = "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedPrivateVariableInClass5.ts b/tests/cases/compiler/unusedPrivateVariableInClass5.ts new file mode 100644 index 0000000000000..51e64afca1d27 --- /dev/null +++ b/tests/cases/compiler/unusedPrivateVariableInClass5.ts @@ -0,0 +1,12 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: string; + private y: string; + public z: string; + + constructor() { + this.x = "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInContructor.ts b/tests/cases/compiler/unusedSingleParameterInContructor.ts new file mode 100644 index 0000000000000..0f8f756fb48e4 --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInContructor.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string) { + var unused = 20; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts b/tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts new file mode 100644 index 0000000000000..8122065d7ca64 --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function greeter(person: string) { + var unused = 20; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts b/tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts new file mode 100644 index 0000000000000..f4a749c33afee --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var func = function(person: string) { + var unused = 20; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts b/tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts new file mode 100644 index 0000000000000..2dee007f21059 --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + public greeter(person: string) { + var unused = 20; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters1.ts b/tests/cases/compiler/unusedTypeParameters1.ts new file mode 100644 index 0000000000000..cec2be7efdafa --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters2.ts b/tests/cases/compiler/unusedTypeParameters2.ts new file mode 100644 index 0000000000000..c1018578147b4 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters2.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: typeparameter2; + + public function1() { + this.x; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters3.ts b/tests/cases/compiler/unusedTypeParameters3.ts new file mode 100644 index 0000000000000..ea67756d5adb5 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters3.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + private x: typeparameter2; + + public function1() { + this.x; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinNamespaces1.ts b/tests/cases/compiler/unusedVariablesinNamespaces1.ts new file mode 100644 index 0000000000000..04febf7026041 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinNamespaces1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinNamespaces2.ts b/tests/cases/compiler/unusedVariablesinNamespaces2.ts new file mode 100644 index 0000000000000..2178da8fbda92 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinNamespaces2.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinNamespaces3.ts b/tests/cases/compiler/unusedVariablesinNamespaces3.ts new file mode 100644 index 0000000000000..9952da92a7fea --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinNamespaces3.ts @@ -0,0 +1,14 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace Validation { + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + export const anotherUnusedVariable = "Dummy value"; + + export class LettersOnlyValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + } +} \ No newline at end of file From d2ff079b75459675a4756c75abc666a7bcabe963 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 6 Jun 2016 11:31:26 -0700 Subject: [PATCH 18/90] Code change that was missed in merge --- src/harness/fourslash.ts | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5da1f2c7745d0..137027b8ed68b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2003,6 +2003,59 @@ namespace FourSlash { } } + public verifyGetScriptLexicalStructureListCount(expected: number) { + const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + const actual = this.getNavigationBarItemsCount(items); + + if (expected !== actual) { + this.raiseError(`verifyGetScriptLexicalStructureListCount failed - found: ${actual} navigation items, expected: ${expected}.`); + } + } + + private getNavigationBarItemsCount(items: ts.NavigationBarItem[]) { + let result = 0; + if (items) { + for (let i = 0, n = items.length; i < n; i++) { + result++; + result += this.getNavigationBarItemsCount(items[i].childItems); + } + } + + return result; + } + + public verifyGetScriptLexicalStructureListContains(name: string, kind: string) { + const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); + + if (!items || items.length === 0) { + this.raiseError("verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one."); + } + + if (this.navigationBarItemsContains(items, name, kind)) { + return; + } + + const missingItem = { name: name, kind: kind }; + this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`); + } + + private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) { + if (items) { + for (let i = 0; i < items.length; i++) { + const item = items[i]; + if (item && item.text === name && item.kind === kind) { + return true; + } + + if (this.navigationBarItemsContains(item.childItems, name, kind)) { + return true; + } + } + } + + return false; + } + public printNavigationItems(searchValue: string) { const items = this.languageService.getNavigateToItems(searchValue); const length = items && items.length; From a3818bab862a66d98c82fd1a467e0f83d9be00ae Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 7 Jun 2016 13:37:01 -0700 Subject: [PATCH 19/90] stash --- src/services/quickfixes/quickFixProvider.ts | 19 +++++++++++++------ src/services/quickfixes/superFixes.ts | 21 +++++++++++---------- src/services/services.ts | 2 +- tests/cases/fourslash/superFix1.ts | 2 +- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/services/quickfixes/quickFixProvider.ts b/src/services/quickfixes/quickFixProvider.ts index 1528c08819c31..25205cf5c96db 100644 --- a/src/services/quickfixes/quickFixProvider.ts +++ b/src/services/quickfixes/quickFixProvider.ts @@ -18,10 +18,17 @@ namespace ts { BelowNormal, } - var quickFixes: Map = {}; + var quickFixes: Map = {}; export function registerQuickFix(fix: QuickFix) { - fix.errorCodes.forEach(error => quickFixes[error] = fix); + fix.errorCodes.forEach(error => { + let fixes = quickFixes[error]; + if (!fixes) { + fixes = []; + quickFixes[error] = fixes; + } + fixes.push(fix); + }); } export class QuickFixProvider { @@ -30,14 +37,14 @@ namespace ts { return getKeys(quickFixes); } - public fix(errorCode: string, sourceFile: SourceFile, start: number, end: number): SuggestedFix { + public getFixes(errorCode: string, sourceFile: SourceFile, start: number, end: number): SuggestedFix { const fix = quickFixes[errorCode]; - if (!fix) { - throw new Error(`No fix found for error: '${errorCode}'.`); + if (!fix || fix.length == 0) { + throw new Error(`No fixes found for error: '${errorCode}'.`); } - return { name: fix.name, textChanges: fix.getFix(sourceFile, start, end) }; + return { name: fix[0].name, textChanges: fix[0].getFix(sourceFile, start, end) }; } } } diff --git a/src/services/quickfixes/superFixes.ts b/src/services/quickfixes/superFixes.ts index 94614f5c06719..be09590d845bd 100644 --- a/src/services/quickfixes/superFixes.ts +++ b/src/services/quickfixes/superFixes.ts @@ -1,6 +1,11 @@ /* @internal */ namespace ts.quickFix { + function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile).getEnd(); + } + registerQuickFix({ name: `Add missing 'super()' call.`, errorCodes: ["TS2377"], @@ -11,10 +16,9 @@ namespace ts.quickFix { throw new Error("Failed to find the constructor."); } - const openCurly = (token.parent).body.getChildren(sourceFile)[0]; // assume this is the open curly - const position = openCurly.getEnd(); // want to position directly after open curly, we'll format using the formatting service in the host + const newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ newText: "super();", span: { start: position, length: 0 } }]; + return [{ newText: "super();", span: { start: newPosition, length: 0 } }]; } }); @@ -26,20 +30,17 @@ namespace ts.quickFix { const constructor = getContainingFunction(token); if (constructor.kind !== SyntaxKind.Constructor) { - // wait why are we not a on a constructor? + // Wait why are we not a on a constructor? throw new Error("Failed to find the constructor."); } const superCall = findSuperCall((constructor).body); - const children = (constructor).body.getChildren(sourceFile); - - // first child is the open curly, this is where we want to put the 'super' call. - const newPosition = children[0].getEnd(); - if (!superCall) { throw new Error(`Failed to find super call.`); } + const newPosition = getOpenBraceEnd(constructor, sourceFile); + return [{ newText: superCall.getText(sourceFile), span: { start: newPosition, length: 0 } @@ -47,7 +48,7 @@ namespace ts.quickFix { { newText: "", span: { start: superCall.getStart(sourceFile), length: superCall.getFullWidth() } - }] + }]; function findSuperCall(n: Node): Node { if (isSuperCallExpression(n)) { diff --git a/src/services/services.ts b/src/services/services.ts index e0cce53b465a9..8e8b504329d96 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -7489,7 +7489,7 @@ namespace ts { synchronizeHostData(); const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return quickFixProvider.fix(errorCodes[0], sourceFile, start, end); + return quickFixProvider.getFixes(errorCodes[0], sourceFile, start, end); } /** diff --git a/tests/cases/fourslash/superFix1.ts b/tests/cases/fourslash/superFix1.ts index 5f4646f2bddc0..d5bd278ab3315 100644 --- a/tests/cases/fourslash/superFix1.ts +++ b/tests/cases/fourslash/superFix1.ts @@ -3,7 +3,7 @@ ////class Base{ ////} ////class C extends Base{ -//// /*0*/constructor() { +//// constructor() {/*0*/ //// } ////} From c619cabcf0fd8b598c5d36ff645f5fd420922d68 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 8 Jun 2016 15:31:50 -0700 Subject: [PATCH 20/90] First Commit for API Changes for Tracking Unused Identifiers --- src/harness/fourslash.ts | 11 ++- src/services/quickfixes/references.ts | 1 + src/services/quickfixes/superFixes.ts | 9 +++ .../quickfixes/unusedIdentifierFixes.ts | 73 +++++++++++++++++++ .../fourslash/unusedClassInNamespace1.ts | 9 +++ .../fourslash/unusedClassInNamespace2.ts | 11 +++ .../fourslash/unusedFunctionInNamespace1.ts | 9 +++ .../fourslash/unusedFunctionInNamespace2.ts | 11 +++ .../fourslash/unusedInterfaceInNamespace1.ts | 9 +++ .../fourslash/unusedInterfaceInNamespace2.ts | 11 +++ .../fourslash/unusedLocalsInFunction1.ts | 8 ++ .../fourslash/unusedLocalsInFunction2.ts | 9 +++ .../fourslash/unusedLocalsInFunction3.ts | 10 +++ .../fourslash/unusedLocalsInFunction4.ts | 10 +++ tests/cases/fourslash/unusedMethodInClass1.ts | 9 +++ tests/cases/fourslash/unusedMethodInClass2.ts | 11 +++ tests/cases/fourslash/unusedMethodInClass3.ts | 9 +++ tests/cases/fourslash/unusedMethodInClass4.ts | 11 +++ .../fourslash/unusedParameterInFunction1.ts | 7 ++ .../fourslash/unusedParameterInFunction2.ts | 8 ++ .../fourslash/unusedParameterInFunction3.ts | 8 ++ .../fourslash/unusedParameterInFunction4.ts | 9 +++ .../fourslash/unusedTypeParametersInClass1.ts | 7 ++ .../fourslash/unusedTypeParametersInClass2.ts | 8 ++ .../fourslash/unusedTypeParametersInClass3.ts | 9 +++ .../cases/fourslash/unusedVariableInClass1.ts | 8 ++ .../cases/fourslash/unusedVariableInClass2.ts | 9 +++ .../fourslash/unusedVariableInNamespace1.ts | 8 ++ .../fourslash/unusedVariableInNamespace2.ts | 12 +++ .../fourslash/unusedVariableInNamespace3.ts | 12 +++ 30 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 src/services/quickfixes/unusedIdentifierFixes.ts create mode 100644 tests/cases/fourslash/unusedClassInNamespace1.ts create mode 100644 tests/cases/fourslash/unusedClassInNamespace2.ts create mode 100644 tests/cases/fourslash/unusedFunctionInNamespace1.ts create mode 100644 tests/cases/fourslash/unusedFunctionInNamespace2.ts create mode 100644 tests/cases/fourslash/unusedInterfaceInNamespace1.ts create mode 100644 tests/cases/fourslash/unusedInterfaceInNamespace2.ts create mode 100644 tests/cases/fourslash/unusedLocalsInFunction1.ts create mode 100644 tests/cases/fourslash/unusedLocalsInFunction2.ts create mode 100644 tests/cases/fourslash/unusedLocalsInFunction3.ts create mode 100644 tests/cases/fourslash/unusedLocalsInFunction4.ts create mode 100644 tests/cases/fourslash/unusedMethodInClass1.ts create mode 100644 tests/cases/fourslash/unusedMethodInClass2.ts create mode 100644 tests/cases/fourslash/unusedMethodInClass3.ts create mode 100644 tests/cases/fourslash/unusedMethodInClass4.ts create mode 100644 tests/cases/fourslash/unusedParameterInFunction1.ts create mode 100644 tests/cases/fourslash/unusedParameterInFunction2.ts create mode 100644 tests/cases/fourslash/unusedParameterInFunction3.ts create mode 100644 tests/cases/fourslash/unusedParameterInFunction4.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInClass1.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInClass2.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInClass3.ts create mode 100644 tests/cases/fourslash/unusedVariableInClass1.ts create mode 100644 tests/cases/fourslash/unusedVariableInClass2.ts create mode 100644 tests/cases/fourslash/unusedVariableInNamespace1.ts create mode 100644 tests/cases/fourslash/unusedVariableInNamespace2.ts create mode 100644 tests/cases/fourslash/unusedVariableInNamespace3.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 137027b8ed68b..32cae5c7dac2a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1824,10 +1824,19 @@ namespace FourSlash { const errorCode = diagnostics[0].code; const position = diagnostics[0].start; + const markers = this.getMarkers(); + const start = markers[0].position; + const end = markers[1].position; + const actual = this.languageService.getCodeFixAtPosition(this.activeFile.fileName, position, position, [`TS${errorCode}`]); if (actual.textChanges[0].newText !== expectedChange.newText) { - this.raiseError(`Not the expected text change.`); + this.raiseError("Not the expected text change."); + } + + if (actual.textChanges[0].span.start !== start || + (actual.textChanges[0].span.start + actual.textChanges[0].span.length) !== end) { + this.raiseError("Not the expected span range."); } } diff --git a/src/services/quickfixes/references.ts b/src/services/quickfixes/references.ts index a469d9a43fb5b..5d6e446ea45a9 100644 --- a/src/services/quickfixes/references.ts +++ b/src/services/quickfixes/references.ts @@ -1,3 +1,4 @@ /// /// /// +/// diff --git a/src/services/quickfixes/superFixes.ts b/src/services/quickfixes/superFixes.ts index 5eb4bb2645785..321b5b94f0ef0 100644 --- a/src/services/quickfixes/superFixes.ts +++ b/src/services/quickfixes/superFixes.ts @@ -37,4 +37,13 @@ namespace ts.quickFix { throw new Error("Not implemented"); } }); + + registerQuickFix({ + name: `Remove Unused Local Variable`, + errorCode: "TS6132", + getFix: (sourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { + const token = getTokenAtPosition(sourceFile, start); + throw new Error("Not implemented"); + } + }); } \ No newline at end of file diff --git a/src/services/quickfixes/unusedIdentifierFixes.ts b/src/services/quickfixes/unusedIdentifierFixes.ts new file mode 100644 index 0000000000000..52ea5109e0992 --- /dev/null +++ b/src/services/quickfixes/unusedIdentifierFixes.ts @@ -0,0 +1,73 @@ +/* @internal */ +namespace ts.quickFix { + registerQuickFix({ + name: "Remove Unused Parameters", + errorCode: "TS6133", + getFix: (sourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { + const token = getTokenAtPosition(sourceFile, start); + if (token.kind === ts.SyntaxKind.Identifier) { + if (token.parent.kind === ts.SyntaxKind.Parameter) { + var functionDeclaration = token.parent.parent; + if(functionDeclaration.parameters.length === 1) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos} }]; + } else { + if (functionDeclaration.parameters[0] === token.parent) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }]; + } else { + return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + } + } + } + } + throw new Error("Not implemented"); + } + }); + + registerQuickFix({ + name: "Remove Unused Identifiers", + errorCode: "TS6132", + getFix: (sourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { + const token = getTokenAtPosition(sourceFile, start); + if (token.kind === ts.SyntaxKind.Identifier) { + + if (token.parent.kind === ts.SyntaxKind.VariableDeclaration) { + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return [{ newText: "", span: { start: variableStatement.pos, length: variableStatement.end - variableStatement.pos} }]; + } else { + var declarations = variableStatement.declarationList.declarations; + if (declarations[0].name === token) { + return [{ newText: "", span: { start: token.parent.pos + 1, length: token.parent.end - token.parent.pos } }]; + } else { + return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + } + } + } + + if (token.parent.kind === SyntaxKind.FunctionDeclaration || + token.parent.kind === SyntaxKind.ClassDeclaration || + token.parent.kind === SyntaxKind.InterfaceDeclaration || + token.parent.kind === SyntaxKind.MethodDeclaration) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; + } + + if (token.parent.kind === SyntaxKind.TypeParameter) { + var typeParameters = (token.parent.parent).typeParameters; + if (typeParameters.length === 1) { + return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 2 } }]; + } else { + if(typeParameters[0] === token.parent) { + + } else { + return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + } + } + } + } + + if(token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; + } + } + }); +} diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts new file mode 100644 index 0000000000000..21138e0ba95e2 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace1.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////namespace greeter {/*0*/ +//// class class1 { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts new file mode 100644 index 0000000000000..b53c1f2146842 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace2.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// export class class2 { +//// }/*0*/ +//// class class1 { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts new file mode 100644 index 0000000000000..a82dbe8e6c6d7 --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////namespace greeter {/*0*/ +//// function function1() { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts new file mode 100644 index 0000000000000..c8bab09c675a8 --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace2.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// export function function2() { +//// }/*0*/ +//// function function1() { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts new file mode 100644 index 0000000000000..8774cbbe3effc --- /dev/null +++ b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////namespace greeter {/*0*/ +//// interface interface1 { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts new file mode 100644 index 0000000000000..a51048f14b37d --- /dev/null +++ b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// export interface interface2 { +//// }/*0*/ +//// interface interface1 { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts new file mode 100644 index 0000000000000..ce0e2f618fd4d --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInFunction1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////function greeter() {/*0*/ +//// var x = 0;/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts new file mode 100644 index 0000000000000..d09b2bf37f6fd --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////function greeter() { +//// var x/*0*/, y = 0/*1*/; +//// x++; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts new file mode 100644 index 0000000000000..33ae78df54ca2 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +////function greeter() { +//// var x/*0*/, y = 0/*1*/,z = 1; +//// x++; +//// z++; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts new file mode 100644 index 0000000000000..794b784de3629 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +////function greeter() { +//// var /*0*/ x,/*1*/ y = 0,z = 1; +//// y++; +//// z++; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts new file mode 100644 index 0000000000000..7c503e5546220 --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass1.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////class greeter {/*0*/ +//// private function1() { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts new file mode 100644 index 0000000000000..ea4318426bdc2 --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass2.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +////class greeter { +//// public function2() { +//// }/*0*/ +//// private function1() { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts new file mode 100644 index 0000000000000..4c7244c6dbcb8 --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass3.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////class greeter {/*0*/ +//// private function1 = function() { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts new file mode 100644 index 0000000000000..c175671dfcfc6 --- /dev/null +++ b/tests/cases/fourslash/unusedMethodInClass4.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +////class greeter { +//// public function2(){ +//// }/*0*/ +//// private function1 = function() { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedParameterInFunction1.ts b/tests/cases/fourslash/unusedParameterInFunction1.ts new file mode 100644 index 0000000000000..783a21508bfa8 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction1.ts @@ -0,0 +1,7 @@ +/// + +// @noUnusedParameters: true +////function greeter(/*0*/ x/*1*/) { +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts new file mode 100644 index 0000000000000..9f2bf526d5f67 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction2.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedParameters: true +////function greeter(x/*0*/,y/*1*/) { +//// x++; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedParameterInFunction3.ts b/tests/cases/fourslash/unusedParameterInFunction3.ts new file mode 100644 index 0000000000000..450267d270198 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction3.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedParameters: true +////function greeter(/*0*/x,/*1*/y) { +//// y++; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts new file mode 100644 index 0000000000000..848d409e0fbbd --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInFunction4.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedParameters: true +////function greeter(x/*0*/,y/*1*/,z) { +//// x++; +//// z++; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts new file mode 100644 index 0000000000000..3c75f874d1f39 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInClass1.ts @@ -0,0 +1,7 @@ +/// + +// @noUnusedLocals: true +////class greeter/*0*//*1*/ { +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts new file mode 100644 index 0000000000000..df5d3ffcca0ac --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInClass2.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////class greeter { +//// public a: X; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts new file mode 100644 index 0000000000000..a6a7921c49097 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInClass3.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////class greeter { +//// public a: X; +//// public b: Z; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts new file mode 100644 index 0000000000000..1d4fd6a202148 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInClass1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////class greeter {/*0*/ +//// private greeting: string;/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts new file mode 100644 index 0000000000000..ee0469d15ddb3 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInClass2.ts @@ -0,0 +1,9 @@ +/// + +// @noUnusedLocals: true +////class greeter { +//// public greeting1;/*0*/ +//// private greeting: string;/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts new file mode 100644 index 0000000000000..17b9e80b4e0e9 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInNamespace1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////namespace greeter {/*0*/ +//// let a = "dummy entry";/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts new file mode 100644 index 0000000000000..9a2a5c969dfb4 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// let a = "dummy entry"/*0*/, b/*1*/, c = 0; +//// export function function1() { +//// a = "dummy"; +//// c++; +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts new file mode 100644 index 0000000000000..512f2267ae4d4 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +////namespace greeter { +//// let a = "dummy entry", b/*0*/, c = 0/*1*/; +//// export function function1() { +//// a = "dummy"; +//// b = 0; +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); From 0a592c81c888999e82af495880fc12936b33908e Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 8 Jun 2016 15:48:31 -0700 Subject: [PATCH 21/90] Removed unnecessary change in superfix and add one more test case --- src/services/quickfixes/superFixes.ts | 9 --------- tests/cases/fourslash/unusedVariableInClass3.ts | 8 ++++++++ 2 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 tests/cases/fourslash/unusedVariableInClass3.ts diff --git a/src/services/quickfixes/superFixes.ts b/src/services/quickfixes/superFixes.ts index 321b5b94f0ef0..5eb4bb2645785 100644 --- a/src/services/quickfixes/superFixes.ts +++ b/src/services/quickfixes/superFixes.ts @@ -37,13 +37,4 @@ namespace ts.quickFix { throw new Error("Not implemented"); } }); - - registerQuickFix({ - name: `Remove Unused Local Variable`, - errorCode: "TS6132", - getFix: (sourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { - const token = getTokenAtPosition(sourceFile, start); - throw new Error("Not implemented"); - } - }); } \ No newline at end of file diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts new file mode 100644 index 0000000000000..a2a5d36d6dbf3 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInClass3.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +////class greeter {/*0*/ +//// private X = function() {};/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); From adfb73d7c76f76f46683ca0647bafb7e13bc0b88 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 8 Jun 2016 17:03:28 -0700 Subject: [PATCH 22/90] Additional Fourslash test cases --- .../fourslash/unusedClassInNamespace3.ts | 11 +++++++++ .../fourslash/unusedClassInNamespace4.ts | 16 +++++++++++++ .../fourslash/unusedClassInNamespace5.ts | 20 ++++++++++++++++ .../fourslash/unusedClassInNamespace6.ts | 19 +++++++++++++++ .../fourslash/unusedFunctionInNamespace3.ts | 11 +++++++++ .../fourslash/unusedFunctionInNamespace4.ts | 10 ++++++++ .../fourslash/unusedFunctionInNamespace5.ts | 24 +++++++++++++++++++ .../fourslash/unusedLocalsInMethodFS1.ts | 12 ++++++++++ .../fourslash/unusedLocalsInMethodFS2.ts | 12 ++++++++++ .../fourslash/unusedLocalsinConstructorFS1.ts | 11 +++++++++ .../fourslash/unusedLocalsinConstructorFS2.ts | 13 ++++++++++ 11 files changed, 159 insertions(+) create mode 100644 tests/cases/fourslash/unusedClassInNamespace3.ts create mode 100644 tests/cases/fourslash/unusedClassInNamespace4.ts create mode 100644 tests/cases/fourslash/unusedClassInNamespace5.ts create mode 100644 tests/cases/fourslash/unusedClassInNamespace6.ts create mode 100644 tests/cases/fourslash/unusedFunctionInNamespace3.ts create mode 100644 tests/cases/fourslash/unusedFunctionInNamespace4.ts create mode 100644 tests/cases/fourslash/unusedFunctionInNamespace5.ts create mode 100644 tests/cases/fourslash/unusedLocalsInMethodFS1.ts create mode 100644 tests/cases/fourslash/unusedLocalsInMethodFS2.ts create mode 100644 tests/cases/fourslash/unusedLocalsinConstructorFS1.ts create mode 100644 tests/cases/fourslash/unusedLocalsinConstructorFS2.ts diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts new file mode 100644 index 0000000000000..f91579a3bc2bf --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace3.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +////namespace Validation {/*0*/ +//// class c1 { +//// +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts new file mode 100644 index 0000000000000..0361b37a404d6 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace4.ts @@ -0,0 +1,16 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true + +////namespace Validation {/*0*/ +//// class c1 { +//// +//// }/*1*/ +//// +//// export class c2 { +//// +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedClassInNamespace5.ts b/tests/cases/fourslash/unusedClassInNamespace5.ts new file mode 100644 index 0000000000000..ebf6a784abc0b --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace5.ts @@ -0,0 +1,20 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true + +////namespace Validation { +//// class c1 { +//// +//// } +//// +//// export class c2 { +//// +//// }/*0*/ +//// +//// class c3 extends c1 { +//// +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedClassInNamespace6.ts b/tests/cases/fourslash/unusedClassInNamespace6.ts new file mode 100644 index 0000000000000..b241301897216 --- /dev/null +++ b/tests/cases/fourslash/unusedClassInNamespace6.ts @@ -0,0 +1,19 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +////namespace Validation { +//// class c1 { +//// +//// } +//// +//// export class c2 { +//// +//// }/*0*/ +//// +//// class c3 { +//// public x: c1; +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts new file mode 100644 index 0000000000000..f6bd71dbe051d --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace3.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true + +////namespace Validation {/*0*/ +//// function function1() { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts new file mode 100644 index 0000000000000..9edf0e21e3734 --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace4.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +////namespace Validation {/*0*/ +//// var function1 = function() { +//// }/*1*/ +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts new file mode 100644 index 0000000000000..e128d140b3918 --- /dev/null +++ b/tests/cases/fourslash/unusedFunctionInNamespace5.ts @@ -0,0 +1,24 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +////namespace Validation { +//// var function1 = function() { +//// } +//// +//// export function function2() { +//// +//// } +//// +//// function function3() { +//// function1(); +//// }/*0*/ +//// +//// function function4() { +//// +//// }/*1*/ +//// +//// export let a = function3; +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts new file mode 100644 index 0000000000000..1c36d3ea13ff4 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +////class greeter { +//// public function1() { +//// var /*0*/x,/*1*/ y = 10; +//// y++; +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts new file mode 100644 index 0000000000000..63357128876c4 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +////class greeter { +//// public function1() { +//// var /*0*/x,/*1*/ y; +//// y = 1; +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts new file mode 100644 index 0000000000000..f04f517d3c553 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts @@ -0,0 +1,11 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters:true +////class greeter { +//// constructor() {/*0*/ +//// var unused = 20;/*1*/ +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts new file mode 100644 index 0000000000000..615d835c4e160 --- /dev/null +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +////class greeter { +//// constructor() {/*0*/ +//// var unused = 20;/*1*/ +//// var used = "dummy"; +//// used = used + "second part"; +//// } +////} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); From c102c3a55316209b48d225694274f06adc30a3a7 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 9 Jun 2016 09:58:09 -0700 Subject: [PATCH 23/90] Added error message --- src/services/quickfixes/unusedIdentifierFixes.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/quickfixes/unusedIdentifierFixes.ts b/src/services/quickfixes/unusedIdentifierFixes.ts index 52ea5109e0992..43d3e72de9a0a 100644 --- a/src/services/quickfixes/unusedIdentifierFixes.ts +++ b/src/services/quickfixes/unusedIdentifierFixes.ts @@ -19,7 +19,7 @@ namespace ts.quickFix { } } } - throw new Error("Not implemented"); + throw new Error("No Quick Fix for found"); } }); @@ -47,7 +47,8 @@ namespace ts.quickFix { if (token.parent.kind === SyntaxKind.FunctionDeclaration || token.parent.kind === SyntaxKind.ClassDeclaration || token.parent.kind === SyntaxKind.InterfaceDeclaration || - token.parent.kind === SyntaxKind.MethodDeclaration) { + token.parent.kind === SyntaxKind.MethodDeclaration || + token.parent.kind === SyntaxKind.ArrowFunction) { return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; } @@ -68,6 +69,8 @@ namespace ts.quickFix { if(token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; } + + throw new Error("No Quick Fix for found"); } }); } From eb7fa709d87c5a35744803fd1cf62b6459a3cd6b Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 10 Jun 2016 15:18:45 -0700 Subject: [PATCH 24/90] Fix tests --- src/services/quickfixes/quickFixProvider.ts | 5 ----- src/services/services.ts | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/quickfixes/quickFixProvider.ts b/src/services/quickfixes/quickFixProvider.ts index 25205cf5c96db..551994a7a4c94 100644 --- a/src/services/quickfixes/quickFixProvider.ts +++ b/src/services/quickfixes/quickFixProvider.ts @@ -6,11 +6,6 @@ namespace ts { getFix(sourceFile: SourceFile, start: number, end: number): TextChange[]; } - export interface SuggestedFix { - name: string; - textChanges: TextChange[]; - } - export namespace quickFix { export const enum FixPriority { AboveNormal, diff --git a/src/services/services.ts b/src/services/services.ts index 8e8b504329d96..18ae5f2ca3cb5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1164,6 +1164,11 @@ namespace ts { newText: string; } + export interface SuggestedFix { + name: string; + textChanges: TextChange[]; + } + export interface TextInsertion { newText: string; /** The position in newText the caret should point to after the insertion. */ From a1fa10d60aeb8991372924db65ff29e28a5c22ac Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 13 Jun 2016 11:29:36 -0700 Subject: [PATCH 25/90] Quick fix for implementing interfaces --- src/services/quickfixes/interfaceFixes.ts | 63 +++++++++++++++++++ src/services/quickfixes/quickFixProvider.ts | 6 +- src/services/quickfixes/references.ts | 1 + src/services/services.ts | 4 +- src/services/tsconfig.json | 1 + .../fourslash/unImplementedInterface1.ts | 18 ++++++ .../cases/fourslash/unImplementedIterface1.ts | 18 ++++++ 7 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 src/services/quickfixes/interfaceFixes.ts create mode 100644 tests/cases/fourslash/unImplementedInterface1.ts create mode 100644 tests/cases/fourslash/unImplementedIterface1.ts diff --git a/src/services/quickfixes/interfaceFixes.ts b/src/services/quickfixes/interfaceFixes.ts new file mode 100644 index 0000000000000..a3da8a354e7c1 --- /dev/null +++ b/src/services/quickfixes/interfaceFixes.ts @@ -0,0 +1,63 @@ +/* @internal */ +namespace ts.quickFix { + registerQuickFix({ + name: "Implement Interface", + errorCode: "TS2420", + getFix: (sourceFile: SourceFile, start: number, end: number, program: Program): { newText: string; span: { start: number, length: number } }[] => { + const token = getTokenAtPosition(sourceFile, start); + let changesArray: { newText: string; span: { start: number, length: number } }[] = []; + + if(token.kind === SyntaxKind.Identifier) { + if(token.parent.kind === SyntaxKind.ClassDeclaration) { + let classDeclaration = token.parent; + let typeChecker = program.getTypeChecker(); + + let classMembers: Array = []; + for (let i = 0; classDeclaration.members && i < classDeclaration.members.length; i++) { + if (classDeclaration.members[i].name) { + classMembers.push(classDeclaration.members[i].name.getText()); + } + } + + let interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration); + let startPos: number = classDeclaration.members.pos; + + for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) { + let type = typeChecker.getTypeAtLocation(interfaceClauses[i]); + if (type && type.symbol && type.symbol.declarations) { + let interfaceMembers = (type.symbol.declarations[0]).members; + for (let j = 0; interfaceMembers && j < interfaceMembers.length; j++) { + if (interfaceMembers[j].name && classMembers.indexOf(interfaceMembers[j].name.getText()) === -1) { + if (interfaceMembers[j].kind === SyntaxKind.PropertySignature) { + let interfaceProperty = interfaceMembers[j]; + let propertyText = interfaceProperty.getText() + "sys.newLine"; + changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); + + } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature) { + let interfaceMethod = interfaceMembers[j]; + let methodBody = "throw new Error('Method not Implemented');"; + + let methodText:string = interfaceMethod.getText(); + if(methodText.match(/;$/)) { + methodText = methodText.substr(0, methodText.length - 1); + } + + methodText = methodText.concat("{sys.newLine"); + methodText = methodText.concat(methodBody, "sys.newLine"); + methodText = methodText.concat("}sys.newLine"); + changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); + } + } + } + } + } + } + } + + if (changesArray.length !== 0) + return changesArray; + + throw new Error("No Quick Fix found"); + } + }); +} diff --git a/src/services/quickfixes/quickFixProvider.ts b/src/services/quickfixes/quickFixProvider.ts index 3f77125457a93..32a920874cf7a 100644 --- a/src/services/quickfixes/quickFixProvider.ts +++ b/src/services/quickfixes/quickFixProvider.ts @@ -4,7 +4,7 @@ namespace ts { export interface QuickFix { name: string; errorCode: string; - getFix(sourceFile: SourceFile, start: number, end: number): TextChange[]; + getFix(sourceFile: SourceFile, start: number, end: number, program?: Program): TextChange[]; } export interface SuggestedFix { @@ -36,14 +36,14 @@ namespace ts { return getKeys(quickFixes); } - public fix(errorCode: string, sourceFile: SourceFile, start: number, end: number): SuggestedFix{ + public fix(errorCode: string, sourceFile: SourceFile, start: number, end: number, program: Program): SuggestedFix{ const fix = quickFixes[errorCode]; if (!fix) { throw new Error(`No fix found for error: '${errorCode}'`); } - return { name: fix.name, textChanges: fix.getFix(sourceFile, start, end) }; + return { name: fix.name, textChanges: fix.getFix(sourceFile, start, end, program) }; } } } diff --git a/src/services/quickfixes/references.ts b/src/services/quickfixes/references.ts index 5d6e446ea45a9..9b3412b368654 100644 --- a/src/services/quickfixes/references.ts +++ b/src/services/quickfixes/references.ts @@ -2,3 +2,4 @@ /// /// /// +/// diff --git a/src/services/services.ts b/src/services/services.ts index 1b958883aa6e7..98475ec4185be 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -7511,9 +7511,9 @@ namespace ts { function getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): SuggestedFix { synchronizeHostData(); - const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + const sourceFile = getValidSourceFile(fileName); - return quickFixProvider.fix(errorCodes[0], sourceFile, start, end); + return quickFixProvider.fix(errorCodes[0], sourceFile, start, end, program); } /** diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 6aa7e61391bfd..742a54b614f8d 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -15,6 +15,7 @@ "../compiler/utilities.ts", "../compiler/binder.ts", "../compiler/checker.ts", + "../compiler/utilities.ts", "../compiler/emitter.ts", "../compiler/program.ts", "../compiler/declarationEmitter.ts", diff --git a/tests/cases/fourslash/unImplementedInterface1.ts b/tests/cases/fourslash/unImplementedInterface1.ts new file mode 100644 index 0000000000000..05d4afac652df --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface1.ts @@ -0,0 +1,18 @@ +/// + +////namespace N1 { +//// class K {} +//// export interface I1 { +//// f1(); +//// f2(str: string, num: number): T; +//// x: number; +//// } +////}/*0*//*1*/ +////interface I1 { +//// f1(); +////} +//// +//// class C1 implements N1.I1 { +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); diff --git a/tests/cases/fourslash/unImplementedIterface1.ts b/tests/cases/fourslash/unImplementedIterface1.ts new file mode 100644 index 0000000000000..05d4afac652df --- /dev/null +++ b/tests/cases/fourslash/unImplementedIterface1.ts @@ -0,0 +1,18 @@ +/// + +////namespace N1 { +//// class K {} +//// export interface I1 { +//// f1(); +//// f2(str: string, num: number): T; +//// x: number; +//// } +////}/*0*//*1*/ +////interface I1 { +//// f1(); +////} +//// +//// class C1 implements N1.I1 { +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); From 37e25dfeb695a3299b4f8d2e23570cd1cef7ca12 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 13 Jun 2016 11:33:16 -0700 Subject: [PATCH 26/90] Changes the signature and error message --- src/services/quickfixes/unusedIdentifierFixes.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/services/quickfixes/unusedIdentifierFixes.ts b/src/services/quickfixes/unusedIdentifierFixes.ts index 43d3e72de9a0a..519d666aa8804 100644 --- a/src/services/quickfixes/unusedIdentifierFixes.ts +++ b/src/services/quickfixes/unusedIdentifierFixes.ts @@ -3,7 +3,7 @@ namespace ts.quickFix { registerQuickFix({ name: "Remove Unused Parameters", errorCode: "TS6133", - getFix: (sourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { + getFix: (sourceFile: SourceFile, start: number, end: number): { newText: string; span: { start: number, length: number } }[] => { const token = getTokenAtPosition(sourceFile, start); if (token.kind === ts.SyntaxKind.Identifier) { if (token.parent.kind === ts.SyntaxKind.Parameter) { @@ -19,14 +19,14 @@ namespace ts.quickFix { } } } - throw new Error("No Quick Fix for found"); + throw new Error("No Quick Fix found"); } }); registerQuickFix({ name: "Remove Unused Identifiers", errorCode: "TS6132", - getFix: (sourceFile: SourceFile, start: number, end: number): [{ newText: string; span: { start: number, length: number } }] => { + getFix: (sourceFile: SourceFile, start: number, end: number): { newText: string; span: { start: number, length: number } }[] => { const token = getTokenAtPosition(sourceFile, start); if (token.kind === ts.SyntaxKind.Identifier) { @@ -70,7 +70,7 @@ namespace ts.quickFix { return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; } - throw new Error("No Quick Fix for found"); + throw new Error("No Quick Fix found"); } }); } From 2e48281c5a77ccfa124471aa0aede380ac4d07f0 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 13 Jun 2016 12:36:11 -0700 Subject: [PATCH 27/90] Modified the test case and expected results --- src/harness/fourslash.ts | 13 ++++++++++--- src/services/quickfixes/interfaceFixes.ts | 4 ++-- .../fourslash/unImplementedInterface1.ts | 19 ++++++++----------- .../cases/fourslash/unImplementedIterface1.ts | 18 ------------------ 4 files changed, 20 insertions(+), 34 deletions(-) delete mode 100644 tests/cases/fourslash/unImplementedIterface1.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 32cae5c7dac2a..8e85e45758cb3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1834,9 +1834,16 @@ namespace FourSlash { this.raiseError("Not the expected text change."); } - if (actual.textChanges[0].span.start !== start || - (actual.textChanges[0].span.start + actual.textChanges[0].span.length) !== end) { - this.raiseError("Not the expected span range."); + if (expectedChange.newText.length === 0) { + if (actual.textChanges[0].span.start !== start || + (actual.textChanges[0].span.start + actual.textChanges[0].span.length) !== end) { + this.raiseError("Not the expected span range."); + } + } + else { + if (actual.textChanges[0].span.start !== start) { + this.raiseError("Not the expected span range."); + } } } diff --git a/src/services/quickfixes/interfaceFixes.ts b/src/services/quickfixes/interfaceFixes.ts index a3da8a354e7c1..ce74ab8326643 100644 --- a/src/services/quickfixes/interfaceFixes.ts +++ b/src/services/quickfixes/interfaceFixes.ts @@ -30,7 +30,7 @@ namespace ts.quickFix { if (interfaceMembers[j].name && classMembers.indexOf(interfaceMembers[j].name.getText()) === -1) { if (interfaceMembers[j].kind === SyntaxKind.PropertySignature) { let interfaceProperty = interfaceMembers[j]; - let propertyText = interfaceProperty.getText() + "sys.newLine"; + let propertyText = interfaceProperty.getText() + " sys.newLine"; changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature) { @@ -42,7 +42,7 @@ namespace ts.quickFix { methodText = methodText.substr(0, methodText.length - 1); } - methodText = methodText.concat("{sys.newLine"); + methodText = methodText.concat("{sys.newLine "); methodText = methodText.concat(methodBody, "sys.newLine"); methodText = methodText.concat("}sys.newLine"); changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); diff --git a/tests/cases/fourslash/unImplementedInterface1.ts b/tests/cases/fourslash/unImplementedInterface1.ts index 05d4afac652df..4f7219daac29c 100644 --- a/tests/cases/fourslash/unImplementedInterface1.ts +++ b/tests/cases/fourslash/unImplementedInterface1.ts @@ -1,18 +1,15 @@ /// -////namespace N1 { -//// class K {} -//// export interface I1 { +//// namespace N1 { +//// export interface I1 { +//// f1(); +//// } +//// } +//// interface I1 { //// f1(); -//// f2(str: string, num: number): T; -//// x: number; //// } -////}/*0*//*1*/ -////interface I1 { -//// f1(); -////} //// -//// class C1 implements N1.I1 { +//// class C1 implements N1.I1 {/*0*//*1*/ //// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedIterface1.ts b/tests/cases/fourslash/unImplementedIterface1.ts deleted file mode 100644 index 05d4afac652df..0000000000000 --- a/tests/cases/fourslash/unImplementedIterface1.ts +++ /dev/null @@ -1,18 +0,0 @@ -/// - -////namespace N1 { -//// class K {} -//// export interface I1 { -//// f1(); -//// f2(str: string, num: number): T; -//// x: number; -//// } -////}/*0*//*1*/ -////interface I1 { -//// f1(); -////} -//// -//// class C1 implements N1.I1 { -//// } - -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); From 3d25daf44e7dc0317ed83823a6a742a51328f477 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 14 Jun 2016 17:02:48 -0700 Subject: [PATCH 28/90] Additional scenarios for handling the Interface Implementation --- src/services/quickfixes/interfaceFixes.ts | 198 ++++++++++++++---- .../fourslash/unImplementedInterface10.ts | 15 ++ .../fourslash/unImplementedInterface11.ts | 17 ++ .../fourslash/unImplementedInterface12.ts | 17 ++ .../fourslash/unImplementedInterface13.ts | 17 ++ .../fourslash/unImplementedInterface14.ts | 13 ++ .../fourslash/unImplementedInterface15.ts | 11 + .../fourslash/unImplementedInterface16.ts | 11 + .../fourslash/unImplementedInterface17.ts | 11 + .../fourslash/unImplementedInterface18.ts | 11 + .../fourslash/unImplementedInterface19.ts | 13 ++ .../fourslash/unImplementedInterface2.ts | 15 ++ .../fourslash/unImplementedInterface20.ts | 13 ++ .../fourslash/unImplementedInterface21.ts | 13 ++ .../fourslash/unImplementedInterface22.ts | 11 + .../fourslash/unImplementedInterface23.ts | 13 ++ .../fourslash/unImplementedInterface24.ts | 11 + .../fourslash/unImplementedInterface25.ts | 13 ++ .../fourslash/unImplementedInterface26.ts | 13 ++ .../fourslash/unImplementedInterface27.ts | 15 ++ .../fourslash/unImplementedInterface28.ts | 14 ++ .../fourslash/unImplementedInterface3.ts | 15 ++ .../fourslash/unImplementedInterface4.ts | 15 ++ .../fourslash/unImplementedInterface5.ts | 15 ++ .../fourslash/unImplementedInterface6.ts | 12 ++ .../fourslash/unImplementedInterface7.ts | 12 ++ .../fourslash/unImplementedInterface8.ts | 12 ++ .../fourslash/unImplementedInterface9.ts | 15 ++ 28 files changed, 518 insertions(+), 43 deletions(-) create mode 100644 tests/cases/fourslash/unImplementedInterface10.ts create mode 100644 tests/cases/fourslash/unImplementedInterface11.ts create mode 100644 tests/cases/fourslash/unImplementedInterface12.ts create mode 100644 tests/cases/fourslash/unImplementedInterface13.ts create mode 100644 tests/cases/fourslash/unImplementedInterface14.ts create mode 100644 tests/cases/fourslash/unImplementedInterface15.ts create mode 100644 tests/cases/fourslash/unImplementedInterface16.ts create mode 100644 tests/cases/fourslash/unImplementedInterface17.ts create mode 100644 tests/cases/fourslash/unImplementedInterface18.ts create mode 100644 tests/cases/fourslash/unImplementedInterface19.ts create mode 100644 tests/cases/fourslash/unImplementedInterface2.ts create mode 100644 tests/cases/fourslash/unImplementedInterface20.ts create mode 100644 tests/cases/fourslash/unImplementedInterface21.ts create mode 100644 tests/cases/fourslash/unImplementedInterface22.ts create mode 100644 tests/cases/fourslash/unImplementedInterface23.ts create mode 100644 tests/cases/fourslash/unImplementedInterface24.ts create mode 100644 tests/cases/fourslash/unImplementedInterface25.ts create mode 100644 tests/cases/fourslash/unImplementedInterface26.ts create mode 100644 tests/cases/fourslash/unImplementedInterface27.ts create mode 100644 tests/cases/fourslash/unImplementedInterface28.ts create mode 100644 tests/cases/fourslash/unImplementedInterface3.ts create mode 100644 tests/cases/fourslash/unImplementedInterface4.ts create mode 100644 tests/cases/fourslash/unImplementedInterface5.ts create mode 100644 tests/cases/fourslash/unImplementedInterface6.ts create mode 100644 tests/cases/fourslash/unImplementedInterface7.ts create mode 100644 tests/cases/fourslash/unImplementedInterface8.ts create mode 100644 tests/cases/fourslash/unImplementedInterface9.ts diff --git a/src/services/quickfixes/interfaceFixes.ts b/src/services/quickfixes/interfaceFixes.ts index ce74ab8326643..b723dca6dd975 100644 --- a/src/services/quickfixes/interfaceFixes.ts +++ b/src/services/quickfixes/interfaceFixes.ts @@ -1,56 +1,53 @@ /* @internal */ namespace ts.quickFix { registerQuickFix({ - name: "Implement Interface", - errorCode: "TS2420", + name: "Implement Interface on Reference", + errorCode: "TS2322", getFix: (sourceFile: SourceFile, start: number, end: number, program: Program): { newText: string; span: { start: number, length: number } }[] => { const token = getTokenAtPosition(sourceFile, start); let changesArray: { newText: string; span: { start: number, length: number } }[] = []; - if(token.kind === SyntaxKind.Identifier) { - if(token.parent.kind === SyntaxKind.ClassDeclaration) { - let classDeclaration = token.parent; - let typeChecker = program.getTypeChecker(); + if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.VariableDeclaration) { + let variableDeclaration = token.parent; + let membersAndStartPosObject: { startPos: number, members: Array } = getMembersAndStartPosFromReference(variableDeclaration); + let variableMembers: Array = membersAndStartPosObject.members; + let trackingAddedMembers: Array = []; + let startPos: number = membersAndStartPosObject.startPos; - let classMembers: Array = []; - for (let i = 0; classDeclaration.members && i < classDeclaration.members.length; i++) { - if (classDeclaration.members[i].name) { - classMembers.push(classDeclaration.members[i].name.getText()); - } + if (variableDeclaration.type.kind === SyntaxKind.TypeReference) { + changesArray = changesArray.concat(getChanges(variableDeclaration.type, variableMembers, startPos, program, true, trackingAddedMembers)); + } + else if(variableDeclaration.type.kind === SyntaxKind.UnionType) { + let types = (variableDeclaration.type).types; + for (let i = 0; i < types.length; i++) { + changesArray = changesArray.concat(getChanges(types[i], variableMembers, startPos, program, true, trackingAddedMembers)); } + } + } - let interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration); - let startPos: number = classDeclaration.members.pos; - - for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) { - let type = typeChecker.getTypeAtLocation(interfaceClauses[i]); - if (type && type.symbol && type.symbol.declarations) { - let interfaceMembers = (type.symbol.declarations[0]).members; - for (let j = 0; interfaceMembers && j < interfaceMembers.length; j++) { - if (interfaceMembers[j].name && classMembers.indexOf(interfaceMembers[j].name.getText()) === -1) { - if (interfaceMembers[j].kind === SyntaxKind.PropertySignature) { - let interfaceProperty = interfaceMembers[j]; - let propertyText = interfaceProperty.getText() + " sys.newLine"; - changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); - - } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature) { - let interfaceMethod = interfaceMembers[j]; - let methodBody = "throw new Error('Method not Implemented');"; - - let methodText:string = interfaceMethod.getText(); - if(methodText.match(/;$/)) { - methodText = methodText.substr(0, methodText.length - 1); - } - - methodText = methodText.concat("{sys.newLine "); - methodText = methodText.concat(methodBody, "sys.newLine"); - methodText = methodText.concat("}sys.newLine"); - changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); - } - } - } - } - } + if (changesArray.length !== 0) + return changesArray; + + throw new Error("No Quick Fix found"); + } + }); + + registerQuickFix({ + name: "Implement Interface On Class", + errorCode: "TS2420", + getFix: (sourceFile: SourceFile, start: number, end: number, program: Program): { newText: string; span: { start: number, length: number } }[] => { + const token = getTokenAtPosition(sourceFile, start); + let changesArray: { newText: string; span: { start: number, length: number } }[] = []; + + if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { + let classDeclaration = token.parent; + let startPos: number = classDeclaration.members.pos; + let classMembers: Array = getClassMembers(classDeclaration); + let trackingAddedMembers: Array = []; + let interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration); + + for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) { + changesArray = changesArray.concat(getChanges(interfaceClauses[i], classMembers, startPos, program, false, trackingAddedMembers)); } } @@ -60,4 +57,119 @@ namespace ts.quickFix { throw new Error("No Quick Fix found"); } }); + + function getChanges(interfaceClause: Node, existingMembers: Array, startPos: number, program: Program, reference: boolean, trackingAddedMembers: Array): { newText: string; span: { start: number, length: number } }[] { + let type = program.getTypeChecker().getTypeAtLocation(interfaceClause); + let changesArray: { newText: string; span: { start: number, length: number } }[] = []; + + if (type && type.symbol && type.symbol.declarations) { + let interfaceMembers = getMembers(type.symbol.declarations[0], program); + for (let j = 0; interfaceMembers && j < interfaceMembers.length; j++) { + if (interfaceMembers[j].name && existingMembers.indexOf(interfaceMembers[j].name.getText()) === -1) { + if (interfaceMembers[j].kind === SyntaxKind.PropertySignature) { + let interfaceProperty = interfaceMembers[j]; + if(trackingAddedMembers.indexOf(interfaceProperty.name.getText()) === -1) { + let propertyText:string = ""; + if(reference) { + propertyText = interfaceProperty.name.getText(); + propertyText += " : "; + propertyText += getDefaultValue(interfaceProperty.type.kind) + propertyText += ",sys.newLine"; + } else { + propertyText = interfaceProperty.getText(); + let stringToAdd:string = (propertyText.match(/;$/) === null) ? ";sys.newLine" : "sys.newLine"; + propertyText += stringToAdd; + } + changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); + trackingAddedMembers.push(interfaceProperty.name.getText()); + } + } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature) { + let interfaceMethod = interfaceMembers[j]; + if (trackingAddedMembers.indexOf(interfaceMethod.name.getText())) { + let methodBody = "throw new Error('Method not Implemented');"; + + let methodText: string = interfaceMethod.getText(); + if (methodText.match(/;$/)) { + methodText = methodText.substr(0, methodText.length - 1); + } + + methodText = methodText.concat("{sys.newLine "); + methodText = methodText.concat(methodBody, "sys.newLine"); + methodText = reference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); + changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); + trackingAddedMembers.push(interfaceMethod.name.getText()); + } + } + } + } + } + + if(reference && existingMembers.length === 0 && changesArray.length > 0) { + let lastValue:string = changesArray[changesArray.length - 1].newText; + lastValue = lastValue.substr(0, lastValue.length - 12); + lastValue = lastValue + " sys.newLine"; + changesArray[changesArray.length - 1].newText = lastValue; + } + + return changesArray; + } + + function getMembers(declaration: InterfaceDeclaration, program: Program): Array { + let clauses = getInterfaceBaseTypeNodes(declaration); + let result = new Array(); + for (let i = 0; clauses && i < clauses.length; i++) { + let type = program.getTypeChecker().getTypeAtLocation(clauses[i]); + if (type && type.symbol && type.symbol.declarations) { + result = result.concat(getMembers(type.symbol.declarations[0], program)); + } + } + + if (declaration.members) { + result = result.concat(declaration.members); + } + + return result; + } + + function getClassMembers(classDeclaration: ClassDeclaration): Array { + let classMembers: Array = []; + for (let i = 0; classDeclaration.members && i < classDeclaration.members.length; i++) { + if (classDeclaration.members[i].name) { + classMembers.push(classDeclaration.members[i].name.getText()); + } + } + return classMembers; + } + + function getMembersAndStartPosFromReference(variableDeclaration: VariableDeclaration): { startPos: number, members: Array } { + let children: Node[] = variableDeclaration.getChildren(); + let variableMembers: Array = new Array(); + let startPos: number = 0; + + for (let i = 0; i < children.length; i++) { + if (children[i].kind === SyntaxKind.ObjectLiteralExpression) { + startPos = children[i].pos + 1; + let properties = (children[i]).properties; + for (let j = 0; properties && j < properties.length; j++) { + if (properties[j].name) { + variableMembers.push(properties[j].name.getText()); + } + } + } + } + + return { startPos: startPos, members: variableMembers }; + } + + function getDefaultValue(kind: SyntaxKind): string { + switch(kind) { + case SyntaxKind.StringKeyword: + return '""'; + case SyntaxKind.BooleanKeyword: + return "false"; + case SyntaxKind.NumberKeyword: + return "0"; + } + return "null"; + } } diff --git a/tests/cases/fourslash/unImplementedInterface10.ts b/tests/cases/fourslash/unImplementedInterface10.ts new file mode 100644 index 0000000000000..4ed197fd25d23 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface10.ts @@ -0,0 +1,15 @@ +/// + +//// interface I1 { +//// f1() +//// } +//// +//// interface I2 extends I1 { +//// +//// } +//// +//// +//// class C1 implements I2 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface11.ts b/tests/cases/fourslash/unImplementedInterface11.ts new file mode 100644 index 0000000000000..9fae38f33b6ff --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface11.ts @@ -0,0 +1,17 @@ +/// + +//// interface I1 { +//// +//// } +//// +//// interface I2 extends I1 { +//// f1(); +//// } +//// +//// interface I3 extends I2 {} +//// +//// +//// class C1 implements I3 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface12.ts b/tests/cases/fourslash/unImplementedInterface12.ts new file mode 100644 index 0000000000000..6c9a96f6e9786 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface12.ts @@ -0,0 +1,17 @@ +/// + +//// interface I1 { +//// +//// } +//// +//// interface I2 { +//// f1(); +//// } +//// +//// interface I3 extends I2, I1 {} +//// +//// +//// class C1 implements I3 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface13.ts b/tests/cases/fourslash/unImplementedInterface13.ts new file mode 100644 index 0000000000000..1a7d7796e88a5 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface13.ts @@ -0,0 +1,17 @@ +/// + +//// interface I1 { +//// f1(); +//// } +//// +//// interface I2 { +//// f1(); +//// } +//// +//// interface I3 extends I2, I1 {} +//// +//// +//// class C1 implements I3 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface14.ts b/tests/cases/fourslash/unImplementedInterface14.ts new file mode 100644 index 0000000000000..8a38715f7beb0 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface14.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// f1(); +//// f2(); +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// f2() {} +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine},sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface15.ts b/tests/cases/fourslash/unImplementedInterface15.ts new file mode 100644 index 0000000000000..b1664153e6d10 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface15.ts @@ -0,0 +1,11 @@ +/// + +//// interface I1 { +//// f1(); +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface16.ts b/tests/cases/fourslash/unImplementedInterface16.ts new file mode 100644 index 0000000000000..9c89289ff3310 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface16.ts @@ -0,0 +1,11 @@ +/// + +//// interface I1 { +//// x:string; +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: 'x : "" sys.newLine' }); diff --git a/tests/cases/fourslash/unImplementedInterface17.ts b/tests/cases/fourslash/unImplementedInterface17.ts new file mode 100644 index 0000000000000..7d523fdde3b07 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface17.ts @@ -0,0 +1,11 @@ +/// + +//// interface I1 { +//// x:number; +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : 0 sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface18.ts b/tests/cases/fourslash/unImplementedInterface18.ts new file mode 100644 index 0000000000000..4b1261b7dd53e --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface18.ts @@ -0,0 +1,11 @@ +/// + +//// interface I1 { +//// x:boolean; +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : false sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface19.ts b/tests/cases/fourslash/unImplementedInterface19.ts new file mode 100644 index 0000000000000..0d8c293608271 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface19.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// x:string; +//// f1(); +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// f1(){} +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: 'x : "",sys.newLine' }); diff --git a/tests/cases/fourslash/unImplementedInterface2.ts b/tests/cases/fourslash/unImplementedInterface2.ts new file mode 100644 index 0000000000000..9e53ad1881c99 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface2.ts @@ -0,0 +1,15 @@ +/// + +//// namespace N1 { +//// export interface I1 { +//// x: number; +//// } +//// } +//// interface I1 { +//// f1(); +//// } +//// +//// class C1 implements N1.I1 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x: number;sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface20.ts b/tests/cases/fourslash/unImplementedInterface20.ts new file mode 100644 index 0000000000000..9aed04827332f --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface20.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// x:number; +//// f1(); +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// f1(){} +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : 0,sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface21.ts b/tests/cases/fourslash/unImplementedInterface21.ts new file mode 100644 index 0000000000000..f82bdd8deb98f --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface21.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// x:boolean; +//// f1(); +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// f1(){} +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : false,sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface22.ts b/tests/cases/fourslash/unImplementedInterface22.ts new file mode 100644 index 0000000000000..02a5b8f7537b9 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface22.ts @@ -0,0 +1,11 @@ +/// + +//// interface I1 { +//// x:[string]; +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface23.ts b/tests/cases/fourslash/unImplementedInterface23.ts new file mode 100644 index 0000000000000..2ea9416d3f405 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface23.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// x:[string]; +//// f1(); +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// f1(){} +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null,sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface24.ts b/tests/cases/fourslash/unImplementedInterface24.ts new file mode 100644 index 0000000000000..9365de0c792c0 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface24.ts @@ -0,0 +1,11 @@ +/// + +//// interface I1 { +//// x:Array; +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface25.ts b/tests/cases/fourslash/unImplementedInterface25.ts new file mode 100644 index 0000000000000..3659ed3512ffd --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface25.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// x:Array; +//// f1(); +//// } +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// f1(){} +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null,sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface26.ts b/tests/cases/fourslash/unImplementedInterface26.ts new file mode 100644 index 0000000000000..fa11a73dbb777 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface26.ts @@ -0,0 +1,13 @@ +/// + +//// interface I1 { +//// x:T; +//// } +//// +//// class T {} +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface27.ts b/tests/cases/fourslash/unImplementedInterface27.ts new file mode 100644 index 0000000000000..bf674e43e053f --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface27.ts @@ -0,0 +1,15 @@ +/// + +//// interface I1 { +//// x:T; +//// f1(); +//// } +//// +//// class T {} +//// +//// +//// var x: I1 ={/*0*//*1*/ +//// f1(){} +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null,sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface28.ts b/tests/cases/fourslash/unImplementedInterface28.ts new file mode 100644 index 0000000000000..1ec0e2fe56110 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface28.ts @@ -0,0 +1,14 @@ +/// + +//// interface I1 { +//// f1(); +//// } +//// +//// interface I2 { +//// f2(); +//// } +//// +//// var x: I1|I2 ={/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface3.ts b/tests/cases/fourslash/unImplementedInterface3.ts new file mode 100644 index 0000000000000..5f60acee7ca1c --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface3.ts @@ -0,0 +1,15 @@ +/// + +//// namespace N1 { +//// export interface I1 { +//// x: number +//// } +//// } +//// interface I1 { +//// f1(); +//// } +//// +//// class C1 implements N1.I1 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x: number;sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface4.ts b/tests/cases/fourslash/unImplementedInterface4.ts new file mode 100644 index 0000000000000..95f9a2db90a09 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface4.ts @@ -0,0 +1,15 @@ +/// + +//// namespace N1 { +//// export interface I1 { +//// f1() +//// } +//// } +//// interface I1 { +//// f1(); +//// } +//// +//// class C1 implements N1.I1 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface5.ts b/tests/cases/fourslash/unImplementedInterface5.ts new file mode 100644 index 0000000000000..dc487b68d9a1b --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface5.ts @@ -0,0 +1,15 @@ +/// + +//// namespace N1 { +//// export interface I1 { +//// f1(x: number, y: string) +//// } +//// } +//// interface I1 { +//// f1(); +//// } +//// +//// class C1 implements N1.I1 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number, y: string){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface6.ts b/tests/cases/fourslash/unImplementedInterface6.ts new file mode 100644 index 0000000000000..fd7e059f813de --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface6.ts @@ -0,0 +1,12 @@ +/// + +//// interface I1 { +//// f1(x: number, y: T); +//// } +//// +//// class T {} +//// +//// class C1 implements I1 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number, y: T){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface7.ts b/tests/cases/fourslash/unImplementedInterface7.ts new file mode 100644 index 0000000000000..77f3b96d1c661 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface7.ts @@ -0,0 +1,12 @@ +/// + +//// interface I1 { +//// f1(x: number, y: C2); +//// } +//// +//// class C2 {} +//// +//// class C1 implements I1 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number, y: C2){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface8.ts b/tests/cases/fourslash/unImplementedInterface8.ts new file mode 100644 index 0000000000000..902309f0fd82a --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface8.ts @@ -0,0 +1,12 @@ +/// + +//// interface I1 { +//// f1(x: number, y: C2); +//// } +//// +//// class C2 {} +//// +//// class C1 implements I1 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number, y: C2){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface9.ts b/tests/cases/fourslash/unImplementedInterface9.ts new file mode 100644 index 0000000000000..bfaa87ea51c0e --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface9.ts @@ -0,0 +1,15 @@ +/// + +//// interface I1 { +//// +//// } +//// +//// interface I2 extends I1 { +//// f1(); +//// } +//// +//// +//// class C1 implements I2 {/*0*//*1*/ +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); From 5a34352d6f897c0ff4ce5f557639958272f6f417 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 11:24:28 -0700 Subject: [PATCH 29/90] Adding condition to ignore constructor parameters --- src/compiler/checker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 05172c9ed5c73..5dbc92d6d91ff 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14221,7 +14221,9 @@ namespace ts { function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { checkUnusedIdentifiers(node); - checkUnusedParameters(node); + if (node.kind !== SyntaxKind.Constructor) { + checkUnusedParameters(node); + } } function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { From 93b7490115c1270ed029c3c8d459dc451ca4eb1d Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 11:42:04 -0700 Subject: [PATCH 30/90] Removing unnecessary tests --- .../unusedIdentifiersConsolidated1.errors.txt | 153 -------------- .../unusedIdentifiersConsolidated1.js | 187 ------------------ ...dMultipleParameter1InContructor.errors.txt | 16 -- .../unusedMultipleParameter1InContructor.js | 17 -- ...dMultipleParameter2InContructor.errors.txt | 19 -- .../unusedMultipleParameter2InContructor.js | 17 -- .../unusedParametersinConstructor1.errors.txt | 11 -- .../unusedParametersinConstructor1.js | 13 -- .../unusedParametersinConstructor2.errors.txt | 12 -- .../unusedParametersinConstructor2.js | 15 -- .../unusedParametersinConstructor3.errors.txt | 15 -- .../unusedParametersinConstructor3.js | 15 -- ...usedSingleParameterInContructor.errors.txt | 15 -- .../unusedSingleParameterInContructor.js | 15 -- .../unusedMultipleParameter1InContructor.ts | 9 - .../unusedMultipleParameter2InContructor.ts | 9 - .../unusedParametersinConstructor1.ts | 7 - .../unusedParametersinConstructor2.ts | 8 - .../unusedParametersinConstructor3.ts | 8 - .../unusedSingleParameterInContructor.ts | 8 - 20 files changed, 569 deletions(-) delete mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt delete mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.js delete mode 100644 tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt delete mode 100644 tests/baselines/reference/unusedMultipleParameter1InContructor.js delete mode 100644 tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt delete mode 100644 tests/baselines/reference/unusedMultipleParameter2InContructor.js delete mode 100644 tests/baselines/reference/unusedParametersinConstructor1.errors.txt delete mode 100644 tests/baselines/reference/unusedParametersinConstructor1.js delete mode 100644 tests/baselines/reference/unusedParametersinConstructor2.errors.txt delete mode 100644 tests/baselines/reference/unusedParametersinConstructor2.js delete mode 100644 tests/baselines/reference/unusedParametersinConstructor3.errors.txt delete mode 100644 tests/baselines/reference/unusedParametersinConstructor3.js delete mode 100644 tests/baselines/reference/unusedSingleParameterInContructor.errors.txt delete mode 100644 tests/baselines/reference/unusedSingleParameterInContructor.js delete mode 100644 tests/cases/compiler/unusedMultipleParameter1InContructor.ts delete mode 100644 tests/cases/compiler/unusedMultipleParameter2InContructor.ts delete mode 100644 tests/cases/compiler/unusedParametersinConstructor1.ts delete mode 100644 tests/cases/compiler/unusedParametersinConstructor2.ts delete mode 100644 tests/cases/compiler/unusedParametersinConstructor3.ts delete mode 100644 tests/cases/compiler/unusedSingleParameterInContructor.ts diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt deleted file mode 100644 index 27ec7d90821da..0000000000000 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ /dev/null @@ -1,153 +0,0 @@ -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): message TS6132: Variable 'unusedtypeparameter' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): message TS6132: Variable 'unusedprivatevariable' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): message TS6133: Parameter 'message' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): message TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): message TS6132: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): message TS6132: Variable 'numberRegexp' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): message TS6132: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): message TS6132: Variable 'usedLocallyInterface2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): message TS6132: Variable 'dummy' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): message TS6132: Variable 'unusedInterface' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): message TS6132: Variable 'class3' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: Variable 'interface5' has never been used. - - -==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== - - function greeter(person: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. - var unused = 20; - ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. - } - - class Dummy { - ~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedtypeparameter' has never been used. - private unusedprivatevariable: string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedprivatevariable' has never been used. - private greeting: string; - public unusedpublicvariable: string; - public typedvariable: usedtypeparameter; - - constructor(message: string) { - ~~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'message' has never been used. - var unused2 = 22; - ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. - this.greeting = "Dummy Message"; - } - - public greeter(person: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. - var unused = 20; - ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. - this.usedPrivateFunction(); - } - - private usedPrivateFunction() { - } - - private unUsedPrivateFunction() { - ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. - } - } - - var user = "Jane User"; - var user2 = "Jane2 User2"; - - namespace Validation { - export interface StringValidator { - isAcceptable(s: string): boolean; - } - - const lettersRegexp = /^[A-Za-z]+$/; - const numberRegexp = /^[0-9]+$/; - ~~~~~~~~~~~~ -!!! message TS6132: Variable 'numberRegexp' has never been used. - - export class LettersOnlyValidator implements StringValidator { - isAcceptable(s2: string) { - return lettersRegexp.test(s2); - } - - private unUsedPrivateFunction() { - ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. - } - } - - export class ZipCodeValidator implements StringValidator { - isAcceptable(s3: string) { - return s3.length === 5; - } - } - - interface usedLocallyInterface { - } - - interface usedLocallyInterface2 { - ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'usedLocallyInterface2' has never been used. - someFunction(s1: string): void; - } - - export interface exportedInterface { - } - - class dummy implements usedLocallyInterface { - ~~~~~ -!!! message TS6132: Variable 'dummy' has never been used. - } - - interface unusedInterface { - ~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedInterface' has never been used. - } - } - - - namespace Greeter { - class class1 { - } - - export class class2 extends class1 { - } - - class class3 { - ~~~~~~ -!!! message TS6132: Variable 'class3' has never been used. - } - - export class class4 { - } - - interface interface1 { - } - - export interface interface2 extends interface1 { - } - - interface interface3 { - } - - export interface interface4 { - } - - export let a: interface3; - - interface interface5 { - ~~~~~~~~~~ -!!! message TS6132: Variable 'interface5' has never been used. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.js b/tests/baselines/reference/unusedIdentifiersConsolidated1.js deleted file mode 100644 index 521f17bf5ef7e..0000000000000 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.js +++ /dev/null @@ -1,187 +0,0 @@ -//// [unusedIdentifiersConsolidated1.ts] - -function greeter(person: string) { - var unused = 20; -} - -class Dummy { - private unusedprivatevariable: string; - private greeting: string; - public unusedpublicvariable: string; - public typedvariable: usedtypeparameter; - - constructor(message: string) { - var unused2 = 22; - this.greeting = "Dummy Message"; - } - - public greeter(person: string) { - var unused = 20; - this.usedPrivateFunction(); - } - - private usedPrivateFunction() { - } - - private unUsedPrivateFunction() { - } -} - -var user = "Jane User"; -var user2 = "Jane2 User2"; - -namespace Validation { - export interface StringValidator { - isAcceptable(s: string): boolean; - } - - const lettersRegexp = /^[A-Za-z]+$/; - const numberRegexp = /^[0-9]+$/; - - export class LettersOnlyValidator implements StringValidator { - isAcceptable(s2: string) { - return lettersRegexp.test(s2); - } - - private unUsedPrivateFunction() { - } - } - - export class ZipCodeValidator implements StringValidator { - isAcceptable(s3: string) { - return s3.length === 5; - } - } - - interface usedLocallyInterface { - } - - interface usedLocallyInterface2 { - someFunction(s1: string): void; - } - - export interface exportedInterface { - } - - class dummy implements usedLocallyInterface { - } - - interface unusedInterface { - } -} - - -namespace Greeter { - class class1 { - } - - export class class2 extends class1 { - } - - class class3 { - } - - export class class4 { - } - - interface interface1 { - } - - export interface interface2 extends interface1 { - } - - interface interface3 { - } - - export interface interface4 { - } - - export let a: interface3; - - interface interface5 { - } -} - -//// [unusedIdentifiersConsolidated1.js] -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -function greeter(person) { - var unused = 20; -} -var Dummy = (function () { - function Dummy(message) { - var unused2 = 22; - this.greeting = "Dummy Message"; - } - Dummy.prototype.greeter = function (person) { - var unused = 20; - this.usedPrivateFunction(); - }; - Dummy.prototype.usedPrivateFunction = function () { - }; - Dummy.prototype.unUsedPrivateFunction = function () { - }; - return Dummy; -}()); -var user = "Jane User"; -var user2 = "Jane2 User2"; -var Validation; -(function (Validation) { - var lettersRegexp = /^[A-Za-z]+$/; - var numberRegexp = /^[0-9]+$/; - var LettersOnlyValidator = (function () { - function LettersOnlyValidator() { - } - LettersOnlyValidator.prototype.isAcceptable = function (s2) { - return lettersRegexp.test(s2); - }; - LettersOnlyValidator.prototype.unUsedPrivateFunction = function () { - }; - return LettersOnlyValidator; - }()); - Validation.LettersOnlyValidator = LettersOnlyValidator; - var ZipCodeValidator = (function () { - function ZipCodeValidator() { - } - ZipCodeValidator.prototype.isAcceptable = function (s3) { - return s3.length === 5; - }; - return ZipCodeValidator; - }()); - Validation.ZipCodeValidator = ZipCodeValidator; - var dummy = (function () { - function dummy() { - } - return dummy; - }()); -})(Validation || (Validation = {})); -var Greeter; -(function (Greeter) { - var class1 = (function () { - function class1() { - } - return class1; - }()); - var class2 = (function (_super) { - __extends(class2, _super); - function class2() { - _super.apply(this, arguments); - } - return class2; - }(class1)); - Greeter.class2 = class2; - var class3 = (function () { - function class3() { - } - return class3; - }()); - var class4 = (function () { - function class4() { - } - return class4; - }()); - Greeter.class4 = class4; -})(Greeter || (Greeter = {})); diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt deleted file mode 100644 index ad829ef8bcbbd..0000000000000 --- a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. - - -==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== - - class Dummy { - constructor(person: string, person2: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. - var unused = 20; - ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. - person2 = "Dummy value"; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.js b/tests/baselines/reference/unusedMultipleParameter1InContructor.js deleted file mode 100644 index e236ea3d26a09..0000000000000 --- a/tests/baselines/reference/unusedMultipleParameter1InContructor.js +++ /dev/null @@ -1,17 +0,0 @@ -//// [unusedMultipleParameter1InContructor.ts] - -class Dummy { - constructor(person: string, person2: string) { - var unused = 20; - person2 = "Dummy value"; - } -} - -//// [unusedMultipleParameter1InContructor.js] -var Dummy = (function () { - function Dummy(person, person2) { - var unused = 20; - person2 = "Dummy value"; - } - return Dummy; -}()); diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt deleted file mode 100644 index 7196273a5c725..0000000000000 --- a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): message TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. - - -==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== - - class Dummy { - constructor(person: string, person2: string, person3: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. - ~~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person3' has never been used. - var unused = 20; - ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. - person2 = "Dummy value"; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.js b/tests/baselines/reference/unusedMultipleParameter2InContructor.js deleted file mode 100644 index 8ffd4c3659124..0000000000000 --- a/tests/baselines/reference/unusedMultipleParameter2InContructor.js +++ /dev/null @@ -1,17 +0,0 @@ -//// [unusedMultipleParameter2InContructor.ts] - -class Dummy { - constructor(person: string, person2: string, person3: string) { - var unused = 20; - person2 = "Dummy value"; - } -} - -//// [unusedMultipleParameter2InContructor.js] -var Dummy = (function () { - function Dummy(person, person2, person3) { - var unused = 20; - person2 = "Dummy value"; - } - return Dummy; -}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt deleted file mode 100644 index ca4bc497c7559..0000000000000 --- a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): message TS6133: Parameter 'param1' has never been used. - - -==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== - - class greeter { - constructor(param1: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param1' has never been used. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor1.js b/tests/baselines/reference/unusedParametersinConstructor1.js deleted file mode 100644 index 500d7a45eb2f5..0000000000000 --- a/tests/baselines/reference/unusedParametersinConstructor1.js +++ /dev/null @@ -1,13 +0,0 @@ -//// [unusedParametersinConstructor1.ts] - -class greeter { - constructor(param1: string) { - } -} - -//// [unusedParametersinConstructor1.js] -var greeter = (function () { - function greeter(param1) { - } - return greeter; -}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt deleted file mode 100644 index 282e40b0f68da..0000000000000 --- a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): message TS6133: Parameter 'param1' has never been used. - - -==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== - - class greeter { - constructor(param1: string, param2: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param1' has never been used. - param2 = param2 + "dummy value"; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.js b/tests/baselines/reference/unusedParametersinConstructor2.js deleted file mode 100644 index 97bbf21ee0437..0000000000000 --- a/tests/baselines/reference/unusedParametersinConstructor2.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [unusedParametersinConstructor2.ts] - -class greeter { - constructor(param1: string, param2: string) { - param2 = param2 + "dummy value"; - } -} - -//// [unusedParametersinConstructor2.js] -var greeter = (function () { - function greeter(param1, param2) { - param2 = param2 + "dummy value"; - } - return greeter; -}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt deleted file mode 100644 index 29f3685327190..0000000000000 --- a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): message TS6133: Parameter 'param1' has never been used. -tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): message TS6133: Parameter 'param3' has never been used. - - -==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== - - class greeter { - constructor(param1: string, param2: string, param3: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param1' has never been used. - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param3' has never been used. - param2 = param2 + "dummy value"; - } - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.js b/tests/baselines/reference/unusedParametersinConstructor3.js deleted file mode 100644 index 06ac99229ac94..0000000000000 --- a/tests/baselines/reference/unusedParametersinConstructor3.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [unusedParametersinConstructor3.ts] - -class greeter { - constructor(param1: string, param2: string, param3: string) { - param2 = param2 + "dummy value"; - } -} - -//// [unusedParametersinConstructor3.js] -var greeter = (function () { - function greeter(param1, param2, param3) { - param2 = param2 + "dummy value"; - } - return greeter; -}()); diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt deleted file mode 100644 index 923a743d224b8..0000000000000 --- a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt +++ /dev/null @@ -1,15 +0,0 @@ -tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. - - -==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== - - class Dummy { - constructor(person: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. - var unused = 20; - ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.js b/tests/baselines/reference/unusedSingleParameterInContructor.js deleted file mode 100644 index 172f9e20ab860..0000000000000 --- a/tests/baselines/reference/unusedSingleParameterInContructor.js +++ /dev/null @@ -1,15 +0,0 @@ -//// [unusedSingleParameterInContructor.ts] - -class Dummy { - constructor(person: string) { - var unused = 20; - } -} - -//// [unusedSingleParameterInContructor.js] -var Dummy = (function () { - function Dummy(person) { - var unused = 20; - } - return Dummy; -}()); diff --git a/tests/cases/compiler/unusedMultipleParameter1InContructor.ts b/tests/cases/compiler/unusedMultipleParameter1InContructor.ts deleted file mode 100644 index b9565cafca62a..0000000000000 --- a/tests/cases/compiler/unusedMultipleParameter1InContructor.ts +++ /dev/null @@ -1,9 +0,0 @@ -//@noUnusedLocals:true -//@noUnusedParameters:true - -class Dummy { - constructor(person: string, person2: string) { - var unused = 20; - person2 = "Dummy value"; - } -} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter2InContructor.ts b/tests/cases/compiler/unusedMultipleParameter2InContructor.ts deleted file mode 100644 index 34d54c714af6f..0000000000000 --- a/tests/cases/compiler/unusedMultipleParameter2InContructor.ts +++ /dev/null @@ -1,9 +0,0 @@ -//@noUnusedLocals:true -//@noUnusedParameters:true - -class Dummy { - constructor(person: string, person2: string, person3: string) { - var unused = 20; - person2 = "Dummy value"; - } -} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor1.ts b/tests/cases/compiler/unusedParametersinConstructor1.ts deleted file mode 100644 index 421636d661b74..0000000000000 --- a/tests/cases/compiler/unusedParametersinConstructor1.ts +++ /dev/null @@ -1,7 +0,0 @@ -//@noUnusedLocals:true -//@noUnusedParameters:true - -class greeter { - constructor(param1: string) { - } -} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor2.ts b/tests/cases/compiler/unusedParametersinConstructor2.ts deleted file mode 100644 index d6812f438c598..0000000000000 --- a/tests/cases/compiler/unusedParametersinConstructor2.ts +++ /dev/null @@ -1,8 +0,0 @@ -//@noUnusedLocals:true -//@noUnusedParameters:true - -class greeter { - constructor(param1: string, param2: string) { - param2 = param2 + "dummy value"; - } -} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor3.ts b/tests/cases/compiler/unusedParametersinConstructor3.ts deleted file mode 100644 index e6295cd49fadf..0000000000000 --- a/tests/cases/compiler/unusedParametersinConstructor3.ts +++ /dev/null @@ -1,8 +0,0 @@ -//@noUnusedLocals:true -//@noUnusedParameters:true - -class greeter { - constructor(param1: string, param2: string, param3: string) { - param2 = param2 + "dummy value"; - } -} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInContructor.ts b/tests/cases/compiler/unusedSingleParameterInContructor.ts deleted file mode 100644 index 0f8f756fb48e4..0000000000000 --- a/tests/cases/compiler/unusedSingleParameterInContructor.ts +++ /dev/null @@ -1,8 +0,0 @@ -//@noUnusedLocals:true -//@noUnusedParameters:true - -class Dummy { - constructor(person: string) { - var unused = 20; - } -} \ No newline at end of file From 7aba6266b396ec1b3c624acbffec29dbfa49284d Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 12:11:54 -0700 Subject: [PATCH 31/90] Additional changes for compiler code --- src/compiler/checker.ts | 21 +- .../unusedIdentifiersConsolidated1.errors.txt | 150 ++++++++++++++ .../unusedIdentifiersConsolidated1.js | 187 ++++++++++++++++++ 3 files changed, 344 insertions(+), 14 deletions(-) create mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt create mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.js diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5dbc92d6d91ff..068c4613433bd 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8103,15 +8103,6 @@ namespace ts { return container === declarationContainer; } - function updateReferences(node: Identifier): void { - if (!isSourceFileADefinitionFile) { - const symbol = getReferencedValueSymbol(node); - if (symbol) { - symbol.hasReference = true; - } - } - } - function updateReferencesForTypedParameters(node: TypeNode): void { const symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { @@ -8131,7 +8122,9 @@ namespace ts { function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); - updateReferences(node); + if (symbol && !isSourceFileADefinitionFile) { + symbol.hasReference = true; + } // As noted in ECMAScript 6 language spec, arrow functions never have an arguments objects. // Although in down-level emit of arrow function, we emit it using function expression which means that @@ -14216,14 +14209,14 @@ namespace ts { } function checkSourceFileADefinitionFile(node: Node): boolean { - return getSourceFileOfNode(node).fileName.indexOf(".d.ts") > 0; + return /\.d\.ts$/.test(getSourceFileOfNode(node).fileName); } function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { checkUnusedIdentifiers(node); if (node.kind !== SyntaxKind.Constructor) { checkUnusedParameters(node); - } + } } function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { @@ -14241,7 +14234,7 @@ namespace ts { function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { if (compilerOptions.noUnusedParameters && !isSourceFileADefinitionFile) { for (const key in node.locals) { - if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { + if (hasProperty(node.locals, key) && !node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter && node.parent.kind !== SyntaxKind.InterfaceDeclaration) { error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); } @@ -14253,7 +14246,7 @@ namespace ts { function checkUnusedModulePrivates(node: ModuleDeclaration): void { if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { for (const key in node.locals) { - if (!node.locals[key].hasReference && !node.locals[key].exportSymbol) { + if (hasProperty(node.locals, key) && !node.locals[key].hasReference && !node.locals[key].exportSymbol) { if ((node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind)) { error(node.locals[key].valueDeclaration, Diagnostics.Variable_0_has_never_been_used, key); } diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt new file mode 100644 index 0000000000000..561b7891942d9 --- /dev/null +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -0,0 +1,150 @@ +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): message TS6132: Variable 'unusedtypeparameter' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): message TS6132: Variable 'unusedprivatevariable' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): message TS6132: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): message TS6132: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): message TS6132: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): message TS6132: Variable 'usedLocallyInterface2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): message TS6132: Variable 'dummy' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): message TS6132: Variable 'unusedInterface' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): message TS6132: Variable 'class3' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: Variable 'interface5' has never been used. + + +==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (15 errors) ==== + + function greeter(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } + + class Dummy { + ~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedtypeparameter' has never been used. + private unusedprivatevariable: string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedprivatevariable' has never been used. + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. + } + } + + var user = "Jane User"; + var user2 = "Jane2 User2"; + + namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + ~~~~~~~~~~~~ +!!! message TS6132: Variable 'numberRegexp' has never been used. + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'usedLocallyInterface2' has never been used. + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + ~~~~~ +!!! message TS6132: Variable 'dummy' has never been used. + } + + interface unusedInterface { + ~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedInterface' has never been used. + } + } + + + namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + ~~~~~~ +!!! message TS6132: Variable 'class3' has never been used. + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + ~~~~~~~~~~ +!!! message TS6132: Variable 'interface5' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.js b/tests/baselines/reference/unusedIdentifiersConsolidated1.js new file mode 100644 index 0000000000000..521f17bf5ef7e --- /dev/null +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.js @@ -0,0 +1,187 @@ +//// [unusedIdentifiersConsolidated1.ts] + +function greeter(person: string) { + var unused = 20; +} + +class Dummy { + private unusedprivatevariable: string; + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + var unused = 20; + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + } +} + +var user = "Jane User"; +var user2 = "Jane2 User2"; + +namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + } + + interface unusedInterface { + } +} + + +namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + } +} + +//// [unusedIdentifiersConsolidated1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +function greeter(person) { + var unused = 20; +} +var Dummy = (function () { + function Dummy(message) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + Dummy.prototype.greeter = function (person) { + var unused = 20; + this.usedPrivateFunction(); + }; + Dummy.prototype.usedPrivateFunction = function () { + }; + Dummy.prototype.unUsedPrivateFunction = function () { + }; + return Dummy; +}()); +var user = "Jane User"; +var user2 = "Jane2 User2"; +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; + var numberRegexp = /^[0-9]+$/; + var LettersOnlyValidator = (function () { + function LettersOnlyValidator() { + } + LettersOnlyValidator.prototype.isAcceptable = function (s2) { + return lettersRegexp.test(s2); + }; + LettersOnlyValidator.prototype.unUsedPrivateFunction = function () { + }; + return LettersOnlyValidator; + }()); + Validation.LettersOnlyValidator = LettersOnlyValidator; + var ZipCodeValidator = (function () { + function ZipCodeValidator() { + } + ZipCodeValidator.prototype.isAcceptable = function (s3) { + return s3.length === 5; + }; + return ZipCodeValidator; + }()); + Validation.ZipCodeValidator = ZipCodeValidator; + var dummy = (function () { + function dummy() { + } + return dummy; + }()); +})(Validation || (Validation = {})); +var Greeter; +(function (Greeter) { + var class1 = (function () { + function class1() { + } + return class1; + }()); + var class2 = (function (_super) { + __extends(class2, _super); + function class2() { + _super.apply(this, arguments); + } + return class2; + }(class1)); + Greeter.class2 = class2; + var class3 = (function () { + function class3() { + } + return class3; + }()); + var class4 = (function () { + function class4() { + } + return class4; + }()); + Greeter.class4 = class4; +})(Greeter || (Greeter = {})); From ed5052d9aa2016698de4e923c47f0acad823c297 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 13:08:43 -0700 Subject: [PATCH 32/90] Additional changes to handle constructor scenario --- src/compiler/checker.ts | 21 +- .../unusedIdentifiersConsolidated1.errors.txt | 150 -------------- .../unusedIdentifiersConsolidated1.js | 187 ------------------ ...dMultipleParameter1InContructor.errors.txt | 16 ++ .../unusedMultipleParameter1InContructor.js | 17 ++ ...dMultipleParameter2InContructor.errors.txt | 19 ++ .../unusedMultipleParameter2InContructor.js | 17 ++ .../unusedParametersinConstructor1.errors.txt | 11 ++ .../unusedParametersinConstructor1.js | 13 ++ .../unusedParametersinConstructor2.errors.txt | 12 ++ .../unusedParametersinConstructor2.js | 15 ++ .../unusedParametersinConstructor3.errors.txt | 15 ++ .../unusedParametersinConstructor3.js | 15 ++ ...usedSingleParameterInContructor.errors.txt | 15 ++ .../unusedSingleParameterInContructor.js | 15 ++ .../unusedMultipleParameter1InContructor.ts | 9 + .../unusedMultipleParameter2InContructor.ts | 9 + .../unusedParametersinConstructor1.ts | 7 + .../unusedParametersinConstructor2.ts | 8 + .../unusedParametersinConstructor3.ts | 8 + .../unusedSingleParameterInContructor.ts | 8 + 21 files changed, 246 insertions(+), 341 deletions(-) delete mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt delete mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.js create mode 100644 tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter1InContructor.js create mode 100644 tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt create mode 100644 tests/baselines/reference/unusedMultipleParameter2InContructor.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor1.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor1.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor2.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor2.js create mode 100644 tests/baselines/reference/unusedParametersinConstructor3.errors.txt create mode 100644 tests/baselines/reference/unusedParametersinConstructor3.js create mode 100644 tests/baselines/reference/unusedSingleParameterInContructor.errors.txt create mode 100644 tests/baselines/reference/unusedSingleParameterInContructor.js create mode 100644 tests/cases/compiler/unusedMultipleParameter1InContructor.ts create mode 100644 tests/cases/compiler/unusedMultipleParameter2InContructor.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor1.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor2.ts create mode 100644 tests/cases/compiler/unusedParametersinConstructor3.ts create mode 100644 tests/cases/compiler/unusedSingleParameterInContructor.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 068c4613433bd..0c46778135fe1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14214,9 +14214,7 @@ namespace ts { function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { checkUnusedIdentifiers(node); - if (node.kind !== SyntaxKind.Constructor) { - checkUnusedParameters(node); - } + checkUnusedParameters(node); } function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { @@ -14236,7 +14234,13 @@ namespace ts { for (const key in node.locals) { if (hasProperty(node.locals, key) && !node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter && node.parent.kind !== SyntaxKind.InterfaceDeclaration) { - error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); + if (node.locals[key].valueDeclaration.modifiers) { + if (!checkModifiersForPublicAccess(node.locals[key].valueDeclaration.modifiers)) { + error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); + } + } else { + error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); + } } } } @@ -14289,6 +14293,15 @@ namespace ts { return false; } + function checkModifiersForPublicAccess(modifiers: ModifiersArray): boolean { + for (let i = 0; i < modifiers.length; i++) { + if (modifiers[i].kind === SyntaxKind.PublicKeyword) { + return true; + } + } + return false; + } + function checkBlock(node: Block) { // Grammar checking for SyntaxKind.Block if (node.kind === SyntaxKind.Block) { diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt deleted file mode 100644 index 561b7891942d9..0000000000000 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ /dev/null @@ -1,150 +0,0 @@ -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): message TS6132: Variable 'unusedtypeparameter' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): message TS6132: Variable 'unusedprivatevariable' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): message TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): message TS6132: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): message TS6132: Variable 'numberRegexp' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): message TS6132: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): message TS6132: Variable 'usedLocallyInterface2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): message TS6132: Variable 'dummy' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): message TS6132: Variable 'unusedInterface' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): message TS6132: Variable 'class3' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: Variable 'interface5' has never been used. - - -==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (15 errors) ==== - - function greeter(person: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. - var unused = 20; - ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. - } - - class Dummy { - ~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedtypeparameter' has never been used. - private unusedprivatevariable: string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedprivatevariable' has never been used. - private greeting: string; - public unusedpublicvariable: string; - public typedvariable: usedtypeparameter; - - constructor(message: string) { - var unused2 = 22; - ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. - this.greeting = "Dummy Message"; - } - - public greeter(person: string) { - ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. - var unused = 20; - ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. - this.usedPrivateFunction(); - } - - private usedPrivateFunction() { - } - - private unUsedPrivateFunction() { - ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. - } - } - - var user = "Jane User"; - var user2 = "Jane2 User2"; - - namespace Validation { - export interface StringValidator { - isAcceptable(s: string): boolean; - } - - const lettersRegexp = /^[A-Za-z]+$/; - const numberRegexp = /^[0-9]+$/; - ~~~~~~~~~~~~ -!!! message TS6132: Variable 'numberRegexp' has never been used. - - export class LettersOnlyValidator implements StringValidator { - isAcceptable(s2: string) { - return lettersRegexp.test(s2); - } - - private unUsedPrivateFunction() { - ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. - } - } - - export class ZipCodeValidator implements StringValidator { - isAcceptable(s3: string) { - return s3.length === 5; - } - } - - interface usedLocallyInterface { - } - - interface usedLocallyInterface2 { - ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'usedLocallyInterface2' has never been used. - someFunction(s1: string): void; - } - - export interface exportedInterface { - } - - class dummy implements usedLocallyInterface { - ~~~~~ -!!! message TS6132: Variable 'dummy' has never been used. - } - - interface unusedInterface { - ~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedInterface' has never been used. - } - } - - - namespace Greeter { - class class1 { - } - - export class class2 extends class1 { - } - - class class3 { - ~~~~~~ -!!! message TS6132: Variable 'class3' has never been used. - } - - export class class4 { - } - - interface interface1 { - } - - export interface interface2 extends interface1 { - } - - interface interface3 { - } - - export interface interface4 { - } - - export let a: interface3; - - interface interface5 { - ~~~~~~~~~~ -!!! message TS6132: Variable 'interface5' has never been used. - } - } \ No newline at end of file diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.js b/tests/baselines/reference/unusedIdentifiersConsolidated1.js deleted file mode 100644 index 521f17bf5ef7e..0000000000000 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.js +++ /dev/null @@ -1,187 +0,0 @@ -//// [unusedIdentifiersConsolidated1.ts] - -function greeter(person: string) { - var unused = 20; -} - -class Dummy { - private unusedprivatevariable: string; - private greeting: string; - public unusedpublicvariable: string; - public typedvariable: usedtypeparameter; - - constructor(message: string) { - var unused2 = 22; - this.greeting = "Dummy Message"; - } - - public greeter(person: string) { - var unused = 20; - this.usedPrivateFunction(); - } - - private usedPrivateFunction() { - } - - private unUsedPrivateFunction() { - } -} - -var user = "Jane User"; -var user2 = "Jane2 User2"; - -namespace Validation { - export interface StringValidator { - isAcceptable(s: string): boolean; - } - - const lettersRegexp = /^[A-Za-z]+$/; - const numberRegexp = /^[0-9]+$/; - - export class LettersOnlyValidator implements StringValidator { - isAcceptable(s2: string) { - return lettersRegexp.test(s2); - } - - private unUsedPrivateFunction() { - } - } - - export class ZipCodeValidator implements StringValidator { - isAcceptable(s3: string) { - return s3.length === 5; - } - } - - interface usedLocallyInterface { - } - - interface usedLocallyInterface2 { - someFunction(s1: string): void; - } - - export interface exportedInterface { - } - - class dummy implements usedLocallyInterface { - } - - interface unusedInterface { - } -} - - -namespace Greeter { - class class1 { - } - - export class class2 extends class1 { - } - - class class3 { - } - - export class class4 { - } - - interface interface1 { - } - - export interface interface2 extends interface1 { - } - - interface interface3 { - } - - export interface interface4 { - } - - export let a: interface3; - - interface interface5 { - } -} - -//// [unusedIdentifiersConsolidated1.js] -var __extends = (this && this.__extends) || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -}; -function greeter(person) { - var unused = 20; -} -var Dummy = (function () { - function Dummy(message) { - var unused2 = 22; - this.greeting = "Dummy Message"; - } - Dummy.prototype.greeter = function (person) { - var unused = 20; - this.usedPrivateFunction(); - }; - Dummy.prototype.usedPrivateFunction = function () { - }; - Dummy.prototype.unUsedPrivateFunction = function () { - }; - return Dummy; -}()); -var user = "Jane User"; -var user2 = "Jane2 User2"; -var Validation; -(function (Validation) { - var lettersRegexp = /^[A-Za-z]+$/; - var numberRegexp = /^[0-9]+$/; - var LettersOnlyValidator = (function () { - function LettersOnlyValidator() { - } - LettersOnlyValidator.prototype.isAcceptable = function (s2) { - return lettersRegexp.test(s2); - }; - LettersOnlyValidator.prototype.unUsedPrivateFunction = function () { - }; - return LettersOnlyValidator; - }()); - Validation.LettersOnlyValidator = LettersOnlyValidator; - var ZipCodeValidator = (function () { - function ZipCodeValidator() { - } - ZipCodeValidator.prototype.isAcceptable = function (s3) { - return s3.length === 5; - }; - return ZipCodeValidator; - }()); - Validation.ZipCodeValidator = ZipCodeValidator; - var dummy = (function () { - function dummy() { - } - return dummy; - }()); -})(Validation || (Validation = {})); -var Greeter; -(function (Greeter) { - var class1 = (function () { - function class1() { - } - return class1; - }()); - var class2 = (function (_super) { - __extends(class2, _super); - function class2() { - _super.apply(this, arguments); - } - return class2; - }(class1)); - Greeter.class2 = class2; - var class3 = (function () { - function class3() { - } - return class3; - }()); - var class4 = (function () { - function class4() { - } - return class4; - }()); - Greeter.class4 = class4; -})(Greeter || (Greeter = {})); diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt new file mode 100644 index 0000000000000..ad829ef8bcbbd --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== + + class Dummy { + constructor(person: string, person2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "Dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.js b/tests/baselines/reference/unusedMultipleParameter1InContructor.js new file mode 100644 index 0000000000000..e236ea3d26a09 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.js @@ -0,0 +1,17 @@ +//// [unusedMultipleParameter1InContructor.ts] + +class Dummy { + constructor(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; + } +} + +//// [unusedMultipleParameter1InContructor.js] +var Dummy = (function () { + function Dummy(person, person2) { + var unused = 20; + person2 = "Dummy value"; + } + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt new file mode 100644 index 0000000000000..7196273a5c725 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -0,0 +1,19 @@ +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): message TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== + + class Dummy { + constructor(person: string, person2: string, person3: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + ~~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person3' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + person2 = "Dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.js b/tests/baselines/reference/unusedMultipleParameter2InContructor.js new file mode 100644 index 0000000000000..8ffd4c3659124 --- /dev/null +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.js @@ -0,0 +1,17 @@ +//// [unusedMultipleParameter2InContructor.ts] + +class Dummy { + constructor(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; + } +} + +//// [unusedMultipleParameter2InContructor.js] +var Dummy = (function () { + function Dummy(person, person2, person3) { + var unused = 20; + person2 = "Dummy value"; + } + return Dummy; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt new file mode 100644 index 0000000000000..ca4bc497c7559 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): message TS6133: Parameter 'param1' has never been used. + + +==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== + + class greeter { + constructor(param1: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param1' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor1.js b/tests/baselines/reference/unusedParametersinConstructor1.js new file mode 100644 index 0000000000000..500d7a45eb2f5 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor1.js @@ -0,0 +1,13 @@ +//// [unusedParametersinConstructor1.ts] + +class greeter { + constructor(param1: string) { + } +} + +//// [unusedParametersinConstructor1.js] +var greeter = (function () { + function greeter(param1) { + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt new file mode 100644 index 0000000000000..282e40b0f68da --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): message TS6133: Parameter 'param1' has never been used. + + +==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== + + class greeter { + constructor(param1: string, param2: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param1' has never been used. + param2 = param2 + "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.js b/tests/baselines/reference/unusedParametersinConstructor2.js new file mode 100644 index 0000000000000..97bbf21ee0437 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor2.js @@ -0,0 +1,15 @@ +//// [unusedParametersinConstructor2.ts] + +class greeter { + constructor(param1: string, param2: string) { + param2 = param2 + "dummy value"; + } +} + +//// [unusedParametersinConstructor2.js] +var greeter = (function () { + function greeter(param1, param2) { + param2 = param2 + "dummy value"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt new file mode 100644 index 0000000000000..29f3685327190 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): message TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): message TS6133: Parameter 'param3' has never been used. + + +==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== + + class greeter { + constructor(param1: string, param2: string, param3: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param1' has never been used. + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'param3' has never been used. + param2 = param2 + "dummy value"; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.js b/tests/baselines/reference/unusedParametersinConstructor3.js new file mode 100644 index 0000000000000..06ac99229ac94 --- /dev/null +++ b/tests/baselines/reference/unusedParametersinConstructor3.js @@ -0,0 +1,15 @@ +//// [unusedParametersinConstructor3.ts] + +class greeter { + constructor(param1: string, param2: string, param3: string) { + param2 = param2 + "dummy value"; + } +} + +//// [unusedParametersinConstructor3.js] +var greeter = (function () { + function greeter(param1, param2, param3) { + param2 = param2 + "dummy value"; + } + return greeter; +}()); diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt new file mode 100644 index 0000000000000..923a743d224b8 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. + + +==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== + + class Dummy { + constructor(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.js b/tests/baselines/reference/unusedSingleParameterInContructor.js new file mode 100644 index 0000000000000..172f9e20ab860 --- /dev/null +++ b/tests/baselines/reference/unusedSingleParameterInContructor.js @@ -0,0 +1,15 @@ +//// [unusedSingleParameterInContructor.ts] + +class Dummy { + constructor(person: string) { + var unused = 20; + } +} + +//// [unusedSingleParameterInContructor.js] +var Dummy = (function () { + function Dummy(person) { + var unused = 20; + } + return Dummy; +}()); diff --git a/tests/cases/compiler/unusedMultipleParameter1InContructor.ts b/tests/cases/compiler/unusedMultipleParameter1InContructor.ts new file mode 100644 index 0000000000000..b9565cafca62a --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter1InContructor.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string, person2: string) { + var unused = 20; + person2 = "Dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMultipleParameter2InContructor.ts b/tests/cases/compiler/unusedMultipleParameter2InContructor.ts new file mode 100644 index 0000000000000..34d54c714af6f --- /dev/null +++ b/tests/cases/compiler/unusedMultipleParameter2InContructor.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string, person2: string, person3: string) { + var unused = 20; + person2 = "Dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor1.ts b/tests/cases/compiler/unusedParametersinConstructor1.ts new file mode 100644 index 0000000000000..421636d661b74 --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor1.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string) { + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor2.ts b/tests/cases/compiler/unusedParametersinConstructor2.ts new file mode 100644 index 0000000000000..d6812f438c598 --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor2.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string, param2: string) { + param2 = param2 + "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersinConstructor3.ts b/tests/cases/compiler/unusedParametersinConstructor3.ts new file mode 100644 index 0000000000000..e6295cd49fadf --- /dev/null +++ b/tests/cases/compiler/unusedParametersinConstructor3.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class greeter { + constructor(param1: string, param2: string, param3: string) { + param2 = param2 + "dummy value"; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSingleParameterInContructor.ts b/tests/cases/compiler/unusedSingleParameterInContructor.ts new file mode 100644 index 0000000000000..0f8f756fb48e4 --- /dev/null +++ b/tests/cases/compiler/unusedSingleParameterInContructor.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Dummy { + constructor(person: string) { + var unused = 20; + } +} \ No newline at end of file From f5cdc9c39ecf8669d4ca08595c3942f4797b2e0a Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 13:09:42 -0700 Subject: [PATCH 33/90] Fixing the consolidated case --- .../unusedIdentifiersConsolidated1.errors.txt | 153 ++++++++++++++ .../unusedIdentifiersConsolidated1.js | 187 ++++++++++++++++++ 2 files changed, 340 insertions(+) create mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt create mode 100644 tests/baselines/reference/unusedIdentifiersConsolidated1.js diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt new file mode 100644 index 0000000000000..27ec7d90821da --- /dev/null +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -0,0 +1,153 @@ +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): message TS6132: Variable 'unusedtypeparameter' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): message TS6132: Variable 'unusedprivatevariable' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): message TS6133: Parameter 'message' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): message TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): message TS6132: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): message TS6132: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): message TS6132: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): message TS6132: Variable 'usedLocallyInterface2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): message TS6132: Variable 'dummy' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): message TS6132: Variable 'unusedInterface' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): message TS6132: Variable 'class3' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: Variable 'interface5' has never been used. + + +==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== + + function greeter(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + } + + class Dummy { + ~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedtypeparameter' has never been used. + private unusedprivatevariable: string; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedprivatevariable' has never been used. + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + ~~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'message' has never been used. + var unused2 = 22; + ~~~~~~~ +!!! message TS6132: Variable 'unused2' has never been used. + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + ~~~~~~~~~~~~~~ +!!! message TS6133: Parameter 'person' has never been used. + var unused = 20; + ~~~~~~ +!!! message TS6132: Variable 'unused' has never been used. + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. + } + } + + var user = "Jane User"; + var user2 = "Jane2 User2"; + + namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + ~~~~~~~~~~~~ +!!! message TS6132: Variable 'numberRegexp' has never been used. + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + ~~~~~~~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'usedLocallyInterface2' has never been used. + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + ~~~~~ +!!! message TS6132: Variable 'dummy' has never been used. + } + + interface unusedInterface { + ~~~~~~~~~~~~~~~ +!!! message TS6132: Variable 'unusedInterface' has never been used. + } + } + + + namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + ~~~~~~ +!!! message TS6132: Variable 'class3' has never been used. + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + ~~~~~~~~~~ +!!! message TS6132: Variable 'interface5' has never been used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.js b/tests/baselines/reference/unusedIdentifiersConsolidated1.js new file mode 100644 index 0000000000000..521f17bf5ef7e --- /dev/null +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.js @@ -0,0 +1,187 @@ +//// [unusedIdentifiersConsolidated1.ts] + +function greeter(person: string) { + var unused = 20; +} + +class Dummy { + private unusedprivatevariable: string; + private greeting: string; + public unusedpublicvariable: string; + public typedvariable: usedtypeparameter; + + constructor(message: string) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + + public greeter(person: string) { + var unused = 20; + this.usedPrivateFunction(); + } + + private usedPrivateFunction() { + } + + private unUsedPrivateFunction() { + } +} + +var user = "Jane User"; +var user2 = "Jane2 User2"; + +namespace Validation { + export interface StringValidator { + isAcceptable(s: string): boolean; + } + + const lettersRegexp = /^[A-Za-z]+$/; + const numberRegexp = /^[0-9]+$/; + + export class LettersOnlyValidator implements StringValidator { + isAcceptable(s2: string) { + return lettersRegexp.test(s2); + } + + private unUsedPrivateFunction() { + } + } + + export class ZipCodeValidator implements StringValidator { + isAcceptable(s3: string) { + return s3.length === 5; + } + } + + interface usedLocallyInterface { + } + + interface usedLocallyInterface2 { + someFunction(s1: string): void; + } + + export interface exportedInterface { + } + + class dummy implements usedLocallyInterface { + } + + interface unusedInterface { + } +} + + +namespace Greeter { + class class1 { + } + + export class class2 extends class1 { + } + + class class3 { + } + + export class class4 { + } + + interface interface1 { + } + + export interface interface2 extends interface1 { + } + + interface interface3 { + } + + export interface interface4 { + } + + export let a: interface3; + + interface interface5 { + } +} + +//// [unusedIdentifiersConsolidated1.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +function greeter(person) { + var unused = 20; +} +var Dummy = (function () { + function Dummy(message) { + var unused2 = 22; + this.greeting = "Dummy Message"; + } + Dummy.prototype.greeter = function (person) { + var unused = 20; + this.usedPrivateFunction(); + }; + Dummy.prototype.usedPrivateFunction = function () { + }; + Dummy.prototype.unUsedPrivateFunction = function () { + }; + return Dummy; +}()); +var user = "Jane User"; +var user2 = "Jane2 User2"; +var Validation; +(function (Validation) { + var lettersRegexp = /^[A-Za-z]+$/; + var numberRegexp = /^[0-9]+$/; + var LettersOnlyValidator = (function () { + function LettersOnlyValidator() { + } + LettersOnlyValidator.prototype.isAcceptable = function (s2) { + return lettersRegexp.test(s2); + }; + LettersOnlyValidator.prototype.unUsedPrivateFunction = function () { + }; + return LettersOnlyValidator; + }()); + Validation.LettersOnlyValidator = LettersOnlyValidator; + var ZipCodeValidator = (function () { + function ZipCodeValidator() { + } + ZipCodeValidator.prototype.isAcceptable = function (s3) { + return s3.length === 5; + }; + return ZipCodeValidator; + }()); + Validation.ZipCodeValidator = ZipCodeValidator; + var dummy = (function () { + function dummy() { + } + return dummy; + }()); +})(Validation || (Validation = {})); +var Greeter; +(function (Greeter) { + var class1 = (function () { + function class1() { + } + return class1; + }()); + var class2 = (function (_super) { + __extends(class2, _super); + function class2() { + _super.apply(this, arguments); + } + return class2; + }(class1)); + Greeter.class2 = class2; + var class3 = (function () { + function class3() { + } + return class3; + }()); + var class4 = (function () { + function class4() { + } + return class4; + }()); + Greeter.class4 = class4; +})(Greeter || (Greeter = {})); From 8c3c7b1309300d4197b36ab05c695bff1ed36ba8 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 13:30:57 -0700 Subject: [PATCH 34/90] Changed logic to search for private instead of public --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0c46778135fe1..4b40d3e4deb6a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14235,7 +14235,7 @@ namespace ts { if (hasProperty(node.locals, key) && !node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter && node.parent.kind !== SyntaxKind.InterfaceDeclaration) { if (node.locals[key].valueDeclaration.modifiers) { - if (!checkModifiersForPublicAccess(node.locals[key].valueDeclaration.modifiers)) { + if (checkModifiersForPrivateAccess(node.locals[key].valueDeclaration.modifiers)) { error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); } } else { @@ -14293,9 +14293,9 @@ namespace ts { return false; } - function checkModifiersForPublicAccess(modifiers: ModifiersArray): boolean { + function checkModifiersForPrivateAccess(modifiers: ModifiersArray): boolean { for (let i = 0; i < modifiers.length; i++) { - if (modifiers[i].kind === SyntaxKind.PublicKeyword) { + if (modifiers[i].kind === SyntaxKind.PrivateKeyword) { return true; } } From dfad7cc388478b4468268c004c7e2899fde555f3 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 15:57:32 -0700 Subject: [PATCH 35/90] Response to PR Comments --- src/compiler/checker.ts | 21 +++--- src/compiler/commandLineParser.ts | 4 +- src/compiler/diagnosticMessages.json | 12 +++- .../unusedClassesinNamespace1.errors.txt | 4 +- .../unusedClassesinNamespace2.errors.txt | 4 +- .../unusedClassesinNamespace4.errors.txt | 4 +- .../unusedClassesinNamespace5.errors.txt | 4 +- .../unusedFunctionsinNamespaces1.errors.txt | 4 +- .../unusedFunctionsinNamespaces2.errors.txt | 4 +- .../unusedFunctionsinNamespaces3.errors.txt | 8 +-- .../unusedFunctionsinNamespaces4.errors.txt | 4 +- .../unusedFunctionsinNamespaces5.errors.txt | 8 +-- .../unusedFunctionsinNamespaces6.errors.txt | 4 +- .../unusedIdentifiersConsolidated1.errors.txt | 64 +++++++++---------- .../unusedInterfaceinNamespace1.errors.txt | 4 +- .../unusedInterfaceinNamespace2.errors.txt | 4 +- .../unusedInterfaceinNamespace3.errors.txt | 4 +- .../unusedLocalsInMethod1.errors.txt | 4 +- .../unusedLocalsInMethod2.errors.txt | 4 +- .../unusedLocalsInMethod3.errors.txt | 4 +- ...ationWithinFunctionDeclaration1.errors.txt | 20 +++--- ...ationWithinFunctionDeclaration2.errors.txt | 28 ++++---- ...rationWithinFunctionExpression1.errors.txt | 20 +++--- ...rationWithinFunctionExpression2.errors.txt | 28 ++++---- ...ssionWithinFunctionDeclaration1.errors.txt | 20 +++--- ...ssionWithinFunctionDeclaration2.errors.txt | 28 ++++---- ...essionWithinFunctionExpression1.errors.txt | 20 +++--- ...essionWithinFunctionExpression2.errors.txt | 28 ++++---- .../unusedLocalsinConstructor1.errors.txt | 4 +- .../unusedLocalsinConstructor2.errors.txt | 4 +- ...dMultipleParameter1InContructor.errors.txt | 8 +-- ...eParameter1InFunctionExpression.errors.txt | 8 +-- ...dMultipleParameter2InContructor.errors.txt | 12 ++-- ...eParameter2InFunctionExpression.errors.txt | 12 ++-- ...arameters1InFunctionDeclaration.errors.txt | 8 +-- ...eParameters1InMethodDeclaration.errors.txt | 8 +-- ...arameters2InFunctionDeclaration.errors.txt | 12 ++-- ...eParameters2InMethodDeclaration.errors.txt | 12 ++-- .../unusedParametersinConstructor1.errors.txt | 4 +- .../unusedParametersinConstructor2.errors.txt | 4 +- .../unusedParametersinConstructor3.errors.txt | 8 +-- .../unusedPrivateMethodInClass1.errors.txt | 4 +- .../unusedPrivateMethodInClass2.errors.txt | 8 +-- .../unusedPrivateMethodInClass3.errors.txt | 8 +-- .../unusedPrivateMethodInClass4.errors.txt | 4 +- .../unusedPrivateVariableInClass1.errors.txt | 4 +- .../unusedPrivateVariableInClass2.errors.txt | 8 +-- .../unusedPrivateVariableInClass3.errors.txt | 8 +-- .../unusedPrivateVariableInClass4.errors.txt | 4 +- .../unusedPrivateVariableInClass5.errors.txt | 4 +- ...usedSingleParameterInContructor.errors.txt | 8 +-- ...eParameterInFunctionDeclaration.errors.txt | 8 +-- ...leParameterInFunctionExpression.errors.txt | 8 +-- ...gleParameterInMethodDeclaration.errors.txt | 8 +-- .../unusedTypeParameters1.errors.txt | 4 +- .../unusedTypeParameters2.errors.txt | 4 +- .../unusedTypeParameters3.errors.txt | 8 +-- .../unusedVariablesinNamespaces1.errors.txt | 4 +- .../unusedVariablesinNamespaces2.errors.txt | 4 +- .../unusedVariablesinNamespaces3.errors.txt | 4 +- 60 files changed, 292 insertions(+), 289 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4b40d3e4deb6a..98441867cf3d2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -44,7 +44,6 @@ namespace ts { let typeCount = 0; let symbolCount = 0; - let isSourceFileADefinitionFile = false; const emptyArray: any[] = []; const emptySymbols: SymbolTable = {}; @@ -8122,7 +8121,7 @@ namespace ts { function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); - if (symbol && !isSourceFileADefinitionFile) { + if (symbol && !isInAmbientContext(node)) { symbol.hasReference = true; } @@ -14208,17 +14207,13 @@ namespace ts { } } - function checkSourceFileADefinitionFile(node: Node): boolean { - return /\.d\.ts$/.test(getSourceFileOfNode(node).fileName); - } - function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { checkUnusedIdentifiers(node); checkUnusedParameters(node); } function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { - if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind !== SyntaxKind.Parameter) { @@ -14230,7 +14225,7 @@ namespace ts { } function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { - if (compilerOptions.noUnusedParameters && !isSourceFileADefinitionFile) { + if (compilerOptions.noUnusedParameters && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key) && !node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter && node.parent.kind !== SyntaxKind.InterfaceDeclaration) { @@ -14238,9 +14233,10 @@ namespace ts { if (checkModifiersForPrivateAccess(node.locals[key].valueDeclaration.modifiers)) { error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); } - } else { + } + else { error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); - } + } } } } @@ -14248,7 +14244,7 @@ namespace ts { } function checkUnusedModulePrivates(node: ModuleDeclaration): void { - if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key) && !node.locals[key].hasReference && !node.locals[key].exportSymbol) { if ((node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind)) { @@ -14263,7 +14259,7 @@ namespace ts { } function checkUnusedPrivates(node: ClassDeclaration): void { - if (compilerOptions.noUnusedLocals && !isSourceFileADefinitionFile) { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (let i = 0; node.members && i < node.members.length; i++) { switch (node.members[i].kind) { case SyntaxKind.MethodDeclaration: @@ -16661,7 +16657,6 @@ namespace ts { function checkSourceFile(node: SourceFile) { const start = new Date().getTime(); - isSourceFileADefinitionFile = checkSourceFileADefinitionFile(node); checkSourceFileWorker(node); checkTime += new Date().getTime() - start; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index f5b1fe3b48358..d388fa38c5dd4 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -135,12 +135,12 @@ namespace ts { { name: "noUnusedLocals", type: "boolean", - description: Diagnostics.Variable_0_has_never_been_used, + description: Diagnostics.Report_Errors_on_Unused_Locals, }, { name: "noUnusedParameters", type: "boolean", - description: Diagnostics.Parameter_0_has_never_been_used + description: Diagnostics.Report_Errors_on_Unused_Parameters }, { name: "noLib", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4462e2b3832fb..c61c7a81983f2 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2773,13 +2773,21 @@ "code": 6131 }, "Variable '{0}' has never been used.": { - "category": "Message", + "category": "Error", "code": 6132 }, "Parameter '{0}' has never been used.": { - "category": "Message", + "category": "Error", "code": 6133 }, + "Report Errors on Unused Locals.": { + "category": "Message", + "code": 6134 + }, + "Report Errors on Unused Parameters.": { + "category": "Message", + "code": 6135 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt index eea58a29d7ff3..8f1a90233f7a8 100644 --- a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): message TS6132: Variable 'c1' has never been used. +tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): error TS6132: Variable 'c1' has never been used. ==== tests/cases/compiler/unusedClassesinNamespace1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): message TS6132: Variabl namespace Validation { class c1 { ~~ -!!! message TS6132: Variable 'c1' has never been used. +!!! error TS6132: Variable 'c1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt index b3520e3047395..e818568378873 100644 --- a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): message TS6132: Variable 'c1' has never been used. +tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): error TS6132: Variable 'c1' has never been used. ==== tests/cases/compiler/unusedClassesinNamespace2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): message TS6132: Variabl namespace Validation { class c1 { ~~ -!!! message TS6132: Variable 'c1' has never been used. +!!! error TS6132: Variable 'c1' has never been used. } diff --git a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt index bd4f46bbd6484..4553f2b3fa1dc 100644 --- a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): message TS6132: Variable 'c3' has never been used. +tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): error TS6132: Variable 'c3' has never been used. ==== tests/cases/compiler/unusedClassesinNamespace4.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): message TS6132: Variab class c3 extends c1 { ~~ -!!! message TS6132: Variable 'c3' has never been used. +!!! error TS6132: Variable 'c3' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt index 81cbad6e11515..ce1eb4f578b32 100644 --- a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): message TS6132: Variable 'c3' has never been used. +tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): error TS6132: Variable 'c3' has never been used. ==== tests/cases/compiler/unusedClassesinNamespace5.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): message TS6132: Variab class c3 { ~~ -!!! message TS6132: Variable 'c3' has never been used. +!!! error TS6132: Variable 'c3' has never been used. public x: c1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt index 6f02e5c2f9f8c..bfb24d043f7fe 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): message TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): error TS6132: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): message TS6132: Vari namespace Validation { function function1() { ~~~~~~~~~ -!!! message TS6132: Variable 'function1' has never been used. +!!! error TS6132: Variable 'function1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt index e956ea08a03c2..dc5fdd1740b3e 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): message TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): error TS6132: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces2.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): message TS6132: Varia namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! message TS6132: Variable 'function1' has never been used. +!!! error TS6132: Variable 'function1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt index d375fb6026204..8ba79b408d48d 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,9): message TS6132: Variable 'function1' has never been used. -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): message TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,9): error TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6133: Parameter 'param1' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces3.ts (2 errors) ==== @@ -7,8 +7,8 @@ tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): message TS6133: Para namespace Validation { var function1 = function(param1:string) { ~~~~~~~~~ -!!! message TS6132: Variable 'function1' has never been used. +!!! error TS6132: Variable 'function1' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param1' has never been used. +!!! error TS6133: Parameter 'param1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt index f4bccdd6df609..1fce88371d999 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): message TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): error TS6132: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces4.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): message TS6132: Varia namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! message TS6132: Variable 'function1' has never been used. +!!! error TS6132: Variable 'function1' has never been used. } export function function2() { diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt index 5f76bec8356c8..30da9d7227e6a 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(10,14): message TS6132: Variable 'function3' has never been used. -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): message TS6132: Variable 'function4' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(10,14): error TS6132: Variable 'function3' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): error TS6132: Variable 'function4' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces5.ts (2 errors) ==== @@ -14,13 +14,13 @@ tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): message TS6132: Var function function3() { ~~~~~~~~~ -!!! message TS6132: Variable 'function3' has never been used. +!!! error TS6132: Variable 'function3' has never been used. function1(); } function function4() { ~~~~~~~~~ -!!! message TS6132: Variable 'function4' has never been used. +!!! error TS6132: Variable 'function4' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt index 08dc040017d71..470dba934d9e4 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): message TS6132: Variable 'function4' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): error TS6132: Variable 'function4' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces6.ts (1 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): message TS6132: Var function function4() { ~~~~~~~~~ -!!! message TS6132: Variable 'function4' has never been used. +!!! error TS6132: Variable 'function4' has never been used. } diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt index 27ec7d90821da..d9ada7955c49a 100644 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -1,56 +1,56 @@ -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): message TS6132: Variable 'unusedtypeparameter' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): message TS6132: Variable 'unusedprivatevariable' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): message TS6133: Parameter 'message' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): message TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): message TS6132: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): message TS6132: Variable 'numberRegexp' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): message TS6132: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): message TS6132: Variable 'usedLocallyInterface2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): message TS6132: Variable 'dummy' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): message TS6132: Variable 'unusedInterface' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): message TS6132: Variable 'class3' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: Variable 'interface5' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): error TS6132: Variable 'unusedtypeparameter' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): error TS6132: Variable 'unusedprivatevariable' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): error TS6133: Parameter 'message' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): error TS6132: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): error TS6132: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): error TS6132: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): error TS6132: Variable 'usedLocallyInterface2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): error TS6132: Variable 'dummy' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): error TS6132: Variable 'unusedInterface' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): error TS6132: Variable 'class3' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Variable 'interface5' has never been used. ==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== function greeter(person: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. } class Dummy { ~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedtypeparameter' has never been used. +!!! error TS6132: Variable 'unusedtypeparameter' has never been used. private unusedprivatevariable: string; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedprivatevariable' has never been used. +!!! error TS6132: Variable 'unusedprivatevariable' has never been used. private greeting: string; public unusedpublicvariable: string; public typedvariable: usedtypeparameter; constructor(message: string) { ~~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'message' has never been used. +!!! error TS6133: Parameter 'message' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. this.greeting = "Dummy Message"; } public greeter(person: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. this.usedPrivateFunction(); } @@ -59,7 +59,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. +!!! error TS6132: Variable 'unUsedPrivateFunction' has never been used. } } @@ -74,7 +74,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! message TS6132: Variable 'numberRegexp' has never been used. +!!! error TS6132: Variable 'numberRegexp' has never been used. export class LettersOnlyValidator implements StringValidator { isAcceptable(s2: string) { @@ -83,7 +83,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unUsedPrivateFunction' has never been used. +!!! error TS6132: Variable 'unUsedPrivateFunction' has never been used. } } @@ -98,7 +98,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: interface usedLocallyInterface2 { ~~~~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'usedLocallyInterface2' has never been used. +!!! error TS6132: Variable 'usedLocallyInterface2' has never been used. someFunction(s1: string): void; } @@ -107,12 +107,12 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: class dummy implements usedLocallyInterface { ~~~~~ -!!! message TS6132: Variable 'dummy' has never been used. +!!! error TS6132: Variable 'dummy' has never been used. } interface unusedInterface { ~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'unusedInterface' has never been used. +!!! error TS6132: Variable 'unusedInterface' has never been used. } } @@ -126,7 +126,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: class class3 { ~~~~~~ -!!! message TS6132: Variable 'class3' has never been used. +!!! error TS6132: Variable 'class3' has never been used. } export class class4 { @@ -148,6 +148,6 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): message TS6132: interface interface5 { ~~~~~~~~~~ -!!! message TS6132: Variable 'interface5' has never been used. +!!! error TS6132: Variable 'interface5' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt index fb56fe108ec3d..18cd225212777 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): message TS6132: Variable 'i1' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): error TS6132: Variable 'i1' has never been used. ==== tests/cases/compiler/unusedInterfaceinNamespace1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): message TS6132: Varia namespace Validation { interface i1 { ~~ -!!! message TS6132: Variable 'i1' has never been used. +!!! error TS6132: Variable 'i1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt index 0ec233548818b..8df7aa310eb8a 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): message TS6132: Variable 'i1' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): error TS6132: Variable 'i1' has never been used. ==== tests/cases/compiler/unusedInterfaceinNamespace2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): message TS6132: Varia namespace Validation { interface i1 { ~~ -!!! message TS6132: Variable 'i1' has never been used. +!!! error TS6132: Variable 'i1' has never been used. } diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt index 7f6abaa11b070..5d33e1cae70d2 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): message TS6132: Variable 'i3' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): error TS6132: Variable 'i3' has never been used. ==== tests/cases/compiler/unusedInterfaceinNamespace3.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): message TS6132: Vari interface i3 extends i1 { ~~ -!!! message TS6132: Variable 'i3' has never been used. +!!! error TS6132: Variable 'i3' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt index 2e6c31edd4ce1..e3423d57c5e95 100644 --- a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): message TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): error TS6132: Variable 'x' has never been used. ==== tests/cases/compiler/unusedLocalsInMethod1.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): message TS6132: Variable 'x public function1() { var x = 10; ~ -!!! message TS6132: Variable 'x' has never been used. +!!! error TS6132: Variable 'x' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt index 104700882aa15..f990d97bfd34d 100644 --- a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): message TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): error TS6132: Variable 'x' has never been used. ==== tests/cases/compiler/unusedLocalsInMethod2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): message TS6132: Variable 'x public function1() { var x, y = 10; ~ -!!! message TS6132: Variable 'x' has never been used. +!!! error TS6132: Variable 'x' has never been used. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt index 4859b2256e00e..fd869922678e4 100644 --- a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): message TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): error TS6132: Variable 'x' has never been used. ==== tests/cases/compiler/unusedLocalsInMethod3.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): message TS6132: Variable 'x public function1() { var x, y; ~ -!!! message TS6132: Variable 'x' has never been used. +!!! error TS6132: Variable 'x' has never been used. y = 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt index 36281a919089a..5347d79da2e4c 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,14): message TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,20): message TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(5,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,18): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,14): error TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,20): error TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(5,13): error TS6132: Variable 'unused2' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. function maker(child: string): void { ~~~~~ -!!! message TS6132: Variable 'maker' has never been used. +!!! error TS6132: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child' has never been used. +!!! error TS6133: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt index cb4521998e850..1beab8f93d50d 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,14): message TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,20): message TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(5,13): message TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,21): message TS6133: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(8,13): message TS6132: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,18): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,14): error TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,20): error TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(5,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,21): error TS6133: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(8,13): error TS6132: Variable 'unused3' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. function maker(child: string): void { ~~~~~ -!!! message TS6132: Variable 'maker' has never been used. +!!! error TS6132: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child' has never been used. +!!! error TS6133: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. } function maker2(child2: string): void { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child2' has never been used. +!!! error TS6133: Parameter 'child2' has never been used. var unused3 = 23; ~~~~~~~ -!!! message TS6132: Variable 'unused3' has never been used. +!!! error TS6132: Variable 'unused3' has never been used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt index 509e83e8c624d..dd3736acb1fe7 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,25): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,14): message TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,20): message TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(5,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,25): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,14): error TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,20): error TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(5,13): error TS6132: Variable 'unused2' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (5 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. function maker(child: string): void { ~~~~~ -!!! message TS6132: Variable 'maker' has never been used. +!!! error TS6132: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child' has never been used. +!!! error TS6133: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt index 10610f397fc59..54a871430783a 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,25): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,14): message TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,20): message TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(5,13): message TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,21): message TS6133: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(8,13): message TS6132: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,25): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,14): error TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,20): error TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(5,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,21): error TS6133: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(8,13): error TS6132: Variable 'unused3' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. function maker(child: string): void { ~~~~~ -!!! message TS6132: Variable 'maker' has never been used. +!!! error TS6132: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child' has never been used. +!!! error TS6133: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. } function maker2(child2: string): void { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child2' has never been used. +!!! error TS6133: Parameter 'child2' has never been used. var unused3 = 23; ~~~~~~~ -!!! message TS6132: Variable 'unused3' has never been used. +!!! error TS6132: Variable 'unused3' has never been used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt index 4265702a17c05..4bdb2ea988b25 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,9): message TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,27): message TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(5,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,18): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,9): error TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,27): error TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(5,13): error TS6132: Variable 'unused2' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (5 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. var maker = function (child: string): void { ~~~~~ -!!! message TS6132: Variable 'maker' has never been used. +!!! error TS6132: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child' has never been used. +!!! error TS6133: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt index 586dab0eb0aed..47d757fa9a625 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,9): message TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,26): message TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(5,13): message TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,27): message TS6133: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(8,13): message TS6132: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,18): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,9): error TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,26): error TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(5,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,27): error TS6133: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(8,13): error TS6132: Variable 'unused3' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. var maker = function(child: string): void { ~~~~~ -!!! message TS6132: Variable 'maker' has never been used. +!!! error TS6132: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child' has never been used. +!!! error TS6133: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. } var maker2 = function(child2: string): void { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child2' has never been used. +!!! error TS6133: Parameter 'child2' has never been used. var unused3 = 23; ~~~~~~~ -!!! message TS6132: Variable 'unused3' has never been used. +!!! error TS6132: Variable 'unused3' has never been used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt index 86a461ce6c781..fb9a59d151cf5 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,25): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,9): message TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,27): message TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(5,13): message TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,25): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,9): error TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,27): error TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(5,13): error TS6132: Variable 'unused2' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (5 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. var maker = function (child: string): void { ~~~~~ -!!! message TS6132: Variable 'maker' has never been used. +!!! error TS6132: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child' has never been used. +!!! error TS6133: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt index ce78a2fb1839e..4af157ffc3d3e 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,25): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): message TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,9): message TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,27): message TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(5,13): message TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,28): message TS6133: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(8,13): message TS6132: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,25): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,9): error TS6132: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,27): error TS6133: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(5,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,28): error TS6133: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(8,13): error TS6132: Variable 'unused3' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. var maker = function (child: string): void { ~~~~~ -!!! message TS6132: Variable 'maker' has never been used. +!!! error TS6132: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child' has never been used. +!!! error TS6133: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! message TS6132: Variable 'unused2' has never been used. +!!! error TS6132: Variable 'unused2' has never been used. } var maker2 = function (child2: string): void { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'child2' has never been used. +!!! error TS6133: Parameter 'child2' has never been used. var unused3 = 23; ~~~~~~~ -!!! message TS6132: Variable 'unused3' has never been used. +!!! error TS6132: Variable 'unused3' has never been used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt index aea22dceeb356..dfab136e6a5db 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedLocalsinConstructor1.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): message TS6132: Variab constructor() { var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt index 7eced3493f7f3..e150e39f8bbb9 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedLocalsinConstructor2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): message TS6132: Variab constructor() { var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. var used = "dummy"; used = used + "second part"; } diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt index ad829ef8bcbbd..d98ec7d187a4f 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): message TS61 class Dummy { constructor(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt index 97e152e96fe34..6eaf329566a22 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,21): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,21): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (2 errors) ==== var func = function(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt index 7196273a5c725..fe2ffc2a3c277 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): message TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): error TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== @@ -8,12 +8,12 @@ tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): message TS61 class Dummy { constructor(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. ~~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person3' has never been used. +!!! error TS6133: Parameter 'person3' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt index ddf63a22146f8..939dd2c6beecd 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,21): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,54): message TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,21): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,54): error TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (3 errors) ==== var func = function(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. ~~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person3' has never been used. +!!! error TS6133: Parameter 'person3' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt index 61a1864318235..722a9294c98bc 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,18): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (2 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt index 7037ef6423a64..3a767b5436d41 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,20): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,20): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): mess class Dummy { public greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt index 83594231e532f..8287c68183250 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,51): message TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,18): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,51): error TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (3 errors) ==== function greeter(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. ~~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person3' has never been used. +!!! error TS6133: Parameter 'person3' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt index 27f4db42d7c94..fd9dd4bf802de 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,20): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,53): message TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,20): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,53): error TS6133: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (3 errors) ==== @@ -8,12 +8,12 @@ tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): mess class Dummy { public greeter(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. ~~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person3' has never been used. +!!! error TS6133: Parameter 'person3' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt index ca4bc497c7559..aeb2bdd402cf0 100644 --- a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): message TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6133: Parameter 'param1' has never been used. ==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): message TS6133: Pa class greeter { constructor(param1: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param1' has never been used. +!!! error TS6133: Parameter 'param1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt index 282e40b0f68da..1b0ac945c8607 100644 --- a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): message TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6133: Parameter 'param1' has never been used. ==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): message TS6133: Pa class greeter { constructor(param1: string, param2: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param1' has never been used. +!!! error TS6133: Parameter 'param1' has never been used. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt index 29f3685327190..5209fc59e1d1c 100644 --- a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): message TS6133: Parameter 'param1' has never been used. -tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): message TS6133: Parameter 'param3' has never been used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): error TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6133: Parameter 'param3' has never been used. ==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): message TS6133: Pa class greeter { constructor(param1: string, param2: string, param3: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param1' has never been used. +!!! error TS6133: Parameter 'param1' has never been used. ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'param3' has never been used. +!!! error TS6133: Parameter 'param3' has never been used. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt index f426aac6cc939..c6ff8c0d35d16 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): message TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6132: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): message TS6132: Varia class greeter { private function1() { ~~~~~~~~~ -!!! message TS6132: Variable 'function1' has never been used. +!!! error TS6132: Variable 'function1' has never been used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt index 605458197d1da..d23f0ea4ed80b 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): message TS6132: Variable 'function1' has never been used. -tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): message TS6132: Variable 'function2' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): error TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6132: Variable 'function2' has never been used. ==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (2 errors) ==== @@ -7,14 +7,14 @@ tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): message TS6132: Varia class greeter { private function1() { ~~~~~~~~~ -!!! message TS6132: Variable 'function1' has never been used. +!!! error TS6132: Variable 'function1' has never been used. var y = 10; y++; } private function2() { ~~~~~~~~~ -!!! message TS6132: Variable 'function2' has never been used. +!!! error TS6132: Variable 'function2' has never been used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt index e25cd2b61bf56..6a91e1bf86824 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): message TS6132: Variable 'function1' has never been used. -tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): message TS6132: Variable 'function2' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): error TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6132: Variable 'function2' has never been used. ==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (2 errors) ==== @@ -7,14 +7,14 @@ tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): message TS6132: Varia class greeter { private function1() { ~~~~~~~~~ -!!! message TS6132: Variable 'function1' has never been used. +!!! error TS6132: Variable 'function1' has never been used. var y = 10; y++; } private function2() { ~~~~~~~~~ -!!! message TS6132: Variable 'function2' has never been used. +!!! error TS6132: Variable 'function2' has never been used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt index 1c2796e37717d..f8e1e7974c43c 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): message TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6132: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): message TS6132: Varia class greeter { private function1() { ~~~~~~~~~ -!!! message TS6132: Variable 'function1' has never been used. +!!! error TS6132: Variable 'function1' has never been used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt index 1be4db39e31d4..8a0cde20b16b2 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): message TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): error TS6132: Variable 'x' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass1.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): message TS6132: Vari class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'x' has never been used. +!!! error TS6132: Variable 'x' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt index bc5772507ef52..d43c82a744091 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,5): message TS6132: Variable 'x' has never been used. -tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): message TS6132: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,5): error TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): error TS6132: Variable 'y' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass2.ts (2 errors) ==== @@ -7,8 +7,8 @@ tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): message TS6132: Vari class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'x' has never been used. +!!! error TS6132: Variable 'x' has never been used. private y: string; ~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'y' has never been used. +!!! error TS6132: Variable 'y' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt index c63294bb6e12e..88086ce5400c5 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,5): message TS6132: Variable 'x' has never been used. -tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): message TS6132: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,5): error TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): error TS6132: Variable 'y' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass3.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): message TS6132: Vari class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'x' has never been used. +!!! error TS6132: Variable 'x' has never been used. private y: string; ~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'y' has never been used. +!!! error TS6132: Variable 'y' has never been used. public z: string; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt index 65edb89ef0cf7..fac8a5f181542 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): message TS6132: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6132: Variable 'y' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass4.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): message TS6132: Vari private x: string; private y: string; ~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'y' has never been used. +!!! error TS6132: Variable 'y' has never been used. public z: string; public method1() { diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt index eb056fc446049..7bca524abe3cd 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): message TS6132: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6132: Variable 'y' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass5.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): message TS6132: Vari private x: string; private y: string; ~~~~~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'y' has never been used. +!!! error TS6132: Variable 'y' has never been used. public z: string; constructor() { diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt index 923a743d224b8..eff1706fa3d5f 100644 --- a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): message TS6132: class Dummy { constructor(person: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt index 0e8e7598f122b..4ebd5831afe02 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,18): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,18): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts (2 errors) ==== function greeter(person: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt index a614b0058c8ce..32fd26c5e41de 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,21): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,21): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts (2 errors) ==== var func = function(person: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt index b34d8a9bfc5db..9de8d178b2317 100644 --- a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,20): message TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): message TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,20): error TS6133: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS6132: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): message class Dummy { public greeter(person: string) { ~~~~~~~~~~~~~~ -!!! message TS6133: Parameter 'person' has never been used. +!!! error TS6133: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! message TS6132: Variable 'unused' has never been used. +!!! error TS6132: Variable 'unused' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters1.errors.txt b/tests/baselines/reference/unusedTypeParameters1.errors.txt index c00d0b072e8b3..df131943498ed 100644 --- a/tests/baselines/reference/unusedTypeParameters1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameters1.ts(2,15): message TS6132: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters1.ts(2,15): error TS6132: Variable 'typeparameter1' has never been used. ==== tests/cases/compiler/unusedTypeParameters1.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'typeparameter1' has never been used. +!!! error TS6132: Variable 'typeparameter1' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters2.errors.txt b/tests/baselines/reference/unusedTypeParameters2.errors.txt index af6192260c31f..1938df8431807 100644 --- a/tests/baselines/reference/unusedTypeParameters2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameters2.ts(2,15): message TS6132: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters2.ts(2,15): error TS6132: Variable 'typeparameter1' has never been used. ==== tests/cases/compiler/unusedTypeParameters2.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'typeparameter1' has never been used. +!!! error TS6132: Variable 'typeparameter1' has never been used. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedTypeParameters3.errors.txt b/tests/baselines/reference/unusedTypeParameters3.errors.txt index 2f74d3f53dfd4..ff3e4bf3d575b 100644 --- a/tests/baselines/reference/unusedTypeParameters3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedTypeParameters3.ts(2,15): message TS6132: Variable 'typeparameter1' has never been used. -tests/cases/compiler/unusedTypeParameters3.ts(2,47): message TS6132: Variable 'typeparameter3' has never been used. +tests/cases/compiler/unusedTypeParameters3.ts(2,15): error TS6132: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters3.ts(2,47): error TS6132: Variable 'typeparameter3' has never been used. ==== tests/cases/compiler/unusedTypeParameters3.ts (2 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'typeparameter1' has never been used. +!!! error TS6132: Variable 'typeparameter1' has never been used. ~~~~~~~~~~~~~~ -!!! message TS6132: Variable 'typeparameter3' has never been used. +!!! error TS6132: Variable 'typeparameter3' has never been used. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt index 460a06ef91558..f311e02928b94 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): message TS6132: Variable 'lettersRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): error TS6132: Variable 'lettersRegexp' has never been used. ==== tests/cases/compiler/unusedVariablesinNamespaces1.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): message TS6132: Vari namespace Validation { const lettersRegexp = /^[A-Za-z]+$/; ~~~~~~~~~~~~~ -!!! message TS6132: Variable 'lettersRegexp' has never been used. +!!! error TS6132: Variable 'lettersRegexp' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt index f175e709bcd39..01c30549f6762 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): message TS6132: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): error TS6132: Variable 'numberRegexp' has never been used. ==== tests/cases/compiler/unusedVariablesinNamespaces2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): message TS6132: Vari const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! message TS6132: Variable 'numberRegexp' has never been used. +!!! error TS6132: Variable 'numberRegexp' has never been used. export class LettersOnlyValidator { isAcceptable(s2: string) { diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt index e9ab2418904d8..0c0d7b3ceaf21 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): message TS6132: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): error TS6132: Variable 'numberRegexp' has never been used. ==== tests/cases/compiler/unusedVariablesinNamespaces3.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): message TS6132: Vari const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! message TS6132: Variable 'numberRegexp' has never been used. +!!! error TS6132: Variable 'numberRegexp' has never been used. export const anotherUnusedVariable = "Dummy value"; export class LettersOnlyValidator { From 6a711bc261b65b217486f749e4c822997e17ff25 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 16:56:05 -0700 Subject: [PATCH 36/90] Changed the error code in test cases as result of merge with master --- .../unusedClassesinNamespace1.errors.txt | 4 +- .../unusedClassesinNamespace2.errors.txt | 4 +- .../unusedClassesinNamespace4.errors.txt | 4 +- .../unusedClassesinNamespace5.errors.txt | 4 +- .../unusedFunctionsinNamespaces1.errors.txt | 4 +- .../unusedFunctionsinNamespaces2.errors.txt | 4 +- .../unusedFunctionsinNamespaces3.errors.txt | 8 +-- .../unusedFunctionsinNamespaces4.errors.txt | 4 +- .../unusedFunctionsinNamespaces5.errors.txt | 8 +-- .../unusedFunctionsinNamespaces6.errors.txt | 4 +- .../unusedIdentifiersConsolidated1.errors.txt | 64 +++++++++---------- .../unusedInterfaceinNamespace1.errors.txt | 4 +- .../unusedInterfaceinNamespace2.errors.txt | 4 +- .../unusedInterfaceinNamespace3.errors.txt | 4 +- .../unusedLocalsInMethod1.errors.txt | 4 +- .../unusedLocalsInMethod2.errors.txt | 4 +- .../unusedLocalsInMethod3.errors.txt | 4 +- ...ationWithinFunctionDeclaration1.errors.txt | 20 +++--- ...ationWithinFunctionDeclaration2.errors.txt | 28 ++++---- ...rationWithinFunctionExpression1.errors.txt | 20 +++--- ...rationWithinFunctionExpression2.errors.txt | 28 ++++---- ...ssionWithinFunctionDeclaration1.errors.txt | 20 +++--- ...ssionWithinFunctionDeclaration2.errors.txt | 28 ++++---- ...essionWithinFunctionExpression1.errors.txt | 20 +++--- ...essionWithinFunctionExpression2.errors.txt | 28 ++++---- .../unusedLocalsinConstructor1.errors.txt | 4 +- .../unusedLocalsinConstructor2.errors.txt | 4 +- ...dMultipleParameter1InContructor.errors.txt | 8 +-- ...eParameter1InFunctionExpression.errors.txt | 8 +-- ...dMultipleParameter2InContructor.errors.txt | 12 ++-- ...eParameter2InFunctionExpression.errors.txt | 12 ++-- ...arameters1InFunctionDeclaration.errors.txt | 8 +-- ...eParameters1InMethodDeclaration.errors.txt | 8 +-- ...arameters2InFunctionDeclaration.errors.txt | 12 ++-- ...eParameters2InMethodDeclaration.errors.txt | 12 ++-- .../unusedParametersinConstructor1.errors.txt | 4 +- .../unusedParametersinConstructor2.errors.txt | 4 +- .../unusedParametersinConstructor3.errors.txt | 8 +-- .../unusedPrivateMethodInClass1.errors.txt | 4 +- .../unusedPrivateMethodInClass2.errors.txt | 8 +-- .../unusedPrivateMethodInClass3.errors.txt | 8 +-- .../unusedPrivateMethodInClass4.errors.txt | 4 +- .../unusedPrivateVariableInClass1.errors.txt | 4 +- .../unusedPrivateVariableInClass2.errors.txt | 8 +-- .../unusedPrivateVariableInClass3.errors.txt | 8 +-- .../unusedPrivateVariableInClass4.errors.txt | 4 +- .../unusedPrivateVariableInClass5.errors.txt | 4 +- ...usedSingleParameterInContructor.errors.txt | 8 +-- ...eParameterInFunctionDeclaration.errors.txt | 8 +-- ...leParameterInFunctionExpression.errors.txt | 8 +-- ...gleParameterInMethodDeclaration.errors.txt | 8 +-- .../unusedTypeParameters1.errors.txt | 4 +- .../unusedTypeParameters2.errors.txt | 4 +- .../unusedTypeParameters3.errors.txt | 8 +-- .../unusedVariablesinNamespaces1.errors.txt | 4 +- .../unusedVariablesinNamespaces2.errors.txt | 4 +- .../unusedVariablesinNamespaces3.errors.txt | 4 +- 57 files changed, 272 insertions(+), 272 deletions(-) diff --git a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt index 8f1a90233f7a8..dffa3d93a5759 100644 --- a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): error TS6132: Variable 'c1' has never been used. +tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): error TS6133: Variable 'c1' has never been used. ==== tests/cases/compiler/unusedClassesinNamespace1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): error TS6132: Variable namespace Validation { class c1 { ~~ -!!! error TS6132: Variable 'c1' has never been used. +!!! error TS6133: Variable 'c1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt index e818568378873..f8e6573b27c5f 100644 --- a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): error TS6132: Variable 'c1' has never been used. +tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): error TS6133: Variable 'c1' has never been used. ==== tests/cases/compiler/unusedClassesinNamespace2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): error TS6132: Variable namespace Validation { class c1 { ~~ -!!! error TS6132: Variable 'c1' has never been used. +!!! error TS6133: Variable 'c1' has never been used. } diff --git a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt index 4553f2b3fa1dc..8f7aad5f0b03e 100644 --- a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): error TS6132: Variable 'c3' has never been used. +tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): error TS6133: Variable 'c3' has never been used. ==== tests/cases/compiler/unusedClassesinNamespace4.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): error TS6132: Variable class c3 extends c1 { ~~ -!!! error TS6132: Variable 'c3' has never been used. +!!! error TS6133: Variable 'c3' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt index ce1eb4f578b32..d3f491635327f 100644 --- a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): error TS6132: Variable 'c3' has never been used. +tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): error TS6133: Variable 'c3' has never been used. ==== tests/cases/compiler/unusedClassesinNamespace5.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): error TS6132: Variable class c3 { ~~ -!!! error TS6132: Variable 'c3' has never been used. +!!! error TS6133: Variable 'c3' has never been used. public x: c1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt index bfb24d043f7fe..a5c859adb7ea8 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): error TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): error TS6133: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): error TS6132: Variab namespace Validation { function function1() { ~~~~~~~~~ -!!! error TS6132: Variable 'function1' has never been used. +!!! error TS6133: Variable 'function1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt index dc5fdd1740b3e..0bb9df4299d61 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): error TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): error TS6133: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces2.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): error TS6132: Variabl namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! error TS6132: Variable 'function1' has never been used. +!!! error TS6133: Variable 'function1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt index 8ba79b408d48d..7d4d68968db15 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,9): error TS6132: Variable 'function1' has never been used. -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,9): error TS6133: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6134: Parameter 'param1' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces3.ts (2 errors) ==== @@ -7,8 +7,8 @@ tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6133: Parame namespace Validation { var function1 = function(param1:string) { ~~~~~~~~~ -!!! error TS6132: Variable 'function1' has never been used. +!!! error TS6133: Variable 'function1' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'param1' has never been used. +!!! error TS6134: Parameter 'param1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt index 1fce88371d999..ec1e958a0b05d 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): error TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): error TS6133: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces4.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): error TS6132: Variabl namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! error TS6132: Variable 'function1' has never been used. +!!! error TS6133: Variable 'function1' has never been used. } export function function2() { diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt index 30da9d7227e6a..1e1eb28b40eb0 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(10,14): error TS6132: Variable 'function3' has never been used. -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): error TS6132: Variable 'function4' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(10,14): error TS6133: Variable 'function3' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): error TS6133: Variable 'function4' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces5.ts (2 errors) ==== @@ -14,13 +14,13 @@ tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): error TS6132: Varia function function3() { ~~~~~~~~~ -!!! error TS6132: Variable 'function3' has never been used. +!!! error TS6133: Variable 'function3' has never been used. function1(); } function function4() { ~~~~~~~~~ -!!! error TS6132: Variable 'function4' has never been used. +!!! error TS6133: Variable 'function4' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt index 470dba934d9e4..60de8e8908d23 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): error TS6132: Variable 'function4' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): error TS6133: Variable 'function4' has never been used. ==== tests/cases/compiler/unusedFunctionsinNamespaces6.ts (1 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): error TS6132: Varia function function4() { ~~~~~~~~~ -!!! error TS6132: Variable 'function4' has never been used. +!!! error TS6133: Variable 'function4' has never been used. } diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt index d9ada7955c49a..d16450b6267d2 100644 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -1,56 +1,56 @@ -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): error TS6132: Variable 'unusedtypeparameter' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): error TS6132: Variable 'unusedprivatevariable' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): error TS6133: Parameter 'message' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): error TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): error TS6132: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): error TS6132: Variable 'numberRegexp' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): error TS6132: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): error TS6132: Variable 'usedLocallyInterface2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): error TS6132: Variable 'dummy' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): error TS6132: Variable 'unusedInterface' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): error TS6132: Variable 'class3' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Variable 'interface5' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): error TS6133: Variable 'unusedtypeparameter' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): error TS6133: Variable 'unusedprivatevariable' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): error TS6134: Parameter 'message' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): error TS6133: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): error TS6133: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): error TS6133: Variable 'unUsedPrivateFunction' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): error TS6133: Variable 'usedLocallyInterface2' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): error TS6133: Variable 'dummy' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): error TS6133: Variable 'unusedInterface' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): error TS6133: Variable 'class3' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Variable 'interface5' has never been used. ==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== function greeter(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. } class Dummy { ~~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'unusedtypeparameter' has never been used. +!!! error TS6133: Variable 'unusedtypeparameter' has never been used. private unusedprivatevariable: string; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'unusedprivatevariable' has never been used. +!!! error TS6133: Variable 'unusedprivatevariable' has never been used. private greeting: string; public unusedpublicvariable: string; public typedvariable: usedtypeparameter; constructor(message: string) { ~~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'message' has never been used. +!!! error TS6134: Parameter 'message' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. this.greeting = "Dummy Message"; } public greeter(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. this.usedPrivateFunction(); } @@ -59,7 +59,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Va private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'unUsedPrivateFunction' has never been used. +!!! error TS6133: Variable 'unUsedPrivateFunction' has never been used. } } @@ -74,7 +74,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Va const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6132: Variable 'numberRegexp' has never been used. +!!! error TS6133: Variable 'numberRegexp' has never been used. export class LettersOnlyValidator implements StringValidator { isAcceptable(s2: string) { @@ -83,7 +83,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Va private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'unUsedPrivateFunction' has never been used. +!!! error TS6133: Variable 'unUsedPrivateFunction' has never been used. } } @@ -98,7 +98,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Va interface usedLocallyInterface2 { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'usedLocallyInterface2' has never been used. +!!! error TS6133: Variable 'usedLocallyInterface2' has never been used. someFunction(s1: string): void; } @@ -107,12 +107,12 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Va class dummy implements usedLocallyInterface { ~~~~~ -!!! error TS6132: Variable 'dummy' has never been used. +!!! error TS6133: Variable 'dummy' has never been used. } interface unusedInterface { ~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'unusedInterface' has never been used. +!!! error TS6133: Variable 'unusedInterface' has never been used. } } @@ -126,7 +126,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Va class class3 { ~~~~~~ -!!! error TS6132: Variable 'class3' has never been used. +!!! error TS6133: Variable 'class3' has never been used. } export class class4 { @@ -148,6 +148,6 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6132: Va interface interface5 { ~~~~~~~~~~ -!!! error TS6132: Variable 'interface5' has never been used. +!!! error TS6133: Variable 'interface5' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt index 18cd225212777..be49c3cd2fffe 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): error TS6132: Variable 'i1' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): error TS6133: Variable 'i1' has never been used. ==== tests/cases/compiler/unusedInterfaceinNamespace1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): error TS6132: Variabl namespace Validation { interface i1 { ~~ -!!! error TS6132: Variable 'i1' has never been used. +!!! error TS6133: Variable 'i1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt index 8df7aa310eb8a..e2d37845ae49b 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): error TS6132: Variable 'i1' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): error TS6133: Variable 'i1' has never been used. ==== tests/cases/compiler/unusedInterfaceinNamespace2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): error TS6132: Variabl namespace Validation { interface i1 { ~~ -!!! error TS6132: Variable 'i1' has never been used. +!!! error TS6133: Variable 'i1' has never been used. } diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt index 5d33e1cae70d2..06cbd6ae70566 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): error TS6132: Variable 'i3' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): error TS6133: Variable 'i3' has never been used. ==== tests/cases/compiler/unusedInterfaceinNamespace3.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): error TS6132: Variab interface i3 extends i1 { ~~ -!!! error TS6132: Variable 'i3' has never been used. +!!! error TS6133: Variable 'i3' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt index e3423d57c5e95..f8b7761877bb9 100644 --- a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): error TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): error TS6133: Variable 'x' has never been used. ==== tests/cases/compiler/unusedLocalsInMethod1.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): error TS6132: Variable 'x' public function1() { var x = 10; ~ -!!! error TS6132: Variable 'x' has never been used. +!!! error TS6133: Variable 'x' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt index f990d97bfd34d..7d263db7d49cc 100644 --- a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): error TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): error TS6133: Variable 'x' has never been used. ==== tests/cases/compiler/unusedLocalsInMethod2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): error TS6132: Variable 'x' public function1() { var x, y = 10; ~ -!!! error TS6132: Variable 'x' has never been used. +!!! error TS6133: Variable 'x' has never been used. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt index fd869922678e4..dbe7c19d2ae8d 100644 --- a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): error TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): error TS6133: Variable 'x' has never been used. ==== tests/cases/compiler/unusedLocalsInMethod3.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): error TS6132: Variable 'x' public function1() { var x, y; ~ -!!! error TS6132: Variable 'x' has never been used. +!!! error TS6133: Variable 'x' has never been used. y = 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt index 5347d79da2e4c..8fe7ac6736db2 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,18): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,14): error TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,20): error TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(5,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,18): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,14): error TS6133: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,20): error TS6134: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(5,13): error TS6133: Variable 'unused2' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. function maker(child: string): void { ~~~~~ -!!! error TS6132: Variable 'maker' has never been used. +!!! error TS6133: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child' has never been used. +!!! error TS6134: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt index 1beab8f93d50d..e0d0c5e8f3941 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,18): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,14): error TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,20): error TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(5,13): error TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,21): error TS6133: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(8,13): error TS6132: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,18): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,14): error TS6133: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,20): error TS6134: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(5,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,21): error TS6134: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(8,13): error TS6133: Variable 'unused3' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. function maker(child: string): void { ~~~~~ -!!! error TS6132: Variable 'maker' has never been used. +!!! error TS6133: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child' has never been used. +!!! error TS6134: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. } function maker2(child2: string): void { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child2' has never been used. +!!! error TS6134: Parameter 'child2' has never been used. var unused3 = 23; ~~~~~~~ -!!! error TS6132: Variable 'unused3' has never been used. +!!! error TS6133: Variable 'unused3' has never been used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt index dd3736acb1fe7..489afc59602e9 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,25): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,14): error TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,20): error TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(5,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,25): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,14): error TS6133: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,20): error TS6134: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(5,13): error TS6133: Variable 'unused2' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (5 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. function maker(child: string): void { ~~~~~ -!!! error TS6132: Variable 'maker' has never been used. +!!! error TS6133: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child' has never been used. +!!! error TS6134: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt index 54a871430783a..f156759768980 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,25): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,14): error TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,20): error TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(5,13): error TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,21): error TS6133: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(8,13): error TS6132: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,25): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,14): error TS6133: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,20): error TS6134: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(5,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,21): error TS6134: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(8,13): error TS6133: Variable 'unused3' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. function maker(child: string): void { ~~~~~ -!!! error TS6132: Variable 'maker' has never been used. +!!! error TS6133: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child' has never been used. +!!! error TS6134: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. } function maker2(child2: string): void { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child2' has never been used. +!!! error TS6134: Parameter 'child2' has never been used. var unused3 = 23; ~~~~~~~ -!!! error TS6132: Variable 'unused3' has never been used. +!!! error TS6133: Variable 'unused3' has never been used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt index 4bdb2ea988b25..ce63c48ec9478 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,18): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,9): error TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,27): error TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(5,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,18): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,9): error TS6133: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,27): error TS6134: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(5,13): error TS6133: Variable 'unused2' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (5 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. var maker = function (child: string): void { ~~~~~ -!!! error TS6132: Variable 'maker' has never been used. +!!! error TS6133: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child' has never been used. +!!! error TS6134: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt index 47d757fa9a625..d1cadeca88a23 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,18): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,9): error TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,26): error TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(5,13): error TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,27): error TS6133: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(8,13): error TS6132: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,18): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,9): error TS6133: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,26): error TS6134: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(5,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,27): error TS6134: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(8,13): error TS6133: Variable 'unused3' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. var maker = function(child: string): void { ~~~~~ -!!! error TS6132: Variable 'maker' has never been used. +!!! error TS6133: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child' has never been used. +!!! error TS6134: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. } var maker2 = function(child2: string): void { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child2' has never been used. +!!! error TS6134: Parameter 'child2' has never been used. var unused3 = 23; ~~~~~~~ -!!! error TS6132: Variable 'unused3' has never been used. +!!! error TS6133: Variable 'unused3' has never been used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt index fb9a59d151cf5..64924de57b595 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,25): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,9): error TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,27): error TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(5,13): error TS6132: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,25): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,9): error TS6133: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,27): error TS6134: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(5,13): error TS6133: Variable 'unused2' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (5 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. var maker = function (child: string): void { ~~~~~ -!!! error TS6132: Variable 'maker' has never been used. +!!! error TS6133: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child' has never been used. +!!! error TS6134: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt index 4af157ffc3d3e..1c247f4183758 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,25): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6132: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,9): error TS6132: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,27): error TS6133: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(5,13): error TS6132: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,28): error TS6133: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(8,13): error TS6132: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,25): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,9): error TS6133: Variable 'maker' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,27): error TS6134: Parameter 'child' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(5,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,28): error TS6134: Parameter 'child2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(8,13): error TS6133: Variable 'unused3' has never been used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. var maker = function (child: string): void { ~~~~~ -!!! error TS6132: Variable 'maker' has never been used. +!!! error TS6133: Variable 'maker' has never been used. ~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child' has never been used. +!!! error TS6134: Parameter 'child' has never been used. var unused2 = 22; ~~~~~~~ -!!! error TS6132: Variable 'unused2' has never been used. +!!! error TS6133: Variable 'unused2' has never been used. } var maker2 = function (child2: string): void { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'child2' has never been used. +!!! error TS6134: Parameter 'child2' has never been used. var unused3 = 23; ~~~~~~~ -!!! error TS6132: Variable 'unused3' has never been used. +!!! error TS6133: Variable 'unused3' has never been used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt index dfab136e6a5db..e024997c04fb8 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedLocalsinConstructor1.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): error TS6132: Variable constructor() { var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt index e150e39f8bbb9..59df6f20a9526 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedLocalsinConstructor2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): error TS6132: Variable constructor() { var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. var used = "dummy"; used = used + "second part"; } diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt index d98ec7d187a4f..57fa43dee23ce 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6132 class Dummy { constructor(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt index 6eaf329566a22..8647672af5dee 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,21): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,21): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (2 errors) ==== var func = function(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt index fe2ffc2a3c277..bb0c690c55e79 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): error TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): error TS6134: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== @@ -8,12 +8,12 @@ tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6132 class Dummy { constructor(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. ~~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person3' has never been used. +!!! error TS6134: Parameter 'person3' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt index 939dd2c6beecd..d34640e1c9164 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,21): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,54): error TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,21): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,54): error TS6134: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (3 errors) ==== var func = function(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. ~~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person3' has never been used. +!!! error TS6134: Parameter 'person3' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt index 722a9294c98bc..fc9a6670a9b28 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,18): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,18): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (2 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt index 3a767b5436d41..d0463b5dcce6d 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,20): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,20): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): erro class Dummy { public greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt index 8287c68183250..258a29a8b1ccd 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,18): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,51): error TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,18): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,51): error TS6134: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (3 errors) ==== function greeter(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. ~~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person3' has never been used. +!!! error TS6134: Parameter 'person3' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt index fd9dd4bf802de..59cfdcad01a7f 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,20): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,53): error TS6133: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,20): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,53): error TS6134: Parameter 'person3' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (3 errors) ==== @@ -8,12 +8,12 @@ tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): erro class Dummy { public greeter(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. ~~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person3' has never been used. +!!! error TS6134: Parameter 'person3' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt index aeb2bdd402cf0..68f61956de795 100644 --- a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6134: Parameter 'param1' has never been used. ==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6133: Para class greeter { constructor(param1: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'param1' has never been used. +!!! error TS6134: Parameter 'param1' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt index 1b0ac945c8607..061960c867081 100644 --- a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6133: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6134: Parameter 'param1' has never been used. ==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6133: Para class greeter { constructor(param1: string, param2: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'param1' has never been used. +!!! error TS6134: Parameter 'param1' has never been used. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt index 5209fc59e1d1c..6dc7c9925ddf9 100644 --- a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): error TS6133: Parameter 'param1' has never been used. -tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6133: Parameter 'param3' has never been used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): error TS6134: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6134: Parameter 'param3' has never been used. ==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6133: Para class greeter { constructor(param1: string, param2: string, param3: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'param1' has never been used. +!!! error TS6134: Parameter 'param1' has never been used. ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'param3' has never been used. +!!! error TS6134: Parameter 'param3' has never been used. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt index c6ff8c0d35d16..1ebfa445f943c 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6133: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6132: Variabl class greeter { private function1() { ~~~~~~~~~ -!!! error TS6132: Variable 'function1' has never been used. +!!! error TS6133: Variable 'function1' has never been used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt index d23f0ea4ed80b..56aa61dac4145 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): error TS6132: Variable 'function1' has never been used. -tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6132: Variable 'function2' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): error TS6133: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6133: Variable 'function2' has never been used. ==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (2 errors) ==== @@ -7,14 +7,14 @@ tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6132: Variabl class greeter { private function1() { ~~~~~~~~~ -!!! error TS6132: Variable 'function1' has never been used. +!!! error TS6133: Variable 'function1' has never been used. var y = 10; y++; } private function2() { ~~~~~~~~~ -!!! error TS6132: Variable 'function2' has never been used. +!!! error TS6133: Variable 'function2' has never been used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt index 6a91e1bf86824..9b4c6589f661e 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): error TS6132: Variable 'function1' has never been used. -tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6132: Variable 'function2' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): error TS6133: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6133: Variable 'function2' has never been used. ==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (2 errors) ==== @@ -7,14 +7,14 @@ tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6132: Variabl class greeter { private function1() { ~~~~~~~~~ -!!! error TS6132: Variable 'function1' has never been used. +!!! error TS6133: Variable 'function1' has never been used. var y = 10; y++; } private function2() { ~~~~~~~~~ -!!! error TS6132: Variable 'function2' has never been used. +!!! error TS6133: Variable 'function2' has never been used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt index f8e1e7974c43c..2bf406d88292d 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6132: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6133: Variable 'function1' has never been used. ==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6132: Variabl class greeter { private function1() { ~~~~~~~~~ -!!! error TS6132: Variable 'function1' has never been used. +!!! error TS6133: Variable 'function1' has never been used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt index 8a0cde20b16b2..dedbf1c01a0fa 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): error TS6132: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): error TS6133: Variable 'x' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass1.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): error TS6132: Variab class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'x' has never been used. +!!! error TS6133: Variable 'x' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt index d43c82a744091..492a65b3afa24 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,5): error TS6132: Variable 'x' has never been used. -tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): error TS6132: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,5): error TS6133: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): error TS6133: Variable 'y' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass2.ts (2 errors) ==== @@ -7,8 +7,8 @@ tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): error TS6132: Variab class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'x' has never been used. +!!! error TS6133: Variable 'x' has never been used. private y: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'y' has never been used. +!!! error TS6133: Variable 'y' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt index 88086ce5400c5..d33a59a6bda60 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,5): error TS6132: Variable 'x' has never been used. -tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): error TS6132: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,5): error TS6133: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): error TS6133: Variable 'y' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass3.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): error TS6132: Variab class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'x' has never been used. +!!! error TS6133: Variable 'x' has never been used. private y: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'y' has never been used. +!!! error TS6133: Variable 'y' has never been used. public z: string; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt index fac8a5f181542..6cf355497e1ca 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6132: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6133: Variable 'y' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass4.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6132: Variab private x: string; private y: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'y' has never been used. +!!! error TS6133: Variable 'y' has never been used. public z: string; public method1() { diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt index 7bca524abe3cd..36e68408cd0e8 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6132: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6133: Variable 'y' has never been used. ==== tests/cases/compiler/unusedPrivateVariableInClass5.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6132: Variab private x: string; private y: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'y' has never been used. +!!! error TS6133: Variable 'y' has never been used. public z: string; constructor() { diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt index eff1706fa3d5f..f767ee564d150 100644 --- a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6132: V class Dummy { constructor(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt index 4ebd5831afe02..1e94be8e6f58d 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,18): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,18): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts (2 errors) ==== function greeter(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt index 32fd26c5e41de..179310d246c91 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,21): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,21): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts (2 errors) ==== var func = function(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt index 9de8d178b2317..b17937883b257 100644 --- a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,20): error TS6133: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS6132: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,20): error TS6134: Parameter 'person' has never been used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS6133: Variable 'unused' has never been used. ==== tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS class Dummy { public greeter(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6133: Parameter 'person' has never been used. +!!! error TS6134: Parameter 'person' has never been used. var unused = 20; ~~~~~~ -!!! error TS6132: Variable 'unused' has never been used. +!!! error TS6133: Variable 'unused' has never been used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters1.errors.txt b/tests/baselines/reference/unusedTypeParameters1.errors.txt index df131943498ed..22b2f5579bb43 100644 --- a/tests/baselines/reference/unusedTypeParameters1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameters1.ts(2,15): error TS6132: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters1.ts(2,15): error TS6133: Variable 'typeparameter1' has never been used. ==== tests/cases/compiler/unusedTypeParameters1.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'typeparameter1' has never been used. +!!! error TS6133: Variable 'typeparameter1' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters2.errors.txt b/tests/baselines/reference/unusedTypeParameters2.errors.txt index 1938df8431807..ef71d3ebeefe0 100644 --- a/tests/baselines/reference/unusedTypeParameters2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameters2.ts(2,15): error TS6132: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters2.ts(2,15): error TS6133: Variable 'typeparameter1' has never been used. ==== tests/cases/compiler/unusedTypeParameters2.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'typeparameter1' has never been used. +!!! error TS6133: Variable 'typeparameter1' has never been used. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedTypeParameters3.errors.txt b/tests/baselines/reference/unusedTypeParameters3.errors.txt index ff3e4bf3d575b..0970af65bf1fe 100644 --- a/tests/baselines/reference/unusedTypeParameters3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedTypeParameters3.ts(2,15): error TS6132: Variable 'typeparameter1' has never been used. -tests/cases/compiler/unusedTypeParameters3.ts(2,47): error TS6132: Variable 'typeparameter3' has never been used. +tests/cases/compiler/unusedTypeParameters3.ts(2,15): error TS6133: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters3.ts(2,47): error TS6133: Variable 'typeparameter3' has never been used. ==== tests/cases/compiler/unusedTypeParameters3.ts (2 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'typeparameter1' has never been used. +!!! error TS6133: Variable 'typeparameter1' has never been used. ~~~~~~~~~~~~~~ -!!! error TS6132: Variable 'typeparameter3' has never been used. +!!! error TS6133: Variable 'typeparameter3' has never been used. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt index f311e02928b94..d2b0d4c9ee8ca 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): error TS6132: Variable 'lettersRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): error TS6133: Variable 'lettersRegexp' has never been used. ==== tests/cases/compiler/unusedVariablesinNamespaces1.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): error TS6132: Variab namespace Validation { const lettersRegexp = /^[A-Za-z]+$/; ~~~~~~~~~~~~~ -!!! error TS6132: Variable 'lettersRegexp' has never been used. +!!! error TS6133: Variable 'lettersRegexp' has never been used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt index 01c30549f6762..2026419029d0d 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): error TS6132: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): error TS6133: Variable 'numberRegexp' has never been used. ==== tests/cases/compiler/unusedVariablesinNamespaces2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): error TS6132: Variab const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6132: Variable 'numberRegexp' has never been used. +!!! error TS6133: Variable 'numberRegexp' has never been used. export class LettersOnlyValidator { isAcceptable(s2: string) { diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt index 0c0d7b3ceaf21..ecc8e48356b55 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): error TS6132: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): error TS6133: Variable 'numberRegexp' has never been used. ==== tests/cases/compiler/unusedVariablesinNamespaces3.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): error TS6132: Variab const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6132: Variable 'numberRegexp' has never been used. +!!! error TS6133: Variable 'numberRegexp' has never been used. export const anotherUnusedVariable = "Dummy value"; export class LettersOnlyValidator { From d62a43f234ada2a06f1af7fc018177d480db00c2 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 17:00:04 -0700 Subject: [PATCH 37/90] Adding the missing file --- lib/lib.scripthost.d.ts | 294 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 294 insertions(+) create mode 100644 lib/lib.scripthost.d.ts diff --git a/lib/lib.scripthost.d.ts b/lib/lib.scripthost.d.ts new file mode 100644 index 0000000000000..70aedd809339d --- /dev/null +++ b/lib/lib.scripthost.d.ts @@ -0,0 +1,294 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +/// + + +///////////////////////////// +/// Windows Script Host APIS +///////////////////////////// + + +interface ActiveXObject { + new (s: string): any; +} +declare var ActiveXObject: ActiveXObject; + +interface ITextWriter { + Write(s: string): void; + WriteLine(s: string): void; + Close(): void; +} + +interface TextStreamBase { + /** + * The column number of the current character position in an input stream. + */ + Column: number; + + /** + * The current line number in an input stream. + */ + Line: number; + + /** + * Closes a text stream. + * It is not necessary to close standard streams; they close automatically when the process ends. If + * you close a standard stream, be aware that any other pointers to that standard stream become invalid. + */ + Close(): void; +} + +interface TextStreamWriter extends TextStreamBase { + /** + * Sends a string to an output stream. + */ + Write(s: string): void; + + /** + * Sends a specified number of blank lines (newline characters) to an output stream. + */ + WriteBlankLines(intLines: number): void; + + /** + * Sends a string followed by a newline character to an output stream. + */ + WriteLine(s: string): void; +} + +interface TextStreamReader extends TextStreamBase { + /** + * Returns a specified number of characters from an input stream, starting at the current pointer position. + * Does not return until the ENTER key is pressed. + * Can only be used on a stream in reading mode; causes an error in writing or appending mode. + */ + Read(characters: number): string; + + /** + * Returns all characters from an input stream. + * Can only be used on a stream in reading mode; causes an error in writing or appending mode. + */ + ReadAll(): string; + + /** + * Returns an entire line from an input stream. + * Although this method extracts the newline character, it does not add it to the returned string. + * Can only be used on a stream in reading mode; causes an error in writing or appending mode. + */ + ReadLine(): string; + + /** + * Skips a specified number of characters when reading from an input text stream. + * Can only be used on a stream in reading mode; causes an error in writing or appending mode. + * @param characters Positive number of characters to skip forward. (Backward skipping is not supported.) + */ + Skip(characters: number): void; + + /** + * Skips the next line when reading from an input text stream. + * Can only be used on a stream in reading mode, not writing or appending mode. + */ + SkipLine(): void; + + /** + * Indicates whether the stream pointer position is at the end of a line. + */ + AtEndOfLine: boolean; + + /** + * Indicates whether the stream pointer position is at the end of a stream. + */ + AtEndOfStream: boolean; +} + +declare var WScript: { + /** + * Outputs text to either a message box (under WScript.exe) or the command console window followed by + * a newline (under CScript.exe). + */ + Echo(s: any): void; + + /** + * Exposes the write-only error output stream for the current script. + * Can be accessed only while using CScript.exe. + */ + StdErr: TextStreamWriter; + + /** + * Exposes the write-only output stream for the current script. + * Can be accessed only while using CScript.exe. + */ + StdOut: TextStreamWriter; + Arguments: { length: number; Item(n: number): string; }; + + /** + * The full path of the currently running script. + */ + ScriptFullName: string; + + /** + * Forces the script to stop immediately, with an optional exit code. + */ + Quit(exitCode?: number): number; + + /** + * The Windows Script Host build version number. + */ + BuildVersion: number; + + /** + * Fully qualified path of the host executable. + */ + FullName: string; + + /** + * Gets/sets the script mode - interactive(true) or batch(false). + */ + Interactive: boolean; + + /** + * The name of the host executable (WScript.exe or CScript.exe). + */ + Name: string; + + /** + * Path of the directory containing the host executable. + */ + Path: string; + + /** + * The filename of the currently running script. + */ + ScriptName: string; + + /** + * Exposes the read-only input stream for the current script. + * Can be accessed only while using CScript.exe. + */ + StdIn: TextStreamReader; + + /** + * Windows Script Host version + */ + Version: string; + + /** + * Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event. + */ + ConnectObject(objEventSource: any, strPrefix: string): void; + + /** + * Creates a COM object. + * @param strProgiID + * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events. + */ + CreateObject(strProgID: string, strPrefix?: string): any; + + /** + * Disconnects a COM object from its event sources. + */ + DisconnectObject(obj: any): void; + + /** + * Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file. + * @param strPathname Fully qualified path to the file containing the object persisted to disk. + * For objects in memory, pass a zero-length string. + * @param strProgID + * @param strPrefix Function names in the form prefix_event will be bound to this object's COM events. + */ + GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any; + + /** + * Suspends script execution for a specified length of time, then continues execution. + * @param intTime Interval (in milliseconds) to suspend script execution. + */ + Sleep(intTime: number): void; +}; + +/** + * Allows enumerating over a COM collection, which may not have indexed item access. + */ +interface Enumerator { + /** + * Returns true if the current item is the last one in the collection, or the collection is empty, + * or the current item is undefined. + */ + atEnd(): boolean; + + /** + * Returns the current item in the collection + */ + item(): T; + + /** + * Resets the current item in the collection to the first item. If there are no items in the collection, + * the current item is set to undefined. + */ + moveFirst(): void; + + /** + * Moves the current item to the next item in the collection. If the enumerator is at the end of + * the collection or the collection is empty, the current item is set to undefined. + */ + moveNext(): void; +} + +interface EnumeratorConstructor { + new (collection: any): Enumerator; + new (collection: any): Enumerator; +} + +declare var Enumerator: EnumeratorConstructor; + +/** + * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. + */ +interface VBArray { + /** + * Returns the number of dimensions (1-based). + */ + dimensions(): number; + + /** + * Takes an index for each dimension in the array, and returns the item at the corresponding location. + */ + getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T; + + /** + * Returns the smallest available index for a given dimension. + * @param dimension 1-based dimension (defaults to 1) + */ + lbound(dimension?: number): number; + + /** + * Returns the largest available index for a given dimension. + * @param dimension 1-based dimension (defaults to 1) + */ + ubound(dimension?: number): number; + + /** + * Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions, + * each successive dimension is appended to the end of the array. + * Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6] + */ + toArray(): T[]; +} + +interface VBArrayConstructor { + new (safeArray: any): VBArray; + new (safeArray: any): VBArray; +} + +declare var VBArray: VBArrayConstructor; \ No newline at end of file From 043a62568dacb3b79fc1233207e4be57305dedc6 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 15 Jun 2016 17:01:17 -0700 Subject: [PATCH 38/90] Adding the missing file II --- lib/lib.scripthost.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/lib.scripthost.d.ts b/lib/lib.scripthost.d.ts index 70aedd809339d..d4c6131fd93ba 100644 --- a/lib/lib.scripthost.d.ts +++ b/lib/lib.scripthost.d.ts @@ -1,14 +1,14 @@ /*! ***************************************************************************** -Copyright (c) Microsoft Corporation. All rights reserved. +Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the -License at http://www.apache.org/licenses/LICENSE-2.0 - +License at http://www.apache.org/licenses/LICENSE-2.0 + THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED -WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, -MERCHANTABLITY OR NON-INFRINGEMENT. - +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ @@ -45,7 +45,7 @@ interface TextStreamBase { /** * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If + * It is not necessary to close standard streams; they close automatically when the process ends. If * you close a standard stream, be aware that any other pointers to that standard stream become invalid. */ Close(): void; @@ -291,4 +291,4 @@ interface VBArrayConstructor { new (safeArray: any): VBArray; } -declare var VBArray: VBArrayConstructor; \ No newline at end of file +declare var VBArray: VBArrayConstructor; From 6d4020bdde80b54666b880261cc632f01eb6a51e Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 16 Jun 2016 14:39:44 -0700 Subject: [PATCH 39/90] Rename QuickFix to CodeFix --- src/harness/harnessLanguageService.ts | 4 ++-- src/server/client.ts | 2 +- src/services/quickfixes/quickFixProvider.ts | 8 +------- src/services/services.ts | 12 ++++++------ src/services/shims.ts | 11 +++++++---- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 3978f79d1a6ba..82caf13927630 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -440,8 +440,8 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPostion(fileName, position, openingBrace)); } - getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.SuggestedFix { - return unwrapJSONCallResult(this.shim.getCodeFixAtPosition(fileName, start, end, errorCodes)); + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeFix[] { + return unwrapJSONCallResult(this.shim.getCodeFixesAtPosition(fileName, start, end, JSON.stringify(errorCodes))); } getEmitOutput(fileName: string): ts.EmitOutput { return unwrapJSONCallResult(this.shim.getEmitOutput(fileName)); diff --git a/src/server/client.ts b/src/server/client.ts index eda9ad21d12c6..7cffc3018a5e6 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -572,7 +572,7 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } - getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.SuggestedFix { + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeFix[] { throw new Error("Not Implemented Yet."); } diff --git a/src/services/quickfixes/quickFixProvider.ts b/src/services/quickfixes/quickFixProvider.ts index 551994a7a4c94..8321936aef4dd 100644 --- a/src/services/quickfixes/quickFixProvider.ts +++ b/src/services/quickfixes/quickFixProvider.ts @@ -7,12 +7,6 @@ namespace ts { } export namespace quickFix { - export const enum FixPriority { - AboveNormal, - Normal, - BelowNormal, - } - var quickFixes: Map = {}; export function registerQuickFix(fix: QuickFix) { @@ -32,7 +26,7 @@ namespace ts { return getKeys(quickFixes); } - public getFixes(errorCode: string, sourceFile: SourceFile, start: number, end: number): SuggestedFix { + public getFixes(errorCode: string, sourceFile: SourceFile, start: number, end: number): CodeFix { const fix = quickFixes[errorCode]; if (!fix || fix.length == 0) { diff --git a/src/services/services.ts b/src/services/services.ts index 18ae5f2ca3cb5..07d65b73c2ae0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -10,7 +10,7 @@ /// /// /// -/// +/// namespace ts { /** The version of the language service API */ @@ -1116,7 +1116,7 @@ namespace ts { isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): SuggestedFix; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeFix[]; getEmitOutput(fileName: string): EmitOutput; @@ -1164,7 +1164,7 @@ namespace ts { newText: string; } - export interface SuggestedFix { + export interface CodeFix { name: string; textChanges: TextChange[]; } @@ -7490,11 +7490,11 @@ namespace ts { return []; } - function getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): SuggestedFix { + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeFix[] { synchronizeHostData(); const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return quickFixProvider.getFixes(errorCodes[0], sourceFile, start, end); + return [quickFixProvider.getFixes(errorCodes[0], sourceFile, start, end)]; } /** @@ -7967,7 +7967,7 @@ namespace ts { getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, isValidBraceCompletionAtPostion, - getCodeFixAtPosition, + getCodeFixesAtPosition, getEmitOutput, getNonBoundSourceFile, getProgram diff --git a/src/services/shims.ts b/src/services/shims.ts index be959bdb4878a..404fa315e76c1 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -228,7 +228,7 @@ namespace ts { */ isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string; - getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): string; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string): string; getEmitOutput(fileName: string): string; } @@ -854,10 +854,13 @@ namespace ts { ); } - public getCodeFixAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): string { + public getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string): string { return this.forwardJSONCall( - `getCodeFixAtPosition( '${fileName}', ${start}, ${end}, '[${errorCodes.join(",")}]')`, - () => this.languageService.getCodeFixAtPosition(fileName, start, end, errorCodes) + `getCodeFixesAtPosition( '${fileName}', ${start}, ${end}, ${errorCodes}')`, + () => { + const localErrors: string[] = JSON.parse(errorCodes); + return this.languageService.getCodeFixesAtPosition(fileName, start, end, localErrors); + } ); } From 7792e180c3b5e28af1ae87d5c80a65bff09aa978 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 16 Jun 2016 15:59:04 -0700 Subject: [PATCH 40/90] Bunch of renames --- .../codeFixProvider.ts} | 20 +++++++++---------- .../{quickfixes => codefixes}/references.ts | 2 +- .../{quickfixes => codefixes}/superFixes.ts | 19 +++++------------- src/services/services.ts | 8 ++++---- 4 files changed, 20 insertions(+), 29 deletions(-) rename src/services/{quickfixes/quickFixProvider.ts => codefixes/codeFixProvider.ts} (58%) rename src/services/{quickfixes => codefixes}/references.ts (62%) rename src/services/{quickfixes => codefixes}/superFixes.ts (81%) diff --git a/src/services/quickfixes/quickFixProvider.ts b/src/services/codefixes/codeFixProvider.ts similarity index 58% rename from src/services/quickfixes/quickFixProvider.ts rename to src/services/codefixes/codeFixProvider.ts index 8321936aef4dd..62c5694d603bf 100644 --- a/src/services/quickfixes/quickFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -1,36 +1,36 @@ /* @internal */ namespace ts { - export interface QuickFix { + export interface CodeAction { name: string; errorCodes: string[]; getFix(sourceFile: SourceFile, start: number, end: number): TextChange[]; } - export namespace quickFix { - var quickFixes: Map = {}; + export namespace codeFix { + var codeActions: Map = {}; - export function registerQuickFix(fix: QuickFix) { + export function registerCodeFix(fix: CodeAction) { fix.errorCodes.forEach(error => { - let fixes = quickFixes[error]; + let fixes = codeActions[error]; if (!fixes) { fixes = []; - quickFixes[error] = fixes; + codeActions[error] = fixes; } fixes.push(fix); }); } - export class QuickFixProvider { + export class CodeFixProvider { public static getSupportedErrorCodes() { - return getKeys(quickFixes); + return getKeys(codeActions); } public getFixes(errorCode: string, sourceFile: SourceFile, start: number, end: number): CodeFix { - const fix = quickFixes[errorCode]; + const fix = codeActions[errorCode]; if (!fix || fix.length == 0) { - throw new Error(`No fixes found for error: '${errorCode}'.`); + throw new Error("No fixes found for error: '${errorCode}'."); } return { name: fix[0].name, textChanges: fix[0].getFix(sourceFile, start, end) }; diff --git a/src/services/quickfixes/references.ts b/src/services/codefixes/references.ts similarity index 62% rename from src/services/quickfixes/references.ts rename to src/services/codefixes/references.ts index a469d9a43fb5b..a9ab7a98b3395 100644 --- a/src/services/quickfixes/references.ts +++ b/src/services/codefixes/references.ts @@ -1,3 +1,3 @@ /// -/// +/// /// diff --git a/src/services/quickfixes/superFixes.ts b/src/services/codefixes/superFixes.ts similarity index 81% rename from src/services/quickfixes/superFixes.ts rename to src/services/codefixes/superFixes.ts index be09590d845bd..4e4a1640beaa7 100644 --- a/src/services/quickfixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -1,13 +1,13 @@ /* @internal */ -namespace ts.quickFix { +namespace ts.codeFix { function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { // First token is the open curly, this is where we want to put the 'super' call. return constructor.body.getFirstToken(sourceFile).getEnd(); } - registerQuickFix({ - name: `Add missing 'super()' call.`, + registerCodeFix({ + name: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), errorCodes: ["TS2377"], getFix: (sourceFile: SourceFile, start: number, end: number) => { const token = getTokenAtPosition(sourceFile, start); @@ -22,7 +22,7 @@ namespace ts.quickFix { } }); - registerQuickFix({ + registerCodeFix({ name: `Make super call the first statement in the constructor.`, errorCodes: ["TS17009"], getFix: (sourceFile: SourceFile, start: number, end: number): TextChange[] => { @@ -36,7 +36,7 @@ namespace ts.quickFix { const superCall = findSuperCall((constructor).body); if (!superCall) { - throw new Error(`Failed to find super call.`); + throw new Error("Failed to find super call."); } const newPosition = getOpenBraceEnd(constructor, sourceFile); @@ -61,13 +61,4 @@ namespace ts.quickFix { } } }); - - registerQuickFix({ - name: `Add Type to static member access.`, - errorCodes: ["TS2662"], - getFix: (sourceFile: SourceFile, start: number, end: number): TextChange[] => { - - throw new Error("Not implemented"); - } - }); } \ No newline at end of file diff --git a/src/services/services.ts b/src/services/services.ts index 07d65b73c2ae0..a29fb8ca20a56 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -10,7 +10,7 @@ /// /// /// -/// +/// namespace ts { /** The version of the language service API */ @@ -1762,7 +1762,7 @@ namespace ts { } export function getSupportedCodeFixes() { - return quickFix.QuickFixProvider.getSupportedErrorCodes(); + return codeFix.CodeFixProvider.getSupportedErrorCodes(); } // Cache host information about script Should be refreshed @@ -2837,7 +2837,7 @@ namespace ts { documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { const syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); - const quickFixProvider: quickFix.QuickFixProvider = new quickFix.QuickFixProvider(); + const codeFixProvider: codeFix.CodeFixProvider = new codeFix.CodeFixProvider(); let ruleProvider: formatting.RulesProvider; let program: Program; let lastProjectVersion: string; @@ -7494,7 +7494,7 @@ namespace ts { synchronizeHostData(); const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return [quickFixProvider.getFixes(errorCodes[0], sourceFile, start, end)]; + return [codeFixProvider.getFixes(errorCodes[0], sourceFile, start, end)]; } /** From e57e628eb680c51d29a0198edc27e4cd1657d58d Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 16 Jun 2016 17:32:20 -0700 Subject: [PATCH 41/90] Make provider work with multiple fixes --- src/compiler/diagnosticMessages.json | 4 ++++ src/compiler/types.ts | 1 + src/services/codefixes/codeFixProvider.ts | 18 +++++++++++++----- src/services/codefixes/superFixes.ts | 4 ++-- src/services/services.ts | 13 +++++++++++-- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 899b4292f04d1..8ea7e51948cc5 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2959,5 +2959,9 @@ "Unknown typing option '{0}'.": { "category": "Error", "code": 17010 + }, + "Add missing 'super()' call.": { + "category": "CodeFix", + "code": 90001 } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 777141b45fbd6..aebbc720271a4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2430,6 +2430,7 @@ namespace ts { Warning, Error, Message, + CodeFix, } export enum ModuleResolutionKind { diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 62c5694d603bf..e05dfdecbc619 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -3,7 +3,7 @@ namespace ts { export interface CodeAction { name: string; errorCodes: string[]; - getFix(sourceFile: SourceFile, start: number, end: number): TextChange[]; + getTextChanges(sourceFile: SourceFile, start: number, end: number): TextChange[]; } export namespace codeFix { @@ -26,14 +26,22 @@ namespace ts { return getKeys(codeActions); } - public getFixes(errorCode: string, sourceFile: SourceFile, start: number, end: number): CodeFix { - const fix = codeActions[errorCode]; + public getFixes(errorCode: string, sourceFile: SourceFile, start: number, end: number): CodeFix[] { + const actions = codeActions[errorCode]; + const fixes: CodeFix[] = []; - if (!fix || fix.length == 0) { + if (!actions || actions.length == 0) { throw new Error("No fixes found for error: '${errorCode}'."); } - return { name: fix[0].name, textChanges: fix[0].getFix(sourceFile, start, end) }; + actions.forEach(a => { + const textChanges = a.getTextChanges(sourceFile, start, end); + if (textChanges && textChanges.length > 0) { + fixes.push({ name: a.name, textChanges: textChanges }); + } + }); + + return fixes; } } } diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 4e4a1640beaa7..117b17838d50f 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -9,7 +9,7 @@ namespace ts.codeFix { registerCodeFix({ name: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), errorCodes: ["TS2377"], - getFix: (sourceFile: SourceFile, start: number, end: number) => { + getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { const token = getTokenAtPosition(sourceFile, start); if (token.kind !== SyntaxKind.ConstructorKeyword) { // wait why are we not a on a constructor? @@ -25,7 +25,7 @@ namespace ts.codeFix { registerCodeFix({ name: `Make super call the first statement in the constructor.`, errorCodes: ["TS17009"], - getFix: (sourceFile: SourceFile, start: number, end: number): TextChange[] => { + getTextChanges: (sourceFile: SourceFile, start: number, end: number): TextChange[] => { const token = getTokenAtPosition(sourceFile, start); const constructor = getContainingFunction(token); diff --git a/src/services/services.ts b/src/services/services.ts index a29fb8ca20a56..e9613dd1afd8a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -7492,9 +7492,18 @@ namespace ts { function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeFix[] { synchronizeHostData(); - const sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); + const sourceFile = getValidSourceFile(fileName); + + let fixes: CodeFix[] = []; + + errorCodes.forEach(error => { + const fix = codeFixProvider.getFixes(error, sourceFile, start, end); + if (fix) { + fixes = fixes.concat(fix); + } + }); - return [codeFixProvider.getFixes(errorCodes[0], sourceFile, start, end)]; + return fixes; } /** From 32e578761879ca7c0b733a76709801117b35f72c Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 17 Jun 2016 10:30:24 -0700 Subject: [PATCH 42/90] Adding code for handling classes implemented by other classes --- src/services/quickfixes/interfaceFixes.ts | 26 +++++++++++++++++++ .../fourslash/unImplementedInterface29.ts | 12 +++++++++ .../fourslash/unImplementedInterface30.ts | 16 ++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/cases/fourslash/unImplementedInterface29.ts create mode 100644 tests/cases/fourslash/unImplementedInterface30.ts diff --git a/src/services/quickfixes/interfaceFixes.ts b/src/services/quickfixes/interfaceFixes.ts index b723dca6dd975..2bfd378df19e7 100644 --- a/src/services/quickfixes/interfaceFixes.ts +++ b/src/services/quickfixes/interfaceFixes.ts @@ -99,6 +99,32 @@ namespace ts.quickFix { changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); trackingAddedMembers.push(interfaceMethod.name.getText()); } + } else if (interfaceMembers[j].kind === SyntaxKind.MethodDeclaration) { + let classMethod = interfaceMembers[j]; + if (trackingAddedMembers.indexOf(classMethod.name.getText())) { + let methodName = classMethod.name.getText(); + let parameterArray: Array = []; + for (let k = 0; classMethod.parameters && k < classMethod.parameters.length; k++) { + parameterArray.push(classMethod.parameters[k].getText()); + } + let methodBody = "throw new Error('Method not Implemented');"; + + let methodText: string = methodName; + methodText += "("; + for (let k = 0; k < parameterArray.length;k++) { + methodText += parameterArray[k]; + if(k !== parameterArray.length -1) { + methodText += ","; + } + } + methodText += ")"; + methodText += "{sys.newLine "; + methodText += methodBody; + methodText += "sys.newLine"; + methodText += "} sys.newLine"; + changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); + trackingAddedMembers.push(classMethod.name.getText()); + } } } } diff --git a/tests/cases/fourslash/unImplementedInterface29.ts b/tests/cases/fourslash/unImplementedInterface29.ts new file mode 100644 index 0000000000000..f7b1b7381441d --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface29.ts @@ -0,0 +1,12 @@ +/// + +//// abstract class C1 { +//// f1(){} +//// } +//// +//// class C2 implements C1 {/*0*//*1*/ +//// f2(){} +//// } + + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface30.ts b/tests/cases/fourslash/unImplementedInterface30.ts new file mode 100644 index 0000000000000..902554d3b15c5 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface30.ts @@ -0,0 +1,16 @@ +/// + +//// abstract class C1 { +//// f1(){} +//// } +//// +//// abstract class C2 extends C1 { +//// +//// } +//// +//// class C3 implements C2 {/*0*//*1*/ +//// f2(){} +//// } + + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); From 394a4d1be7596ac513a9e23395152bb119c8c5b6 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 17 Jun 2016 13:41:14 -0700 Subject: [PATCH 43/90] Optimizing code Part I --- src/services/quickfixes/interfaceFixes.ts | 56 ++++++++++++++++--- .../fourslash/unImplementedInterface29.ts | 2 +- .../fourslash/unImplementedInterface30.ts | 2 +- .../fourslash/unImplementedInterface5.ts | 2 +- .../fourslash/unImplementedInterface6.ts | 2 +- .../fourslash/unImplementedInterface7.ts | 2 +- .../fourslash/unImplementedInterface8.ts | 2 +- 7 files changed, 55 insertions(+), 13 deletions(-) diff --git a/src/services/quickfixes/interfaceFixes.ts b/src/services/quickfixes/interfaceFixes.ts index 2bfd378df19e7..b794f66135e98 100644 --- a/src/services/quickfixes/interfaceFixes.ts +++ b/src/services/quickfixes/interfaceFixes.ts @@ -86,15 +86,41 @@ namespace ts.quickFix { } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature) { let interfaceMethod = interfaceMembers[j]; if (trackingAddedMembers.indexOf(interfaceMethod.name.getText())) { + let methodName = interfaceMethod.name.getText(); + let typeParameterArray: Array = []; + for (let k = 0; interfaceMethod.typeParameters && k < interfaceMethod.typeParameters.length; k++) { + typeParameterArray.push(interfaceMethod.typeParameters[k].getText()); + } + let parameterArray: Array = []; + for (let k = 0; interfaceMethod.parameters && k < interfaceMethod.parameters.length; k++) { + parameterArray.push(interfaceMethod.parameters[k].getText()); + } let methodBody = "throw new Error('Method not Implemented');"; - let methodText: string = interfaceMethod.getText(); - if (methodText.match(/;$/)) { - methodText = methodText.substr(0, methodText.length - 1); + let methodText: string = methodName; + if (typeParameterArray.length > 0) { + methodText += "<" } - - methodText = methodText.concat("{sys.newLine "); - methodText = methodText.concat(methodBody, "sys.newLine"); + for (let k = 0; k < typeParameterArray.length; k++) { + methodText += typeParameterArray[k]; + if(k !== typeParameterArray.length - 1) { + methodText += ","; + } + } + if (typeParameterArray.length > 0) { + methodText += ">" + } + methodText += "("; + for (let k = 0; k < parameterArray.length; k++) { + methodText += parameterArray[k]; + if (k !== parameterArray.length - 1) { + methodText += ","; + } + } + methodText += ")"; + methodText += "{sys.newLine "; + methodText += methodBody; + methodText += "sys.newLine"; methodText = reference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); trackingAddedMembers.push(interfaceMethod.name.getText()); @@ -103,6 +129,10 @@ namespace ts.quickFix { let classMethod = interfaceMembers[j]; if (trackingAddedMembers.indexOf(classMethod.name.getText())) { let methodName = classMethod.name.getText(); + let typeParameterArray: Array = []; + for (let k = 0; classMethod.typeParameters && k < classMethod.typeParameters.length; k++) { + typeParameterArray.push(classMethod.typeParameters[k].getText()); + } let parameterArray: Array = []; for (let k = 0; classMethod.parameters && k < classMethod.parameters.length; k++) { parameterArray.push(classMethod.parameters[k].getText()); @@ -110,6 +140,18 @@ namespace ts.quickFix { let methodBody = "throw new Error('Method not Implemented');"; let methodText: string = methodName; + if (typeParameterArray.length > 0) { + methodText += "<" + } + for (let k = 0; k < typeParameterArray.length; k++) { + methodText += typeParameterArray[k]; + if (k !== typeParameterArray.length - 1) { + methodText += ","; + } + } + if (typeParameterArray.length > 0) { + methodText += ">" + } methodText += "("; for (let k = 0; k < parameterArray.length;k++) { methodText += parameterArray[k]; @@ -121,7 +163,7 @@ namespace ts.quickFix { methodText += "{sys.newLine "; methodText += methodBody; methodText += "sys.newLine"; - methodText += "} sys.newLine"; + methodText = reference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); trackingAddedMembers.push(classMethod.name.getText()); } diff --git a/tests/cases/fourslash/unImplementedInterface29.ts b/tests/cases/fourslash/unImplementedInterface29.ts index f7b1b7381441d..b23ef932c58a9 100644 --- a/tests/cases/fourslash/unImplementedInterface29.ts +++ b/tests/cases/fourslash/unImplementedInterface29.ts @@ -9,4 +9,4 @@ //// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface30.ts b/tests/cases/fourslash/unImplementedInterface30.ts index 902554d3b15c5..84f96bac3ee8b 100644 --- a/tests/cases/fourslash/unImplementedInterface30.ts +++ b/tests/cases/fourslash/unImplementedInterface30.ts @@ -13,4 +13,4 @@ //// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface5.ts b/tests/cases/fourslash/unImplementedInterface5.ts index dc487b68d9a1b..180e6346e6ae5 100644 --- a/tests/cases/fourslash/unImplementedInterface5.ts +++ b/tests/cases/fourslash/unImplementedInterface5.ts @@ -12,4 +12,4 @@ //// class C1 implements N1.I1 {/*0*//*1*/ //// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number, y: string){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number,y: string){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface6.ts b/tests/cases/fourslash/unImplementedInterface6.ts index fd7e059f813de..1b41d3b2e440a 100644 --- a/tests/cases/fourslash/unImplementedInterface6.ts +++ b/tests/cases/fourslash/unImplementedInterface6.ts @@ -9,4 +9,4 @@ //// class C1 implements I1 {/*0*//*1*/ //// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number, y: T){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number,y: T){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface7.ts b/tests/cases/fourslash/unImplementedInterface7.ts index 77f3b96d1c661..bec4f5531dec9 100644 --- a/tests/cases/fourslash/unImplementedInterface7.ts +++ b/tests/cases/fourslash/unImplementedInterface7.ts @@ -9,4 +9,4 @@ //// class C1 implements I1 {/*0*//*1*/ //// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number, y: C2){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number,y: C2){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface8.ts b/tests/cases/fourslash/unImplementedInterface8.ts index 902309f0fd82a..970c968ef1875 100644 --- a/tests/cases/fourslash/unImplementedInterface8.ts +++ b/tests/cases/fourslash/unImplementedInterface8.ts @@ -9,4 +9,4 @@ //// class C1 implements I1 {/*0*//*1*/ //// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number, y: C2){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number,y: C2){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); From dca1263bf7c31b270520cfa77ba8e78c4baf7d4b Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 17 Jun 2016 13:52:05 -0700 Subject: [PATCH 44/90] Optimizing code Part II --- src/services/quickfixes/interfaceFixes.ts | 128 ++++++++-------------- 1 file changed, 45 insertions(+), 83 deletions(-) diff --git a/src/services/quickfixes/interfaceFixes.ts b/src/services/quickfixes/interfaceFixes.ts index b794f66135e98..5a716b80beca3 100644 --- a/src/services/quickfixes/interfaceFixes.ts +++ b/src/services/quickfixes/interfaceFixes.ts @@ -83,90 +83,9 @@ namespace ts.quickFix { changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); trackingAddedMembers.push(interfaceProperty.name.getText()); } - } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature) { + } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature || interfaceMembers[j].kind === SyntaxKind.MethodDeclaration) { let interfaceMethod = interfaceMembers[j]; - if (trackingAddedMembers.indexOf(interfaceMethod.name.getText())) { - let methodName = interfaceMethod.name.getText(); - let typeParameterArray: Array = []; - for (let k = 0; interfaceMethod.typeParameters && k < interfaceMethod.typeParameters.length; k++) { - typeParameterArray.push(interfaceMethod.typeParameters[k].getText()); - } - let parameterArray: Array = []; - for (let k = 0; interfaceMethod.parameters && k < interfaceMethod.parameters.length; k++) { - parameterArray.push(interfaceMethod.parameters[k].getText()); - } - let methodBody = "throw new Error('Method not Implemented');"; - - let methodText: string = methodName; - if (typeParameterArray.length > 0) { - methodText += "<" - } - for (let k = 0; k < typeParameterArray.length; k++) { - methodText += typeParameterArray[k]; - if(k !== typeParameterArray.length - 1) { - methodText += ","; - } - } - if (typeParameterArray.length > 0) { - methodText += ">" - } - methodText += "("; - for (let k = 0; k < parameterArray.length; k++) { - methodText += parameterArray[k]; - if (k !== parameterArray.length - 1) { - methodText += ","; - } - } - methodText += ")"; - methodText += "{sys.newLine "; - methodText += methodBody; - methodText += "sys.newLine"; - methodText = reference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); - changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); - trackingAddedMembers.push(interfaceMethod.name.getText()); - } - } else if (interfaceMembers[j].kind === SyntaxKind.MethodDeclaration) { - let classMethod = interfaceMembers[j]; - if (trackingAddedMembers.indexOf(classMethod.name.getText())) { - let methodName = classMethod.name.getText(); - let typeParameterArray: Array = []; - for (let k = 0; classMethod.typeParameters && k < classMethod.typeParameters.length; k++) { - typeParameterArray.push(classMethod.typeParameters[k].getText()); - } - let parameterArray: Array = []; - for (let k = 0; classMethod.parameters && k < classMethod.parameters.length; k++) { - parameterArray.push(classMethod.parameters[k].getText()); - } - let methodBody = "throw new Error('Method not Implemented');"; - - let methodText: string = methodName; - if (typeParameterArray.length > 0) { - methodText += "<" - } - for (let k = 0; k < typeParameterArray.length; k++) { - methodText += typeParameterArray[k]; - if (k !== typeParameterArray.length - 1) { - methodText += ","; - } - } - if (typeParameterArray.length > 0) { - methodText += ">" - } - methodText += "("; - for (let k = 0; k < parameterArray.length;k++) { - methodText += parameterArray[k]; - if(k !== parameterArray.length -1) { - methodText += ","; - } - } - methodText += ")"; - methodText += "{sys.newLine "; - methodText += methodBody; - methodText += "sys.newLine"; - methodText = reference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); - changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); - trackingAddedMembers.push(classMethod.name.getText()); - } + handleMethods(interfaceMethod, startPos, reference, trackingAddedMembers, changesArray); } } } @@ -240,4 +159,47 @@ namespace ts.quickFix { } return "null"; } + + function handleMethods(interfaceMethod: MethodSignature, startPos: number, reference: boolean, trackingAddedMembers: Array, changesArray: { newText: string; span: { start: number, length: number } }[]) { + if (trackingAddedMembers.indexOf(interfaceMethod.name.getText())) { + let methodName = interfaceMethod.name.getText(); + let typeParameterArray: Array = []; + for (let k = 0; interfaceMethod.typeParameters && k < interfaceMethod.typeParameters.length; k++) { + typeParameterArray.push(interfaceMethod.typeParameters[k].getText()); + } + let parameterArray: Array = []; + for (let k = 0; interfaceMethod.parameters && k < interfaceMethod.parameters.length; k++) { + parameterArray.push(interfaceMethod.parameters[k].getText()); + } + let methodBody = "throw new Error('Method not Implemented');"; + + let methodText: string = methodName; + if (typeParameterArray.length > 0) { + methodText += "<" + } + for (let k = 0; k < typeParameterArray.length; k++) { + methodText += typeParameterArray[k]; + if (k !== typeParameterArray.length - 1) { + methodText += ","; + } + } + if (typeParameterArray.length > 0) { + methodText += ">" + } + methodText += "("; + for (let k = 0; k < parameterArray.length; k++) { + methodText += parameterArray[k]; + if (k !== parameterArray.length - 1) { + methodText += ","; + } + } + methodText += ")"; + methodText += "{sys.newLine "; + methodText += methodBody; + methodText += "sys.newLine"; + methodText = reference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); + changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); + trackingAddedMembers.push(interfaceMethod.name.getText()); + } + } } From 03e203779de324ff6c7758d7cddc043c0d8b2847 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 17 Jun 2016 17:32:14 -0700 Subject: [PATCH 45/90] Verify the code changes result in the expected new code. --- src/harness/fourslash.ts | 35 ++++++++++++++++++++++-------- tests/cases/fourslash/fourslash.ts | 2 +- tests/cases/fourslash/superFix1.ts | 9 +++++++- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 9badcfee897c1..8d9e734127c3d 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -383,7 +383,7 @@ namespace FourSlash { if (exists !== negative) { this.printErrorLog(negative, this.getAllDiagnostics()); - throw new Error("Failure between markers: " + startMarkerName + ", " + endMarkerName); + throw new Error(`Failure between markers: '${startMarkerName}', '${endMarkerName}'`); } } @@ -1512,6 +1512,10 @@ namespace FourSlash { } } + private removeWhitespace(text: string): string { + return text.replace(/[ \r\n\t]/g, ""); + } + public goToBOF() { this.goToPosition(0); } @@ -1816,21 +1820,34 @@ namespace FourSlash { } } - public verifyCodeFixAtPosition(expectedChange: { span: ts.TextSpan, newText: string }) { - const diagnostics = this.getDiagnostics(this.activeFile.fileName); + public verifyCodeFixAtPosition(expectedText: string) { + const fileName = this.activeFile.fileName; + const diagnostics = this.getDiagnostics(fileName); if (diagnostics.length === 0) { - this.raiseError("Errors expected"); + this.raiseError("Errors expected."); } // we expect a single error per file const errorCode = diagnostics[0].code; const position = diagnostics[0].start; - const actual = this.languageService.getCodeFixAtPosition(this.activeFile.fileName, position, position, [`TS${errorCode}`]); + const actual = this.languageService.getCodeFixesAtPosition(this.activeFile.fileName, position, position, [`TS${errorCode}`]); + + if (!actual || actual.length == 0) { + this.raiseError("No codefixes returned."); + } + + if (actual.length > 1) { + this.raiseError("More than 1 codefix returned."); + } + + this.applyEdits(fileName, actual[0].textChanges, /*isFormattingEdit*/ false); + const actualText = this.getFileContent(fileName); - if (actual.textChanges[0].newText !== expectedChange.newText) { - this.raiseError(`Not the expected text change.`); + // We expect the editor to do the final formatting, so we can strip the compare ignoring whitespace + if (this.removeWhitespace(expectedText) !== this.removeWhitespace(actualText)) { + this.raiseError(`Expected insertion: '${expectedText}', actual insertion '${actualText}'.`) } } @@ -3046,8 +3063,8 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } - public codeFixAtPosition(expectedChange: { span: ts.TextSpan, newText: string }) { - this.state.verifyCodeFixAtPosition(expectedChange); + public codeFixAtPosition(expectedText: string) { + this.state.verifyCodeFixAtPosition(expectedText); } public getScriptLexicalStructureListCount(count: number) { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 16211609671a4..56e78f6f5434a 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -174,7 +174,7 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; - codeFixAtPosition(expectedChange: { span: TextSpan, newText: string }); + codeFixAtPosition(expectedText: string); getScriptLexicalStructureListCount(count: number): void; getScriptLexicalStructureListContains(name: string, kind: string, fileName?: string, parentName?: string, isAdditionalSpan?: boolean, markerPosition?: number): void; diff --git a/tests/cases/fourslash/superFix1.ts b/tests/cases/fourslash/superFix1.ts index d5bd278ab3315..bfde1c0a57d31 100644 --- a/tests/cases/fourslash/superFix1.ts +++ b/tests/cases/fourslash/superFix1.ts @@ -7,4 +7,11 @@ //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "super();" }); +verify.codeFixAtPosition(` +class Base { +} +class C extends Base { + constructor() { + super(); + } +}`); From 8f9d4ae3ecccb658d8ba9d2249b6591fff345a82 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 20 Jun 2016 11:33:42 -0700 Subject: [PATCH 46/90] Response to PR comments --- src/compiler/checker.ts | 98 +++++++++---------- src/compiler/diagnosticMessages.json | 10 +- .../unusedClassesinNamespace1.errors.txt | 4 +- .../unusedClassesinNamespace2.errors.txt | 4 +- .../unusedClassesinNamespace4.errors.txt | 4 +- .../unusedClassesinNamespace5.errors.txt | 4 +- .../unusedFunctionsinNamespaces1.errors.txt | 4 +- .../unusedFunctionsinNamespaces2.errors.txt | 4 +- .../unusedFunctionsinNamespaces3.errors.txt | 8 +- .../unusedFunctionsinNamespaces4.errors.txt | 4 +- .../unusedFunctionsinNamespaces5.errors.txt | 8 +- .../unusedFunctionsinNamespaces6.errors.txt | 4 +- .../reference/unusedGetterInClass.js | 23 +++++ .../reference/unusedGetterInClass.symbols | 17 ++++ .../reference/unusedGetterInClass.types | 17 ++++ .../unusedIdentifiersConsolidated1.errors.txt | 64 ++++++------ .../unusedInterfaceinNamespace1.errors.txt | 4 +- .../unusedInterfaceinNamespace2.errors.txt | 4 +- .../unusedInterfaceinNamespace3.errors.txt | 4 +- .../unusedLocalsInMethod1.errors.txt | 4 +- .../unusedLocalsInMethod2.errors.txt | 4 +- .../unusedLocalsInMethod3.errors.txt | 4 +- ...ationWithinFunctionDeclaration1.errors.txt | 20 ++-- ...ationWithinFunctionDeclaration2.errors.txt | 28 +++--- ...rationWithinFunctionExpression1.errors.txt | 20 ++-- ...rationWithinFunctionExpression2.errors.txt | 28 +++--- ...ssionWithinFunctionDeclaration1.errors.txt | 20 ++-- ...ssionWithinFunctionDeclaration2.errors.txt | 28 +++--- ...essionWithinFunctionExpression1.errors.txt | 20 ++-- ...essionWithinFunctionExpression2.errors.txt | 28 +++--- .../unusedLocalsinConstructor1.errors.txt | 4 +- .../unusedLocalsinConstructor2.errors.txt | 4 +- .../reference/unusedMethodsInInterface.js | 8 ++ .../unusedMethodsInInterface.symbols | 13 +++ .../reference/unusedMethodsInInterface.types | 13 +++ ...dMultipleParameter1InContructor.errors.txt | 8 +- ...eParameter1InFunctionExpression.errors.txt | 8 +- ...dMultipleParameter2InContructor.errors.txt | 12 +-- ...eParameter2InFunctionExpression.errors.txt | 12 +-- ...arameters1InFunctionDeclaration.errors.txt | 8 +- ...eParameters1InMethodDeclaration.errors.txt | 8 +- ...arameters2InFunctionDeclaration.errors.txt | 12 +-- ...eParameters2InMethodDeclaration.errors.txt | 12 +-- .../reference/unusedParameterUsedInTypeOf.js | 10 ++ .../unusedParameterUsedInTypeOf.symbols | 11 +++ .../unusedParameterUsedInTypeOf.types | 12 +++ .../unusedParametersinConstructor1.errors.txt | 4 +- .../unusedParametersinConstructor2.errors.txt | 4 +- .../unusedParametersinConstructor3.errors.txt | 8 +- .../unusedPrivateMethodInClass1.errors.txt | 4 +- .../unusedPrivateMethodInClass2.errors.txt | 8 +- .../unusedPrivateMethodInClass3.errors.txt | 8 +- .../unusedPrivateMethodInClass4.errors.txt | 4 +- .../unusedPrivateVariableInClass1.errors.txt | 4 +- .../unusedPrivateVariableInClass2.errors.txt | 8 +- .../unusedPrivateVariableInClass3.errors.txt | 8 +- .../unusedPrivateVariableInClass4.errors.txt | 4 +- .../unusedPrivateVariableInClass5.errors.txt | 4 +- .../reference/unusedSetterInClass.js | 23 +++++ .../reference/unusedSetterInClass.symbols | 19 ++++ .../reference/unusedSetterInClass.types | 20 ++++ ...usedSingleParameterInContructor.errors.txt | 8 +- ...eParameterInFunctionDeclaration.errors.txt | 8 +- ...leParameterInFunctionExpression.errors.txt | 8 +- ...gleParameterInMethodDeclaration.errors.txt | 8 +- .../unusedTypeParameters1.errors.txt | 4 +- .../unusedTypeParameters2.errors.txt | 4 +- .../unusedTypeParameters3.errors.txt | 8 +- .../unusedVariablesinBlocks1.errors.txt | 14 +++ .../reference/unusedVariablesinBlocks1.js | 18 ++++ .../unusedVariablesinBlocks2.errors.txt | 14 +++ .../reference/unusedVariablesinBlocks2.js | 18 ++++ .../unusedVariablesinForLoop.errors.txt | 12 +++ .../reference/unusedVariablesinForLoop.js | 13 +++ .../unusedVariablesinForLoop2.errors.txt | 12 +++ .../reference/unusedVariablesinForLoop2.js | 13 +++ .../unusedVariablesinForLoop3.errors.txt | 12 +++ .../reference/unusedVariablesinForLoop3.js | 14 +++ .../unusedVariablesinForLoop4.errors.txt | 13 +++ .../reference/unusedVariablesinForLoop4.js | 17 ++++ .../unusedVariablesinNamespaces1.errors.txt | 4 +- .../unusedVariablesinNamespaces2.errors.txt | 4 +- .../unusedVariablesinNamespaces3.errors.txt | 4 +- tests/cases/compiler/unusedGetterInClass.ts | 11 +++ .../compiler/unusedMethodsInInterface.ts | 7 ++ .../compiler/unusedParameterUsedInTypeOf.ts | 7 ++ tests/cases/compiler/unusedSetterInClass.ts | 11 +++ .../compiler/unusedVariablesinBlocks1.ts | 10 ++ .../compiler/unusedVariablesinBlocks2.ts | 10 ++ .../compiler/unusedVariablesinForLoop.ts | 8 ++ .../compiler/unusedVariablesinForLoop2.ts | 8 ++ .../compiler/unusedVariablesinForLoop3.ts | 8 ++ .../compiler/unusedVariablesinForLoop4.ts | 9 ++ 93 files changed, 768 insertions(+), 329 deletions(-) create mode 100644 tests/baselines/reference/unusedGetterInClass.js create mode 100644 tests/baselines/reference/unusedGetterInClass.symbols create mode 100644 tests/baselines/reference/unusedGetterInClass.types create mode 100644 tests/baselines/reference/unusedMethodsInInterface.js create mode 100644 tests/baselines/reference/unusedMethodsInInterface.symbols create mode 100644 tests/baselines/reference/unusedMethodsInInterface.types create mode 100644 tests/baselines/reference/unusedParameterUsedInTypeOf.js create mode 100644 tests/baselines/reference/unusedParameterUsedInTypeOf.symbols create mode 100644 tests/baselines/reference/unusedParameterUsedInTypeOf.types create mode 100644 tests/baselines/reference/unusedSetterInClass.js create mode 100644 tests/baselines/reference/unusedSetterInClass.symbols create mode 100644 tests/baselines/reference/unusedSetterInClass.types create mode 100644 tests/baselines/reference/unusedVariablesinBlocks1.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinBlocks1.js create mode 100644 tests/baselines/reference/unusedVariablesinBlocks2.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinBlocks2.js create mode 100644 tests/baselines/reference/unusedVariablesinForLoop.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinForLoop.js create mode 100644 tests/baselines/reference/unusedVariablesinForLoop2.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinForLoop2.js create mode 100644 tests/baselines/reference/unusedVariablesinForLoop3.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinForLoop3.js create mode 100644 tests/baselines/reference/unusedVariablesinForLoop4.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinForLoop4.js create mode 100644 tests/cases/compiler/unusedGetterInClass.ts create mode 100644 tests/cases/compiler/unusedMethodsInInterface.ts create mode 100644 tests/cases/compiler/unusedParameterUsedInTypeOf.ts create mode 100644 tests/cases/compiler/unusedSetterInClass.ts create mode 100644 tests/cases/compiler/unusedVariablesinBlocks1.ts create mode 100644 tests/cases/compiler/unusedVariablesinBlocks2.ts create mode 100644 tests/cases/compiler/unusedVariablesinForLoop.ts create mode 100644 tests/cases/compiler/unusedVariablesinForLoop2.ts create mode 100644 tests/cases/compiler/unusedVariablesinForLoop3.ts create mode 100644 tests/cases/compiler/unusedVariablesinForLoop4.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 69d0ba6d7abf3..65e43646dedb4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8157,7 +8157,7 @@ namespace ts { } } - function updateReferencesForInterfaceImplementations(node: InterfaceDeclaration): void { + function updateReferencesForInterfaceHeritiageClauseTargets(node: InterfaceDeclaration): void { const extendedTypeNode = getClassExtendsHeritageClauseElement(node); if (extendedTypeNode) { const t = getTypeFromTypeNode(extendedTypeNode); @@ -14276,35 +14276,41 @@ namespace ts { } } - function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { + function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block): void { checkUnusedIdentifiers(node); checkUnusedParameters(node); } - function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { + function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { - if (!node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { - if (node.locals[key].valueDeclaration.kind !== SyntaxKind.Parameter) { - error(node.locals[key].valueDeclaration, Diagnostics.Variable_0_has_never_been_used, key); + if (hasProperty(node.locals, key)) { + const local = node.locals[key]; + if (!local.hasReference && local.valueDeclaration && local.valueDeclaration.kind) { + if (local.valueDeclaration.kind !== SyntaxKind.Parameter) { + error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); + } } } } } } - function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction): void { - if (compilerOptions.noUnusedParameters && !isInAmbientContext(node)) { + function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block): void { + if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && compilerOptions.noUnusedParameters && !isInAmbientContext(node)) { for (const key in node.locals) { - if (hasProperty(node.locals, key) && !node.locals[key].hasReference && node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind) { - if (node.locals[key].valueDeclaration.kind === SyntaxKind.Parameter && node.parent.kind !== SyntaxKind.InterfaceDeclaration) { - if (node.locals[key].valueDeclaration.modifiers) { - if (checkModifiersForPrivateAccess(node.locals[key].valueDeclaration.modifiers)) { - error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); + if (hasProperty(node.locals, key)) { + const local = node.locals[key]; + if (!local.hasReference && local.valueDeclaration && local.valueDeclaration.kind) { + if (local.valueDeclaration.kind === SyntaxKind.Parameter) { + if (local.valueDeclaration.modifiers) { + if (getCombinedNodeFlags(local.valueDeclaration) & NodeFlags.Private) { + error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); + } + } + else { + error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); } - } - else { - error(node.locals[key].valueDeclaration, Diagnostics.Parameter_0_has_never_been_used, key); } } } @@ -14315,12 +14321,15 @@ namespace ts { function checkUnusedModulePrivates(node: ModuleDeclaration): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { - if (hasProperty(node.locals, key) && !node.locals[key].hasReference && !node.locals[key].exportSymbol) { - if ((node.locals[key].valueDeclaration && node.locals[key].valueDeclaration.kind)) { - error(node.locals[key].valueDeclaration, Diagnostics.Variable_0_has_never_been_used, key); - } - else if (node.locals[key].declarations && node.locals[key].declarations[0].kind === SyntaxKind.InterfaceDeclaration) { - error(node.locals[key].declarations[0], Diagnostics.Variable_0_has_never_been_used, key); + if (hasProperty(node.locals, key)) { + const local = node.locals[key]; + if (!local.hasReference && !local.exportSymbol) { + if ((local.valueDeclaration && local.valueDeclaration.kind)) { + error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); + } + else if (local.declarations && local.declarations[0].kind === SyntaxKind.InterfaceDeclaration) { + error(local.declarations[0], Diagnostics._0_is_declared_but_never_used, key); + } } } } @@ -14329,42 +14338,28 @@ namespace ts { function checkUnusedPrivates(node: ClassDeclaration): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { - for (let i = 0; node.members && i < node.members.length; i++) { - switch (node.members[i].kind) { - case SyntaxKind.MethodDeclaration: - case SyntaxKind.PropertyDeclaration: - if (isPrivateClassElement(node.members[i]) && !node.members[i].symbol.hasReference) { - error(node.members[i], Diagnostics.Variable_0_has_never_been_used, node.members[i].symbol.name); + if (node.members) { + for (const member of node.members) { + if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) { + if (isPrivateClassElement(member) && !member.symbol.hasReference) { + error(member, Diagnostics._0_is_declared_but_never_used, member.symbol.name); } - break; - default: - break; + } } } - for (let i = 0; node.typeParameters && i < node.typeParameters.length; i++) { - if (!node.typeParameters[i].symbol.hasReference) { - error(node.typeParameters[i], Diagnostics.Variable_0_has_never_been_used, node.typeParameters[i].symbol.name); + if (node.typeParameters) { + for (const typeParameter of node.typeParameters) { + if (!typeParameter.symbol.hasReference) { + error(typeParameter, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); + } } } } } function isPrivateClassElement(node: ClassElement): boolean { - for (let i = 0; node.modifiers && i < node.modifiers.length; i++) { - if (node.modifiers[i].kind === SyntaxKind.PrivateKeyword) - return true; - } - return false; - } - - function checkModifiersForPrivateAccess(modifiers: ModifiersArray): boolean { - for (let i = 0; i < modifiers.length; i++) { - if (modifiers[i].kind === SyntaxKind.PrivateKeyword) { - return true; - } - } - return false; + return (node.flags & NodeFlags.Private) !== 0; } function checkBlock(node: Block) { @@ -14373,6 +14368,7 @@ namespace ts { checkGrammarStatementInAmbientContext(node); } forEach(node.statements, checkSourceElement); + checkUnusedLocals(node); } function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) { @@ -14877,6 +14873,7 @@ namespace ts { } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInStatement(node: ForInStatement) { @@ -14924,6 +14921,7 @@ namespace ts { } checkSourceElement(node.statement); + checkUnusedIdentifiers(node); } function checkForInOrForOfVariableDeclaration(iterationStatement: ForInStatement | ForOfStatement): void { @@ -15810,7 +15808,7 @@ namespace ts { checkExportsOnMergedDeclarations(node); const symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - updateReferencesForInterfaceImplementations(node); + updateReferencesForInterfaceHeritiageClauseTargets(node); // Only check this symbol once const firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); @@ -16235,7 +16233,7 @@ namespace ts { if (node.body) { checkSourceElement(node.body); checkUnusedModulePrivates(node); - } + } } function checkModuleAugmentationElement(node: Node, isGlobalAugmentation: boolean): void { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 24261782d617c..bd7bc7f1498bc 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2776,21 +2776,17 @@ "category": "Message", "code": 6132 }, - "Variable '{0}' has never been used.": { + "'{0}' is declared but never used.": { "category": "Error", "code": 6133 }, - "Parameter '{0}' has never been used.": { - "category": "Error", - "code": 6134 - }, "Report Errors on Unused Locals.": { "category": "Message", - "code": 6135 + "code": 6134 }, "Report Errors on Unused Parameters.": { "category": "Message", - "code": 6136 + "code": 6135 }, "Variable '{0}' implicitly has an '{1}' type.": { diff --git a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt index dffa3d93a5759..dc5dc397fec38 100644 --- a/tests/baselines/reference/unusedClassesinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): error TS6133: Variable 'c1' has never been used. +tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): error TS6133: 'c1' is declared but never used. ==== tests/cases/compiler/unusedClassesinNamespace1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedClassesinNamespace1.ts(3,11): error TS6133: Variable namespace Validation { class c1 { ~~ -!!! error TS6133: Variable 'c1' has never been used. +!!! error TS6133: 'c1' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt index f8e6573b27c5f..322b2697550e5 100644 --- a/tests/baselines/reference/unusedClassesinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): error TS6133: Variable 'c1' has never been used. +tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): error TS6133: 'c1' is declared but never used. ==== tests/cases/compiler/unusedClassesinNamespace2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedClassesinNamespace2.ts(3,11): error TS6133: Variable namespace Validation { class c1 { ~~ -!!! error TS6133: Variable 'c1' has never been used. +!!! error TS6133: 'c1' is declared but never used. } diff --git a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt index 8f7aad5f0b03e..2fd6e70524ef8 100644 --- a/tests/baselines/reference/unusedClassesinNamespace4.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): error TS6133: Variable 'c3' has never been used. +tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): error TS6133: 'c3' is declared but never used. ==== tests/cases/compiler/unusedClassesinNamespace4.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedClassesinNamespace4.ts(11,11): error TS6133: Variable class c3 extends c1 { ~~ -!!! error TS6133: Variable 'c3' has never been used. +!!! error TS6133: 'c3' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt index d3f491635327f..752036b2d0314 100644 --- a/tests/baselines/reference/unusedClassesinNamespace5.errors.txt +++ b/tests/baselines/reference/unusedClassesinNamespace5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): error TS6133: Variable 'c3' has never been used. +tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): error TS6133: 'c3' is declared but never used. ==== tests/cases/compiler/unusedClassesinNamespace5.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedClassesinNamespace5.ts(11,11): error TS6133: Variable class c3 { ~~ -!!! error TS6133: Variable 'c3' has never been used. +!!! error TS6133: 'c3' is declared but never used. public x: c1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt index a5c859adb7ea8..428eeae8de5f0 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): error TS6133: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): error TS6133: 'function1' is declared but never used. ==== tests/cases/compiler/unusedFunctionsinNamespaces1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedFunctionsinNamespaces1.ts(3,14): error TS6133: Variab namespace Validation { function function1() { ~~~~~~~~~ -!!! error TS6133: Variable 'function1' has never been used. +!!! error TS6133: 'function1' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt index 0bb9df4299d61..2b0b6def37833 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): error TS6133: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): error TS6133: 'function1' is declared but never used. ==== tests/cases/compiler/unusedFunctionsinNamespaces2.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedFunctionsinNamespaces2.ts(3,9): error TS6133: Variabl namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! error TS6133: Variable 'function1' has never been used. +!!! error TS6133: 'function1' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt index 7d4d68968db15..35829175f052e 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,9): error TS6133: Variable 'function1' has never been used. -tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6134: Parameter 'param1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,9): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6133: 'param1' is declared but never used. ==== tests/cases/compiler/unusedFunctionsinNamespaces3.ts (2 errors) ==== @@ -7,8 +7,8 @@ tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6134: Parame namespace Validation { var function1 = function(param1:string) { ~~~~~~~~~ -!!! error TS6133: Variable 'function1' has never been used. +!!! error TS6133: 'function1' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'param1' has never been used. +!!! error TS6133: 'param1' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt index ec1e958a0b05d..72ce63924fd3e 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): error TS6133: Variable 'function1' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): error TS6133: 'function1' is declared but never used. ==== tests/cases/compiler/unusedFunctionsinNamespaces4.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces4.ts(3,9): error TS6133: Variabl namespace Validation { var function1 = function() { ~~~~~~~~~ -!!! error TS6133: Variable 'function1' has never been used. +!!! error TS6133: 'function1' is declared but never used. } export function function2() { diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt index 1e1eb28b40eb0..239680499bdae 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces5.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(10,14): error TS6133: Variable 'function3' has never been used. -tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): error TS6133: Variable 'function4' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(10,14): error TS6133: 'function3' is declared but never used. +tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): error TS6133: 'function4' is declared but never used. ==== tests/cases/compiler/unusedFunctionsinNamespaces5.ts (2 errors) ==== @@ -14,13 +14,13 @@ tests/cases/compiler/unusedFunctionsinNamespaces5.ts(14,14): error TS6133: Varia function function3() { ~~~~~~~~~ -!!! error TS6133: Variable 'function3' has never been used. +!!! error TS6133: 'function3' is declared but never used. function1(); } function function4() { ~~~~~~~~~ -!!! error TS6133: Variable 'function4' has never been used. +!!! error TS6133: 'function4' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt index 60de8e8908d23..f8f0d12dd51ac 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): error TS6133: Variable 'function4' has never been used. +tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): error TS6133: 'function4' is declared but never used. ==== tests/cases/compiler/unusedFunctionsinNamespaces6.ts (1 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces6.ts(14,14): error TS6133: Varia function function4() { ~~~~~~~~~ -!!! error TS6133: Variable 'function4' has never been used. +!!! error TS6133: 'function4' is declared but never used. } diff --git a/tests/baselines/reference/unusedGetterInClass.js b/tests/baselines/reference/unusedGetterInClass.js new file mode 100644 index 0000000000000..0920ace0195ba --- /dev/null +++ b/tests/baselines/reference/unusedGetterInClass.js @@ -0,0 +1,23 @@ +//// [unusedGetterInClass.ts] + +class Employee { + private _fullName: string; + + get fullName(): string { + return this._fullName; + } +} + +//// [unusedGetterInClass.js] +var Employee = (function () { + function Employee() { + } + Object.defineProperty(Employee.prototype, "fullName", { + get: function () { + return this._fullName; + }, + enumerable: true, + configurable: true + }); + return Employee; +}()); diff --git a/tests/baselines/reference/unusedGetterInClass.symbols b/tests/baselines/reference/unusedGetterInClass.symbols new file mode 100644 index 0000000000000..3d19dd41241c7 --- /dev/null +++ b/tests/baselines/reference/unusedGetterInClass.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/unusedGetterInClass.ts === + +class Employee { +>Employee : Symbol(Employee, Decl(unusedGetterInClass.ts, 0, 0)) + + private _fullName: string; +>_fullName : Symbol(Employee._fullName, Decl(unusedGetterInClass.ts, 1, 16)) + + get fullName(): string { +>fullName : Symbol(Employee.fullName, Decl(unusedGetterInClass.ts, 2, 30)) + + return this._fullName; +>this._fullName : Symbol(Employee._fullName, Decl(unusedGetterInClass.ts, 1, 16)) +>this : Symbol(Employee, Decl(unusedGetterInClass.ts, 0, 0)) +>_fullName : Symbol(Employee._fullName, Decl(unusedGetterInClass.ts, 1, 16)) + } +} diff --git a/tests/baselines/reference/unusedGetterInClass.types b/tests/baselines/reference/unusedGetterInClass.types new file mode 100644 index 0000000000000..8ad7479c443d0 --- /dev/null +++ b/tests/baselines/reference/unusedGetterInClass.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/unusedGetterInClass.ts === + +class Employee { +>Employee : Employee + + private _fullName: string; +>_fullName : string + + get fullName(): string { +>fullName : string + + return this._fullName; +>this._fullName : string +>this : this +>_fullName : string + } +} diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt index d16450b6267d2..009603dba36ef 100644 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -1,56 +1,56 @@ -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): error TS6133: Variable 'unusedtypeparameter' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): error TS6133: Variable 'unusedprivatevariable' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): error TS6134: Parameter 'message' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): error TS6133: Variable 'unused2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): error TS6133: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): error TS6133: Variable 'numberRegexp' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): error TS6133: Variable 'unUsedPrivateFunction' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): error TS6133: Variable 'usedLocallyInterface2' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): error TS6133: Variable 'dummy' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): error TS6133: Variable 'unusedInterface' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): error TS6133: Variable 'class3' has never been used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Variable 'interface5' has never been used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): error TS6133: 'unusedtypeparameter' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): error TS6133: 'unusedprivatevariable' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): error TS6133: 'message' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(18,13): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(25,13): error TS6133: 'unUsedPrivateFunction' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(38,11): error TS6133: 'numberRegexp' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(45,17): error TS6133: 'unUsedPrivateFunction' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(58,15): error TS6133: 'usedLocallyInterface2' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(65,11): error TS6133: 'dummy' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(68,15): error TS6133: 'unusedInterface' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(80,11): error TS6133: 'class3' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: 'interface5' is declared but never used. ==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== function greeter(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. } class Dummy { ~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'unusedtypeparameter' has never been used. +!!! error TS6133: 'unusedtypeparameter' is declared but never used. private unusedprivatevariable: string; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'unusedprivatevariable' has never been used. +!!! error TS6133: 'unusedprivatevariable' is declared but never used. private greeting: string; public unusedpublicvariable: string; public typedvariable: usedtypeparameter; constructor(message: string) { ~~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'message' has never been used. +!!! error TS6133: 'message' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. this.greeting = "Dummy Message"; } public greeter(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. this.usedPrivateFunction(); } @@ -59,7 +59,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Va private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'unUsedPrivateFunction' has never been used. +!!! error TS6133: 'unUsedPrivateFunction' is declared but never used. } } @@ -74,7 +74,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Va const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: Variable 'numberRegexp' has never been used. +!!! error TS6133: 'numberRegexp' is declared but never used. export class LettersOnlyValidator implements StringValidator { isAcceptable(s2: string) { @@ -83,7 +83,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Va private unUsedPrivateFunction() { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'unUsedPrivateFunction' has never been used. +!!! error TS6133: 'unUsedPrivateFunction' is declared but never used. } } @@ -98,7 +98,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Va interface usedLocallyInterface2 { ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'usedLocallyInterface2' has never been used. +!!! error TS6133: 'usedLocallyInterface2' is declared but never used. someFunction(s1: string): void; } @@ -107,12 +107,12 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Va class dummy implements usedLocallyInterface { ~~~~~ -!!! error TS6133: Variable 'dummy' has never been used. +!!! error TS6133: 'dummy' is declared but never used. } interface unusedInterface { ~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'unusedInterface' has never been used. +!!! error TS6133: 'unusedInterface' is declared but never used. } } @@ -126,7 +126,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Va class class3 { ~~~~~~ -!!! error TS6133: Variable 'class3' has never been used. +!!! error TS6133: 'class3' is declared but never used. } export class class4 { @@ -148,6 +148,6 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: Va interface interface5 { ~~~~~~~~~~ -!!! error TS6133: Variable 'interface5' has never been used. +!!! error TS6133: 'interface5' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt index be49c3cd2fffe..3fa066e5aae27 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): error TS6133: Variable 'i1' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): error TS6133: 'i1' is declared but never used. ==== tests/cases/compiler/unusedInterfaceinNamespace1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedInterfaceinNamespace1.ts(3,15): error TS6133: Variabl namespace Validation { interface i1 { ~~ -!!! error TS6133: Variable 'i1' has never been used. +!!! error TS6133: 'i1' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt index e2d37845ae49b..0635e7be07b79 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): error TS6133: Variable 'i1' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): error TS6133: 'i1' is declared but never used. ==== tests/cases/compiler/unusedInterfaceinNamespace2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedInterfaceinNamespace2.ts(3,15): error TS6133: Variabl namespace Validation { interface i1 { ~~ -!!! error TS6133: Variable 'i1' has never been used. +!!! error TS6133: 'i1' is declared but never used. } diff --git a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt index 06cbd6ae70566..8aa0e89ae1a14 100644 --- a/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt +++ b/tests/baselines/reference/unusedInterfaceinNamespace3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): error TS6133: Variable 'i3' has never been used. +tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): error TS6133: 'i3' is declared but never used. ==== tests/cases/compiler/unusedInterfaceinNamespace3.ts (1 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/unusedInterfaceinNamespace3.ts(11,15): error TS6133: Variab interface i3 extends i1 { ~~ -!!! error TS6133: Variable 'i3' has never been used. +!!! error TS6133: 'i3' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt index f8b7761877bb9..18141e5acdd6f 100644 --- a/tests/baselines/reference/unusedLocalsInMethod1.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): error TS6133: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): error TS6133: 'x' is declared but never used. ==== tests/cases/compiler/unusedLocalsInMethod1.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unusedLocalsInMethod1.ts(4,13): error TS6133: Variable 'x' public function1() { var x = 10; ~ -!!! error TS6133: Variable 'x' has never been used. +!!! error TS6133: 'x' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt index 7d263db7d49cc..524580bcdf416 100644 --- a/tests/baselines/reference/unusedLocalsInMethod2.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): error TS6133: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): error TS6133: 'x' is declared but never used. ==== tests/cases/compiler/unusedLocalsInMethod2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsInMethod2.ts(4,13): error TS6133: Variable 'x' public function1() { var x, y = 10; ~ -!!! error TS6133: Variable 'x' has never been used. +!!! error TS6133: 'x' is declared but never used. y++; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt index dbe7c19d2ae8d..b82ceaedba267 100644 --- a/tests/baselines/reference/unusedLocalsInMethod3.errors.txt +++ b/tests/baselines/reference/unusedLocalsInMethod3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): error TS6133: Variable 'x' has never been used. +tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): error TS6133: 'x' is declared but never used. ==== tests/cases/compiler/unusedLocalsInMethod3.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsInMethod3.ts(4,13): error TS6133: Variable 'x' public function1() { var x, y; ~ -!!! error TS6133: Variable 'x' has never been used. +!!! error TS6133: 'x' is declared but never used. y = 1; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt index 8fe7ac6736db2..eb06e886a03a4 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,18): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,14): error TS6133: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,20): error TS6134: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(5,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,14): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(4,20): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts(5,13): error TS6133: 'unused2' is declared but never used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. function maker(child: string): void { ~~~~~ -!!! error TS6133: Variable 'maker' has never been used. +!!! error TS6133: 'maker' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child' has never been used. +!!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt index e0d0c5e8f3941..301b272743652 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,18): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,14): error TS6133: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,20): error TS6134: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(5,13): error TS6133: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,21): error TS6134: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(8,13): error TS6133: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,14): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(4,20): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(5,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(7,21): error TS6133: 'child2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts(8,13): error TS6133: 'unused3' is declared but never used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. function maker(child: string): void { ~~~~~ -!!! error TS6133: Variable 'maker' has never been used. +!!! error TS6133: 'maker' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child' has never been used. +!!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. } function maker2(child2: string): void { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child2' has never been used. +!!! error TS6133: 'child2' is declared but never used. var unused3 = 23; ~~~~~~~ -!!! error TS6133: Variable 'unused3' has never been used. +!!! error TS6133: 'unused3' is declared but never used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt index 489afc59602e9..6bc6e9a6ebadb 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,25): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,14): error TS6133: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,20): error TS6134: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(5,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(2,25): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,14): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(4,20): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts(5,13): error TS6133: 'unused2' is declared but never used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (5 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. function maker(child: string): void { ~~~~~ -!!! error TS6133: Variable 'maker' has never been used. +!!! error TS6133: 'maker' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child' has never been used. +!!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt index f156759768980..9fc90274866e0 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,25): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,14): error TS6133: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,20): error TS6134: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(5,13): error TS6133: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,21): error TS6134: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(8,13): error TS6133: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(2,25): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,14): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(4,20): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(5,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(7,21): error TS6133: 'child2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts(8,13): error TS6133: 'unused3' is declared but never used. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. function maker(child: string): void { ~~~~~ -!!! error TS6133: Variable 'maker' has never been used. +!!! error TS6133: 'maker' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child' has never been used. +!!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. } function maker2(child2: string): void { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child2' has never been used. +!!! error TS6133: 'child2' is declared but never used. var unused3 = 23; ~~~~~~~ -!!! error TS6133: Variable 'unused3' has never been used. +!!! error TS6133: 'unused3' is declared but never used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt index ce63c48ec9478..103d6b9623903 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,18): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,9): error TS6133: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,27): error TS6134: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(5,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,9): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(4,27): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts(5,13): error TS6133: 'unused2' is declared but never used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (5 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: Variable 'maker' has never been used. +!!! error TS6133: 'maker' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child' has never been used. +!!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt index d1cadeca88a23..feb51048e3521 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,18): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,9): error TS6133: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,26): error TS6134: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(5,13): error TS6133: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,27): error TS6134: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(8,13): error TS6133: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,9): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(4,26): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(5,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(7,27): error TS6133: 'child2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts(8,13): error TS6133: 'unused3' is declared but never used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. var maker = function(child: string): void { ~~~~~ -!!! error TS6133: Variable 'maker' has never been used. +!!! error TS6133: 'maker' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child' has never been used. +!!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. } var maker2 = function(child2: string): void { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child2' has never been used. +!!! error TS6133: 'child2' is declared but never used. var unused3 = 23; ~~~~~~~ -!!! error TS6133: Variable 'unused3' has never been used. +!!! error TS6133: 'unused3' is declared but never used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt index 64924de57b595..c00232c73991f 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt @@ -1,26 +1,26 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,25): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,9): error TS6133: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,27): error TS6134: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(5,13): error TS6133: Variable 'unused2' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(2,25): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,9): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(4,27): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts(5,13): error TS6133: 'unused2' is declared but never used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (5 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: Variable 'maker' has never been used. +!!! error TS6133: 'maker' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child' has never been used. +!!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. } person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt index 1c247f4183758..fec95669f494a 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt @@ -1,35 +1,35 @@ -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,25): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6133: Variable 'unused' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,9): error TS6133: Variable 'maker' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,27): error TS6134: Parameter 'child' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(5,13): error TS6133: Variable 'unused2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,28): error TS6134: Parameter 'child2' has never been used. -tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(8,13): error TS6133: Variable 'unused3' has never been used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(2,25): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(3,9): error TS6133: 'unused' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,9): error TS6133: 'maker' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(4,27): error TS6133: 'child' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(5,13): error TS6133: 'unused2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(7,28): error TS6133: 'child2' is declared but never used. +tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts(8,13): error TS6133: 'unused3' is declared but never used. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. var maker = function (child: string): void { ~~~~~ -!!! error TS6133: Variable 'maker' has never been used. +!!! error TS6133: 'maker' is declared but never used. ~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child' has never been used. +!!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ -!!! error TS6133: Variable 'unused2' has never been used. +!!! error TS6133: 'unused2' is declared but never used. } var maker2 = function (child2: string): void { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'child2' has never been used. +!!! error TS6133: 'child2' is declared but never used. var unused3 = 23; ~~~~~~~ -!!! error TS6133: Variable 'unused3' has never been used. +!!! error TS6133: 'unused3' is declared but never used. } maker2(person2); } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt index e024997c04fb8..6fa3ef0883942 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedLocalsinConstructor1.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/unusedLocalsinConstructor1.ts(4,13): error TS6133: Variable constructor() { var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt index 59df6f20a9526..44c0bddf87cbc 100644 --- a/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedLocalsinConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedLocalsinConstructor2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedLocalsinConstructor2.ts(4,13): error TS6133: Variable constructor() { var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. var used = "dummy"; used = used + "second part"; } diff --git a/tests/baselines/reference/unusedMethodsInInterface.js b/tests/baselines/reference/unusedMethodsInInterface.js new file mode 100644 index 0000000000000..7a1142d99b9aa --- /dev/null +++ b/tests/baselines/reference/unusedMethodsInInterface.js @@ -0,0 +1,8 @@ +//// [unusedMethodsInInterface.ts] + +interface I1 { + f1(); + f2(x: number, y: string); +} + +//// [unusedMethodsInInterface.js] diff --git a/tests/baselines/reference/unusedMethodsInInterface.symbols b/tests/baselines/reference/unusedMethodsInInterface.symbols new file mode 100644 index 0000000000000..66e4c6cb100cd --- /dev/null +++ b/tests/baselines/reference/unusedMethodsInInterface.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/unusedMethodsInInterface.ts === + +interface I1 { +>I1 : Symbol(I1, Decl(unusedMethodsInInterface.ts, 0, 0)) + + f1(); +>f1 : Symbol(I1.f1, Decl(unusedMethodsInInterface.ts, 1, 14)) + + f2(x: number, y: string); +>f2 : Symbol(I1.f2, Decl(unusedMethodsInInterface.ts, 2, 9)) +>x : Symbol(x, Decl(unusedMethodsInInterface.ts, 3, 7)) +>y : Symbol(y, Decl(unusedMethodsInInterface.ts, 3, 17)) +} diff --git a/tests/baselines/reference/unusedMethodsInInterface.types b/tests/baselines/reference/unusedMethodsInInterface.types new file mode 100644 index 0000000000000..eb1befac9f0d3 --- /dev/null +++ b/tests/baselines/reference/unusedMethodsInInterface.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/unusedMethodsInInterface.ts === + +interface I1 { +>I1 : I1 + + f1(); +>f1 : () => any + + f2(x: number, y: string); +>f2 : (x: number, y: string) => any +>x : number +>y : string +} diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt index 57fa43dee23ce..b6c5a4a4b8e3a 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(3,17): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedMultipleParameter1InContructor.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6133 class Dummy { constructor(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt index 8647672af5dee..8fd7e91dae051 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,21): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(2,21): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (2 errors) ==== var func = function(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt index bb0c690c55e79..e6ac70c932c1a 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): error TS6134: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,17): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(3,50): error TS6133: 'person3' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedMultipleParameter2InContructor.ts (3 errors) ==== @@ -8,12 +8,12 @@ tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6133 class Dummy { constructor(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. ~~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person3' has never been used. +!!! error TS6133: 'person3' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. person2 = "Dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt index d34640e1c9164..534d75c870392 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,21): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,54): error TS6134: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,21): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(2,54): error TS6133: 'person3' is declared but never used. +tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (3 errors) ==== var func = function(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. ~~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person3' has never been used. +!!! error TS6133: 'person3' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. person2 = "Dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt index fc9a6670a9b28..c0d9540ad8108 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,18): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (2 errors) ==== function greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt index d0463b5dcce6d..8a783563a5096 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,20): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(3,20): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): erro class Dummy { public greeter(person: string, person2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt index 258a29a8b1ccd..4537cede8bbda 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt @@ -1,17 +1,17 @@ -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,18): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,51): error TS6134: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(2,51): error TS6133: 'person3' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (3 errors) ==== function greeter(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. ~~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person3' has never been used. +!!! error TS6133: 'person3' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. person2 = "dummy value"; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt index 59cfdcad01a7f..9b9fe8448a24d 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,20): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,53): error TS6134: Parameter 'person3' has never been used. -tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,20): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(3,53): error TS6133: 'person3' is declared but never used. +tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts (3 errors) ==== @@ -8,12 +8,12 @@ tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): erro class Dummy { public greeter(person: string, person2: string, person3: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. ~~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person3' has never been used. +!!! error TS6133: 'person3' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. person2 = "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.js b/tests/baselines/reference/unusedParameterUsedInTypeOf.js new file mode 100644 index 0000000000000..fc2589c31ff8c --- /dev/null +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.js @@ -0,0 +1,10 @@ +//// [unusedParameterUsedInTypeOf.ts] + +function f1 (a: number, b: typeof a) { + b++; +} + +//// [unusedParameterUsedInTypeOf.js] +function f1(a, b) { + b++; +} diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols b/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols new file mode 100644 index 0000000000000..9730baca34fef --- /dev/null +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/unusedParameterUsedInTypeOf.ts === + +function f1 (a: number, b: typeof a) { +>f1 : Symbol(f1, Decl(unusedParameterUsedInTypeOf.ts, 0, 0)) +>a : Symbol(a, Decl(unusedParameterUsedInTypeOf.ts, 1, 13)) +>b : Symbol(b, Decl(unusedParameterUsedInTypeOf.ts, 1, 23)) +>a : Symbol(a, Decl(unusedParameterUsedInTypeOf.ts, 1, 13)) + + b++; +>b : Symbol(b, Decl(unusedParameterUsedInTypeOf.ts, 1, 23)) +} diff --git a/tests/baselines/reference/unusedParameterUsedInTypeOf.types b/tests/baselines/reference/unusedParameterUsedInTypeOf.types new file mode 100644 index 0000000000000..d3b5bb6766126 --- /dev/null +++ b/tests/baselines/reference/unusedParameterUsedInTypeOf.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/unusedParameterUsedInTypeOf.ts === + +function f1 (a: number, b: typeof a) { +>f1 : (a: number, b: number) => void +>a : number +>b : number +>a : number + + b++; +>b++ : number +>b : number +} diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt index 68f61956de795..d5d2248547703 100644 --- a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6134: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6133: 'param1' is declared but never used. ==== tests/cases/compiler/unusedParametersinConstructor1.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6134: Para class greeter { constructor(param1: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'param1' has never been used. +!!! error TS6133: 'param1' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt index 061960c867081..c755488a630f5 100644 --- a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6134: Parameter 'param1' has never been used. +tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6133: 'param1' is declared but never used. ==== tests/cases/compiler/unusedParametersinConstructor2.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6134: Para class greeter { constructor(param1: string, param2: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'param1' has never been used. +!!! error TS6133: 'param1' is declared but never used. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt index 6dc7c9925ddf9..25c72fc13221d 100644 --- a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): error TS6134: Parameter 'param1' has never been used. -tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6134: Parameter 'param3' has never been used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,17): error TS6133: 'param1' is declared but never used. +tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6133: 'param3' is declared but never used. ==== tests/cases/compiler/unusedParametersinConstructor3.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6134: Para class greeter { constructor(param1: string, param2: string, param3: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'param1' has never been used. +!!! error TS6133: 'param1' is declared but never used. ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'param3' has never been used. +!!! error TS6133: 'param3' is declared but never used. param2 = param2 + "dummy value"; } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt index 1ebfa445f943c..40357c0b7f005 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6133: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6133: 'function1' is declared but never used. ==== tests/cases/compiler/unusedPrivateMethodInClass1.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedPrivateMethodInClass1.ts(3,13): error TS6133: Variabl class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: Variable 'function1' has never been used. +!!! error TS6133: 'function1' is declared but never used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt index 56aa61dac4145..36a7a3c40d04b 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): error TS6133: Variable 'function1' has never been used. -tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6133: Variable 'function2' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(3,13): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6133: 'function2' is declared but never used. ==== tests/cases/compiler/unusedPrivateMethodInClass2.ts (2 errors) ==== @@ -7,14 +7,14 @@ tests/cases/compiler/unusedPrivateMethodInClass2.ts(8,13): error TS6133: Variabl class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: Variable 'function1' has never been used. +!!! error TS6133: 'function1' is declared but never used. var y = 10; y++; } private function2() { ~~~~~~~~~ -!!! error TS6133: Variable 'function2' has never been used. +!!! error TS6133: 'function2' is declared but never used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt index 9b4c6589f661e..365cfb321351f 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): error TS6133: Variable 'function1' has never been used. -tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6133: Variable 'function2' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(3,13): error TS6133: 'function1' is declared but never used. +tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6133: 'function2' is declared but never used. ==== tests/cases/compiler/unusedPrivateMethodInClass3.ts (2 errors) ==== @@ -7,14 +7,14 @@ tests/cases/compiler/unusedPrivateMethodInClass3.ts(8,13): error TS6133: Variabl class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: Variable 'function1' has never been used. +!!! error TS6133: 'function1' is declared but never used. var y = 10; y++; } private function2() { ~~~~~~~~~ -!!! error TS6133: Variable 'function2' has never been used. +!!! error TS6133: 'function2' is declared but never used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt index 2bf406d88292d..324e7d17bbc54 100644 --- a/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateMethodInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6133: Variable 'function1' has never been used. +tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6133: 'function1' is declared but never used. ==== tests/cases/compiler/unusedPrivateMethodInClass4.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedPrivateMethodInClass4.ts(3,13): error TS6133: Variabl class greeter { private function1() { ~~~~~~~~~ -!!! error TS6133: Variable 'function1' has never been used. +!!! error TS6133: 'function1' is declared but never used. var y = 10; y++; } diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt index dedbf1c01a0fa..6155d1b089579 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): error TS6133: Variable 'x' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): error TS6133: 'x' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass1.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): error TS6133: Variab class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'x' has never been used. +!!! error TS6133: 'x' is declared but never used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt index 492a65b3afa24..6b79756c63ff7 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,5): error TS6133: Variable 'x' has never been used. -tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): error TS6133: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,5): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): error TS6133: 'y' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass2.ts (2 errors) ==== @@ -7,8 +7,8 @@ tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): error TS6133: Variab class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'x' has never been used. +!!! error TS6133: 'x' is declared but never used. private y: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'y' has never been used. +!!! error TS6133: 'y' is declared but never used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt index d33a59a6bda60..d0b662a337ff9 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,5): error TS6133: Variable 'x' has never been used. -tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): error TS6133: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,5): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): error TS6133: 'y' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass3.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): error TS6133: Variab class greeter { private x: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'x' has never been used. +!!! error TS6133: 'x' is declared but never used. private y: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'y' has never been used. +!!! error TS6133: 'y' is declared but never used. public z: string; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt index 6cf355497e1ca..c43b877b79973 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6133: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6133: 'y' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass4.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6133: Variab private x: string; private y: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'y' has never been used. +!!! error TS6133: 'y' is declared but never used. public z: string; public method1() { diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt index 36e68408cd0e8..4ae07dfcba66d 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6133: Variable 'y' has never been used. +tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6133: 'y' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass5.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6133: Variab private x: string; private y: string; ~~~~~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'y' has never been used. +!!! error TS6133: 'y' is declared but never used. public z: string; constructor() { diff --git a/tests/baselines/reference/unusedSetterInClass.js b/tests/baselines/reference/unusedSetterInClass.js new file mode 100644 index 0000000000000..aff12b7d043b5 --- /dev/null +++ b/tests/baselines/reference/unusedSetterInClass.js @@ -0,0 +1,23 @@ +//// [unusedSetterInClass.ts] + +class Employee { + private _fullName: string; + + set fullName(newName: string) { + this._fullName = newName; + } +} + +//// [unusedSetterInClass.js] +var Employee = (function () { + function Employee() { + } + Object.defineProperty(Employee.prototype, "fullName", { + set: function (newName) { + this._fullName = newName; + }, + enumerable: true, + configurable: true + }); + return Employee; +}()); diff --git a/tests/baselines/reference/unusedSetterInClass.symbols b/tests/baselines/reference/unusedSetterInClass.symbols new file mode 100644 index 0000000000000..511b106adedee --- /dev/null +++ b/tests/baselines/reference/unusedSetterInClass.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/unusedSetterInClass.ts === + +class Employee { +>Employee : Symbol(Employee, Decl(unusedSetterInClass.ts, 0, 0)) + + private _fullName: string; +>_fullName : Symbol(Employee._fullName, Decl(unusedSetterInClass.ts, 1, 16)) + + set fullName(newName: string) { +>fullName : Symbol(Employee.fullName, Decl(unusedSetterInClass.ts, 2, 30)) +>newName : Symbol(newName, Decl(unusedSetterInClass.ts, 4, 17)) + + this._fullName = newName; +>this._fullName : Symbol(Employee._fullName, Decl(unusedSetterInClass.ts, 1, 16)) +>this : Symbol(Employee, Decl(unusedSetterInClass.ts, 0, 0)) +>_fullName : Symbol(Employee._fullName, Decl(unusedSetterInClass.ts, 1, 16)) +>newName : Symbol(newName, Decl(unusedSetterInClass.ts, 4, 17)) + } +} diff --git a/tests/baselines/reference/unusedSetterInClass.types b/tests/baselines/reference/unusedSetterInClass.types new file mode 100644 index 0000000000000..9a74ef383ae14 --- /dev/null +++ b/tests/baselines/reference/unusedSetterInClass.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/unusedSetterInClass.ts === + +class Employee { +>Employee : Employee + + private _fullName: string; +>_fullName : string + + set fullName(newName: string) { +>fullName : string +>newName : string + + this._fullName = newName; +>this._fullName = newName : string +>this._fullName : string +>this : this +>_fullName : string +>newName : string + } +} diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt index f767ee564d150..b3238b0d9f94b 100644 --- a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(3,17): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedSingleParameterInContructor.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6133: V class Dummy { constructor(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt index 1e94be8e6f58d..82260b15f7ed0 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,18): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(2,18): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts (2 errors) ==== function greeter(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt index 179310d246c91..1f32b823c090a 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,21): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(2,21): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts (2 errors) ==== var func = function(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt index b17937883b257..ab5f028d5017c 100644 --- a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,20): error TS6134: Parameter 'person' has never been used. -tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS6133: Variable 'unused' has never been used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(3,20): error TS6133: 'person' is declared but never used. +tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS6133: 'unused' is declared but never used. ==== tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS class Dummy { public greeter(person: string) { ~~~~~~~~~~~~~~ -!!! error TS6134: Parameter 'person' has never been used. +!!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ -!!! error TS6133: Variable 'unused' has never been used. +!!! error TS6133: 'unused' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters1.errors.txt b/tests/baselines/reference/unusedTypeParameters1.errors.txt index 22b2f5579bb43..15d85d0e8159e 100644 --- a/tests/baselines/reference/unusedTypeParameters1.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedTypeParameters1.ts(2,15): error TS6133: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters1.ts(2,15): error TS6133: 'typeparameter1' is declared but never used. ==== tests/cases/compiler/unusedTypeParameters1.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'typeparameter1' has never been used. +!!! error TS6133: 'typeparameter1' is declared but never used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters2.errors.txt b/tests/baselines/reference/unusedTypeParameters2.errors.txt index ef71d3ebeefe0..a82a119d2ca2f 100644 --- a/tests/baselines/reference/unusedTypeParameters2.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/unusedTypeParameters2.ts(2,15): error TS6133: Variable 'typeparameter1' has never been used. +tests/cases/compiler/unusedTypeParameters2.ts(2,15): error TS6133: 'typeparameter1' is declared but never used. ==== tests/cases/compiler/unusedTypeParameters2.ts (1 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'typeparameter1' has never been used. +!!! error TS6133: 'typeparameter1' is declared but never used. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedTypeParameters3.errors.txt b/tests/baselines/reference/unusedTypeParameters3.errors.txt index 0970af65bf1fe..0b051ad476b1b 100644 --- a/tests/baselines/reference/unusedTypeParameters3.errors.txt +++ b/tests/baselines/reference/unusedTypeParameters3.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedTypeParameters3.ts(2,15): error TS6133: Variable 'typeparameter1' has never been used. -tests/cases/compiler/unusedTypeParameters3.ts(2,47): error TS6133: Variable 'typeparameter3' has never been used. +tests/cases/compiler/unusedTypeParameters3.ts(2,15): error TS6133: 'typeparameter1' is declared but never used. +tests/cases/compiler/unusedTypeParameters3.ts(2,47): error TS6133: 'typeparameter3' is declared but never used. ==== tests/cases/compiler/unusedTypeParameters3.ts (2 errors) ==== class greeter { ~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'typeparameter1' has never been used. +!!! error TS6133: 'typeparameter1' is declared but never used. ~~~~~~~~~~~~~~ -!!! error TS6133: Variable 'typeparameter3' has never been used. +!!! error TS6133: 'typeparameter3' is declared but never used. private x: typeparameter2; public function1() { diff --git a/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt b/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt new file mode 100644 index 0000000000000..4f4291395f334 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinBlocks1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedVariablesinBlocks1.ts(3,9): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinBlocks1.ts (1 errors) ==== + + function f1 () { + let x = 10; + ~ +!!! error TS6133: 'x' is declared but never used. + { + let x = 11; + x++; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinBlocks1.js b/tests/baselines/reference/unusedVariablesinBlocks1.js new file mode 100644 index 0000000000000..d569485aa820b --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinBlocks1.js @@ -0,0 +1,18 @@ +//// [unusedVariablesinBlocks1.ts] + +function f1 () { + let x = 10; + { + let x = 11; + x++; + } +} + +//// [unusedVariablesinBlocks1.js] +function f1() { + var x = 10; + { + var x_1 = 11; + x_1++; + } +} diff --git a/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt b/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt new file mode 100644 index 0000000000000..70af896324caa --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinBlocks2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedVariablesinBlocks2.ts(5,13): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinBlocks2.ts (1 errors) ==== + + function f1 () { + let x = 10; + { + let x = 11; + ~ +!!! error TS6133: 'x' is declared but never used. + } + x++; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinBlocks2.js b/tests/baselines/reference/unusedVariablesinBlocks2.js new file mode 100644 index 0000000000000..0f4cb3463985a --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinBlocks2.js @@ -0,0 +1,18 @@ +//// [unusedVariablesinBlocks2.ts] + +function f1 () { + let x = 10; + { + let x = 11; + } + x++; +} + +//// [unusedVariablesinBlocks2.js] +function f1() { + var x = 10; + { + var x_1 = 11; + } + x++; +} diff --git a/tests/baselines/reference/unusedVariablesinForLoop.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop.errors.txt new file mode 100644 index 0000000000000..b44e9dfdab1e7 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedVariablesinForLoop.ts(3,13): error TS6133: 'i' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinForLoop.ts (1 errors) ==== + + function f1 () { + for(var i = 0; ;) { + ~ +!!! error TS6133: 'i' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop.js b/tests/baselines/reference/unusedVariablesinForLoop.js new file mode 100644 index 0000000000000..a87e395d6e721 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop.js @@ -0,0 +1,13 @@ +//// [unusedVariablesinForLoop.ts] + +function f1 () { + for(var i = 0; ;) { + + } +} + +//// [unusedVariablesinForLoop.js] +function f1() { + for (var i = 0;;) { + } +} diff --git a/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt new file mode 100644 index 0000000000000..71974af00f4ea --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop2.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedVariablesinForLoop2.ts(3,16): error TS6133: 'elem' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinForLoop2.ts (1 errors) ==== + + function f1 () { + for (const elem in ["a", "b", "c"]) { + ~~~~ +!!! error TS6133: 'elem' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop2.js b/tests/baselines/reference/unusedVariablesinForLoop2.js new file mode 100644 index 0000000000000..523fdb18f9e60 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop2.js @@ -0,0 +1,13 @@ +//// [unusedVariablesinForLoop2.ts] + +function f1 () { + for (const elem in ["a", "b", "c"]) { + + } +} + +//// [unusedVariablesinForLoop2.js] +function f1() { + for (var elem in ["a", "b", "c"]) { + } +} diff --git a/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt new file mode 100644 index 0000000000000..dbaf91ae70d17 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop3.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedVariablesinForLoop3.ts(3,16): error TS6133: 'elem' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinForLoop3.ts (1 errors) ==== + + function f1 () { + for (const elem of ["a", "b", "c"]) { + ~~~~ +!!! error TS6133: 'elem' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop3.js b/tests/baselines/reference/unusedVariablesinForLoop3.js new file mode 100644 index 0000000000000..833214f3ba549 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop3.js @@ -0,0 +1,14 @@ +//// [unusedVariablesinForLoop3.ts] + +function f1 () { + for (const elem of ["a", "b", "c"]) { + + } +} + +//// [unusedVariablesinForLoop3.js] +function f1() { + for (var _i = 0, _a = ["a", "b", "c"]; _i < _a.length; _i++) { + var elem = _a[_i]; + } +} diff --git a/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt b/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt new file mode 100644 index 0000000000000..d54500d353d57 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop4.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedVariablesinForLoop4.ts(5,13): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinForLoop4.ts (1 errors) ==== + + function f1 () { + for (const elem of ["a", "b", "c"]) { + elem; + var x = 20; + ~ +!!! error TS6133: 'x' is declared but never used. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinForLoop4.js b/tests/baselines/reference/unusedVariablesinForLoop4.js new file mode 100644 index 0000000000000..6ec7f6fec556b --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinForLoop4.js @@ -0,0 +1,17 @@ +//// [unusedVariablesinForLoop4.ts] + +function f1 () { + for (const elem of ["a", "b", "c"]) { + elem; + var x = 20; + } +} + +//// [unusedVariablesinForLoop4.js] +function f1() { + for (var _i = 0, _a = ["a", "b", "c"]; _i < _a.length; _i++) { + var elem = _a[_i]; + elem; + var x = 20; + } +} diff --git a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt index d2b0d4c9ee8ca..39c1cdc4e080d 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): error TS6133: Variable 'lettersRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): error TS6133: 'lettersRegexp' is declared but never used. ==== tests/cases/compiler/unusedVariablesinNamespaces1.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/unusedVariablesinNamespaces1.ts(3,11): error TS6133: Variab namespace Validation { const lettersRegexp = /^[A-Za-z]+$/; ~~~~~~~~~~~~~ -!!! error TS6133: Variable 'lettersRegexp' has never been used. +!!! error TS6133: 'lettersRegexp' is declared but never used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt index 2026419029d0d..43d41e6338bdc 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): error TS6133: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): error TS6133: 'numberRegexp' is declared but never used. ==== tests/cases/compiler/unusedVariablesinNamespaces2.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedVariablesinNamespaces2.ts(4,11): error TS6133: Variab const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: Variable 'numberRegexp' has never been used. +!!! error TS6133: 'numberRegexp' is declared but never used. export class LettersOnlyValidator { isAcceptable(s2: string) { diff --git a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt index ecc8e48356b55..a0a274c6b2ae3 100644 --- a/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedVariablesinNamespaces3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): error TS6133: Variable 'numberRegexp' has never been used. +tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): error TS6133: 'numberRegexp' is declared but never used. ==== tests/cases/compiler/unusedVariablesinNamespaces3.ts (1 errors) ==== @@ -7,7 +7,7 @@ tests/cases/compiler/unusedVariablesinNamespaces3.ts(4,11): error TS6133: Variab const lettersRegexp = /^[A-Za-z]+$/; const numberRegexp = /^[0-9]+$/; ~~~~~~~~~~~~ -!!! error TS6133: Variable 'numberRegexp' has never been used. +!!! error TS6133: 'numberRegexp' is declared but never used. export const anotherUnusedVariable = "Dummy value"; export class LettersOnlyValidator { diff --git a/tests/cases/compiler/unusedGetterInClass.ts b/tests/cases/compiler/unusedGetterInClass.ts new file mode 100644 index 0000000000000..e5259f91cdc42 --- /dev/null +++ b/tests/cases/compiler/unusedGetterInClass.ts @@ -0,0 +1,11 @@ +//@target: ES5 +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Employee { + private _fullName: string; + + get fullName(): string { + return this._fullName; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedMethodsInInterface.ts b/tests/cases/compiler/unusedMethodsInInterface.ts new file mode 100644 index 0000000000000..29769bc5b115c --- /dev/null +++ b/tests/cases/compiler/unusedMethodsInInterface.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +interface I1 { + f1(); + f2(x: number, y: string); +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParameterUsedInTypeOf.ts b/tests/cases/compiler/unusedParameterUsedInTypeOf.ts new file mode 100644 index 0000000000000..b69b2412314d3 --- /dev/null +++ b/tests/cases/compiler/unusedParameterUsedInTypeOf.ts @@ -0,0 +1,7 @@ +//@target: ES5 +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 (a: number, b: typeof a) { + b++; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedSetterInClass.ts b/tests/cases/compiler/unusedSetterInClass.ts new file mode 100644 index 0000000000000..a8e45bab43434 --- /dev/null +++ b/tests/cases/compiler/unusedSetterInClass.ts @@ -0,0 +1,11 @@ +//@target: ES5 +//@noUnusedLocals:true +//@noUnusedParameters:true + +class Employee { + private _fullName: string; + + set fullName(newName: string) { + this._fullName = newName; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinBlocks1.ts b/tests/cases/compiler/unusedVariablesinBlocks1.ts new file mode 100644 index 0000000000000..b937fbd8ac19a --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinBlocks1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + let x = 10; + { + let x = 11; + x++; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinBlocks2.ts b/tests/cases/compiler/unusedVariablesinBlocks2.ts new file mode 100644 index 0000000000000..248e6302cd099 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinBlocks2.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + let x = 10; + { + let x = 11; + } + x++; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinForLoop.ts b/tests/cases/compiler/unusedVariablesinForLoop.ts new file mode 100644 index 0000000000000..01f8a4bdfc5e2 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinForLoop.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + for(var i = 0; ;) { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinForLoop2.ts b/tests/cases/compiler/unusedVariablesinForLoop2.ts new file mode 100644 index 0000000000000..b5d3496608dcf --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinForLoop2.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + for (const elem in ["a", "b", "c"]) { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinForLoop3.ts b/tests/cases/compiler/unusedVariablesinForLoop3.ts new file mode 100644 index 0000000000000..c08f225e7beb7 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinForLoop3.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + for (const elem of ["a", "b", "c"]) { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinForLoop4.ts b/tests/cases/compiler/unusedVariablesinForLoop4.ts new file mode 100644 index 0000000000000..ac75e065b9e99 --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinForLoop4.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1 () { + for (const elem of ["a", "b", "c"]) { + elem; + var x = 20; + } +} \ No newline at end of file From 1d3a888a418f2f8d3d1659b857417d32e3fd1208 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 20 Jun 2016 13:31:18 -0700 Subject: [PATCH 47/90] Fixing the error code --- .../quickfixes/unusedIdentifierFixes.ts | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/src/services/quickfixes/unusedIdentifierFixes.ts b/src/services/quickfixes/unusedIdentifierFixes.ts index 519d666aa8804..3bdd07b357378 100644 --- a/src/services/quickfixes/unusedIdentifierFixes.ts +++ b/src/services/quickfixes/unusedIdentifierFixes.ts @@ -1,31 +1,8 @@ /* @internal */ namespace ts.quickFix { - registerQuickFix({ - name: "Remove Unused Parameters", - errorCode: "TS6133", - getFix: (sourceFile: SourceFile, start: number, end: number): { newText: string; span: { start: number, length: number } }[] => { - const token = getTokenAtPosition(sourceFile, start); - if (token.kind === ts.SyntaxKind.Identifier) { - if (token.parent.kind === ts.SyntaxKind.Parameter) { - var functionDeclaration = token.parent.parent; - if(functionDeclaration.parameters.length === 1) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos} }]; - } else { - if (functionDeclaration.parameters[0] === token.parent) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }]; - } else { - return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; - } - } - } - } - throw new Error("No Quick Fix found"); - } - }); - registerQuickFix({ name: "Remove Unused Identifiers", - errorCode: "TS6132", + errorCode: "TS6133", getFix: (sourceFile: SourceFile, start: number, end: number): { newText: string; span: { start: number, length: number } }[] => { const token = getTokenAtPosition(sourceFile, start); if (token.kind === ts.SyntaxKind.Identifier) { @@ -64,6 +41,19 @@ namespace ts.quickFix { } } } + + if (token.parent.kind === ts.SyntaxKind.Parameter) { + var functionDeclaration = token.parent.parent; + if(functionDeclaration.parameters.length === 1) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos} }]; + } else { + if (functionDeclaration.parameters[0] === token.parent) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }]; + } else { + return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + } + } + } } if(token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { From c82453f60c11ae4a4aca9ab548504bf64d8d052e Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 20 Jun 2016 14:29:43 -0700 Subject: [PATCH 48/90] Code changes for checking unused imports --- src/compiler/checker.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa3ed795daa39..0f4d366f77bef 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14518,6 +14518,24 @@ namespace ts { return (node.flags & NodeFlags.Private) !== 0; } + function checkUnusedImports(node: SourceFile) { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { + for (const local in node.locals) { + if (hasProperty(node.locals, local)) { + const localValue = node.locals[local]; + if (localValue.declarations && !localValue.exportSymbol) { + for (const declaration of localValue.declarations) { + const symbol = declaration.symbol; + if (!symbol.hasReference) { + error(declaration, Diagnostics._0_is_declared_but_never_used, symbol.name); + } + } + } + } + } + } + } + function checkBlock(node: Block) { // Grammar checking for SyntaxKind.Block if (node.kind === SyntaxKind.Block) { @@ -16569,6 +16587,7 @@ namespace ts { if (target.flags & SymbolFlags.Type) { checkTypeNameIsReserved(node.name, Diagnostics.Import_name_cannot_be_0); } + target.hasReference = true; } } else { @@ -16911,6 +16930,7 @@ namespace ts { deferredNodes = []; forEach(node.statements, checkSourceElement); + checkUnusedImports(node); checkDeferredNodes(); deferredNodes = undefined; From bcd6fc408a7c8124e6ab103f8978edc60b7b780f Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 20 Jun 2016 15:49:30 -0700 Subject: [PATCH 49/90] Test Cases for Unused Imports --- src/compiler/checker.ts | 10 +++-- .../reference/unusedImports1.errors.txt | 13 ++++++ tests/baselines/reference/unusedImports1.js | 21 +++++++++ .../reference/unusedImports2.errors.txt | 21 +++++++++ tests/baselines/reference/unusedImports2.js | 36 +++++++++++++++ .../reference/unusedImports3.errors.txt | 24 ++++++++++ tests/baselines/reference/unusedImports3.js | 42 ++++++++++++++++++ .../reference/unusedImports4.errors.txt | 25 +++++++++++ tests/baselines/reference/unusedImports4.js | 44 +++++++++++++++++++ .../reference/unusedImports5.errors.txt | 25 +++++++++++ tests/baselines/reference/unusedImports5.js | 44 +++++++++++++++++++ .../reference/unusedImports6.errors.txt | 25 +++++++++++ tests/baselines/reference/unusedImports6.js | 41 +++++++++++++++++ .../reference/unusedImports7.errors.txt | 23 ++++++++++ tests/baselines/reference/unusedImports7.js | 39 ++++++++++++++++ .../reference/unusedImports8.errors.txt | 25 +++++++++++ tests/baselines/reference/unusedImports8.js | 44 +++++++++++++++++++ .../reference/unusedImports9.errors.txt | 21 +++++++++ tests/baselines/reference/unusedImports9.js | 36 +++++++++++++++ tests/cases/compiler/unusedImports1.ts | 10 +++++ tests/cases/compiler/unusedImports2.ts | 18 ++++++++ tests/cases/compiler/unusedImports3.ts | 21 +++++++++ tests/cases/compiler/unusedImports4.ts | 22 ++++++++++ tests/cases/compiler/unusedImports5.ts | 22 ++++++++++ tests/cases/compiler/unusedImports6.ts | 21 +++++++++ tests/cases/compiler/unusedImports7.ts | 19 ++++++++ tests/cases/compiler/unusedImports8.ts | 22 ++++++++++ tests/cases/compiler/unusedImports9.ts | 18 ++++++++ 28 files changed, 728 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/unusedImports1.errors.txt create mode 100644 tests/baselines/reference/unusedImports1.js create mode 100644 tests/baselines/reference/unusedImports2.errors.txt create mode 100644 tests/baselines/reference/unusedImports2.js create mode 100644 tests/baselines/reference/unusedImports3.errors.txt create mode 100644 tests/baselines/reference/unusedImports3.js create mode 100644 tests/baselines/reference/unusedImports4.errors.txt create mode 100644 tests/baselines/reference/unusedImports4.js create mode 100644 tests/baselines/reference/unusedImports5.errors.txt create mode 100644 tests/baselines/reference/unusedImports5.js create mode 100644 tests/baselines/reference/unusedImports6.errors.txt create mode 100644 tests/baselines/reference/unusedImports6.js create mode 100644 tests/baselines/reference/unusedImports7.errors.txt create mode 100644 tests/baselines/reference/unusedImports7.js create mode 100644 tests/baselines/reference/unusedImports8.errors.txt create mode 100644 tests/baselines/reference/unusedImports8.js create mode 100644 tests/baselines/reference/unusedImports9.errors.txt create mode 100644 tests/baselines/reference/unusedImports9.js create mode 100644 tests/cases/compiler/unusedImports1.ts create mode 100644 tests/cases/compiler/unusedImports2.ts create mode 100644 tests/cases/compiler/unusedImports3.ts create mode 100644 tests/cases/compiler/unusedImports4.ts create mode 100644 tests/cases/compiler/unusedImports5.ts create mode 100644 tests/cases/compiler/unusedImports6.ts create mode 100644 tests/cases/compiler/unusedImports7.ts create mode 100644 tests/cases/compiler/unusedImports8.ts create mode 100644 tests/cases/compiler/unusedImports9.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0f4d366f77bef..201fb67512fdb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14525,10 +14525,12 @@ namespace ts { const localValue = node.locals[local]; if (localValue.declarations && !localValue.exportSymbol) { for (const declaration of localValue.declarations) { - const symbol = declaration.symbol; - if (!symbol.hasReference) { - error(declaration, Diagnostics._0_is_declared_but_never_used, symbol.name); - } + if (declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause || declaration.kind === SyntaxKind.NamespaceImport || declaration.kind === SyntaxKind.ImportEqualsDeclaration) { + const symbol = declaration.symbol; + if (!symbol.hasReference) { + error(declaration, Diagnostics._0_is_declared_but_never_used, symbol.name); + } + } } } } diff --git a/tests/baselines/reference/unusedImports1.errors.txt b/tests/baselines/reference/unusedImports1.errors.txt new file mode 100644 index 0000000000000..f2d59c994b556 --- /dev/null +++ b/tests/baselines/reference/unusedImports1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator} from "./file1" + ~~~~~~~~~~ +!!! error TS6133: 'Calculator' is declared but never used. \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports1.js b/tests/baselines/reference/unusedImports1.js new file mode 100644 index 0000000000000..afd6eb80843f6 --- /dev/null +++ b/tests/baselines/reference/unusedImports1.js @@ -0,0 +1,21 @@ +//// [tests/cases/compiler/unusedImports1.ts] //// + +//// [file1.ts] + +export class Calculator { + +} + +//// [file2.ts] +import {Calculator} from "./file1" + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + return Calculator; +}()); +exports.Calculator = Calculator; +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/unusedImports2.errors.txt b/tests/baselines/reference/unusedImports2.errors.txt new file mode 100644 index 0000000000000..d2b3a3c2bc565 --- /dev/null +++ b/tests/baselines/reference/unusedImports2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/file2.ts(2,9): error TS6133: 'test' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator} from "./file1" + import {test} from "./file1" + ~~~~ +!!! error TS6133: 'test' is declared but never used. + + var x = new Calculator(); + x.handleChar(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports2.js b/tests/baselines/reference/unusedImports2.js new file mode 100644 index 0000000000000..f8918db5ab1e5 --- /dev/null +++ b/tests/baselines/reference/unusedImports2.js @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/unusedImports2.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +//// [file2.ts] +import {Calculator} from "./file1" +import {test} from "./file1" + +var x = new Calculator(); +x.handleChar(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +var x = new file1_1.Calculator(); +x.handleChar(); diff --git a/tests/baselines/reference/unusedImports3.errors.txt b/tests/baselines/reference/unusedImports3.errors.txt new file mode 100644 index 0000000000000..fe398ab4f8ed9 --- /dev/null +++ b/tests/baselines/reference/unusedImports3.errors.txt @@ -0,0 +1,24 @@ +tests/cases/compiler/file2.ts(1,9): error TS6133: 'Calculator' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator, test, test2} from "./file1" + ~~~~~~~~~~ +!!! error TS6133: 'Calculator' is declared but never used. + + test(); + test2(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports3.js b/tests/baselines/reference/unusedImports3.js new file mode 100644 index 0000000000000..5c0a3edf16bf1 --- /dev/null +++ b/tests/baselines/reference/unusedImports3.js @@ -0,0 +1,42 @@ +//// [tests/cases/compiler/unusedImports3.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import {Calculator, test, test2} from "./file1" + +test(); +test2(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +file1_1.test(); +file1_1.test2(); diff --git a/tests/baselines/reference/unusedImports4.errors.txt b/tests/baselines/reference/unusedImports4.errors.txt new file mode 100644 index 0000000000000..872ef8e452e07 --- /dev/null +++ b/tests/baselines/reference/unusedImports4.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file2.ts(1,21): error TS6133: 'test' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator, test, test2} from "./file1" + ~~~~ +!!! error TS6133: 'test' is declared but never used. + + var x = new Calculator(); + x.handleChar(); + test2(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports4.js b/tests/baselines/reference/unusedImports4.js new file mode 100644 index 0000000000000..e95938091aed4 --- /dev/null +++ b/tests/baselines/reference/unusedImports4.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/unusedImports4.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import {Calculator, test, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test2(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +var x = new file1_1.Calculator(); +x.handleChar(); +file1_1.test2(); diff --git a/tests/baselines/reference/unusedImports5.errors.txt b/tests/baselines/reference/unusedImports5.errors.txt new file mode 100644 index 0000000000000..deb9dd00f9cff --- /dev/null +++ b/tests/baselines/reference/unusedImports5.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file2.ts(1,27): error TS6133: 'test2' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator, test, test2} from "./file1" + ~~~~~ +!!! error TS6133: 'test2' is declared but never used. + + var x = new Calculator(); + x.handleChar(); + test(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports5.js b/tests/baselines/reference/unusedImports5.js new file mode 100644 index 0000000000000..cf92d01eb7524 --- /dev/null +++ b/tests/baselines/reference/unusedImports5.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/unusedImports5.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import {Calculator, test, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +var x = new file1_1.Calculator(); +x.handleChar(); +file1_1.test(); diff --git a/tests/baselines/reference/unusedImports6.errors.txt b/tests/baselines/reference/unusedImports6.errors.txt new file mode 100644 index 0000000000000..b27e50ab2d3b7 --- /dev/null +++ b/tests/baselines/reference/unusedImports6.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file2.ts(1,8): error TS6133: 'd' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export default function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import d from "./file1" + ~ +!!! error TS6133: 'd' is declared but never used. + + + + \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports6.js b/tests/baselines/reference/unusedImports6.js new file mode 100644 index 0000000000000..2e203a62a1bad --- /dev/null +++ b/tests/baselines/reference/unusedImports6.js @@ -0,0 +1,41 @@ +//// [tests/cases/compiler/unusedImports6.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export default function test2() { + +} + +//// [file2.ts] +import d from "./file1" + + + + + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.__esModule = true; +exports["default"] = test2; +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/unusedImports7.errors.txt b/tests/baselines/reference/unusedImports7.errors.txt new file mode 100644 index 0000000000000..8731188d80d71 --- /dev/null +++ b/tests/baselines/reference/unusedImports7.errors.txt @@ -0,0 +1,23 @@ +tests/cases/compiler/file2.ts(1,8): error TS6133: 'n' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export default function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import * as n from "./file1" + ~~~~~~ +!!! error TS6133: 'n' is declared but never used. + + \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports7.js b/tests/baselines/reference/unusedImports7.js new file mode 100644 index 0000000000000..67524fcd22a45 --- /dev/null +++ b/tests/baselines/reference/unusedImports7.js @@ -0,0 +1,39 @@ +//// [tests/cases/compiler/unusedImports7.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export default function test2() { + +} + +//// [file2.ts] +import * as n from "./file1" + + + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.__esModule = true; +exports["default"] = test2; +//// [file2.js] +"use strict"; diff --git a/tests/baselines/reference/unusedImports8.errors.txt b/tests/baselines/reference/unusedImports8.errors.txt new file mode 100644 index 0000000000000..566fce7e468ad --- /dev/null +++ b/tests/baselines/reference/unusedImports8.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file2.ts(1,41): error TS6133: 't2' is declared but never used. + + +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import {Calculator as calc, test as t1, test2 as t2} from "./file1" + ~~~~~~~~~~~ +!!! error TS6133: 't2' is declared but never used. + + var x = new calc(); + x.handleChar(); + t1(); \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports8.js b/tests/baselines/reference/unusedImports8.js new file mode 100644 index 0000000000000..2554472e6cebe --- /dev/null +++ b/tests/baselines/reference/unusedImports8.js @@ -0,0 +1,44 @@ +//// [tests/cases/compiler/unusedImports8.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import {Calculator as calc, test as t1, test2 as t2} from "./file1" + +var x = new calc(); +x.handleChar(); +t1(); + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; +var file1_1 = require("./file1"); +var x = new file1_1.Calculator(); +x.handleChar(); +file1_1.test(); diff --git a/tests/baselines/reference/unusedImports9.errors.txt b/tests/baselines/reference/unusedImports9.errors.txt new file mode 100644 index 0000000000000..007ac0088c835 --- /dev/null +++ b/tests/baselines/reference/unusedImports9.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/file2.ts(1,1): error TS6133: 'c' is declared but never used. + + +==== tests/cases/compiler/file2.ts (1 errors) ==== + import c = require('./file1') + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS6133: 'c' is declared but never used. +==== tests/cases/compiler/file1.ts (0 errors) ==== + + export class Calculator { + handleChar() {} + } + + export function test() { + + } + + export function test2() { + + } + \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports9.js b/tests/baselines/reference/unusedImports9.js new file mode 100644 index 0000000000000..cd19e167b1971 --- /dev/null +++ b/tests/baselines/reference/unusedImports9.js @@ -0,0 +1,36 @@ +//// [tests/cases/compiler/unusedImports9.ts] //// + +//// [file1.ts] + +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +//// [file2.ts] +import c = require('./file1') + +//// [file1.js] +"use strict"; +var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handleChar = function () { }; + return Calculator; +}()); +exports.Calculator = Calculator; +function test() { +} +exports.test = test; +function test2() { +} +exports.test2 = test2; +//// [file2.js] +"use strict"; diff --git a/tests/cases/compiler/unusedImports1.ts b/tests/cases/compiler/unusedImports1.ts new file mode 100644 index 0000000000000..30fff0c1ed195 --- /dev/null +++ b/tests/cases/compiler/unusedImports1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + +} + +// @Filename: file2.ts +import {Calculator} from "./file1" \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports2.ts b/tests/cases/compiler/unusedImports2.ts new file mode 100644 index 0000000000000..00e7fcff33bc3 --- /dev/null +++ b/tests/cases/compiler/unusedImports2.ts @@ -0,0 +1,18 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +// @Filename: file2.ts +import {Calculator} from "./file1" +import {test} from "./file1" + +var x = new Calculator(); +x.handleChar(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports3.ts b/tests/cases/compiler/unusedImports3.ts new file mode 100644 index 0000000000000..349c2c9abe8e6 --- /dev/null +++ b/tests/cases/compiler/unusedImports3.ts @@ -0,0 +1,21 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import {Calculator, test, test2} from "./file1" + +test(); +test2(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports4.ts b/tests/cases/compiler/unusedImports4.ts new file mode 100644 index 0000000000000..472c59658509c --- /dev/null +++ b/tests/cases/compiler/unusedImports4.ts @@ -0,0 +1,22 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import {Calculator, test, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test2(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports5.ts b/tests/cases/compiler/unusedImports5.ts new file mode 100644 index 0000000000000..85943691ce2e2 --- /dev/null +++ b/tests/cases/compiler/unusedImports5.ts @@ -0,0 +1,22 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import {Calculator, test, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports6.ts b/tests/cases/compiler/unusedImports6.ts new file mode 100644 index 0000000000000..6ff45cc1b295e --- /dev/null +++ b/tests/cases/compiler/unusedImports6.ts @@ -0,0 +1,21 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export default function test2() { + +} + +// @Filename: file2.ts +import d from "./file1" + + + diff --git a/tests/cases/compiler/unusedImports7.ts b/tests/cases/compiler/unusedImports7.ts new file mode 100644 index 0000000000000..94df358174524 --- /dev/null +++ b/tests/cases/compiler/unusedImports7.ts @@ -0,0 +1,19 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export default function test2() { + +} + +// @Filename: file2.ts +import * as n from "./file1" + diff --git a/tests/cases/compiler/unusedImports8.ts b/tests/cases/compiler/unusedImports8.ts new file mode 100644 index 0000000000000..e8bd982d0380e --- /dev/null +++ b/tests/cases/compiler/unusedImports8.ts @@ -0,0 +1,22 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import {Calculator as calc, test as t1, test2 as t2} from "./file1" + +var x = new calc(); +x.handleChar(); +t1(); \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports9.ts b/tests/cases/compiler/unusedImports9.ts new file mode 100644 index 0000000000000..2e13e216c1558 --- /dev/null +++ b/tests/cases/compiler/unusedImports9.ts @@ -0,0 +1,18 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +// @Filename: file1.ts +export class Calculator { + handleChar() {} +} + +export function test() { + +} + +export function test2() { + +} + +// @Filename: file2.ts +import c = require('./file1') \ No newline at end of file From 49385f4a86783e29e2974a3a82a78dae40a67bd0 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 20 Jun 2016 17:08:13 -0700 Subject: [PATCH 50/90] Response to PR comments --- src/compiler/checker.ts | 8 +++--- .../unusedClassesinModule1.errors.txt | 13 ++++++++++ .../reference/unusedClassesinModule1.js | 20 +++++++++++++++ .../reference/unusedImports10.errors.txt | 17 +++++++++++++ tests/baselines/reference/unusedImports10.js | 25 +++++++++++++++++++ .../reference/unusedModuleInModule.errors.txt | 10 ++++++++ .../reference/unusedModuleInModule.js | 7 ++++++ .../unusedNamespaceInModule.errors.txt | 11 ++++++++ .../reference/unusedNamespaceInModule.js | 8 ++++++ .../unusedNamespaceInNamespace.errors.txt | 11 ++++++++ .../reference/unusedNamespaceInNamespace.js | 8 ++++++ .../cases/compiler/unusedClassesinModule1.ts | 9 +++++++ tests/cases/compiler/unusedImports10.ts | 13 ++++++++++ tests/cases/compiler/unusedModuleInModule.ts | 6 +++++ .../cases/compiler/unusedNamespaceInModule.ts | 7 ++++++ .../compiler/unusedNamespaceInNamespace.ts | 7 ++++++ 16 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/unusedClassesinModule1.errors.txt create mode 100644 tests/baselines/reference/unusedClassesinModule1.js create mode 100644 tests/baselines/reference/unusedImports10.errors.txt create mode 100644 tests/baselines/reference/unusedImports10.js create mode 100644 tests/baselines/reference/unusedModuleInModule.errors.txt create mode 100644 tests/baselines/reference/unusedModuleInModule.js create mode 100644 tests/baselines/reference/unusedNamespaceInModule.errors.txt create mode 100644 tests/baselines/reference/unusedNamespaceInModule.js create mode 100644 tests/baselines/reference/unusedNamespaceInNamespace.errors.txt create mode 100644 tests/baselines/reference/unusedNamespaceInNamespace.js create mode 100644 tests/cases/compiler/unusedClassesinModule1.ts create mode 100644 tests/cases/compiler/unusedImports10.ts create mode 100644 tests/cases/compiler/unusedModuleInModule.ts create mode 100644 tests/cases/compiler/unusedNamespaceInModule.ts create mode 100644 tests/cases/compiler/unusedNamespaceInNamespace.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 201fb67512fdb..1388df230df6b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14483,7 +14483,8 @@ namespace ts { if ((local.valueDeclaration && local.valueDeclaration.kind)) { error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); } - else if (local.declarations && local.declarations[0].kind === SyntaxKind.InterfaceDeclaration) { + else if (local.declarations && + (local.declarations[0].kind === SyntaxKind.InterfaceDeclaration || local.declarations[0].kind === SyntaxKind.ImportEqualsDeclaration || local.declarations[0].kind === SyntaxKind.ModuleDeclaration)) { error(local.declarations[0], Diagnostics._0_is_declared_but_never_used, key); } } @@ -14525,12 +14526,13 @@ namespace ts { const localValue = node.locals[local]; if (localValue.declarations && !localValue.exportSymbol) { for (const declaration of localValue.declarations) { - if (declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause || declaration.kind === SyntaxKind.NamespaceImport || declaration.kind === SyntaxKind.ImportEqualsDeclaration) { + if (declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause + || declaration.kind === SyntaxKind.NamespaceImport || declaration.kind === SyntaxKind.ImportEqualsDeclaration) { const symbol = declaration.symbol; if (!symbol.hasReference) { error(declaration, Diagnostics._0_is_declared_but_never_used, symbol.name); } - } + } } } } diff --git a/tests/baselines/reference/unusedClassesinModule1.errors.txt b/tests/baselines/reference/unusedClassesinModule1.errors.txt new file mode 100644 index 0000000000000..6f2f936ce2568 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinModule1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedClassesinModule1.ts(3,11): error TS6133: 'Calculator' is declared but never used. + + +==== tests/cases/compiler/unusedClassesinModule1.ts (1 errors) ==== + + module A { + class Calculator { + ~~~~~~~~~~ +!!! error TS6133: 'Calculator' is declared but never used. + public handelChar() { + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedClassesinModule1.js b/tests/baselines/reference/unusedClassesinModule1.js new file mode 100644 index 0000000000000..d3fb726c2dd53 --- /dev/null +++ b/tests/baselines/reference/unusedClassesinModule1.js @@ -0,0 +1,20 @@ +//// [unusedClassesinModule1.ts] + +module A { + class Calculator { + public handelChar() { + } + } +} + +//// [unusedClassesinModule1.js] +var A; +(function (A) { + var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handelChar = function () { + }; + return Calculator; + }()); +})(A || (A = {})); diff --git a/tests/baselines/reference/unusedImports10.errors.txt b/tests/baselines/reference/unusedImports10.errors.txt new file mode 100644 index 0000000000000..f0f32b8c01e5f --- /dev/null +++ b/tests/baselines/reference/unusedImports10.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/unusedImports10.ts(10,5): error TS6133: 'a' is declared but never used. + + +==== tests/cases/compiler/unusedImports10.ts (1 errors) ==== + + module A { + export class Calculator { + public handelChar() { + } + } + } + + module B { + import a = A; + ~~~~~~~~~~~~~ +!!! error TS6133: 'a' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports10.js b/tests/baselines/reference/unusedImports10.js new file mode 100644 index 0000000000000..49365e6e3ff13 --- /dev/null +++ b/tests/baselines/reference/unusedImports10.js @@ -0,0 +1,25 @@ +//// [unusedImports10.ts] + +module A { + export class Calculator { + public handelChar() { + } + } +} + +module B { + import a = A; +} + +//// [unusedImports10.js] +var A; +(function (A) { + var Calculator = (function () { + function Calculator() { + } + Calculator.prototype.handelChar = function () { + }; + return Calculator; + }()); + A.Calculator = Calculator; +})(A || (A = {})); diff --git a/tests/baselines/reference/unusedModuleInModule.errors.txt b/tests/baselines/reference/unusedModuleInModule.errors.txt new file mode 100644 index 0000000000000..2430b07c392cc --- /dev/null +++ b/tests/baselines/reference/unusedModuleInModule.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedModuleInModule.ts(3,12): error TS6133: 'B' is declared but never used. + + +==== tests/cases/compiler/unusedModuleInModule.ts (1 errors) ==== + + module A { + module B {} + ~ +!!! error TS6133: 'B' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedModuleInModule.js b/tests/baselines/reference/unusedModuleInModule.js new file mode 100644 index 0000000000000..68042be932106 --- /dev/null +++ b/tests/baselines/reference/unusedModuleInModule.js @@ -0,0 +1,7 @@ +//// [unusedModuleInModule.ts] + +module A { + module B {} +} + +//// [unusedModuleInModule.js] diff --git a/tests/baselines/reference/unusedNamespaceInModule.errors.txt b/tests/baselines/reference/unusedNamespaceInModule.errors.txt new file mode 100644 index 0000000000000..78e389f4c474e --- /dev/null +++ b/tests/baselines/reference/unusedNamespaceInModule.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedNamespaceInModule.ts(3,15): error TS6133: 'B' is declared but never used. + + +==== tests/cases/compiler/unusedNamespaceInModule.ts (1 errors) ==== + + module A { + namespace B { } + ~ +!!! error TS6133: 'B' is declared but never used. + export namespace C {} + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedNamespaceInModule.js b/tests/baselines/reference/unusedNamespaceInModule.js new file mode 100644 index 0000000000000..238ff84767c76 --- /dev/null +++ b/tests/baselines/reference/unusedNamespaceInModule.js @@ -0,0 +1,8 @@ +//// [unusedNamespaceInModule.ts] + +module A { + namespace B { } + export namespace C {} +} + +//// [unusedNamespaceInModule.js] diff --git a/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt b/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt new file mode 100644 index 0000000000000..53582b8bec71e --- /dev/null +++ b/tests/baselines/reference/unusedNamespaceInNamespace.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedNamespaceInNamespace.ts(3,15): error TS6133: 'B' is declared but never used. + + +==== tests/cases/compiler/unusedNamespaceInNamespace.ts (1 errors) ==== + + namespace A { + namespace B { } + ~ +!!! error TS6133: 'B' is declared but never used. + export namespace C {} + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedNamespaceInNamespace.js b/tests/baselines/reference/unusedNamespaceInNamespace.js new file mode 100644 index 0000000000000..1dc8103d77f4e --- /dev/null +++ b/tests/baselines/reference/unusedNamespaceInNamespace.js @@ -0,0 +1,8 @@ +//// [unusedNamespaceInNamespace.ts] + +namespace A { + namespace B { } + export namespace C {} +} + +//// [unusedNamespaceInNamespace.js] diff --git a/tests/cases/compiler/unusedClassesinModule1.ts b/tests/cases/compiler/unusedClassesinModule1.ts new file mode 100644 index 0000000000000..0efc49663882b --- /dev/null +++ b/tests/cases/compiler/unusedClassesinModule1.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +module A { + class Calculator { + public handelChar() { + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedImports10.ts b/tests/cases/compiler/unusedImports10.ts new file mode 100644 index 0000000000000..1cccfbd38bb49 --- /dev/null +++ b/tests/cases/compiler/unusedImports10.ts @@ -0,0 +1,13 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +module A { + export class Calculator { + public handelChar() { + } + } +} + +module B { + import a = A; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedModuleInModule.ts b/tests/cases/compiler/unusedModuleInModule.ts new file mode 100644 index 0000000000000..dc5f55398a7b5 --- /dev/null +++ b/tests/cases/compiler/unusedModuleInModule.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +module A { + module B {} +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedNamespaceInModule.ts b/tests/cases/compiler/unusedNamespaceInModule.ts new file mode 100644 index 0000000000000..adca8a84187ae --- /dev/null +++ b/tests/cases/compiler/unusedNamespaceInModule.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +module A { + namespace B { } + export namespace C {} +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedNamespaceInNamespace.ts b/tests/cases/compiler/unusedNamespaceInNamespace.ts new file mode 100644 index 0000000000000..8de3768a2014e --- /dev/null +++ b/tests/cases/compiler/unusedNamespaceInNamespace.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +namespace A { + namespace B { } + export namespace C {} +} \ No newline at end of file From f58e8ca3d9129ab51bd657623926f2ca83f320df Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 21 Jun 2016 12:26:54 -0700 Subject: [PATCH 51/90] Modified the test code based on the changes in DiscoverActions branch --- src/harness/fourslash.ts | 2 +- .../{ => codefixes}/unusedIdentifierFixes.ts | 8 ++++---- tests/cases/fourslash/unusedClassInNamespace1.ts | 4 +++- tests/cases/fourslash/unusedClassInNamespace2.ts | 7 ++++++- tests/cases/fourslash/unusedClassInNamespace3.ts | 4 +++- tests/cases/fourslash/unusedClassInNamespace4.ts | 6 +++++- tests/cases/fourslash/unusedClassInNamespace5.ts | 9 ++++++++- tests/cases/fourslash/unusedClassInNamespace6.ts | 11 ++++++++++- .../fourslash/unusedFunctionInNamespace1.ts | 4 +++- .../fourslash/unusedFunctionInNamespace2.ts | 6 +++++- .../fourslash/unusedFunctionInNamespace3.ts | 4 +++- .../fourslash/unusedFunctionInNamespace4.ts | 4 +++- .../fourslash/unusedFunctionInNamespace5.ts | 16 +++++++++++++++- .../fourslash/unusedInterfaceInNamespace1.ts | 4 +++- .../fourslash/unusedInterfaceInNamespace2.ts | 6 +++++- tests/cases/fourslash/unusedLocalsInFunction1.ts | 4 +++- tests/cases/fourslash/unusedLocalsInFunction2.ts | 6 +++++- tests/cases/fourslash/unusedLocalsInFunction3.ts | 7 ++++++- tests/cases/fourslash/unusedLocalsInFunction4.ts | 7 ++++++- tests/cases/fourslash/unusedLocalsInMethodFS1.ts | 8 +++++++- tests/cases/fourslash/unusedLocalsInMethodFS2.ts | 8 +++++++- .../fourslash/unusedLocalsinConstructorFS1.ts | 6 +++++- .../fourslash/unusedLocalsinConstructorFS2.ts | 8 +++++++- tests/cases/fourslash/unusedMethodInClass1.ts | 4 +++- tests/cases/fourslash/unusedMethodInClass2.ts | 6 +++++- tests/cases/fourslash/unusedMethodInClass3.ts | 4 +++- tests/cases/fourslash/unusedMethodInClass4.ts | 6 +++++- .../fourslash/unusedParameterInFunction1.ts | 4 +++- .../fourslash/unusedParameterInFunction2.ts | 5 ++++- .../fourslash/unusedParameterInFunction3.ts | 5 ++++- .../fourslash/unusedParameterInFunction4.ts | 6 +++++- .../fourslash/unusedTypeParametersInClass1.ts | 4 +++- .../fourslash/unusedTypeParametersInClass2.ts | 5 ++++- .../fourslash/unusedTypeParametersInClass3.ts | 6 +++++- tests/cases/fourslash/unusedVariableInClass1.ts | 4 +++- tests/cases/fourslash/unusedVariableInClass2.ts | 5 ++++- tests/cases/fourslash/unusedVariableInClass3.ts | 4 +++- .../fourslash/unusedVariableInNamespace1.ts | 4 +++- .../fourslash/unusedVariableInNamespace2.ts | 9 ++++++++- .../fourslash/unusedVariableInNamespace3.ts | 9 ++++++++- 40 files changed, 196 insertions(+), 43 deletions(-) rename src/services/{ => codefixes}/unusedIdentifierFixes.ts (92%) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 17551a34a739d..4690e6ade6769 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1892,7 +1892,7 @@ namespace FourSlash { // We expect the editor to do the final formatting, so we can strip the compare ignoring whitespace if (this.removeWhitespace(expectedText) !== this.removeWhitespace(actualText)) { - this.raiseError(`Expected insertion: '${expectedText}', actual insertion '${actualText}'.`) + this.raiseError(`Expected insertion: '${expectedText}', actual insertion '${actualText}'.`); } } diff --git a/src/services/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts similarity index 92% rename from src/services/unusedIdentifierFixes.ts rename to src/services/codefixes/unusedIdentifierFixes.ts index 3bdd07b357378..bae0c1b6b20a8 100644 --- a/src/services/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -1,9 +1,9 @@ /* @internal */ -namespace ts.quickFix { - registerQuickFix({ +namespace ts.codeFix { + registerCodeFix({ name: "Remove Unused Identifiers", - errorCode: "TS6133", - getFix: (sourceFile: SourceFile, start: number, end: number): { newText: string; span: { start: number, length: number } }[] => { + errorCodes: ["TS6133"], + getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { const token = getTokenAtPosition(sourceFile, start); if (token.kind === ts.SyntaxKind.Identifier) { diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts index 21138e0ba95e2..2f79362f55a7e 100644 --- a/tests/cases/fourslash/unusedClassInNamespace1.ts +++ b/tests/cases/fourslash/unusedClassInNamespace1.ts @@ -6,4 +6,6 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts index b53c1f2146842..81763971c11c2 100644 --- a/tests/cases/fourslash/unusedClassInNamespace2.ts +++ b/tests/cases/fourslash/unusedClassInNamespace2.ts @@ -8,4 +8,9 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { + export class class2 { + } +}`); + diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts index f91579a3bc2bf..12e9e355d7e0c 100644 --- a/tests/cases/fourslash/unusedClassInNamespace3.ts +++ b/tests/cases/fourslash/unusedClassInNamespace3.ts @@ -8,4 +8,6 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); \ No newline at end of file +verify.codeFixAtPosition(` +namespace Validation { +}`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts index 0361b37a404d6..dffb0eca31ce7 100644 --- a/tests/cases/fourslash/unusedClassInNamespace4.ts +++ b/tests/cases/fourslash/unusedClassInNamespace4.ts @@ -13,4 +13,8 @@ //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); \ No newline at end of file +verify.codeFixAtPosition(` +namespace Validation { + export class c2 { + } +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace5.ts b/tests/cases/fourslash/unusedClassInNamespace5.ts index ebf6a784abc0b..2d7dead616110 100644 --- a/tests/cases/fourslash/unusedClassInNamespace5.ts +++ b/tests/cases/fourslash/unusedClassInNamespace5.ts @@ -17,4 +17,11 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); \ No newline at end of file +verify.codeFixAtPosition(` +namespace Validation { + class c1 { + } + + export class c2 { + } +}`); diff --git a/tests/cases/fourslash/unusedClassInNamespace6.ts b/tests/cases/fourslash/unusedClassInNamespace6.ts index b241301897216..1a2da68204415 100644 --- a/tests/cases/fourslash/unusedClassInNamespace6.ts +++ b/tests/cases/fourslash/unusedClassInNamespace6.ts @@ -16,4 +16,13 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); \ No newline at end of file +verify.codeFixAtPosition(` +namespace Validation { + class c1 { + + } + + export class c2 { + + } +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts index a82dbe8e6c6d7..f91cb99f3002b 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -6,4 +6,6 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts index c8bab09c675a8..f2a9251dbf4d8 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace2.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace2.ts @@ -8,4 +8,8 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { + export function function2() { + } +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts index f6bd71dbe051d..dc707609ecc74 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace3.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace3.ts @@ -8,4 +8,6 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace Validation { +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts index 9edf0e21e3734..280160cc3a219 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace4.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace4.ts @@ -7,4 +7,6 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace Validation { +}`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts index e128d140b3918..c4daa52290b1e 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace5.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace5.ts @@ -21,4 +21,18 @@ //// export let a = function3; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace Validation { + var function1 = function() { + } + + export function function2() { + + } + + function function3() { + function1(); + } + + export let a = function3; +}`); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts index 8774cbbe3effc..db4e789018325 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts @@ -6,4 +6,6 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { +}`); diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts index a51048f14b37d..4b3ad5232edea 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts @@ -8,4 +8,8 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { + export interface interface2 { + } +}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts index ce0e2f618fd4d..2f5693e8ea8f3 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction1.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction1.ts @@ -5,4 +5,6 @@ //// var x = 0;/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +function greeter() { +}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts index d09b2bf37f6fd..87001b1952120 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction2.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts @@ -6,4 +6,8 @@ //// x++; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +function greeter() { + var x; + x++; +}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts index 33ae78df54ca2..5c222a617dddb 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction3.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts @@ -7,4 +7,9 @@ //// z++; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +function greeter() { + var x,z = 1; + x++; + z++; +}`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts index 794b784de3629..4f228ca633ee6 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction4.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -7,4 +7,9 @@ //// z++; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +function greeter() { + var y = 0,z = 1; + y++; + z++; +}`); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts index 1c36d3ea13ff4..ab171cdbeafe6 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -9,4 +9,10 @@ //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + public function1() { + var y = 10; + y++; + } +}`); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts index 63357128876c4..678d0e85522b9 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -9,4 +9,10 @@ //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + public function1() { + var y; + y = 1; + } +}`); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts index f04f517d3c553..af8d4c04db4d7 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts @@ -8,4 +8,8 @@ //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + constructor() { + } +}`); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts index 615d835c4e160..53683506fbc54 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts @@ -10,4 +10,10 @@ //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + constructor() { + var used = "dummy"; + used = used + "second part"; + } +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts index 7c503e5546220..300112498a30c 100644 --- a/tests/cases/fourslash/unusedMethodInClass1.ts +++ b/tests/cases/fourslash/unusedMethodInClass1.ts @@ -6,4 +6,6 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts index ea4318426bdc2..c108bfd642885 100644 --- a/tests/cases/fourslash/unusedMethodInClass2.ts +++ b/tests/cases/fourslash/unusedMethodInClass2.ts @@ -8,4 +8,8 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + public function2() { + } +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts index 4c7244c6dbcb8..1c520ebb6a978 100644 --- a/tests/cases/fourslash/unusedMethodInClass3.ts +++ b/tests/cases/fourslash/unusedMethodInClass3.ts @@ -6,4 +6,6 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { +}`); diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts index c175671dfcfc6..ace5a52c6a2bd 100644 --- a/tests/cases/fourslash/unusedMethodInClass4.ts +++ b/tests/cases/fourslash/unusedMethodInClass4.ts @@ -8,4 +8,8 @@ //// }/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + public function2(){ + } +}`); diff --git a/tests/cases/fourslash/unusedParameterInFunction1.ts b/tests/cases/fourslash/unusedParameterInFunction1.ts index 783a21508bfa8..93017d0fcd0d4 100644 --- a/tests/cases/fourslash/unusedParameterInFunction1.ts +++ b/tests/cases/fourslash/unusedParameterInFunction1.ts @@ -4,4 +4,6 @@ ////function greeter(/*0*/ x/*1*/) { ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +function greeter() { +}`); diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts index 9f2bf526d5f67..0404981063a04 100644 --- a/tests/cases/fourslash/unusedParameterInFunction2.ts +++ b/tests/cases/fourslash/unusedParameterInFunction2.ts @@ -5,4 +5,7 @@ //// x++; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +function greeter(x) { + x++; +}`); diff --git a/tests/cases/fourslash/unusedParameterInFunction3.ts b/tests/cases/fourslash/unusedParameterInFunction3.ts index 450267d270198..cd0eec3fd747b 100644 --- a/tests/cases/fourslash/unusedParameterInFunction3.ts +++ b/tests/cases/fourslash/unusedParameterInFunction3.ts @@ -5,4 +5,7 @@ //// y++; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +function greeter(y) { + y++; +}`); diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts index 848d409e0fbbd..8955f07bb44b2 100644 --- a/tests/cases/fourslash/unusedParameterInFunction4.ts +++ b/tests/cases/fourslash/unusedParameterInFunction4.ts @@ -6,4 +6,8 @@ //// z++; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +function greeter(x,z) { + x++; + z++; +}`); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts index 3c75f874d1f39..b4a397c1ac6c8 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass1.ts @@ -4,4 +4,6 @@ ////class greeter/*0*//*1*/ { ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { +}`); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts index df5d3ffcca0ac..acbf100f38714 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass2.ts @@ -5,4 +5,7 @@ //// public a: X; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + public a: X; +}`); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts index a6a7921c49097..33f5a6c948601 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass3.ts @@ -6,4 +6,8 @@ //// public b: Z; ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + public a: X; + public b: Z; +}`); diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts index 1d4fd6a202148..426af6e5bee48 100644 --- a/tests/cases/fourslash/unusedVariableInClass1.ts +++ b/tests/cases/fourslash/unusedVariableInClass1.ts @@ -5,4 +5,6 @@ //// private greeting: string;/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { +}`); diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts index ee0469d15ddb3..771e93dd75071 100644 --- a/tests/cases/fourslash/unusedVariableInClass2.ts +++ b/tests/cases/fourslash/unusedVariableInClass2.ts @@ -6,4 +6,7 @@ //// private greeting: string;/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { + public greeting1; +}`); diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts index a2a5d36d6dbf3..e8281a53e762a 100644 --- a/tests/cases/fourslash/unusedVariableInClass3.ts +++ b/tests/cases/fourslash/unusedVariableInClass3.ts @@ -5,4 +5,6 @@ //// private X = function() {};/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +class greeter { +}`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts index 17b9e80b4e0e9..5e13e1d5681c6 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace1.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace1.ts @@ -5,4 +5,6 @@ //// let a = "dummy entry";/*1*/ ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { +}`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts index 9a2a5c969dfb4..990787098d2a9 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace2.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -9,4 +9,11 @@ //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { + let a = "dummy entry", c = 0; + export function function1() { + a = "dummy"; + c++; + } +}`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts index 512f2267ae4d4..f58d0a581da0b 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace3.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -9,4 +9,11 @@ //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "" }); +verify.codeFixAtPosition(` +namespace greeter { + let a = "dummy entry", b; + export function function1() { + a = "dummy"; + b = 0; + } +}`); From bdf444cef1d5b5035d200df6ead4b8487ac2c725 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 21 Jun 2016 14:46:29 -0700 Subject: [PATCH 52/90] Add fix for moving the super call to be the first call in the constructor --- src/compiler/diagnosticMessages.json | 4 ++++ src/harness/fourslash.ts | 2 +- src/services/codefixes/superFixes.ts | 35 ++++++++++------------------ tests/cases/fourslash/superFix2.ts | 12 ++++++++-- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8ea7e51948cc5..6d5c72b475966 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2963,5 +2963,9 @@ "Add missing 'super()' call.": { "category": "CodeFix", "code": 90001 + }, + "Make super call the first statement in the constructor.":{ + "category": "CodeFix", + "code": 90002 } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8d9e734127c3d..cddc2de732bac 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1847,7 +1847,7 @@ namespace FourSlash { // We expect the editor to do the final formatting, so we can strip the compare ignoring whitespace if (this.removeWhitespace(expectedText) !== this.removeWhitespace(actualText)) { - this.raiseError(`Expected insertion: '${expectedText}', actual insertion '${actualText}'.`) + this.raiseError(`Expected insertion: '${expectedText}', actual insertion '${actualText}'.`); } } diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 117b17838d50f..ff79e9b97bf6f 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -1,6 +1,5 @@ /* @internal */ namespace ts.codeFix { - function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) { // First token is the open curly, this is where we want to put the 'super' call. return constructor.body.getFirstToken(sourceFile).getEnd(); @@ -11,10 +10,7 @@ namespace ts.codeFix { errorCodes: ["TS2377"], getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { const token = getTokenAtPosition(sourceFile, start); - if (token.kind !== SyntaxKind.ConstructorKeyword) { - // wait why are we not a on a constructor? - throw new Error("Failed to find the constructor."); - } + Debug.assert(token.kind === SyntaxKind.ConstructorKeyword,"Failed to find the constructor."); const newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -23,35 +19,28 @@ namespace ts.codeFix { }); registerCodeFix({ - name: `Make super call the first statement in the constructor.`, + name: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), errorCodes: ["TS17009"], getTextChanges: (sourceFile: SourceFile, start: number, end: number): TextChange[] => { const token = getTokenAtPosition(sourceFile, start); const constructor = getContainingFunction(token); + Debug.assert(constructor.kind === SyntaxKind.Constructor, "Failed to find the constructor."); - if (constructor.kind !== SyntaxKind.Constructor) { - // Wait why are we not a on a constructor? - throw new Error("Failed to find the constructor."); - } const superCall = findSuperCall((constructor).body); - - if (!superCall) { - throw new Error("Failed to find super call."); - } + Debug.assert(!!superCall, "Failed to find super call."); const newPosition = getOpenBraceEnd(constructor, sourceFile); - return [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getFullWidth() } - }]; + newText: superCall.getText(sourceFile), + span: { start: newPosition, length: 0 } + }, + { + newText: "", + span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } + }]; function findSuperCall(n: Node): Node { - if (isSuperCallExpression(n)) { + if (n.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((n).expression)) { return n; } if (isFunctionLike(n)) { diff --git a/tests/cases/fourslash/superFix2.ts b/tests/cases/fourslash/superFix2.ts index 71ec52cfde360..49afc6061a2c0 100644 --- a/tests/cases/fourslash/superFix2.ts +++ b/tests/cases/fourslash/superFix2.ts @@ -4,10 +4,18 @@ ////} ////class C extends Base{ //// private a:number; -//// /*0*/constructor() { +//// constructor() { //// this.a = 12; //// super(); //// } ////} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "super();" }); +verify.codeFixAtPosition(`class Base { +} +class C extends Base { + private a: number; + constructor() { + super(); + this.a = 12; + } +}`); From e077ddec1b0b7e7329a5bdce33820595587ed3b2 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 21 Jun 2016 15:20:00 -0700 Subject: [PATCH 53/90] Code changes for unused imports - Part I --- .../codefixes/unusedIdentifierFixes.ts | 23 ++++++++++++++ tests/cases/fourslash/unusedImports1FS.ts | 14 +++++++++ tests/cases/fourslash/unusedImports2FS.ts | 25 ++++++++++++++++ tests/cases/fourslash/unusedImports3FS.ts | 29 ++++++++++++++++++ tests/cases/fourslash/unusedImports4FS.ts | 30 +++++++++++++++++++ tests/cases/fourslash/unusedImports5FS.ts | 30 +++++++++++++++++++ tests/cases/fourslash/unusedImports6FS.ts | 22 ++++++++++++++ tests/cases/fourslash/unusedImports7FS.ts | 22 ++++++++++++++ tests/cases/fourslash/unusedImports8FS.ts | 30 +++++++++++++++++++ tests/cases/fourslash/unusedImports9FS.ts | 22 ++++++++++++++ 10 files changed, 247 insertions(+) create mode 100644 tests/cases/fourslash/unusedImports1FS.ts create mode 100644 tests/cases/fourslash/unusedImports2FS.ts create mode 100644 tests/cases/fourslash/unusedImports3FS.ts create mode 100644 tests/cases/fourslash/unusedImports4FS.ts create mode 100644 tests/cases/fourslash/unusedImports5FS.ts create mode 100644 tests/cases/fourslash/unusedImports6FS.ts create mode 100644 tests/cases/fourslash/unusedImports7FS.ts create mode 100644 tests/cases/fourslash/unusedImports8FS.ts create mode 100644 tests/cases/fourslash/unusedImports9FS.ts diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index bae0c1b6b20a8..fa89e5bd333fa 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -54,12 +54,35 @@ namespace ts.codeFix { } } } + + if (token.parent.kind === SyntaxKind.ImportSpecifier) { + var namedImports = token.parent.parent; + var elements = namedImports.elements; + if (elements.length === 1) { + //Only 1 import and it is unused. So the entire line could be removed. + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; + } else { + if (elements[0] === token.parent) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }]; + } else { + return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + } + } + } + + if(token.parent.kind === SyntaxKind.ImportClause) { + return [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; + } } if(token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; } + if(token.kind === SyntaxKind.AsteriskToken && token.parent.kind === SyntaxKind.NamespaceImport) { + return [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; + } + throw new Error("No Quick Fix found"); } }); diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts new file mode 100644 index 0000000000000..fb5fbac1dbe7c --- /dev/null +++ b/tests/cases/fourslash/unusedImports1FS.ts @@ -0,0 +1,14 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import {/*0*/Calculator/*1*/} from "./file1" + +// @Filename: file1.ts +//// export class Calculator { +//// +//// } + +verify.codeFixAtPosition(` +import {} from "./file1" +`); diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts new file mode 100644 index 0000000000000..30a606b737c9e --- /dev/null +++ b/tests/cases/fourslash/unusedImports2FS.ts @@ -0,0 +1,25 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import {Calculator} from "./file1" +//// import {/*0*/test/*1*/} from "./file1" + +//// var x = new Calculator(); +//// x.handleChar(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() {} +//// } +//// export function test() { +//// +//// } + +verify.codeFixAtPosition(` +import {Calculator} from "./file1" +import {} from "./file1" + +var x = new Calculator(); +x.handleChar(); +`); diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts new file mode 100644 index 0000000000000..54c28f0fe7fc0 --- /dev/null +++ b/tests/cases/fourslash/unusedImports3FS.ts @@ -0,0 +1,29 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import {/*0*/Calculator,/*1*/ test, test2} from "./file1" + +//// test(); +//// test2(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() {} +//// } + +//// export function test() { +//// +//// } + +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(` +import {test, test2} from "./file1" + +test(); +test2(); +`); + diff --git a/tests/cases/fourslash/unusedImports4FS.ts b/tests/cases/fourslash/unusedImports4FS.ts new file mode 100644 index 0000000000000..638144a383fcb --- /dev/null +++ b/tests/cases/fourslash/unusedImports4FS.ts @@ -0,0 +1,30 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import {Calculator/*0*/, test/*1*/, test2} from "./file1" +//// +//// var x = new Calculator(); +//// x.handleChar(); +//// test2(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() {} +//// } +//// +//// export function test() { +//// +//// } +//// +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(` +import {Calculator, test2} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test2(); +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports5FS.ts b/tests/cases/fourslash/unusedImports5FS.ts new file mode 100644 index 0000000000000..d637488c4a200 --- /dev/null +++ b/tests/cases/fourslash/unusedImports5FS.ts @@ -0,0 +1,30 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import {Calculator, test/*0*/, test2/*1*/} from "./file1" +//// +//// var x = new Calculator(); +//// x.handleChar(); +//// test(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() {} +//// } +//// +//// export function test() { +//// +//// } +//// +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(` +import {Calculator, test} from "./file1" + +var x = new Calculator(); +x.handleChar(); +test(); +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports6FS.ts b/tests/cases/fourslash/unusedImports6FS.ts new file mode 100644 index 0000000000000..2c5d3674eced7 --- /dev/null +++ b/tests/cases/fourslash/unusedImports6FS.ts @@ -0,0 +1,22 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import d from "./file1" + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() { } +//// } + +//// export function test() { +//// +//// } + +//// export default function test2() { +//// +//// } + +verify.codeFixAtPosition(` +import {} from "./file1" +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports7FS.ts b/tests/cases/fourslash/unusedImports7FS.ts new file mode 100644 index 0000000000000..f3ec8c5a2261f --- /dev/null +++ b/tests/cases/fourslash/unusedImports7FS.ts @@ -0,0 +1,22 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import * as n from "./file1" + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() { } +//// } +//// +//// export function test() { +//// +//// } +//// +//// export default function test2() { +//// +//// } + +verify.codeFixAtPosition(` +import {} from "./file1" +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports8FS.ts b/tests/cases/fourslash/unusedImports8FS.ts new file mode 100644 index 0000000000000..9677ba1354d26 --- /dev/null +++ b/tests/cases/fourslash/unusedImports8FS.ts @@ -0,0 +1,30 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import {Calculator as calc, test as t1, test2 as t2} from "./file1" +//// +//// var x = new calc(); +//// x.handleChar(); +//// t1(); + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() { } +//// } + +//// export function test() { +//// +//// } + +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(` +import {Calculator as calc, test as t1} from "./file1" + +var x = new calc(); +x.handleChar(); +t1(); +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports9FS.ts b/tests/cases/fourslash/unusedImports9FS.ts new file mode 100644 index 0000000000000..aaeb2545dba63 --- /dev/null +++ b/tests/cases/fourslash/unusedImports9FS.ts @@ -0,0 +1,22 @@ +/// + +// @noUnusedLocals: true +// @Filename: file2.ts +//// import c = require('./file1') + +// @Filename: file1.ts +//// export class Calculator { +//// handleChar() { } +//// } +//// +//// export function test() { +//// +//// } +//// +//// export function test2() { +//// +//// } + +verify.codeFixAtPosition(` +import {} = require('./file1') +`); From 5993015ff3bb314e56aa85acd2ec6925fe502e2c Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 21 Jun 2016 15:46:29 -0700 Subject: [PATCH 54/90] Code change specific to position of Import Declaration --- src/compiler/checker.ts | 10 ++++++---- tests/baselines/reference/unusedImports9.errors.txt | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1388df230df6b..44fc911e8292f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14526,12 +14526,14 @@ namespace ts { const localValue = node.locals[local]; if (localValue.declarations && !localValue.exportSymbol) { for (const declaration of localValue.declarations) { - if (declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause - || declaration.kind === SyntaxKind.NamespaceImport || declaration.kind === SyntaxKind.ImportEqualsDeclaration) { - const symbol = declaration.symbol; - if (!symbol.hasReference) { + const symbol = declaration.symbol; + if (!symbol.hasReference) { + if (declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause || declaration.kind === SyntaxKind.NamespaceImport) { error(declaration, Diagnostics._0_is_declared_but_never_used, symbol.name); } + else if (declaration.kind === SyntaxKind.ImportEqualsDeclaration) { + error(declaration.name, Diagnostics._0_is_declared_but_never_used, symbol.name); + } } } } diff --git a/tests/baselines/reference/unusedImports9.errors.txt b/tests/baselines/reference/unusedImports9.errors.txt index 007ac0088c835..8503a35e29073 100644 --- a/tests/baselines/reference/unusedImports9.errors.txt +++ b/tests/baselines/reference/unusedImports9.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/file2.ts(1,1): error TS6133: 'c' is declared but never used. +tests/cases/compiler/file2.ts(1,8): error TS6133: 'c' is declared but never used. ==== tests/cases/compiler/file2.ts (1 errors) ==== import c = require('./file1') - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS6133: 'c' is declared but never used. ==== tests/cases/compiler/file1.ts (0 errors) ==== From 45d449f80ef8b316f6b7d39002418a0dc2c9bc3b Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 21 Jun 2016 16:07:07 -0700 Subject: [PATCH 55/90] Additional code changes for unused imports --- .../codefixes/unusedIdentifierFixes.ts | 4 +++ tests/cases/fourslash/unusedImports10FS.ts | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/cases/fourslash/unusedImports10FS.ts diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index fa89e5bd333fa..429974b395dc8 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -73,6 +73,10 @@ namespace ts.codeFix { if(token.parent.kind === SyntaxKind.ImportClause) { return [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; } + + if(token.parent.kind === SyntaxKind.ImportEqualsDeclaration) { + return [{ newText: "{}", span: { start: token.pos, length: token.end - token.pos } }]; + } } if(token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts new file mode 100644 index 0000000000000..e20330c3a559f --- /dev/null +++ b/tests/cases/fourslash/unusedImports10FS.ts @@ -0,0 +1,27 @@ +/// + +// @noUnusedLocals: true +//// module A { +//// export class Calculator { +//// public handelChar() { +//// } +//// } +//// } + +//// module B { +//// import a = A; +//// } + +verify.codeFixAtPosition(` +module A { + export class Calculator { + public handelChar() { + } + } +} + +module B { + import {} = A; +} +`); + From f464f92aeee2887169aa9e2c863dfbd05b05e9ea Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 21 Jun 2016 16:18:48 -0700 Subject: [PATCH 56/90] Code change for handling the position for unused import --- src/compiler/checker.ts | 5 ++++- tests/baselines/reference/unusedImports10.errors.txt | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 44fc911e8292f..d2660db039098 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14484,9 +14484,12 @@ namespace ts { error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); } else if (local.declarations && - (local.declarations[0].kind === SyntaxKind.InterfaceDeclaration || local.declarations[0].kind === SyntaxKind.ImportEqualsDeclaration || local.declarations[0].kind === SyntaxKind.ModuleDeclaration)) { + (local.declarations[0].kind === SyntaxKind.InterfaceDeclaration || local.declarations[0].kind === SyntaxKind.ModuleDeclaration)) { error(local.declarations[0], Diagnostics._0_is_declared_but_never_used, key); } + else if (local.declarations && local.declarations[0].kind === SyntaxKind.ImportEqualsDeclaration) { + error(local.declarations[0].name, Diagnostics._0_is_declared_but_never_used, key); + } } } } diff --git a/tests/baselines/reference/unusedImports10.errors.txt b/tests/baselines/reference/unusedImports10.errors.txt index f0f32b8c01e5f..c4937a420f99f 100644 --- a/tests/baselines/reference/unusedImports10.errors.txt +++ b/tests/baselines/reference/unusedImports10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedImports10.ts(10,5): error TS6133: 'a' is declared but never used. +tests/cases/compiler/unusedImports10.ts(10,12): error TS6133: 'a' is declared but never used. ==== tests/cases/compiler/unusedImports10.ts (1 errors) ==== @@ -12,6 +12,6 @@ tests/cases/compiler/unusedImports10.ts(10,5): error TS6133: 'a' is declared but module B { import a = A; - ~~~~~~~~~~~~~ + ~ !!! error TS6133: 'a' is declared but never used. } \ No newline at end of file From 817091c19dad6b02dedba1674269fe3df431daa5 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Tue, 21 Jun 2016 17:38:47 -0700 Subject: [PATCH 57/90] Code changes to handle For statements --- .../codefixes/unusedIdentifierFixes.ts | 42 +++++++++++++++---- .../fourslash/unusedNamespaceInNamespace.ts | 13 ++++++ .../cases/fourslash/unusedVariableInBlocks.ts | 19 +++++++++ .../fourslash/unusedVariableInForLoop1FS.ts | 17 ++++++++ .../fourslash/unusedVariableInForLoop2FS.ts | 16 +++++++ .../fourslash/unusedVariableInForLoop3FS.ts | 17 ++++++++ .../fourslash/unusedVariableInForLoop4FS.ts | 17 ++++++++ .../fourslash/unusedVariableInForLoop5FS.ts | 16 +++++++ .../fourslash/unusedVariableInForLoop6FS.ts | 16 +++++++ .../fourslash/unusedVariableInForLoop7FS.ts | 18 ++++++++ 10 files changed, 183 insertions(+), 8 deletions(-) create mode 100644 tests/cases/fourslash/unusedNamespaceInNamespace.ts create mode 100644 tests/cases/fourslash/unusedVariableInBlocks.ts create mode 100644 tests/cases/fourslash/unusedVariableInForLoop1FS.ts create mode 100644 tests/cases/fourslash/unusedVariableInForLoop2FS.ts create mode 100644 tests/cases/fourslash/unusedVariableInForLoop3FS.ts create mode 100644 tests/cases/fourslash/unusedVariableInForLoop4FS.ts create mode 100644 tests/cases/fourslash/unusedVariableInForLoop5FS.ts create mode 100644 tests/cases/fourslash/unusedVariableInForLoop6FS.ts create mode 100644 tests/cases/fourslash/unusedVariableInForLoop7FS.ts diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 429974b395dc8..ab8e89bcd306b 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -8,15 +8,40 @@ namespace ts.codeFix { if (token.kind === ts.SyntaxKind.Identifier) { if (token.parent.kind === ts.SyntaxKind.VariableDeclaration) { - var variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return [{ newText: "", span: { start: variableStatement.pos, length: variableStatement.end - variableStatement.pos} }]; - } else { - var declarations = variableStatement.declarationList.declarations; - if (declarations[0].name === token) { - return [{ newText: "", span: { start: token.parent.pos + 1, length: token.parent.end - token.parent.pos } }]; + if (token.parent.parent.parent.kind === SyntaxKind.ForStatement) { + var forStatement = token.parent.parent.parent; + var initializer = forStatement.initializer; + if (initializer.declarations.length === 1) { + return [{ newText: "", span: { start: initializer.pos, length: initializer.end - initializer.pos } }]; } else { - return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + if (initializer.declarations[0] === token.parent) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }]; + } else { + return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + } + } + } + else if (token.parent.parent.parent.kind === SyntaxKind.ForInStatement) { + var forInStatement = token.parent.parent.parent; + var initializer = forInStatement.initializer; + return [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }]; + } + else if (token.parent.parent.parent.kind === SyntaxKind.ForOfStatement) { + var forOfStatement = token.parent.parent.parent; + var initializer = forOfStatement.initializer; + return [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }]; + } + else { + var variableStatement = token.parent.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return [{ newText: "", span: { start: variableStatement.pos, length: variableStatement.end - variableStatement.pos } }]; + } else { + var declarations = variableStatement.declarationList.declarations; + if (declarations[0].name === token) { + return [{ newText: "", span: { start: token.parent.pos + 1, length: token.parent.end - token.parent.pos } }]; + } else { + return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + } } } } @@ -25,6 +50,7 @@ namespace ts.codeFix { token.parent.kind === SyntaxKind.ClassDeclaration || token.parent.kind === SyntaxKind.InterfaceDeclaration || token.parent.kind === SyntaxKind.MethodDeclaration || + token.parent.kind === SyntaxKind.ModuleDeclaration || token.parent.kind === SyntaxKind.ArrowFunction) { return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; } diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts new file mode 100644 index 0000000000000..a550fa2f925fc --- /dev/null +++ b/tests/cases/fourslash/unusedNamespaceInNamespace.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +//// namespace A { +//// namespace B { +//// } +//// } + +verify.codeFixAtPosition(` +namespace A { +} +`); + diff --git a/tests/cases/fourslash/unusedVariableInBlocks.ts b/tests/cases/fourslash/unusedVariableInBlocks.ts new file mode 100644 index 0000000000000..0a9cfe6f91dc4 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInBlocks.ts @@ -0,0 +1,19 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// let x = 10; +//// { +//// let x = 11; +//// } +//// x; +//// } + +verify.codeFixAtPosition(` +function f1 () { + let x = 10; + { + } + x; +} +`); diff --git a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts new file mode 100644 index 0000000000000..f8644a1a90418 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts @@ -0,0 +1,17 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for(var i = 0; ;) { +//// +//// } +//// } + +verify.codeFixAtPosition(` +function f1 () { + for(; ;) { + + } +} +`); + diff --git a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts new file mode 100644 index 0000000000000..30c34546d909c --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts @@ -0,0 +1,16 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for(var i = 0, j= 0; ;i++) { +//// +//// } +//// } + +verify.codeFixAtPosition(` +function f1 () { + for(var i = 0; ;i++) { + + } +} +`); diff --git a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts new file mode 100644 index 0000000000000..10014ffa5cbe0 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts @@ -0,0 +1,17 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for(var i = 0, j= 0, k=0; ;i++, k++) { +//// +//// } +//// } + +verify.codeFixAtPosition(` +function f1 () { + for(var i = 0, k=0; ;i++,k++) { + + } +} +`); + diff --git a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts new file mode 100644 index 0000000000000..648a2fdd07bb0 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts @@ -0,0 +1,17 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for(var i = 0, j= 0, k=0; ;j++, k++) { +//// +//// } +//// } + +verify.codeFixAtPosition(` +function f1 () { + for(var j = 0, k=0; ;j++,k++) { + + } +} +`); + diff --git a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts new file mode 100644 index 0000000000000..bf8698aad2635 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts @@ -0,0 +1,16 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for (const elem in ["a", "b", "c"]) { +//// +//// } +//// } + +verify.codeFixAtPosition(` +function f1 () { + for (const {} in ["a", "b", "c"]) { + } +} +`); + diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts new file mode 100644 index 0000000000000..f48233f2c2ab8 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts @@ -0,0 +1,16 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for (const elem of ["a", "b", "c"]) { +//// +//// } +//// } + +verify.codeFixAtPosition(` +function f1 () { + for (const {} of ["a", "b", "c"]) { + } +} +`); + diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts new file mode 100644 index 0000000000000..d1af8351b2db9 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -0,0 +1,18 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// for (const elem of ["a", "b", "c"]) { +//// elem; +//// var x = 20; +//// } +//// } +//// + +verify.codeFixAtPosition(` +function f1 () { + for (const elem of ["a", "b", "c"]) { + elem; + } +} +`); From 3b5f8d27b0dbfc5ce921929a464b77ebcb8262fa Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 22 Jun 2016 12:57:07 -0700 Subject: [PATCH 58/90] New scenarios for handling parameters in lambda function, type parameters in methods, etc. --- src/compiler/checker.ts | 68 ++++++++----------- .../unusedParametersInLambda1.errors.txt | 13 ++++ .../reference/unusedParametersInLambda1.js | 19 ++++++ .../unusedParametersInLambda2.errors.txt | 14 ++++ .../reference/unusedParametersInLambda2.js | 21 ++++++ .../unusedTypeParameterInFunction1.errors.txt | 10 +++ .../unusedTypeParameterInFunction1.js | 9 +++ .../unusedTypeParameterInFunction2.errors.txt | 11 +++ .../unusedTypeParameterInFunction2.js | 12 ++++ .../unusedTypeParameterInFunction3.errors.txt | 13 ++++ .../unusedTypeParameterInFunction3.js | 16 +++++ .../unusedTypeParameterInFunction4.errors.txt | 13 ++++ .../unusedTypeParameterInFunction4.js | 16 +++++ .../unusedTypeParameterInLambda1.errors.txt | 14 ++++ .../reference/unusedTypeParameterInLambda1.js | 20 ++++++ .../unusedTypeParameterInLambda2.errors.txt | 15 ++++ .../reference/unusedTypeParameterInLambda2.js | 23 +++++++ .../unusedTypeParameterInMethod1.errors.txt | 15 ++++ .../reference/unusedTypeParameterInMethod1.js | 23 +++++++ .../unusedTypeParameterInMethod2.errors.txt | 15 ++++ .../reference/unusedTypeParameterInMethod2.js | 23 +++++++ .../unusedTypeParameterInMethod3.errors.txt | 15 ++++ .../reference/unusedTypeParameterInMethod3.js | 23 +++++++ .../unusedTypeParameterInMethod4.errors.txt | 12 ++++ .../reference/unusedTypeParameterInMethod4.js | 16 +++++ .../unusedTypeParameterInMethod5.errors.txt | 12 ++++ .../reference/unusedTypeParameterInMethod5.js | 16 +++++ .../compiler/unusedParametersInLambda1.ts | 9 +++ .../compiler/unusedParametersInLambda2.ts | 10 +++ .../unusedTypeParameterInFunction1.ts | 6 ++ .../unusedTypeParameterInFunction2.ts | 7 ++ .../unusedTypeParameterInFunction3.ts | 9 +++ .../unusedTypeParameterInFunction4.ts | 9 +++ .../compiler/unusedTypeParameterInLambda1.ts | 10 +++ .../compiler/unusedTypeParameterInLambda2.ts | 11 +++ .../compiler/unusedTypeParameterInMethod1.ts | 11 +++ .../compiler/unusedTypeParameterInMethod2.ts | 11 +++ .../compiler/unusedTypeParameterInMethod3.ts | 11 +++ .../compiler/unusedTypeParameterInMethod4.ts | 8 +++ .../compiler/unusedTypeParameterInMethod5.ts | 8 +++ 40 files changed, 556 insertions(+), 41 deletions(-) create mode 100644 tests/baselines/reference/unusedParametersInLambda1.errors.txt create mode 100644 tests/baselines/reference/unusedParametersInLambda1.js create mode 100644 tests/baselines/reference/unusedParametersInLambda2.errors.txt create mode 100644 tests/baselines/reference/unusedParametersInLambda2.js create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction1.js create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction2.js create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction3.js create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInFunction4.js create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda1.js create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda2.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod1.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod2.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod3.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod4.js create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInMethod5.js create mode 100644 tests/cases/compiler/unusedParametersInLambda1.ts create mode 100644 tests/cases/compiler/unusedParametersInLambda2.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInFunction1.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInFunction2.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInFunction3.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInFunction4.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInLambda1.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInLambda2.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod1.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod2.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod3.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod4.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInMethod5.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d2660db039098..9af1a4d8e0632 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8278,18 +8278,11 @@ namespace ts { return container === declarationContainer; } - function updateReferencesForTypedParameters(node: TypeNode): void { - const symbol = getNodeLinks(node).resolvedSymbol; - if (symbol) { - symbol.hasReference = true; - } - } - function updateReferencesForInterfaceHeritiageClauseTargets(node: InterfaceDeclaration): void { const extendedTypeNode = getClassExtendsHeritageClauseElement(node); if (extendedTypeNode) { const t = getTypeFromTypeNode(extendedTypeNode); - if (t !== unknownType && t.symbol) { + if (t !== unknownType && t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { t.symbol.hasReference = true; } } @@ -8297,7 +8290,7 @@ namespace ts { function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); - if (symbol && !isInAmbientContext(node)) { + if (symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { symbol.hasReference = true; } @@ -10189,7 +10182,10 @@ namespace ts { return unknownType; } - prop.hasReference = true; + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + prop.hasReference = true; + } + getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & SymbolFlags.Class) { @@ -12121,7 +12117,6 @@ namespace ts { if (node.body.kind === SyntaxKind.Block) { checkSourceElement(node.body); - checkUnusedLocals(node); } else { // From within an async function you can return either a non-promise value or a promise. Any @@ -12140,6 +12135,8 @@ namespace ts { } } } + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); } } @@ -13339,9 +13336,6 @@ namespace ts { checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name); checkVariableLikeDeclaration(node); - if (node.type && node.type.kind === SyntaxKind.TypeReference) { - updateReferencesForTypedParameters(node.type); - } } function checkMethodDeclaration(node: MethodDeclaration) { @@ -13365,7 +13359,8 @@ namespace ts { checkGrammarConstructorTypeParameters(node) || checkGrammarConstructorTypeAnnotation(node); checkSourceElement(node.body); - checkUnusedLocals(node); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); const symbol = getSymbolOfNode(node); const firstDeclaration = getDeclarationOfKind(symbol, node.kind); @@ -13559,7 +13554,7 @@ namespace ts { checkGrammarTypeArguments(node, node.typeArguments); const type = getTypeFromTypeReference(node); if (type !== unknownType) { - if (type.symbol) { + if (type.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { type.symbol.hasReference = true; } if (node.typeArguments) { @@ -14410,7 +14405,8 @@ namespace ts { } checkSourceElement(node.body); - checkUnusedLocals(node); + checkUnusedIdentifiers(node); + checkUnusedTypeParameters(node); if (!node.asteriskToken) { const returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); @@ -14432,33 +14428,16 @@ namespace ts { } } - function checkUnusedLocals(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block): void { - checkUnusedIdentifiers(node); - checkUnusedParameters(node); - } - function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block): void { - if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { + if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { const local = node.locals[key]; - if (!local.hasReference && local.valueDeclaration && local.valueDeclaration.kind) { - if (local.valueDeclaration.kind !== SyntaxKind.Parameter) { + if (!local.hasReference && local.valueDeclaration) { + if (local.valueDeclaration.kind !== SyntaxKind.Parameter && compilerOptions.noUnusedLocals) { error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); } - } - } - } - } - } - - function checkUnusedParameters(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block): void { - if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && compilerOptions.noUnusedParameters && !isInAmbientContext(node)) { - for (const key in node.locals) { - if (hasProperty(node.locals, key)) { - const local = node.locals[key]; - if (!local.hasReference && local.valueDeclaration && local.valueDeclaration.kind) { - if (local.valueDeclaration.kind === SyntaxKind.Parameter) { + else if (local.valueDeclaration.kind === SyntaxKind.Parameter && compilerOptions.noUnusedParameters) { if (local.valueDeclaration.modifiers) { if (getCombinedNodeFlags(local.valueDeclaration) & NodeFlags.Private) { error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); @@ -14507,7 +14486,11 @@ namespace ts { } } } + } + } + function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration) { + if (compilerOptions.noUnusedLocals) { if (node.typeParameters) { for (const typeParameter of node.typeParameters) { if (!typeParameter.symbol.hasReference) { @@ -14551,7 +14534,7 @@ namespace ts { checkGrammarStatementInAmbientContext(node); } forEach(node.statements, checkSourceElement); - checkUnusedLocals(node); + checkUnusedIdentifiers(node); } function checkCollisionWithArgumentsInGeneratedCode(node: SignatureDeclaration) { @@ -15706,6 +15689,7 @@ namespace ts { checkClassLikeDeclaration(node); forEach(node.members, checkSourceElement); checkUnusedPrivates(node); + checkUnusedTypeParameters(node); } function checkClassLikeDeclaration(node: ClassLikeDeclaration) { @@ -15770,7 +15754,7 @@ namespace ts { if (produceDiagnostics) { const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - if (t.symbol) { + if (t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { t.symbol.hasReference = true; } const declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; @@ -16596,7 +16580,9 @@ namespace ts { if (target.flags & SymbolFlags.Type) { checkTypeNameIsReserved(node.name, Diagnostics.Import_name_cannot_be_0); } - target.hasReference = true; + if ((compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { + target.hasReference = true; + } } } else { diff --git a/tests/baselines/reference/unusedParametersInLambda1.errors.txt b/tests/baselines/reference/unusedParametersInLambda1.errors.txt new file mode 100644 index 0000000000000..2c54de1d571f6 --- /dev/null +++ b/tests/baselines/reference/unusedParametersInLambda1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedParametersInLambda1.ts(4,17): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedParametersInLambda1.ts (1 errors) ==== + + class A { + public f1() { + return (X) => { + ~ +!!! error TS6133: 'X' is declared but never used. + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersInLambda1.js b/tests/baselines/reference/unusedParametersInLambda1.js new file mode 100644 index 0000000000000..c3ca54bd6a775 --- /dev/null +++ b/tests/baselines/reference/unusedParametersInLambda1.js @@ -0,0 +1,19 @@ +//// [unusedParametersInLambda1.ts] + +class A { + public f1() { + return (X) => { + } + } +} + +//// [unusedParametersInLambda1.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + return function (X) { + }; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedParametersInLambda2.errors.txt b/tests/baselines/reference/unusedParametersInLambda2.errors.txt new file mode 100644 index 0000000000000..3044e6d9c88be --- /dev/null +++ b/tests/baselines/reference/unusedParametersInLambda2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedParametersInLambda2.ts(4,17): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedParametersInLambda2.ts (1 errors) ==== + + class A { + public f1() { + return (X, Y) => { + ~ +!!! error TS6133: 'X' is declared but never used. + Y; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersInLambda2.js b/tests/baselines/reference/unusedParametersInLambda2.js new file mode 100644 index 0000000000000..b7833af340eaf --- /dev/null +++ b/tests/baselines/reference/unusedParametersInLambda2.js @@ -0,0 +1,21 @@ +//// [unusedParametersInLambda2.ts] + +class A { + public f1() { + return (X, Y) => { + Y; + } + } +} + +//// [unusedParametersInLambda2.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + return function (X, Y) { + Y; + }; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt new file mode 100644 index 0000000000000..afbdb09c16257 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedTypeParameterInFunction1.ts(2,13): error TS6133: 'T' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInFunction1.ts (1 errors) ==== + + function f1() { + ~ +!!! error TS6133: 'T' is declared but never used. + + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction1.js b/tests/baselines/reference/unusedTypeParameterInFunction1.js new file mode 100644 index 0000000000000..6ecf90343b761 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction1.js @@ -0,0 +1,9 @@ +//// [unusedTypeParameterInFunction1.ts] + +function f1() { + +} + +//// [unusedTypeParameterInFunction1.js] +function f1() { +} diff --git a/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt new file mode 100644 index 0000000000000..0097cc99810a9 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedTypeParameterInFunction2.ts(2,16): error TS6133: 'Y' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInFunction2.ts (1 errors) ==== + + function f1() { + ~ +!!! error TS6133: 'Y' is declared but never used. + var a: X; + a; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction2.js b/tests/baselines/reference/unusedTypeParameterInFunction2.js new file mode 100644 index 0000000000000..7c3eaa9112726 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction2.js @@ -0,0 +1,12 @@ +//// [unusedTypeParameterInFunction2.ts] + +function f1() { + var a: X; + a; +} + +//// [unusedTypeParameterInFunction2.js] +function f1() { + var a; + a; +} diff --git a/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt new file mode 100644 index 0000000000000..7a2e33769da4c --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction3.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedTypeParameterInFunction3.ts(2,16): error TS6133: 'Y' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInFunction3.ts (1 errors) ==== + + function f1() { + ~ +!!! error TS6133: 'Y' is declared but never used. + var a: X; + var b: Z; + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction3.js b/tests/baselines/reference/unusedTypeParameterInFunction3.js new file mode 100644 index 0000000000000..335a5668acc57 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction3.js @@ -0,0 +1,16 @@ +//// [unusedTypeParameterInFunction3.ts] + +function f1() { + var a: X; + var b: Z; + a; + b; +} + +//// [unusedTypeParameterInFunction3.js] +function f1() { + var a; + var b; + a; + b; +} diff --git a/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt b/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt new file mode 100644 index 0000000000000..7840ff31df3ca --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction4.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/unusedTypeParameterInFunction4.ts(2,13): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInFunction4.ts (1 errors) ==== + + function f1() { + ~ +!!! error TS6133: 'X' is declared but never used. + var a: Y; + var b: Z; + a; + b; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInFunction4.js b/tests/baselines/reference/unusedTypeParameterInFunction4.js new file mode 100644 index 0000000000000..e6b26dfbd4e76 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInFunction4.js @@ -0,0 +1,16 @@ +//// [unusedTypeParameterInFunction4.ts] + +function f1() { + var a: Y; + var b: Z; + a; + b; +} + +//// [unusedTypeParameterInFunction4.js] +function f1() { + var a; + var b; + a; + b; +} diff --git a/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt new file mode 100644 index 0000000000000..a84df63b3176a --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedTypeParameterInLambda1.ts(4,17): error TS6133: 'T' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInLambda1.ts (1 errors) ==== + + class A { + public f1() { + return () => { + ~ +!!! error TS6133: 'T' is declared but never used. + + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInLambda1.js b/tests/baselines/reference/unusedTypeParameterInLambda1.js new file mode 100644 index 0000000000000..0f55a4a32a194 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda1.js @@ -0,0 +1,20 @@ +//// [unusedTypeParameterInLambda1.ts] + +class A { + public f1() { + return () => { + + } + } +} + +//// [unusedTypeParameterInLambda1.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + return function () { + }; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt new file mode 100644 index 0000000000000..c11047434722a --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda2.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedTypeParameterInLambda2.ts(4,17): error TS6133: 'T' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInLambda2.ts (1 errors) ==== + + class A { + public f1() { + return () => { + ~ +!!! error TS6133: 'T' is declared but never used. + var a: X; + a; + } + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInLambda2.js b/tests/baselines/reference/unusedTypeParameterInLambda2.js new file mode 100644 index 0000000000000..16545eb13f25a --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda2.js @@ -0,0 +1,23 @@ +//// [unusedTypeParameterInLambda2.ts] + +class A { + public f1() { + return () => { + var a: X; + a; + } + } +} + +//// [unusedTypeParameterInLambda2.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + return function () { + var a; + a; + }; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt new file mode 100644 index 0000000000000..3b39d9b35ecc9 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod1.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedTypeParameterInMethod1.ts(3,15): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod1.ts (1 errors) ==== + + class A { + public f1() { + ~ +!!! error TS6133: 'X' is declared but never used. + var a: Y; + var b: Z; + a; + b; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod1.js b/tests/baselines/reference/unusedTypeParameterInMethod1.js new file mode 100644 index 0000000000000..e5ab22095b83b --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod1.js @@ -0,0 +1,23 @@ +//// [unusedTypeParameterInMethod1.ts] + +class A { + public f1() { + var a: Y; + var b: Z; + a; + b; + } +} + +//// [unusedTypeParameterInMethod1.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + var a; + var b; + a; + b; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt new file mode 100644 index 0000000000000..f1dafb5a19e7a --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod2.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedTypeParameterInMethod2.ts(3,18): error TS6133: 'Y' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod2.ts (1 errors) ==== + + class A { + public f1() { + ~ +!!! error TS6133: 'Y' is declared but never used. + var a: X; + var b: Z; + a; + b; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod2.js b/tests/baselines/reference/unusedTypeParameterInMethod2.js new file mode 100644 index 0000000000000..9fb785634c6e0 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod2.js @@ -0,0 +1,23 @@ +//// [unusedTypeParameterInMethod2.ts] + +class A { + public f1() { + var a: X; + var b: Z; + a; + b; + } +} + +//// [unusedTypeParameterInMethod2.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + var a; + var b; + a; + b; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt new file mode 100644 index 0000000000000..04a43e3d011f4 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod3.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/unusedTypeParameterInMethod3.ts(3,21): error TS6133: 'Z' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod3.ts (1 errors) ==== + + class A { + public f1() { + ~ +!!! error TS6133: 'Z' is declared but never used. + var a: X; + var b: Y; + a; + b; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod3.js b/tests/baselines/reference/unusedTypeParameterInMethod3.js new file mode 100644 index 0000000000000..b81d0796dc4e6 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod3.js @@ -0,0 +1,23 @@ +//// [unusedTypeParameterInMethod3.ts] + +class A { + public f1() { + var a: X; + var b: Y; + a; + b; + } +} + +//// [unusedTypeParameterInMethod3.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + var a; + var b; + a; + b; + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt new file mode 100644 index 0000000000000..9026aaad32143 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod4.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedTypeParameterInMethod4.ts(3,15): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod4.ts (1 errors) ==== + + class A { + public f1() { + ~ +!!! error TS6133: 'X' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod4.js b/tests/baselines/reference/unusedTypeParameterInMethod4.js new file mode 100644 index 0000000000000..4db72f193a208 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod4.js @@ -0,0 +1,16 @@ +//// [unusedTypeParameterInMethod4.ts] + +class A { + public f1() { + + } +} + +//// [unusedTypeParameterInMethod4.js] +var A = (function () { + function A() { + } + A.prototype.f1 = function () { + }; + return A; +}()); diff --git a/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt b/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt new file mode 100644 index 0000000000000..20d95ec4bb5fc --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod5.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedTypeParameterInMethod5.ts(3,26): error TS6133: 'X' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInMethod5.ts (1 errors) ==== + + class A { + public f1 = function() { + ~ +!!! error TS6133: 'X' is declared but never used. + + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInMethod5.js b/tests/baselines/reference/unusedTypeParameterInMethod5.js new file mode 100644 index 0000000000000..e1863b4cbb180 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInMethod5.js @@ -0,0 +1,16 @@ +//// [unusedTypeParameterInMethod5.ts] + +class A { + public f1 = function() { + + } +} + +//// [unusedTypeParameterInMethod5.js] +var A = (function () { + function A() { + this.f1 = function () { + }; + } + return A; +}()); diff --git a/tests/cases/compiler/unusedParametersInLambda1.ts b/tests/cases/compiler/unusedParametersInLambda1.ts new file mode 100644 index 0000000000000..431ac1eb1dce7 --- /dev/null +++ b/tests/cases/compiler/unusedParametersInLambda1.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + return (X) => { + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedParametersInLambda2.ts b/tests/cases/compiler/unusedParametersInLambda2.ts new file mode 100644 index 0000000000000..ed4dfb3404b11 --- /dev/null +++ b/tests/cases/compiler/unusedParametersInLambda2.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + return (X, Y) => { + Y; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInFunction1.ts b/tests/cases/compiler/unusedTypeParameterInFunction1.ts new file mode 100644 index 0000000000000..421d2aa7b3700 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInFunction1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInFunction2.ts b/tests/cases/compiler/unusedTypeParameterInFunction2.ts new file mode 100644 index 0000000000000..76eeb11bb34fc --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInFunction2.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + var a: X; + a; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInFunction3.ts b/tests/cases/compiler/unusedTypeParameterInFunction3.ts new file mode 100644 index 0000000000000..37f01468156e3 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInFunction3.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + var a: X; + var b: Z; + a; + b; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInFunction4.ts b/tests/cases/compiler/unusedTypeParameterInFunction4.ts new file mode 100644 index 0000000000000..56549d9397646 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInFunction4.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + var a: Y; + var b: Z; + a; + b; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInLambda1.ts b/tests/cases/compiler/unusedTypeParameterInLambda1.ts new file mode 100644 index 0000000000000..dd4dbe7824a7a --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInLambda1.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + return () => { + + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInLambda2.ts b/tests/cases/compiler/unusedTypeParameterInLambda2.ts new file mode 100644 index 0000000000000..73177a8b09dab --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInLambda2.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + return () => { + var a: X; + a; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod1.ts b/tests/cases/compiler/unusedTypeParameterInMethod1.ts new file mode 100644 index 0000000000000..f58bde3d2a100 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod1.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + var a: Y; + var b: Z; + a; + b; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod2.ts b/tests/cases/compiler/unusedTypeParameterInMethod2.ts new file mode 100644 index 0000000000000..f344d188b0a5a --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod2.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + var a: X; + var b: Z; + a; + b; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod3.ts b/tests/cases/compiler/unusedTypeParameterInMethod3.ts new file mode 100644 index 0000000000000..9734136bd0359 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod3.ts @@ -0,0 +1,11 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + var a: X; + var b: Y; + a; + b; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod4.ts b/tests/cases/compiler/unusedTypeParameterInMethod4.ts new file mode 100644 index 0000000000000..ef487d1111869 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod4.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1() { + + } +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInMethod5.ts b/tests/cases/compiler/unusedTypeParameterInMethod5.ts new file mode 100644 index 0000000000000..73cedcf402ec9 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInMethod5.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public f1 = function() { + + } +} \ No newline at end of file From ed282d75ab6c7306050a381fd130ddf693bc8e9e Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 22 Jun 2016 16:06:04 -0700 Subject: [PATCH 59/90] Additional scenarios based on PR comments --- src/compiler/checker.ts | 22 ++++++++++++------- .../unusedParameterInCatchClause.errors.txt | 10 +++++++++ .../reference/unusedParameterInCatchClause.js | 11 ++++++++++ .../unusedTypeParameters4.errors.txt | 10 +++++++++ .../reference/unusedTypeParameters4.js | 8 +++++++ .../unusedTypeParameters5.errors.txt | 14 ++++++++++++ .../reference/unusedTypeParameters5.js | 17 ++++++++++++++ .../compiler/unusedParameterInCatchClause.ts | 6 +++++ tests/cases/compiler/unusedTypeParameters4.ts | 6 +++++ tests/cases/compiler/unusedTypeParameters5.ts | 10 +++++++++ 10 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/unusedParameterInCatchClause.errors.txt create mode 100644 tests/baselines/reference/unusedParameterInCatchClause.js create mode 100644 tests/baselines/reference/unusedTypeParameters4.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters4.js create mode 100644 tests/baselines/reference/unusedTypeParameters5.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameters5.js create mode 100644 tests/cases/compiler/unusedParameterInCatchClause.ts create mode 100644 tests/cases/compiler/unusedTypeParameters4.ts create mode 100644 tests/cases/compiler/unusedTypeParameters5.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9af1a4d8e0632..20b74ed5eec48 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13207,6 +13207,9 @@ namespace ts { checkAsyncFunctionReturnType(node); } } + if (node.kind === SyntaxKind.ConstructSignature) { + checkUnusedTypeParameters(node); + } } } @@ -14428,7 +14431,7 @@ namespace ts { } } - function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block): void { + function checkUnusedIdentifiers(node: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction | ForInStatement | Block | CatchClause): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { @@ -14453,7 +14456,7 @@ namespace ts { } } - function checkUnusedModulePrivates(node: ModuleDeclaration): void { + function checkUnusedModuleLocals(node: ModuleDeclaration): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { @@ -14475,7 +14478,7 @@ namespace ts { } } - function checkUnusedPrivates(node: ClassDeclaration): void { + function checkUnusedClassLocals(node: ClassDeclaration): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.members) { for (const member of node.members) { @@ -14489,7 +14492,7 @@ namespace ts { } } - function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration) { + function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration) { if (compilerOptions.noUnusedLocals) { if (node.typeParameters) { for (const typeParameter of node.typeParameters) { @@ -14506,7 +14509,7 @@ namespace ts { } function checkUnusedImports(node: SourceFile) { - if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { + if (compilerOptions.noUnusedLocals) { for (const local in node.locals) { if (hasProperty(node.locals, local)) { const localValue = node.locals[local]; @@ -15527,6 +15530,7 @@ namespace ts { } checkBlock(catchClause.block); + checkUnusedIdentifiers(catchClause); } if (node.finallyBlock) { @@ -15688,7 +15692,7 @@ namespace ts { } checkClassLikeDeclaration(node); forEach(node.members, checkSourceElement); - checkUnusedPrivates(node); + checkUnusedClassLocals(node); checkUnusedTypeParameters(node); } @@ -16399,7 +16403,7 @@ namespace ts { if (node.body) { checkSourceElement(node.body); - checkUnusedModulePrivates(node); + checkUnusedModuleLocals(node); } } @@ -16925,7 +16929,9 @@ namespace ts { deferredNodes = []; forEach(node.statements, checkSourceElement); - checkUnusedImports(node); + if (isExternalModule(node)) { + checkUnusedImports(node); + } checkDeferredNodes(); deferredNodes = undefined; diff --git a/tests/baselines/reference/unusedParameterInCatchClause.errors.txt b/tests/baselines/reference/unusedParameterInCatchClause.errors.txt new file mode 100644 index 0000000000000..e996763e2c6f4 --- /dev/null +++ b/tests/baselines/reference/unusedParameterInCatchClause.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedParameterInCatchClause.ts(3,18): error TS6133: 'ex' is declared but never used. + + +==== tests/cases/compiler/unusedParameterInCatchClause.ts (1 errors) ==== + + function f1() { + try {} catch(ex){} + ~~ +!!! error TS6133: 'ex' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterInCatchClause.js b/tests/baselines/reference/unusedParameterInCatchClause.js new file mode 100644 index 0000000000000..153ee17926efd --- /dev/null +++ b/tests/baselines/reference/unusedParameterInCatchClause.js @@ -0,0 +1,11 @@ +//// [unusedParameterInCatchClause.ts] + +function f1() { + try {} catch(ex){} +} + +//// [unusedParameterInCatchClause.js] +function f1() { + try { } + catch (ex) { } +} diff --git a/tests/baselines/reference/unusedTypeParameters4.errors.txt b/tests/baselines/reference/unusedTypeParameters4.errors.txt new file mode 100644 index 0000000000000..3aad5d5a34693 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters4.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedTypeParameters4.ts(3,13): error TS6133: 'U' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameters4.ts (1 errors) ==== + + var x: { + new (a: T): void; + ~ +!!! error TS6133: 'U' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters4.js b/tests/baselines/reference/unusedTypeParameters4.js new file mode 100644 index 0000000000000..4e679ed3f6b36 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters4.js @@ -0,0 +1,8 @@ +//// [unusedTypeParameters4.ts] + +var x: { + new (a: T): void; +} + +//// [unusedTypeParameters4.js] +var x; diff --git a/tests/baselines/reference/unusedTypeParameters5.errors.txt b/tests/baselines/reference/unusedTypeParameters5.errors.txt new file mode 100644 index 0000000000000..ed150710d94e5 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters5.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedTypeParameters5.ts(7,16): error TS6133: 'K' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameters5.ts (1 errors) ==== + + class A { + public x: Dummy; + } + + var x: { + new (a: T): A; + ~ +!!! error TS6133: 'K' is declared but never used. + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameters5.js b/tests/baselines/reference/unusedTypeParameters5.js new file mode 100644 index 0000000000000..75dfd892effad --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameters5.js @@ -0,0 +1,17 @@ +//// [unusedTypeParameters5.ts] + +class A { + public x: Dummy; +} + +var x: { + new (a: T): A; +} + +//// [unusedTypeParameters5.js] +var A = (function () { + function A() { + } + return A; +}()); +var x; diff --git a/tests/cases/compiler/unusedParameterInCatchClause.ts b/tests/cases/compiler/unusedParameterInCatchClause.ts new file mode 100644 index 0000000000000..3034ab0aef880 --- /dev/null +++ b/tests/cases/compiler/unusedParameterInCatchClause.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +function f1() { + try {} catch(ex){} +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters4.ts b/tests/cases/compiler/unusedTypeParameters4.ts new file mode 100644 index 0000000000000..1b470c4ae28de --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters4.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +var x: { + new (a: T): void; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameters5.ts b/tests/cases/compiler/unusedTypeParameters5.ts new file mode 100644 index 0000000000000..7a5025a790789 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameters5.ts @@ -0,0 +1,10 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + public x: Dummy; +} + +var x: { + new (a: T): A; +} \ No newline at end of file From e502ba079f85f431f6abc67b6e285c25ecd15048 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 22 Jun 2016 16:28:58 -0700 Subject: [PATCH 60/90] Removing a redundant check --- src/compiler/checker.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 20b74ed5eec48..8f3504275ef4f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15758,9 +15758,6 @@ namespace ts { if (produceDiagnostics) { const t = getTypeFromTypeNode(typeRefNode); if (t !== unknownType) { - if (t.symbol && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters) && !isInAmbientContext(node)) { - t.symbol.hasReference = true; - } const declaredType = (t.flags & TypeFlags.Reference) ? (t).target : t; if (declaredType.flags & (TypeFlags.Class | TypeFlags.Interface)) { checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(t, type.thisType), node.name || node, Diagnostics.Class_0_incorrectly_implements_interface_1); From 082c6def1c3dfe236662dda586bafa2762a6e3e3 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Wed, 22 Jun 2016 17:24:16 -0700 Subject: [PATCH 61/90] Additional scenarios added --- src/services/codefixes/unusedIdentifierFixes.ts | 5 +++++ tests/cases/fourslash/unusedParameterInCatch1.ts | 13 +++++++++++++ tests/cases/fourslash/unusedParameterInLambda1.ts | 13 +++++++++++++ .../fourslash/unusedTypeParametersInFunction1.ts | 8 ++++++++ .../fourslash/unusedTypeParametersInFunction2.ts | 8 ++++++++ .../fourslash/unusedTypeParametersInFunction3.ts | 8 ++++++++ .../fourslash/unusedTypeParametersInLambda1.ts | 13 +++++++++++++ .../fourslash/unusedTypeParametersInLambda2.ts | 13 +++++++++++++ .../fourslash/unusedTypeParametersInLambda3.ts | 15 +++++++++++++++ .../fourslash/unusedTypeParametersInMethods1.ts | 12 ++++++++++++ 10 files changed, 108 insertions(+) create mode 100644 tests/cases/fourslash/unusedParameterInCatch1.ts create mode 100644 tests/cases/fourslash/unusedParameterInLambda1.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInFunction1.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInFunction2.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInFunction3.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInLambda1.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInLambda2.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInLambda3.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInMethods1.ts diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index ab8e89bcd306b..fa387259b318b 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -31,6 +31,11 @@ namespace ts.codeFix { var initializer = forOfStatement.initializer; return [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }]; } + else if (token.parent.parent.kind === SyntaxKind.CatchClause) { + var catchClause = token.parent.parent; + var parameter = catchClause.variableDeclaration.getChildren()[0]; + return [{ newText: "", span: { start: parameter.pos, length: parameter.end - parameter.pos } }]; + } else { var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { diff --git a/tests/cases/fourslash/unusedParameterInCatch1.ts b/tests/cases/fourslash/unusedParameterInCatch1.ts new file mode 100644 index 0000000000000..2dc2f1f273e48 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInCatch1.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// function f1() { +//// try {} catch(ex) {} +//// } + +verify.codeFixAtPosition(` +function f1() { +try {} catch() {} +} +`); diff --git a/tests/cases/fourslash/unusedParameterInLambda1.ts b/tests/cases/fourslash/unusedParameterInLambda1.ts new file mode 100644 index 0000000000000..8fe5ed5172134 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInLambda1.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// function f1() { +//// return (x:number) => {} +//// } + +verify.codeFixAtPosition(` +function f1() { + return () => {} +} +`); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts new file mode 100644 index 0000000000000..fc464f6feb5cd --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// function f1() {} + +verify.codeFixAtPosition(` +function f1() {} +`); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts new file mode 100644 index 0000000000000..5f9476f655a8f --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// function f1(a: X) {a} + +verify.codeFixAtPosition(` +function f1(a: X) {a} +`); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts new file mode 100644 index 0000000000000..36e799b894cfc --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts @@ -0,0 +1,8 @@ +/// + +// @noUnusedLocals: true +//// function f1(a: X) {a;var b:Z;b} + +verify.codeFixAtPosition(` +function f1(a: X) {a;var b:Z;b} +`); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts new file mode 100644 index 0000000000000..bd8a8ee16b784 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// function f1() { +//// return (x:number) => {x} +//// } + +verify.codeFixAtPosition(` +function f1() { + return (x:number) => {x} +} +`); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts new file mode 100644 index 0000000000000..b649fef3333d1 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts @@ -0,0 +1,13 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// var x : { +//// new (a: T): void; +//// } + +verify.codeFixAtPosition(` +var x : { + new (a: T): void; +} +`); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts new file mode 100644 index 0000000000000..23b993b996d40 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts @@ -0,0 +1,15 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// class A { public x: Dummy } +//// var x : { +//// new (a: T): A; +//// } + +verify.codeFixAtPosition(` +class A { public x: Dummy } +var x : { + new (a: T): A; +} +`); diff --git a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts new file mode 100644 index 0000000000000..652d6c20e79b7 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +//// class A { +//// public f1(a: X) { a; var b: Z; b } +//// } + +verify.codeFixAtPosition(` +class A { + public f1(a: X) { a; var b: Z; b } +} +`); From 0e2e43d2e880b417e754284d81dda65f5e617fb2 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 23 Jun 2016 10:37:12 -0700 Subject: [PATCH 62/90] Added ambient check to imports and typeparatmeter reporting --- src/compiler/checker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8f3504275ef4f..f46b3b05fdf7b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14493,7 +14493,7 @@ namespace ts { } function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration) { - if (compilerOptions.noUnusedLocals) { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.typeParameters) { for (const typeParameter of node.typeParameters) { if (!typeParameter.symbol.hasReference) { @@ -14509,7 +14509,7 @@ namespace ts { } function checkUnusedImports(node: SourceFile) { - if (compilerOptions.noUnusedLocals) { + if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const local in node.locals) { if (hasProperty(node.locals, local)) { const localValue = node.locals[local]; From 73375c0ffbf42df807edd343ededf10dfe2cd872 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 23 Jun 2016 11:08:21 -0700 Subject: [PATCH 63/90] Code changes and test cases to handle enums --- src/services/codefixes/unusedIdentifierFixes.ts | 4 ++++ tests/cases/fourslash/unusedConstantInFunction1.ts | 12 ++++++++++++ tests/cases/fourslash/unusedEnumInFunction1.ts | 12 ++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/cases/fourslash/unusedConstantInFunction1.ts create mode 100644 tests/cases/fourslash/unusedEnumInFunction1.ts diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index fa387259b318b..93c7d38e4101e 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -108,6 +108,10 @@ namespace ts.codeFix { if(token.parent.kind === SyntaxKind.ImportEqualsDeclaration) { return [{ newText: "{}", span: { start: token.pos, length: token.end - token.pos } }]; } + + if(token.parent.kind === SyntaxKind.EnumDeclaration) { + return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; + } } if(token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { diff --git a/tests/cases/fourslash/unusedConstantInFunction1.ts b/tests/cases/fourslash/unusedConstantInFunction1.ts new file mode 100644 index 0000000000000..3e7932a8afd30 --- /dev/null +++ b/tests/cases/fourslash/unusedConstantInFunction1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// const x: string = "x"; +//// } + +verify.codeFixAtPosition(` +function f1 () { +} +`); + diff --git a/tests/cases/fourslash/unusedEnumInFunction1.ts b/tests/cases/fourslash/unusedEnumInFunction1.ts new file mode 100644 index 0000000000000..c68d1eb48ec46 --- /dev/null +++ b/tests/cases/fourslash/unusedEnumInFunction1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +//// function f1 () { +//// enum Directions { Up, Down} +//// } + +verify.codeFixAtPosition(` +function f1 () { +} +`); + From 754034d5493ab97bef079090bb156dde5f1856cf Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 23 Jun 2016 14:55:30 -0700 Subject: [PATCH 64/90] Added Debug Statement instead of throwing error. --- src/services/codefixes/unusedIdentifierFixes.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 93c7d38e4101e..05dc082968da4 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -122,7 +122,7 @@ namespace ts.codeFix { return [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; } - throw new Error("No Quick Fix found"); + Debug.fail("No Quick fix found."); } }); } From 33f4a6be01be8117b2388b703da266a97ee13e18 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 23 Jun 2016 16:25:41 -0700 Subject: [PATCH 65/90] CR feedback, and add the ability to have fixes which span files. TODO: make the 4slash API better --- src/compiler/diagnosticMessages.json | 2 +- src/harness/fourslash.ts | 2 +- src/services/codefixes/codeFixProvider.ts | 8 ++++---- src/services/codefixes/superFixes.ts | 10 ++++++---- src/services/services.ts | 23 +++++++++++++++-------- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b123d7b614f4a..b011da1e7811f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2997,7 +2997,7 @@ "category": "CodeFix", "code": 90001 }, - "Make super call the first statement in the constructor.":{ + "Make 'super()' call the first statement in the constructor.":{ "category": "CodeFix", "code": 90002 } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 47c04396ec690..c0c549213becb 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1887,7 +1887,7 @@ namespace FourSlash { this.raiseError("More than 1 codefix returned."); } - this.applyEdits(fileName, actual[0].textChanges, /*isFormattingEdit*/ false); + this.applyEdits(actual[0].changes[0].fileName, actual[0].changes[0].textChanges, /*isFormattingEdit*/ false); const actualText = this.getFileContent(fileName); // We expect the editor to do the final formatting, so we can strip the compare ignoring whitespace diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index e05dfdecbc619..291358646d82a 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -3,14 +3,14 @@ namespace ts { export interface CodeAction { name: string; errorCodes: string[]; - getTextChanges(sourceFile: SourceFile, start: number, end: number): TextChange[]; + getTextChanges(sourceFile: SourceFile, start: number, end: number): FileTextChanges[]; } export namespace codeFix { var codeActions: Map = {}; export function registerCodeFix(fix: CodeAction) { - fix.errorCodes.forEach(error => { + forEach( fix.errorCodes, error => { let fixes = codeActions[error]; if (!fixes) { fixes = []; @@ -34,10 +34,10 @@ namespace ts { throw new Error("No fixes found for error: '${errorCode}'."); } - actions.forEach(a => { + forEach(actions, a => { const textChanges = a.getTextChanges(sourceFile, start, end); if (textChanges && textChanges.length > 0) { - fixes.push({ name: a.name, textChanges: textChanges }); + fixes.push({ description: a.name, changes: textChanges }); } }); diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index ff79e9b97bf6f..92f815e1dd191 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -10,18 +10,18 @@ namespace ts.codeFix { errorCodes: ["TS2377"], getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { const token = getTokenAtPosition(sourceFile, start); - Debug.assert(token.kind === SyntaxKind.ConstructorKeyword,"Failed to find the constructor."); + Debug.assert(token.kind === SyntaxKind.ConstructorKeyword, "Failed to find the constructor."); const newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ newText: "super();", span: { start: newPosition, length: 0 } }]; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }]; } }); registerCodeFix({ name: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), errorCodes: ["TS17009"], - getTextChanges: (sourceFile: SourceFile, start: number, end: number): TextChange[] => { + getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { const token = getTokenAtPosition(sourceFile, start); const constructor = getContainingFunction(token); Debug.assert(constructor.kind === SyntaxKind.Constructor, "Failed to find the constructor."); @@ -31,13 +31,15 @@ namespace ts.codeFix { const newPosition = getOpenBraceEnd(constructor, sourceFile); return [{ + fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), span: { start: newPosition, length: 0 } }, { newText: "", span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }]; + }] + }]; function findSuperCall(n: Node): Node { if (n.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((n).expression)) { diff --git a/src/services/services.ts b/src/services/services.ts index f12b9c940212e..b2610234eac32 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1198,11 +1198,18 @@ namespace ts { newText: string; } - export interface CodeFix { - name: string; + export interface FileTextChanges { + fileName: string; textChanges: TextChange[]; } + export interface CodeFix { + /** Description of the code fix to display in the UI of the editor */ + description: string; + /** Text changes to apply to each file as part of the code fix */ + changes: FileTextChanges[]; + } + export interface TextInsertion { newText: string; /** The position in newText the caret should point to after the insertion. */ @@ -7685,16 +7692,16 @@ namespace ts { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); - let fixes: CodeFix[] = []; + let allFixes: CodeFix[] = []; - errorCodes.forEach(error => { - const fix = codeFixProvider.getFixes(error, sourceFile, start, end); - if (fix) { - fixes = fixes.concat(fix); + forEach(errorCodes, error => { + const fixes = codeFixProvider.getFixes(error, sourceFile, start, end); + if (fixes) { + allFixes = allFixes.concat(fixes); } }); - return fixes; + return allFixes; } /** From 42bc9c57dabf6ed947ba8a58455d3dd88b4e7a68 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 23 Jun 2016 16:41:29 -0700 Subject: [PATCH 66/90] fix typo --- src/harness/fourslash.ts | 2 +- src/harness/harnessLanguageService.ts | 2 +- src/server/client.ts | 2 +- src/services/services.ts | 6 +++--- src/services/shims.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c0c549213becb..2097f1a5c42ad 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1949,7 +1949,7 @@ namespace FourSlash { const position = this.currentCaretPosition; - const validBraceCompletion = this.languageService.isValidBraceCompletionAtPostion(this.activeFile.fileName, position, charCode); + const validBraceCompletion = this.languageService.isValidBraceCompletionAtPosition(this.activeFile.fileName, position, charCode); if (!negative && !validBraceCompletion) { this.raiseError(`${position} is not a valid brace completion position for ${openingBrace}`); diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 7a84cca5ed7d4..0bcdf62c663b3 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -450,7 +450,7 @@ namespace Harness.LanguageService { getDocCommentTemplateAtPosition(fileName: string, position: number): ts.TextInsertion { return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position)); } - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPostion(fileName, position, openingBrace)); } getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeFix[] { diff --git a/src/server/client.ts b/src/server/client.ts index 7979598b0001f..d5aca60ff6e30 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -588,7 +588,7 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { throw new Error("Not Implemented Yet."); } diff --git a/src/services/services.ts b/src/services/services.ts index b2610234eac32..eb0cd8e2028c5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1148,7 +1148,7 @@ namespace ts { getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeFix[]; @@ -7805,7 +7805,7 @@ namespace ts { return { newText: result, caretOffset: preamble.length }; } - function isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): boolean { + function isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { // '<' is currently not supported, figuring out if we're in a Generic Type vs. a comparison is too // expensive to do during typing scenarios @@ -8173,7 +8173,7 @@ namespace ts { getFormattingEditsForDocument, getFormattingEditsAfterKeystroke, getDocCommentTemplateAtPosition, - isValidBraceCompletionAtPostion, + isValidBraceCompletionAtPosition, getCodeFixesAtPosition, getEmitOutput, getNonBoundSourceFile, diff --git a/src/services/shims.ts b/src/services/shims.ts index 12098c8df3d94..220b2830319e8 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -779,7 +779,7 @@ namespace ts { public isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string { return this.forwardJSONCall( `isValidBraceCompletionAtPostion('${fileName}', ${position}, ${openingBrace})`, - () => this.languageService.isValidBraceCompletionAtPostion(fileName, position, openingBrace) + () => this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace) ); } From 0516e91cddfaf3ee96a22e2a424b2f26b3d3834c Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 23 Jun 2016 16:41:40 -0700 Subject: [PATCH 67/90] Don't throw --- src/services/codefixes/codeFixProvider.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 291358646d82a..7797416f7fa9a 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -30,9 +30,7 @@ namespace ts { const actions = codeActions[errorCode]; const fixes: CodeFix[] = []; - if (!actions || actions.length == 0) { - throw new Error("No fixes found for error: '${errorCode}'."); - } + Debug.assert(actions && actions.length > 0, "No fixes found for error: '${errorCode}'."); forEach(actions, a => { const textChanges = a.getTextChanges(sourceFile, start, end); From 37cb001d669b1fa6dc593958221ec933fecf5067 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 23 Jun 2016 16:51:25 -0700 Subject: [PATCH 68/90] More typo fixes --- src/harness/fourslash.ts | 2 +- src/harness/harnessLanguageService.ts | 2 +- src/services/shims.ts | 6 ++-- .../commentBraceCompletionPosition.ts | 6 ++-- tests/cases/fourslash/fourslash.ts | 2 +- .../fourslash/jsxBraceCompletionPosition.ts | 28 +++++++++---------- .../stringBraceCompletionPosition.ts | 6 ++-- .../stringTemplateBraceCompletionPosition.ts | 8 +++--- .../fourslash/validBraceCompletionPosition.ts | 10 +++---- 9 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2097f1a5c42ad..5992adadeac52 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2953,7 +2953,7 @@ namespace FourSlashInterface { this.state.verifyDefinitionsName(this.negative, name, containerName); } - public isValidBraceCompletionAtPostion(openingBrace: string) { + public isValidBraceCompletionAtPosition(openingBrace: string) { this.state.verifyBraceCompletionAtPostion(this.negative, openingBrace); } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 0bcdf62c663b3..8f8f36504c35b 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -451,7 +451,7 @@ namespace Harness.LanguageService { return unwrapJSONCallResult(this.shim.getDocCommentTemplateAtPosition(fileName, position)); } isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { - return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPostion(fileName, position, openingBrace)); + return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeFix[] { return unwrapJSONCallResult(this.shim.getCodeFixesAtPosition(fileName, start, end, JSON.stringify(errorCodes))); diff --git a/src/services/shims.ts b/src/services/shims.ts index 220b2830319e8..6a0b937667f4c 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -228,7 +228,7 @@ namespace ts { * at the current position. * E.g. we don't want brace completion inside string-literals, comments, etc. */ - isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string; + isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string): string; @@ -776,9 +776,9 @@ namespace ts { ); } - public isValidBraceCompletionAtPostion(fileName: string, position: number, openingBrace: number): string { + public isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): string { return this.forwardJSONCall( - `isValidBraceCompletionAtPostion('${fileName}', ${position}, ${openingBrace})`, + `isValidBraceCompletionAtPosition('${fileName}', ${position}, ${openingBrace})`, () => this.languageService.isValidBraceCompletionAtPosition(fileName, position, openingBrace) ); } diff --git a/tests/cases/fourslash/commentBraceCompletionPosition.ts b/tests/cases/fourslash/commentBraceCompletionPosition.ts index 23b8240dcaf8e..b92c49d3a14a6 100644 --- a/tests/cases/fourslash/commentBraceCompletionPosition.ts +++ b/tests/cases/fourslash/commentBraceCompletionPosition.ts @@ -14,10 +14,10 @@ //// } goTo.marker('1'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('2'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('3'); -verify.not.isValidBraceCompletionAtPostion('('); \ No newline at end of file +verify.not.isValidBraceCompletionAtPosition('('); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 08b6595306554..d5f74b0521a50 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -134,7 +134,7 @@ declare namespace FourSlashInterface { typeDefinitionCountIs(expectedCount: number): void; definitionLocationExists(): void; verifyDefinitionsName(name: string, containerName: string): void; - isValidBraceCompletionAtPostion(openingBrace?: string): void; + isValidBraceCompletionAtPosition(openingBrace?: string): void; } class verify extends verifyNegatable { assertHasRanges(ranges: Range[]): void; diff --git a/tests/cases/fourslash/jsxBraceCompletionPosition.ts b/tests/cases/fourslash/jsxBraceCompletionPosition.ts index c1c331435ce14..91ee96cc5b785 100644 --- a/tests/cases/fourslash/jsxBraceCompletionPosition.ts +++ b/tests/cases/fourslash/jsxBraceCompletionPosition.ts @@ -19,29 +19,29 @@ //// goTo.marker('1'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('2'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.not.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.not.isValidBraceCompletionAtPosition('{'); goTo.marker('3'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('4'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('5'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('6'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); goTo.marker('7'); -verify.not.isValidBraceCompletionAtPostion('('); -verify.isValidBraceCompletionAtPostion('{'); \ No newline at end of file +verify.not.isValidBraceCompletionAtPosition('('); +verify.isValidBraceCompletionAtPosition('{'); \ No newline at end of file diff --git a/tests/cases/fourslash/stringBraceCompletionPosition.ts b/tests/cases/fourslash/stringBraceCompletionPosition.ts index 09a9a86b0f15f..5df80e2c67652 100644 --- a/tests/cases/fourslash/stringBraceCompletionPosition.ts +++ b/tests/cases/fourslash/stringBraceCompletionPosition.ts @@ -6,11 +6,11 @@ //// /*3*/"; goTo.marker('1'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('2'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('3'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); diff --git a/tests/cases/fourslash/stringTemplateBraceCompletionPosition.ts b/tests/cases/fourslash/stringTemplateBraceCompletionPosition.ts index 33bcd4d0625c7..73c945e932c52 100644 --- a/tests/cases/fourslash/stringTemplateBraceCompletionPosition.ts +++ b/tests/cases/fourslash/stringTemplateBraceCompletionPosition.ts @@ -4,13 +4,13 @@ //// var y = `hello /*2*/world, ${100}how /*3*/are you{ 200 } to/*4*/day!?` goTo.marker('1'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('2'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('3'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); goTo.marker('4'); -verify.not.isValidBraceCompletionAtPostion('('); +verify.not.isValidBraceCompletionAtPosition('('); diff --git a/tests/cases/fourslash/validBraceCompletionPosition.ts b/tests/cases/fourslash/validBraceCompletionPosition.ts index 57c30c27c2163..1d281be705d84 100644 --- a/tests/cases/fourslash/validBraceCompletionPosition.ts +++ b/tests/cases/fourslash/validBraceCompletionPosition.ts @@ -8,16 +8,16 @@ //// var x = /*5*/{ a:true } goTo.marker('1'); -verify.isValidBraceCompletionAtPostion('('); +verify.isValidBraceCompletionAtPosition('('); goTo.marker('2'); -verify.isValidBraceCompletionAtPostion('('); +verify.isValidBraceCompletionAtPosition('('); goTo.marker('3'); -verify.isValidBraceCompletionAtPostion('('); +verify.isValidBraceCompletionAtPosition('('); goTo.marker('4'); -verify.isValidBraceCompletionAtPostion('('); +verify.isValidBraceCompletionAtPosition('('); goTo.marker('5'); -verify.isValidBraceCompletionAtPostion('('); \ No newline at end of file +verify.isValidBraceCompletionAtPosition('('); \ No newline at end of file From f93c6c887cedb2b4440babc7eae422e27e974c2f Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 23 Jun 2016 17:39:18 -0700 Subject: [PATCH 69/90] Added one more scenario to handle type parameters --- src/compiler/checker.ts | 2 +- .../unusedTypeParameterInLambda3.errors.txt | 12 ++++++++++++ .../reference/unusedTypeParameterInLambda3.js | 15 +++++++++++++++ .../compiler/unusedTypeParameterInLambda3.ts | 7 +++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInLambda3.js create mode 100644 tests/cases/compiler/unusedTypeParameterInLambda3.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d1b1fc606fca9..dc5f31c4764c7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13211,7 +13211,7 @@ namespace ts { checkAsyncFunctionReturnType(node); } } - if (node.kind === SyntaxKind.ConstructSignature) { + if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) { checkUnusedTypeParameters(node); } } diff --git a/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt b/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt new file mode 100644 index 0000000000000..5477f611e7299 --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda3.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedTypeParameterInLambda3.ts(5,15): error TS6133: 'U' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInLambda3.ts (1 errors) ==== + class A { + public x: T; + } + + var y: new (a:T)=>void; + ~ +!!! error TS6133: 'U' is declared but never used. + \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInLambda3.js b/tests/baselines/reference/unusedTypeParameterInLambda3.js new file mode 100644 index 0000000000000..27899320fc26c --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInLambda3.js @@ -0,0 +1,15 @@ +//// [unusedTypeParameterInLambda3.ts] +class A { + public x: T; +} + +var y: new (a:T)=>void; + + +//// [unusedTypeParameterInLambda3.js] +var A = (function () { + function A() { + } + return A; +}()); +var y; diff --git a/tests/cases/compiler/unusedTypeParameterInLambda3.ts b/tests/cases/compiler/unusedTypeParameterInLambda3.ts new file mode 100644 index 0000000000000..eb6582caf4e98 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInLambda3.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true +class A { + public x: T; +} + +var y: new (a:T)=>void; From 97a3d904a053aa65c0703bdda28cec4de7189a2b Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Thu, 23 Jun 2016 17:45:13 -0700 Subject: [PATCH 70/90] Added test for another scenario involving type parameters --- .../fourslash/unusedTypeParametersInLambda4.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/cases/fourslash/unusedTypeParametersInLambda4.ts diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts new file mode 100644 index 0000000000000..38783defc253b --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts @@ -0,0 +1,15 @@ +/// + +// @noUnusedLocals: true +//// class A { +//// public x: T; +//// } +//// var y: new (a:T)=>void; + +verify.codeFixAtPosition(` +class A { + public x: T; +} +var y: new (a:T)=>void; +`); + From 452105839f08165ea88875ba1c8034a4675d93e1 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 24 Jun 2016 00:28:30 -0700 Subject: [PATCH 71/90] Added new scenario for TypeParameter on Interface --- src/compiler/checker.ts | 35 +++++++++---------- ...unusedTypeParameterInInterface1.errors.txt | 10 ++++++ .../unusedTypeParameterInInterface1.js | 7 ++++ ...unusedTypeParameterInInterface2.errors.txt | 11 ++++++ .../unusedTypeParameterInInterface2.js | 8 +++++ .../unusedVariablesinModules1.errors.txt | 12 +++++++ .../reference/unusedVariablesinModules1.js | 11 ++++++ .../unusedTypeParameterInInterface1.ts | 6 ++++ .../unusedTypeParameterInInterface2.ts | 7 ++++ .../compiler/unusedVariablesinModules1.ts | 8 +++++ 10 files changed, 96 insertions(+), 19 deletions(-) create mode 100644 tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInInterface1.js create mode 100644 tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt create mode 100644 tests/baselines/reference/unusedTypeParameterInInterface2.js create mode 100644 tests/baselines/reference/unusedVariablesinModules1.errors.txt create mode 100644 tests/baselines/reference/unusedVariablesinModules1.js create mode 100644 tests/cases/compiler/unusedTypeParameterInInterface1.ts create mode 100644 tests/cases/compiler/unusedTypeParameterInInterface2.ts create mode 100644 tests/cases/compiler/unusedVariablesinModules1.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dc5f31c4764c7..f30f556a86cb1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14447,10 +14447,8 @@ namespace ts { error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); } else if (local.valueDeclaration.kind === SyntaxKind.Parameter && compilerOptions.noUnusedParameters) { - if (local.valueDeclaration.modifiers) { - if (getCombinedNodeFlags(local.valueDeclaration) & NodeFlags.Private) { - error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); - } + if (getCombinedNodeFlags(local.valueDeclaration) & NodeFlags.Private) { + error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); } else { error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); @@ -14462,7 +14460,7 @@ namespace ts { } } - function checkUnusedModuleLocals(node: ModuleDeclaration): void { + function checkUnusedModuleLocals(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { if (hasProperty(node.locals, key)) { @@ -14471,13 +14469,12 @@ namespace ts { if ((local.valueDeclaration && local.valueDeclaration.kind)) { error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); } - else if (local.declarations && - (local.declarations[0].kind === SyntaxKind.InterfaceDeclaration || local.declarations[0].kind === SyntaxKind.ModuleDeclaration)) { - error(local.declarations[0], Diagnostics._0_is_declared_but_never_used, key); - } else if (local.declarations && local.declarations[0].kind === SyntaxKind.ImportEqualsDeclaration) { error(local.declarations[0].name, Diagnostics._0_is_declared_but_never_used, key); } + else if (local.declarations) { + error(local.declarations[0], Diagnostics._0_is_declared_but_never_used, key); + } } } } @@ -14498,7 +14495,7 @@ namespace ts { } } - function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration) { + function checkUnusedTypeParameters(node: ClassDeclaration | FunctionDeclaration | MethodDeclaration | FunctionExpression | ArrowFunction | ConstructorDeclaration | SignatureDeclaration | InterfaceDeclaration) { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.typeParameters) { for (const typeParameter of node.typeParameters) { @@ -14520,15 +14517,13 @@ namespace ts { if (hasProperty(node.locals, local)) { const localValue = node.locals[local]; if (localValue.declarations && !localValue.exportSymbol) { - for (const declaration of localValue.declarations) { - const symbol = declaration.symbol; - if (!symbol.hasReference) { - if (declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause || declaration.kind === SyntaxKind.NamespaceImport) { - error(declaration, Diagnostics._0_is_declared_but_never_used, symbol.name); - } - else if (declaration.kind === SyntaxKind.ImportEqualsDeclaration) { - error(declaration.name, Diagnostics._0_is_declared_but_never_used, symbol.name); - } + const declaration = localValue.declarations[0]; + if (!localValue.hasReference) { + if (declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause || declaration.kind === SyntaxKind.NamespaceImport) { + error(declaration, Diagnostics._0_is_declared_but_never_used, localValue.name); + } + else if (declaration.kind === SyntaxKind.ImportEqualsDeclaration) { + error(declaration.name, Diagnostics._0_is_declared_but_never_used, localValue.name); } } } @@ -16010,6 +16005,7 @@ namespace ts { if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); + checkUnusedTypeParameters(node); } } @@ -16934,6 +16930,7 @@ namespace ts { forEach(node.statements, checkSourceElement); if (isExternalModule(node)) { checkUnusedImports(node); + checkUnusedModuleLocals(node); } checkDeferredNodes(); deferredNodes = undefined; diff --git a/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt b/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt new file mode 100644 index 0000000000000..fbe6ef3f0d18c --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInInterface1.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/unusedTypeParameterInInterface1.ts(2,15): error TS6133: 'T' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInInterface1.ts (1 errors) ==== + + interface int { + ~ +!!! error TS6133: 'T' is declared but never used. + + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInInterface1.js b/tests/baselines/reference/unusedTypeParameterInInterface1.js new file mode 100644 index 0000000000000..8f9a6962b359b --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInInterface1.js @@ -0,0 +1,7 @@ +//// [unusedTypeParameterInInterface1.ts] + +interface int { + +} + +//// [unusedTypeParameterInInterface1.js] diff --git a/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt b/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt new file mode 100644 index 0000000000000..ed3e58477742a --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInInterface2.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/unusedTypeParameterInInterface2.ts(2,18): error TS6133: 'U' is declared but never used. + + +==== tests/cases/compiler/unusedTypeParameterInInterface2.ts (1 errors) ==== + + interface int { + ~ +!!! error TS6133: 'U' is declared but never used. + f1(a: T): string; + c: V; + } \ No newline at end of file diff --git a/tests/baselines/reference/unusedTypeParameterInInterface2.js b/tests/baselines/reference/unusedTypeParameterInInterface2.js new file mode 100644 index 0000000000000..d5a4c490d27bd --- /dev/null +++ b/tests/baselines/reference/unusedTypeParameterInInterface2.js @@ -0,0 +1,8 @@ +//// [unusedTypeParameterInInterface2.ts] + +interface int { + f1(a: T): string; + c: V; +} + +//// [unusedTypeParameterInInterface2.js] diff --git a/tests/baselines/reference/unusedVariablesinModules1.errors.txt b/tests/baselines/reference/unusedVariablesinModules1.errors.txt new file mode 100644 index 0000000000000..00faee6a6b3ff --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinModules1.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/unusedVariablesinModules1.ts(4,5): error TS6133: 'x' is declared but never used. + + +==== tests/cases/compiler/unusedVariablesinModules1.ts (1 errors) ==== + + export {}; + + var x: string; + ~ +!!! error TS6133: 'x' is declared but never used. + + export var y: string; \ No newline at end of file diff --git a/tests/baselines/reference/unusedVariablesinModules1.js b/tests/baselines/reference/unusedVariablesinModules1.js new file mode 100644 index 0000000000000..18622a32ba9f0 --- /dev/null +++ b/tests/baselines/reference/unusedVariablesinModules1.js @@ -0,0 +1,11 @@ +//// [unusedVariablesinModules1.ts] + +export {}; + +var x: string; + +export var y: string; + +//// [unusedVariablesinModules1.js] +"use strict"; +var x; diff --git a/tests/cases/compiler/unusedTypeParameterInInterface1.ts b/tests/cases/compiler/unusedTypeParameterInInterface1.ts new file mode 100644 index 0000000000000..2098e5d4bc5b9 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInInterface1.ts @@ -0,0 +1,6 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +interface int { + +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedTypeParameterInInterface2.ts b/tests/cases/compiler/unusedTypeParameterInInterface2.ts new file mode 100644 index 0000000000000..cdcd45a7f30b5 --- /dev/null +++ b/tests/cases/compiler/unusedTypeParameterInInterface2.ts @@ -0,0 +1,7 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +interface int { + f1(a: T): string; + c: V; +} \ No newline at end of file diff --git a/tests/cases/compiler/unusedVariablesinModules1.ts b/tests/cases/compiler/unusedVariablesinModules1.ts new file mode 100644 index 0000000000000..92a5a14590d2d --- /dev/null +++ b/tests/cases/compiler/unusedVariablesinModules1.ts @@ -0,0 +1,8 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +export {}; + +var x: string; + +export var y: string; \ No newline at end of file From ab0fdd4cccb0f2781f9ef2048cddbfef7ce4a323 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 24 Jun 2016 10:04:09 -0700 Subject: [PATCH 72/90] Additional test cases --- .../fourslash/unusedTypeParametersInInterface1.ts | 10 ++++++++++ tests/cases/fourslash/unusedVariableInModule1.ts | 12 ++++++++++++ tests/cases/fourslash/unusedVariableInModule2.ts | 15 +++++++++++++++ tests/cases/fourslash/unusedVariableInModule3.ts | 12 ++++++++++++ tests/cases/fourslash/unusedVariableInModule4.ts | 15 +++++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 tests/cases/fourslash/unusedTypeParametersInInterface1.ts create mode 100644 tests/cases/fourslash/unusedVariableInModule1.ts create mode 100644 tests/cases/fourslash/unusedVariableInModule2.ts create mode 100644 tests/cases/fourslash/unusedVariableInModule3.ts create mode 100644 tests/cases/fourslash/unusedVariableInModule4.ts diff --git a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts new file mode 100644 index 0000000000000..96d7749424361 --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts @@ -0,0 +1,10 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// interface I {} + + +verify.codeFixAtPosition(` +interface I {} +`); diff --git a/tests/cases/fourslash/unusedVariableInModule1.ts b/tests/cases/fourslash/unusedVariableInModule1.ts new file mode 100644 index 0000000000000..d4c3e71fba354 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInModule1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// export {} +//// var x: string; +//// export var y: string; + +verify.codeFixAtPosition(` +export {} +export var y: string; +`); diff --git a/tests/cases/fourslash/unusedVariableInModule2.ts b/tests/cases/fourslash/unusedVariableInModule2.ts new file mode 100644 index 0000000000000..dec89920d5ebb --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInModule2.ts @@ -0,0 +1,15 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// export {} +//// var x: string, y: number; +//// y; +//// export var y: string; + +verify.codeFixAtPosition(` +export {} +var y: number; +y; +export var y: string; +`); diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts new file mode 100644 index 0000000000000..cd7c52ed91aeb --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInModule3.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// export {} +//// var x = function f1() {} +//// export var y: string; + +verify.codeFixAtPosition(` +export {} +export var y: string; +`); diff --git a/tests/cases/fourslash/unusedVariableInModule4.ts b/tests/cases/fourslash/unusedVariableInModule4.ts new file mode 100644 index 0000000000000..d4e4a1e5426e6 --- /dev/null +++ b/tests/cases/fourslash/unusedVariableInModule4.ts @@ -0,0 +1,15 @@ +/// + +// @noUnusedLocals: true +// @noUnusedParameters: true +//// export {} +//// var x = function f1(m: number) {} +//// x; +//// export var y: string; + +verify.codeFixAtPosition(` +export {} +var x = function f1() {} +x; +export var y: string; +`); From 5eb71535a3078ab30e418ed349ab3249cbd1074f Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 24 Jun 2016 12:22:34 -0700 Subject: [PATCH 73/90] Refactoring the code --- src/compiler/checker.ts | 53 ++++--------------- .../unusedFunctionsinNamespaces3.errors.txt | 2 +- .../unusedIdentifiersConsolidated1.errors.txt | 6 +-- .../reference/unusedImports7.errors.txt | 4 +- .../reference/unusedImports8.errors.txt | 4 +- ...ationWithinFunctionDeclaration1.errors.txt | 4 +- ...ationWithinFunctionDeclaration2.errors.txt | 6 +-- ...rationWithinFunctionExpression1.errors.txt | 4 +- ...rationWithinFunctionExpression2.errors.txt | 6 +-- ...ssionWithinFunctionDeclaration1.errors.txt | 4 +- ...ssionWithinFunctionDeclaration2.errors.txt | 6 +-- ...essionWithinFunctionExpression1.errors.txt | 4 +- ...essionWithinFunctionExpression2.errors.txt | 6 +-- ...dMultipleParameter1InContructor.errors.txt | 2 +- ...eParameter1InFunctionExpression.errors.txt | 2 +- ...dMultipleParameter2InContructor.errors.txt | 4 +- ...eParameter2InFunctionExpression.errors.txt | 4 +- ...arameters1InFunctionDeclaration.errors.txt | 2 +- ...eParameters1InMethodDeclaration.errors.txt | 2 +- ...arameters2InFunctionDeclaration.errors.txt | 4 +- ...eParameters2InMethodDeclaration.errors.txt | 4 +- .../unusedParametersinConstructor1.errors.txt | 2 +- .../unusedParametersinConstructor2.errors.txt | 2 +- .../unusedParametersinConstructor3.errors.txt | 4 +- ...usedSingleParameterInContructor.errors.txt | 2 +- ...eParameterInFunctionDeclaration.errors.txt | 2 +- ...leParameterInFunctionExpression.errors.txt | 2 +- ...gleParameterInMethodDeclaration.errors.txt | 2 +- 28 files changed, 58 insertions(+), 91 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f30f556a86cb1..33cb00cf824da 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13211,7 +13211,7 @@ namespace ts { checkAsyncFunctionReturnType(node); } } - if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) { + if (!(node).body) { checkUnusedTypeParameters(node); } } @@ -14444,14 +14444,11 @@ namespace ts { const local = node.locals[key]; if (!local.hasReference && local.valueDeclaration) { if (local.valueDeclaration.kind !== SyntaxKind.Parameter && compilerOptions.noUnusedLocals) { - error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); + error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, key); } else if (local.valueDeclaration.kind === SyntaxKind.Parameter && compilerOptions.noUnusedParameters) { - if (getCombinedNodeFlags(local.valueDeclaration) & NodeFlags.Private) { - error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); - } - else { - error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); + if (local.valueDeclaration.flags === 0) { + error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, key); } } } @@ -14460,27 +14457,6 @@ namespace ts { } } - function checkUnusedModuleLocals(node: ModuleDeclaration | SourceFile): void { - if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { - for (const key in node.locals) { - if (hasProperty(node.locals, key)) { - const local = node.locals[key]; - if (!local.hasReference && !local.exportSymbol) { - if ((local.valueDeclaration && local.valueDeclaration.kind)) { - error(local.valueDeclaration, Diagnostics._0_is_declared_but_never_used, key); - } - else if (local.declarations && local.declarations[0].kind === SyntaxKind.ImportEqualsDeclaration) { - error(local.declarations[0].name, Diagnostics._0_is_declared_but_never_used, key); - } - else if (local.declarations) { - error(local.declarations[0], Diagnostics._0_is_declared_but_never_used, key); - } - } - } - } - } - } - function checkUnusedClassLocals(node: ClassDeclaration): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { if (node.members) { @@ -14511,21 +14487,13 @@ namespace ts { return (node.flags & NodeFlags.Private) !== 0; } - function checkUnusedImports(node: SourceFile) { + function checkUnusedModuleLocals(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { - for (const local in node.locals) { - if (hasProperty(node.locals, local)) { - const localValue = node.locals[local]; - if (localValue.declarations && !localValue.exportSymbol) { - const declaration = localValue.declarations[0]; - if (!localValue.hasReference) { - if (declaration.kind === SyntaxKind.ImportSpecifier || declaration.kind === SyntaxKind.ImportClause || declaration.kind === SyntaxKind.NamespaceImport) { - error(declaration, Diagnostics._0_is_declared_but_never_used, localValue.name); - } - else if (declaration.kind === SyntaxKind.ImportEqualsDeclaration) { - error(declaration.name, Diagnostics._0_is_declared_but_never_used, localValue.name); - } - } + for (const key in node.locals) { + if (hasProperty(node.locals, key)) { + const local = node.locals[key]; + if (!local.hasReference && !local.exportSymbol) { + forEach(local.declarations, d => error(d.name, Diagnostics._0_is_declared_but_never_used, key)); } } } @@ -16929,7 +16897,6 @@ namespace ts { deferredNodes = []; forEach(node.statements, checkSourceElement); if (isExternalModule(node)) { - checkUnusedImports(node); checkUnusedModuleLocals(node); } checkDeferredNodes(); diff --git a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt index 35829175f052e..cfbeecc3c4902 100644 --- a/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt +++ b/tests/baselines/reference/unusedFunctionsinNamespaces3.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/unusedFunctionsinNamespaces3.ts(3,30): error TS6133: 'param var function1 = function(param1:string) { ~~~~~~~~~ !!! error TS6133: 'function1' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'param1' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt index 009603dba36ef..69a6ea38db6e5 100644 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -19,7 +19,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: 'i ==== tests/cases/compiler/unusedIdentifiersConsolidated1.ts (16 errors) ==== function greeter(person: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -37,7 +37,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: 'i public typedvariable: usedtypeparameter; constructor(message: string) { - ~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS6133: 'message' is declared but never used. var unused2 = 22; ~~~~~~~ @@ -46,7 +46,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: 'i } public greeter(person: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedImports7.errors.txt b/tests/baselines/reference/unusedImports7.errors.txt index 8731188d80d71..1ea8ed60635ad 100644 --- a/tests/baselines/reference/unusedImports7.errors.txt +++ b/tests/baselines/reference/unusedImports7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,8): error TS6133: 'n' is declared but never used. +tests/cases/compiler/file2.ts(1,13): error TS6133: 'n' is declared but never used. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,8): error TS6133: 'n' is declared but never used ==== tests/cases/compiler/file2.ts (1 errors) ==== import * as n from "./file1" - ~~~~~~ + ~ !!! error TS6133: 'n' is declared but never used. \ No newline at end of file diff --git a/tests/baselines/reference/unusedImports8.errors.txt b/tests/baselines/reference/unusedImports8.errors.txt index 566fce7e468ad..d82193106b761 100644 --- a/tests/baselines/reference/unusedImports8.errors.txt +++ b/tests/baselines/reference/unusedImports8.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/file2.ts(1,41): error TS6133: 't2' is declared but never used. +tests/cases/compiler/file2.ts(1,50): error TS6133: 't2' is declared but never used. ==== tests/cases/compiler/file1.ts (0 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/file2.ts(1,41): error TS6133: 't2' is declared but never us ==== tests/cases/compiler/file2.ts (1 errors) ==== import {Calculator as calc, test as t1, test2 as t2} from "./file1" - ~~~~~~~~~~~ + ~~ !!! error TS6133: 't2' is declared but never used. var x = new calc(); diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt index eb06e886a03a4..fa8337c8f177c 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1 ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1.ts (5 errors) ==== function greeter(person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -16,7 +16,7 @@ tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration1 function maker(child: string): void { ~~~~~ !!! error TS6133: 'maker' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt index 301b272743652..0e56f97d1a3e0 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.errors.txt @@ -10,7 +10,7 @@ tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2 ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -18,14 +18,14 @@ tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionDeclaration2 function maker(child: string): void { ~~~~~ !!! error TS6133: 'maker' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ !!! error TS6133: 'unused2' is declared but never used. } function maker2(child2: string): void { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'child2' is declared but never used. var unused3 = 23; ~~~~~~~ diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt index 6bc6e9a6ebadb..0b16195283577 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1.ts (5 errors) ==== var greeter = function (person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -16,7 +16,7 @@ tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression1. function maker(child: string): void { ~~~~~ !!! error TS6133: 'maker' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ diff --git a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt index 9fc90274866e0..7e772d986379e 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.errors.txt @@ -10,7 +10,7 @@ tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2. ==== tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -18,14 +18,14 @@ tests/cases/compiler/unusedLocalsOnFunctionDeclarationWithinFunctionExpression2. function maker(child: string): void { ~~~~~ !!! error TS6133: 'maker' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ !!! error TS6133: 'unused2' is declared but never used. } function maker2(child2: string): void { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'child2' is declared but never used. var unused3 = 23; ~~~~~~~ diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt index 103d6b9623903..99a4fef895867 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1.ts (5 errors) ==== function greeter(person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -16,7 +16,7 @@ tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration1. var maker = function (child: string): void { ~~~~~ !!! error TS6133: 'maker' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt index feb51048e3521..8eb1e73d87ca9 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.errors.txt @@ -10,7 +10,7 @@ tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2. ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2.ts (7 errors) ==== function greeter(person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -18,14 +18,14 @@ tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionDeclaration2. var maker = function(child: string): void { ~~~~~ !!! error TS6133: 'maker' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ !!! error TS6133: 'unused2' is declared but never used. } var maker2 = function(child2: string): void { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'child2' is declared but never used. var unused3 = 23; ~~~~~~~ diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt index c00232c73991f..dd4778b4f3dd9 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.t ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.ts (5 errors) ==== var greeter = function (person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -16,7 +16,7 @@ tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression1.t var maker = function (child: string): void { ~~~~~ !!! error TS6133: 'maker' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ diff --git a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt index fec95669f494a..6d22b7a2bde51 100644 --- a/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt +++ b/tests/baselines/reference/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.errors.txt @@ -10,7 +10,7 @@ tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.t ==== tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.ts (7 errors) ==== var greeter = function (person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ @@ -18,14 +18,14 @@ tests/cases/compiler/unusedLocalsOnFunctionExpressionWithinFunctionExpression2.t var maker = function (child: string): void { ~~~~~ !!! error TS6133: 'maker' is declared but never used. - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS6133: 'child' is declared but never used. var unused2 = 22; ~~~~~~~ !!! error TS6133: 'unused2' is declared but never used. } var maker2 = function (child2: string): void { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'child2' is declared but never used. var unused3 = 23; ~~~~~~~ diff --git a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt index b6c5a4a4b8e3a..28cfc1d578fa8 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InContructor.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/unusedMultipleParameter1InContructor.ts(4,13): error TS6133 class Dummy { constructor(person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt index 8fd7e91dae051..d841f7064a159 100644 --- a/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter1InFunctionExpression.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts(3,9): error ==== tests/cases/compiler/unusedMultipleParameter1InFunctionExpression.ts (2 errors) ==== var func = function(person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt index e6ac70c932c1a..2397a849c5c64 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InContructor.errors.txt @@ -7,9 +7,9 @@ tests/cases/compiler/unusedMultipleParameter2InContructor.ts(4,13): error TS6133 class Dummy { constructor(person: string, person2: string, person3: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. - ~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS6133: 'person3' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt index 534d75c870392..1a4e78cd9fa15 100644 --- a/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameter2InFunctionExpression.errors.txt @@ -6,9 +6,9 @@ tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts(3,9): error ==== tests/cases/compiler/unusedMultipleParameter2InFunctionExpression.ts (3 errors) ==== var func = function(person: string, person2: string, person3: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. - ~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS6133: 'person3' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt index c0d9540ad8108..5ca5eb3bd0c13 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InFunctionDeclaration.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts(3,9): err ==== tests/cases/compiler/unusedMultipleParameters1InFunctionDeclaration.ts (2 errors) ==== function greeter(person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt index 8a783563a5096..9e917be257edc 100644 --- a/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters1InMethodDeclaration.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/unusedMultipleParameters1InMethodDeclaration.ts(4,13): erro class Dummy { public greeter(person: string, person2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt index 4537cede8bbda..0c755b404cd35 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InFunctionDeclaration.errors.txt @@ -6,9 +6,9 @@ tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts(3,9): err ==== tests/cases/compiler/unusedMultipleParameters2InFunctionDeclaration.ts (3 errors) ==== function greeter(person: string, person2: string, person3: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. - ~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS6133: 'person3' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt index 9b9fe8448a24d..ab3313dc98b83 100644 --- a/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedMultipleParameters2InMethodDeclaration.errors.txt @@ -7,9 +7,9 @@ tests/cases/compiler/unusedMultipleParameters2InMethodDeclaration.ts(4,13): erro class Dummy { public greeter(person: string, person2: string, person3: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. - ~~~~~~~~~~~~~~~ + ~~~~~~~ !!! error TS6133: 'person3' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt index d5d2248547703..d09d5906ed103 100644 --- a/tests/baselines/reference/unusedParametersinConstructor1.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor1.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/unusedParametersinConstructor1.ts(3,17): error TS6133: 'par class greeter { constructor(param1: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'param1' is declared but never used. } } \ No newline at end of file diff --git a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt index c755488a630f5..4566713f24f62 100644 --- a/tests/baselines/reference/unusedParametersinConstructor2.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor2.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/unusedParametersinConstructor2.ts(3,17): error TS6133: 'par class greeter { constructor(param1: string, param2: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'param1' is declared but never used. param2 = param2 + "dummy value"; } diff --git a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt index 25c72fc13221d..48891e5361eba 100644 --- a/tests/baselines/reference/unusedParametersinConstructor3.errors.txt +++ b/tests/baselines/reference/unusedParametersinConstructor3.errors.txt @@ -6,9 +6,9 @@ tests/cases/compiler/unusedParametersinConstructor3.ts(3,49): error TS6133: 'par class greeter { constructor(param1: string, param2: string, param3: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'param1' is declared but never used. - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'param3' is declared but never used. param2 = param2 + "dummy value"; } diff --git a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt index b3238b0d9f94b..2549266dfc27b 100644 --- a/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInContructor.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/unusedSingleParameterInContructor.ts(4,13): error TS6133: ' class Dummy { constructor(person: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt index 82260b15f7ed0..e29269e9b05bf 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionDeclaration.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts(3,9): error T ==== tests/cases/compiler/unusedSingleParameterInFunctionDeclaration.ts (2 errors) ==== function greeter(person: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt index 1f32b823c090a..ad3e5e67a72f2 100644 --- a/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInFunctionExpression.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts(3,9): error TS ==== tests/cases/compiler/unusedSingleParameterInFunctionExpression.ts (2 errors) ==== var func = function(person: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ diff --git a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt index ab5f028d5017c..af806bbadfb53 100644 --- a/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt +++ b/tests/baselines/reference/unusedSingleParameterInMethodDeclaration.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/unusedSingleParameterInMethodDeclaration.ts(4,13): error TS class Dummy { public greeter(person: string) { - ~~~~~~~~~~~~~~ + ~~~~~~ !!! error TS6133: 'person' is declared but never used. var unused = 20; ~~~~~~ From 5361e5fa7227c74ffde5444edcc4a5ffe98fc141 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 24 Jun 2016 12:59:39 -0700 Subject: [PATCH 74/90] Added scenario to handle private class elements declared in constructor. --- src/compiler/checker.ts | 15 +++++++++++---- .../unusedIdentifiersConsolidated1.errors.txt | 4 ++-- .../unusedPrivateVariableInClass1.errors.txt | 4 ++-- .../unusedPrivateVariableInClass2.errors.txt | 8 ++++---- .../unusedPrivateVariableInClass3.errors.txt | 8 ++++---- .../unusedPrivateVariableInClass4.errors.txt | 4 ++-- .../unusedPrivateVariableInClass5.errors.txt | 4 ++-- 7 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4ca2d3f050c94..8b257689ac8e1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14484,8 +14484,15 @@ namespace ts { if (node.members) { for (const member of node.members) { if (member.kind === SyntaxKind.MethodDeclaration || member.kind === SyntaxKind.PropertyDeclaration) { - if (isPrivateClassElement(member) && !member.symbol.hasReference) { - error(member, Diagnostics._0_is_declared_but_never_used, member.symbol.name); + if (isPrivateNode(member) && !member.symbol.hasReference) { + error(member.name, Diagnostics._0_is_declared_but_never_used, member.symbol.name); + } + } + else if (member.kind === SyntaxKind.Constructor) { + for (const parameter of (member).parameters) { + if (isPrivateNode(parameter) && !parameter.symbol.hasReference) { + error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + } } } } @@ -14505,7 +14512,7 @@ namespace ts { } } - function isPrivateClassElement(node: ClassElement): boolean { + function isPrivateNode(node: Node): boolean { return (node.flags & NodeFlags.Private) !== 0; } @@ -15967,7 +15974,6 @@ namespace ts { checkExportsOnMergedDeclarations(node); const symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(node, symbol); - updateReferencesForInterfaceHeritiageClauseTargets(node); // Only check this symbol once const firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); @@ -15995,6 +16001,7 @@ namespace ts { if (produceDiagnostics) { checkTypeForDuplicateIndexSignatures(node); + updateReferencesForInterfaceHeritiageClauseTargets(node); checkUnusedTypeParameters(node); } } diff --git a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt index 69a6ea38db6e5..a174074bdf77a 100644 --- a/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt +++ b/tests/baselines/reference/unusedIdentifiersConsolidated1.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(2,18): error TS6133: 'person' is declared but never used. tests/cases/compiler/unusedIdentifiersConsolidated1.ts(3,9): error TS6133: 'unused' is declared but never used. tests/cases/compiler/unusedIdentifiersConsolidated1.ts(6,32): error TS6133: 'unusedtypeparameter' is declared but never used. -tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,5): error TS6133: 'unusedprivatevariable' is declared but never used. +tests/cases/compiler/unusedIdentifiersConsolidated1.ts(7,13): error TS6133: 'unusedprivatevariable' is declared but never used. tests/cases/compiler/unusedIdentifiersConsolidated1.ts(12,17): error TS6133: 'message' is declared but never used. tests/cases/compiler/unusedIdentifiersConsolidated1.ts(13,13): error TS6133: 'unused2' is declared but never used. tests/cases/compiler/unusedIdentifiersConsolidated1.ts(17,20): error TS6133: 'person' is declared but never used. @@ -30,7 +30,7 @@ tests/cases/compiler/unusedIdentifiersConsolidated1.ts(100,15): error TS6133: 'i ~~~~~~~~~~~~~~~~~~~ !!! error TS6133: 'unusedtypeparameter' is declared but never used. private unusedprivatevariable: string; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~ !!! error TS6133: 'unusedprivatevariable' is declared but never used. private greeting: string; public unusedpublicvariable: string; diff --git a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt index 6155d1b089579..bb971334135df 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,5): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass1.ts(3,13): error TS6133: 'x' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass1.ts (1 errors) ==== class greeter { private x: string; - ~~~~~~~~~~~~~~~~~~ + ~ !!! error TS6133: 'x' is declared but never used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt index 6b79756c63ff7..3b814e5ca7c35 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass2.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,5): error TS6133: 'x' is declared but never used. -tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,5): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass2.ts(4,13): error TS6133: 'y' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass2.ts (2 errors) ==== class greeter { private x: string; - ~~~~~~~~~~~~~~~~~~ + ~ !!! error TS6133: 'x' is declared but never used. private y: string; - ~~~~~~~~~~~~~~~~~~ + ~ !!! error TS6133: 'y' is declared but never used. } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt index d0b662a337ff9..5d5e18a2fdfd5 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass3.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,5): error TS6133: 'x' is declared but never used. -tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,5): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(3,13): error TS6133: 'x' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass3.ts(4,13): error TS6133: 'y' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass3.ts (2 errors) ==== class greeter { private x: string; - ~~~~~~~~~~~~~~~~~~ + ~ !!! error TS6133: 'x' is declared but never used. private y: string; - ~~~~~~~~~~~~~~~~~~ + ~ !!! error TS6133: 'y' is declared but never used. public z: string; } \ No newline at end of file diff --git a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt index c43b877b79973..83325cf2d8aa8 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,13): error TS6133: 'y' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass4.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedPrivateVariableInClass4.ts(4,5): error TS6133: 'y' is class greeter { private x: string; private y: string; - ~~~~~~~~~~~~~~~~~~ + ~ !!! error TS6133: 'y' is declared but never used. public z: string; diff --git a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt index 4ae07dfcba66d..741406c528480 100644 --- a/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt +++ b/tests/baselines/reference/unusedPrivateVariableInClass5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6133: 'y' is declared but never used. +tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,13): error TS6133: 'y' is declared but never used. ==== tests/cases/compiler/unusedPrivateVariableInClass5.ts (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/compiler/unusedPrivateVariableInClass5.ts(4,5): error TS6133: 'y' is class greeter { private x: string; private y: string; - ~~~~~~~~~~~~~~~~~~ + ~ !!! error TS6133: 'y' is declared but never used. public z: string; From 7fc461607d4747ac783e5f2ebc223afb3cf7edce Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Fri, 24 Jun 2016 13:08:09 -0700 Subject: [PATCH 75/90] Minor change to erro reporting --- src/compiler/checker.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8b257689ac8e1..44604c532b88e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14466,11 +14466,11 @@ namespace ts { const local = node.locals[key]; if (!local.hasReference && local.valueDeclaration) { if (local.valueDeclaration.kind !== SyntaxKind.Parameter && compilerOptions.noUnusedLocals) { - error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, key); + error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } else if (local.valueDeclaration.kind === SyntaxKind.Parameter && compilerOptions.noUnusedParameters) { if (local.valueDeclaration.flags === 0) { - error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, key); + error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } } @@ -14505,7 +14505,7 @@ namespace ts { if (node.typeParameters) { for (const typeParameter of node.typeParameters) { if (!typeParameter.symbol.hasReference) { - error(typeParameter, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); + error(typeParameter.name, Diagnostics._0_is_declared_but_never_used, typeParameter.symbol.name); } } } @@ -14522,7 +14522,7 @@ namespace ts { if (hasProperty(node.locals, key)) { const local = node.locals[key]; if (!local.hasReference && !local.exportSymbol) { - forEach(local.declarations, d => error(d.name, Diagnostics._0_is_declared_but_never_used, key)); + forEach(local.declarations, d => error(d.name, Diagnostics._0_is_declared_but_never_used, local.name)); } } } From 7238991a738409ef002a2fccdea6186870e8a231 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 27 Jun 2016 10:03:55 -0700 Subject: [PATCH 76/90] Additional scenarios --- src/services/codefixes/unusedIdentifierFixes.ts | 5 +++-- .../cases/fourslash/unusedParameterInConstructor1.ts | 12 ++++++++++++ .../cases/fourslash/unusedTypeParametersInMethod1.ts | 12 ++++++++++++ .../cases/fourslash/unusedTypeParametersInMethod2.ts | 12 ++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/unusedParameterInConstructor1.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInMethod1.ts create mode 100644 tests/cases/fourslash/unusedTypeParametersInMethod2.ts diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index 05dc082968da4..f4f5916567cae 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -56,6 +56,7 @@ namespace ts.codeFix { token.parent.kind === SyntaxKind.InterfaceDeclaration || token.parent.kind === SyntaxKind.MethodDeclaration || token.parent.kind === SyntaxKind.ModuleDeclaration || + token.parent.kind === SyntaxKind.PropertyDeclaration || token.parent.kind === SyntaxKind.ArrowFunction) { return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; } @@ -66,7 +67,7 @@ namespace ts.codeFix { return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 2 } }]; } else { if(typeParameters[0] === token.parent) { - + return [{ newText: "", span: { start: token.parent.pos , length: token.parent.end - token.parent.pos + 1 } }]; } else { return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; } @@ -101,7 +102,7 @@ namespace ts.codeFix { } } - if(token.parent.kind === SyntaxKind.ImportClause) { + if(token.parent.parent.kind === SyntaxKind.ImportClause || token.parent.parent.kind === SyntaxKind.ImportDeclaration) { return [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; } diff --git a/tests/cases/fourslash/unusedParameterInConstructor1.ts b/tests/cases/fourslash/unusedParameterInConstructor1.ts new file mode 100644 index 0000000000000..f5a0108c76f28 --- /dev/null +++ b/tests/cases/fourslash/unusedParameterInConstructor1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// constructor(private p1: string, public p2: boolean, public p3: any, p5) { p5; } +//// } + +verify.codeFixAtPosition(` +class C1 { + constructor(public p2: boolean, public p3: any, p5) { p5; } +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts new file mode 100644 index 0000000000000..d92a17a3f115b --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// f1() {} +//// } + +verify.codeFixAtPosition(` +class C1 { + f1() {} +} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts new file mode 100644 index 0000000000000..cb5861dc8a17c --- /dev/null +++ b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts @@ -0,0 +1,12 @@ +/// + +// @noUnusedLocals: true +//// class C1 { +//// f1(a: U) {a;} +//// } + +verify.codeFixAtPosition(` +class C1 { + f1(a: U) {a;} +} +`); \ No newline at end of file From 537e0653cca2230a1b2e065319a5f10f50ca194d Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 27 Jun 2016 14:17:20 -0700 Subject: [PATCH 77/90] Code changes for abstract class extends --- src/services/quickfixes/interfaceFixes.ts | 23 +++++++++++++++++++ .../fourslash/unImplementedInterface31.ts | 16 +++++++++++++ .../fourslash/unImplementedInterface32.ts | 16 +++++++++++++ .../fourslash/unImplementedInterface33.ts | 16 +++++++++++++ .../fourslash/unImplementedInterface34.ts | 11 +++++++++ .../fourslash/unImplementedInterface35.ts | 13 +++++++++++ .../fourslash/unImplementedInterface36.ts | 17 ++++++++++++++ .../fourslash/unImplementedInterface37.ts | 17 ++++++++++++++ .../fourslash/unImplementedInterface38.ts | 9 ++++++++ 9 files changed, 138 insertions(+) create mode 100644 tests/cases/fourslash/unImplementedInterface31.ts create mode 100644 tests/cases/fourslash/unImplementedInterface32.ts create mode 100644 tests/cases/fourslash/unImplementedInterface33.ts create mode 100644 tests/cases/fourslash/unImplementedInterface34.ts create mode 100644 tests/cases/fourslash/unImplementedInterface35.ts create mode 100644 tests/cases/fourslash/unImplementedInterface36.ts create mode 100644 tests/cases/fourslash/unImplementedInterface37.ts create mode 100644 tests/cases/fourslash/unImplementedInterface38.ts diff --git a/src/services/quickfixes/interfaceFixes.ts b/src/services/quickfixes/interfaceFixes.ts index 5a716b80beca3..d505b91bae8ba 100644 --- a/src/services/quickfixes/interfaceFixes.ts +++ b/src/services/quickfixes/interfaceFixes.ts @@ -58,6 +58,29 @@ namespace ts.quickFix { } }); + registerQuickFix({ + name: "Implements Inherited Abstract Class", + errorCode: "TS2515", + getFix: (sourceFile: SourceFile, start: number, end: number, program: Program): { newText: string; span: { start: number, length: number } }[] => { + const token = getTokenAtPosition(sourceFile, start); + let changesArray: { newText: string; span: { start: number, length: number } }[] = []; + + if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { + let classDeclaration = token.parent; + let startPos: number = classDeclaration.members.pos; + let classMembers: Array = getClassMembers(classDeclaration); + let trackingAddedMembers: Array = []; + let extendsClause = ts.getClassExtendsHeritageClauseElement(classDeclaration); + changesArray = changesArray.concat(getChanges(extendsClause, classMembers, startPos, program, false, trackingAddedMembers)); + } + + if (changesArray.length !== 0) + return changesArray; + + throw new Error("No Quick Fix found"); + } + }); + function getChanges(interfaceClause: Node, existingMembers: Array, startPos: number, program: Program, reference: boolean, trackingAddedMembers: Array): { newText: string; span: { start: number, length: number } }[] { let type = program.getTypeChecker().getTypeAtLocation(interfaceClause); let changesArray: { newText: string; span: { start: number, length: number } }[] = []; diff --git a/tests/cases/fourslash/unImplementedInterface31.ts b/tests/cases/fourslash/unImplementedInterface31.ts new file mode 100644 index 0000000000000..cbffb92977db1 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface31.ts @@ -0,0 +1,16 @@ +/// + +//// abstract class C1 { +//// abstract f1(); +//// } +//// +//// abstract class C2 extends C1 { +//// +//// } +//// +//// class C3 implements C2 {/*0*//*1*/ +//// f2(){} +//// } + + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface32.ts b/tests/cases/fourslash/unImplementedInterface32.ts new file mode 100644 index 0000000000000..49aad350a6f10 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface32.ts @@ -0,0 +1,16 @@ +/// + +//// abstract class C1 { +//// abstract f1(); +//// } +//// +//// abstract class C2 extends C1 { +//// +//// } +//// +//// class C3 implements C2 {/*0*//*1*/ +//// f2(){} +//// } + + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface33.ts b/tests/cases/fourslash/unImplementedInterface33.ts new file mode 100644 index 0000000000000..f4dcd796878c8 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface33.ts @@ -0,0 +1,16 @@ +/// + +//// abstract class C1 { +//// abstract f1(); +//// } +//// +//// abstract class C2 extends C1 { +//// +//// } +//// +//// class C3 implements C2 {/*0*//*1*/ +//// f2(){} +//// } + + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface34.ts b/tests/cases/fourslash/unImplementedInterface34.ts new file mode 100644 index 0000000000000..43efe85ccd9ac --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface34.ts @@ -0,0 +1,11 @@ +/// + +//// abstract class C1 { +//// abstract f1(); +//// } +//// +//// class C2 extends C1 {/*0*//*1*/ +//// +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface35.ts b/tests/cases/fourslash/unImplementedInterface35.ts new file mode 100644 index 0000000000000..90f7e3e323158 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface35.ts @@ -0,0 +1,13 @@ +/// + +//// abstract class C1 { +//// abstract f1(); +//// } +//// +//// interface I1 extends C1 {} +//// +//// class C2 implements I1 {/*0*//*1*/ +//// +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface36.ts b/tests/cases/fourslash/unImplementedInterface36.ts new file mode 100644 index 0000000000000..f9b9b00de0579 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface36.ts @@ -0,0 +1,17 @@ +/// + +//// abstract class C1 { +//// +//// } +//// +//// abstract class C2 { +//// abstract f1(); +//// } +//// +//// interface I1 extends C1, C2 {} +//// +//// class C3 implements I1 {/*0*//*1*/ +//// +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface37.ts b/tests/cases/fourslash/unImplementedInterface37.ts new file mode 100644 index 0000000000000..cda6749e33fe8 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface37.ts @@ -0,0 +1,17 @@ +/// + +//// abstract class C1 { +//// abstract f1(); +//// } +//// +//// abstract class C2 extends C1{ +//// +//// } +//// +//// interface I1 extends C2 {} +//// +//// class C3 implements I1 {/*0*//*1*/ +//// +//// } + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); diff --git a/tests/cases/fourslash/unImplementedInterface38.ts b/tests/cases/fourslash/unImplementedInterface38.ts new file mode 100644 index 0000000000000..51f6c2252147a --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface38.ts @@ -0,0 +1,9 @@ +/// + +//// abstract class C2 { +//// abstract f1(); +//// } +//// +//// var x: C2 = {/*0*//*1*/} + +verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); From db4838f196eb59b530fb77cb934f90dade60faaa Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 27 Jun 2016 16:12:44 -0700 Subject: [PATCH 78/90] Code changes for changing extends keyword to implements keyword --- .../codefixes/changeExtendsToImplementsFix.ts | 19 +++++++++++++++++++ src/services/codefixes/references.ts | 1 + .../fourslash/changeExtendsToImplementsFS1.ts | 9 +++++++++ .../fourslash/changeExtendsToImplementsFS2.ts | 9 +++++++++ 4 files changed, 38 insertions(+) create mode 100644 src/services/codefixes/changeExtendsToImplementsFix.ts create mode 100644 tests/cases/fourslash/changeExtendsToImplementsFS1.ts create mode 100644 tests/cases/fourslash/changeExtendsToImplementsFS2.ts diff --git a/src/services/codefixes/changeExtendsToImplementsFix.ts b/src/services/codefixes/changeExtendsToImplementsFix.ts new file mode 100644 index 0000000000000..bcba7e8fa00b2 --- /dev/null +++ b/src/services/codefixes/changeExtendsToImplementsFix.ts @@ -0,0 +1,19 @@ +/* @internal */ +namespace ts.codeFix { + registerCodeFix({ + name: "Change Extends to Implements", + errorCodes: ["TS2689"], + getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { + const token = getTokenAtPosition(sourceFile, start); + if(token.kind === SyntaxKind.Identifier && token.parent.parent.kind === SyntaxKind.HeritageClause) { + let children = (token.parent.parent).getChildren(); + for(const child of children) { + if(child.kind === SyntaxKind.ExtendsKeyword) { + return [{ newText: "implements", span: { start: child.pos, length: child.end - child.pos}}]; + } + } + } + Debug.fail("No Quick fix found."); + } + }); +} diff --git a/src/services/codefixes/references.ts b/src/services/codefixes/references.ts index 4d74dfe446305..9d1a1e5b1d5f9 100644 --- a/src/services/codefixes/references.ts +++ b/src/services/codefixes/references.ts @@ -2,3 +2,4 @@ /// /// /// +/// diff --git a/tests/cases/fourslash/changeExtendsToImplementsFS1.ts b/tests/cases/fourslash/changeExtendsToImplementsFS1.ts new file mode 100644 index 0000000000000..4a76bf8b4e7ed --- /dev/null +++ b/tests/cases/fourslash/changeExtendsToImplementsFS1.ts @@ -0,0 +1,9 @@ +/// + +//// interface I1 {} +//// class c1 /*0*/extends/*1*/ I1{} + +verify.codeFixAtPosition(` +interface I1 {} +class c1 implements I1{} +`); \ No newline at end of file diff --git a/tests/cases/fourslash/changeExtendsToImplementsFS2.ts b/tests/cases/fourslash/changeExtendsToImplementsFS2.ts new file mode 100644 index 0000000000000..9d7f3d7680118 --- /dev/null +++ b/tests/cases/fourslash/changeExtendsToImplementsFS2.ts @@ -0,0 +1,9 @@ +/// + +//// interface I1 {} +//// class c1 /*0*/extends/*1*/ I1{} + +verify.codeFixAtPosition(` +interface I1 {} +class c1 implements I1{} +`); \ No newline at end of file From bf6e045a12f5fb411c6d991f58c75a9db2807e7c Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 28 Jun 2016 15:45:07 -0700 Subject: [PATCH 79/90] Change to use CodeActionContext instead of a bunch of arguments, so it's easier to change in the future. --- src/services/codefixes/codeFixProvider.ts | 15 ++++++++++----- src/services/codefixes/superFixes.ts | 11 +++++++---- src/services/services.ts | 6 ++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 7797416f7fa9a..27d5f730c7ca0 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -3,14 +3,19 @@ namespace ts { export interface CodeAction { name: string; errorCodes: string[]; - getTextChanges(sourceFile: SourceFile, start: number, end: number): FileTextChanges[]; + getTextChanges(context: CodeActionContext): FileTextChanges[]; + } + + export class CodeActionContext { + constructor(public errorCode: string, public sourceFile: SourceFile, public span: TextSpan, public checker: TypeChecker) { + } } export namespace codeFix { var codeActions: Map = {}; export function registerCodeFix(fix: CodeAction) { - forEach( fix.errorCodes, error => { + forEach(fix.errorCodes, error => { let fixes = codeActions[error]; if (!fixes) { fixes = []; @@ -26,14 +31,14 @@ namespace ts { return getKeys(codeActions); } - public getFixes(errorCode: string, sourceFile: SourceFile, start: number, end: number): CodeFix[] { - const actions = codeActions[errorCode]; + public getFixes(context: CodeActionContext): CodeFix[] { + const actions = codeActions[context.errorCode]; const fixes: CodeFix[] = []; Debug.assert(actions && actions.length > 0, "No fixes found for error: '${errorCode}'."); forEach(actions, a => { - const textChanges = a.getTextChanges(sourceFile, start, end); + const textChanges = a.getTextChanges(context); if (textChanges && textChanges.length > 0) { fixes.push({ description: a.name, changes: textChanges }); } diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 92f815e1dd191..681c26df95d5d 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -8,8 +8,9 @@ namespace ts.codeFix { registerCodeFix({ name: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), errorCodes: ["TS2377"], - getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { - const token = getTokenAtPosition(sourceFile, start); + getTextChanges: (context: CodeActionContext) => { + const sourceFile = context.sourceFile; + const token = getTokenAtPosition(sourceFile, context.span.start); Debug.assert(token.kind === SyntaxKind.ConstructorKeyword, "Failed to find the constructor."); const newPosition = getOpenBraceEnd(token.parent, sourceFile); @@ -21,8 +22,10 @@ namespace ts.codeFix { registerCodeFix({ name: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), errorCodes: ["TS17009"], - getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { - const token = getTokenAtPosition(sourceFile, start); + getTextChanges: (context: CodeActionContext) => { + const sourceFile = context.sourceFile; + + const token = getTokenAtPosition(sourceFile, context.span.start); const constructor = getContainingFunction(token); Debug.assert(constructor.kind === SyntaxKind.Constructor, "Failed to find the constructor."); diff --git a/src/services/services.ts b/src/services/services.ts index 815844db108f9..c7b8828c7cdb5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -7708,11 +7708,13 @@ namespace ts { function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeFix[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); - + const checker = program.getTypeChecker(); let allFixes: CodeFix[] = []; forEach(errorCodes, error => { - const fixes = codeFixProvider.getFixes(error, sourceFile, start, end); + const context = new CodeActionContext(error, sourceFile, { start, length: end - start }, checker); + + const fixes = codeFixProvider.getFixes(context); if (fixes) { allFixes = allFixes.concat(fixes); } From 23ea06b9c47183c59e20604f3a29bf21144fc73f Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Tue, 28 Jun 2016 16:56:50 -0700 Subject: [PATCH 80/90] CR Feedback. Turn CodeActionContext into interface --- src/services/codefixes/codeFixProvider.ts | 8 +++++--- src/services/services.ts | 7 ++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 27d5f730c7ca0..46cd652d9c6fc 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -6,9 +6,11 @@ namespace ts { getTextChanges(context: CodeActionContext): FileTextChanges[]; } - export class CodeActionContext { - constructor(public errorCode: string, public sourceFile: SourceFile, public span: TextSpan, public checker: TypeChecker) { - } + export interface CodeActionContext { + errorCode: string; + sourceFile: SourceFile; + span: TextSpan; + checker: TypeChecker; } export namespace codeFix { diff --git a/src/services/services.ts b/src/services/services.ts index c7b8828c7cdb5..e6c8601450413 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -7712,7 +7712,12 @@ namespace ts { let allFixes: CodeFix[] = []; forEach(errorCodes, error => { - const context = new CodeActionContext(error, sourceFile, { start, length: end - start }, checker); + const context = { + errorCode: error, + sourceFile: sourceFile, + span: { start, length: end - start }, + checker: checker + }; const fixes = codeFixProvider.getFixes(context); if (fixes) { From 15d71ebc510f913ce6c2f90dc576af90bd4085bb Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 1 Jul 2016 11:34:02 -0700 Subject: [PATCH 81/90] Improve Fourslash support --- src/compiler/core.ts | 9 +++++++++ src/harness/fourslash.ts | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 4aba46c7839be..171a530fb5c26 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -113,6 +113,15 @@ namespace ts { return -1; } + export function firstOrUndefined(array: T[], predicate: (x: T) => boolean): T { + for (let i = 0, len = array.length; i < len; i++) { + if (predicate(array[i])) { + return array[i]; + } + } + return undefined; + } + export function indexOfAnyCharCode(text: string, charCodes: number[], start?: number): number { for (let i = start || 0, len = text.length; i < len; i++) { if (contains(charCodes, text.charCodeAt(i))) { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8e344a0ddbe03..6f965460d7bd3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1865,7 +1865,7 @@ namespace FourSlash { } } - public verifyCodeFixAtPosition(expectedText: string) { + public verifyCodeFixAtPosition(expectedText: string, errorCode?:number) { const fileName = this.activeFile.fileName; const diagnostics = this.getDiagnostics(fileName); @@ -1873,11 +1873,13 @@ namespace FourSlash { this.raiseError("Errors expected."); } - // we expect a single error per file - const errorCode = diagnostics[0].code; - const position = diagnostics[0].start; + if (diagnostics.length > 1 && !errorCode) { + this.raiseError("When there's more than one error, you must specify the errror to fix."); + } + + let diagnostic = !errorCode ? diagnostics[0] : ts.firstOrUndefined(diagnostics, d => d.code == errorCode); - const actual = this.languageService.getCodeFixesAtPosition(this.activeFile.fileName, position, position, [`TS${errorCode}`]); + const actual = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [`TS${diagnostic.code}`]); if (!actual || actual.length == 0) { this.raiseError("No codefixes returned."); @@ -1887,8 +1889,12 @@ namespace FourSlash { this.raiseError("More than 1 codefix returned."); } + +//todo: handle multiple files, probably need to set the cursor in the test file, and loop over all the files + + this.applyEdits(actual[0].changes[0].fileName, actual[0].changes[0].textChanges, /*isFormattingEdit*/ false); - const actualText = this.getFileContent(fileName); + const actualText = this.getFileContent(actual[0].changes[0].fileName); // We expect the editor to do the final formatting, so we can strip the compare ignoring whitespace if (this.removeWhitespace(expectedText) !== this.removeWhitespace(actualText)) { From d9f9baa4ba50bc56172852b28620f41dd521dab1 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 1 Jul 2016 13:39:11 -0700 Subject: [PATCH 82/90] linter fixes --- src/harness/fourslash.ts | 8 +- .../codefixes/changeExtendsToImplementsFix.ts | 20 +- src/services/codefixes/codeFixProvider.ts | 2 +- src/services/codefixes/interfaceFixes.ts | 239 ++++++++++++++++++ .../codefixes/unusedIdentifierFixes.ts | 136 +++++----- src/services/quickfixes/interfaceFixes.ts | 228 ----------------- 6 files changed, 332 insertions(+), 301 deletions(-) create mode 100644 src/services/codefixes/interfaceFixes.ts delete mode 100644 src/services/quickfixes/interfaceFixes.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5f5f80cee0058..6df7e118d9f59 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1865,7 +1865,7 @@ namespace FourSlash { } } - public verifyCodeFixAtPosition(expectedText: string, errorCode?:number) { + public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { const fileName = this.activeFile.fileName; const diagnostics = this.getDiagnostics(fileName); @@ -1877,7 +1877,7 @@ namespace FourSlash { this.raiseError("When there's more than one error, you must specify the errror to fix."); } - let diagnostic = !errorCode ? diagnostics[0] : ts.firstOrUndefined(diagnostics, d => d.code == errorCode); + const diagnostic = !errorCode ? diagnostics[0] : ts.firstOrUndefined(diagnostics, d => d.code == errorCode); const actual = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [`TS${diagnostic.code}`]); @@ -1890,12 +1890,14 @@ namespace FourSlash { } -//todo: handle multiple files, probably need to set the cursor in the test file, and loop over all the files + // todo: handle multiple files, probably need to set the cursor in the test file, and loop over all the files this.applyEdits(actual[0].changes[0].fileName, actual[0].changes[0].textChanges, /*isFormattingEdit*/ false); const actualText = this.getFileContent(actual[0].changes[0].fileName); + if (this.removeWhitespace(actualText) !== this.removeWhitespace(expectedText)) { + this.raiseError(`Actual text doesn't match expected text. Actual: '${actualText}' Expected: '${expectedText}'`); } } diff --git a/src/services/codefixes/changeExtendsToImplementsFix.ts b/src/services/codefixes/changeExtendsToImplementsFix.ts index bcba7e8fa00b2..34888a909b12b 100644 --- a/src/services/codefixes/changeExtendsToImplementsFix.ts +++ b/src/services/codefixes/changeExtendsToImplementsFix.ts @@ -3,17 +3,23 @@ namespace ts.codeFix { registerCodeFix({ name: "Change Extends to Implements", errorCodes: ["TS2689"], - getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { + getTextChanges: (context: CodeActionContext) => { + const sourceFile = context.sourceFile; + const start = context.span.start; const token = getTokenAtPosition(sourceFile, start); - if(token.kind === SyntaxKind.Identifier && token.parent.parent.kind === SyntaxKind.HeritageClause) { - let children = (token.parent.parent).getChildren(); - for(const child of children) { - if(child.kind === SyntaxKind.ExtendsKeyword) { - return [{ newText: "implements", span: { start: child.pos, length: child.end - child.pos}}]; + + if (token.kind === SyntaxKind.Identifier && token.parent.parent.kind === SyntaxKind.HeritageClause) { + const children = (token.parent.parent).getChildren(); + for (const child of children) { + if (child.kind === SyntaxKind.ExtendsKeyword) { + return [{ + fileName: sourceFile.fileName, + textChanges: [{ newText: "implements", span: { start: child.pos, length: child.end - child.pos } }] + }]; } } } - Debug.fail("No Quick fix found."); + Debug.fail("Failed to construct a fix."); } }); } diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 46cd652d9c6fc..fe40478f9fdf9 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -14,7 +14,7 @@ namespace ts { } export namespace codeFix { - var codeActions: Map = {}; + const codeActions: Map = {}; export function registerCodeFix(fix: CodeAction) { forEach(fix.errorCodes, error => { diff --git a/src/services/codefixes/interfaceFixes.ts b/src/services/codefixes/interfaceFixes.ts new file mode 100644 index 0000000000000..3ccdd62841c73 --- /dev/null +++ b/src/services/codefixes/interfaceFixes.ts @@ -0,0 +1,239 @@ +/* @internal */ +namespace ts.codeFix { + registerCodeFix({ + name: "Implement Interface on Reference", + errorCodes: ["TS2322"], + getTextChanges: (context: CodeActionContext) => { + const sourceFile = context.sourceFile; + const start = context.span.start; + const token = getTokenAtPosition(sourceFile, start); + let changesArray: TextChange[] = []; + + if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.VariableDeclaration) { + const variableDeclaration = token.parent; + const membersAndStartPosObject = getMembersAndStartPosFromReference(variableDeclaration); + const variableMembers = membersAndStartPosObject.members; + const trackingAddedMembers: string[] = []; + const startPos: number = membersAndStartPosObject.startPos; + + if (variableDeclaration.type.kind === SyntaxKind.TypeReference) { + changesArray = changesArray.concat(getChanges(variableDeclaration.type, variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers)); + } + else if (variableDeclaration.type.kind === SyntaxKind.UnionType) { + const types = (variableDeclaration.type).types; + for (let i = 0; i < types.length; i++) { + changesArray = changesArray.concat(getChanges(types[i], variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers)); + } + } + } + + if (changesArray.length !== 0) { + return [{ fileName: sourceFile.fileName, textChanges: changesArray }]; + } + + Debug.fail("No Quick Fix found"); + } + }); + + registerCodeFix({ + name: "Implement Interface On Class", + errorCodes: ["TS2420"], + getTextChanges: (context: CodeActionContext) => { + const sourceFile = context.sourceFile; + const start = context.span.start; + const token = getTokenAtPosition(sourceFile, start); + let changesArray: TextChange[] = []; + + if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { + const classDeclaration = token.parent; + const startPos: number = classDeclaration.members.pos; + const classMembers: Array = getClassMembers(classDeclaration); + const trackingAddedMembers: Array = []; + const interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration); + + for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) { + changesArray = changesArray.concat(getChanges(interfaceClauses[i], classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); + } + } + + if (changesArray.length !== 0) { + return [{ fileName: sourceFile.fileName, textChanges: changesArray }]; + } + + Debug.fail("No Quick Fix found"); + } + }); + + registerCodeFix({ + name: "Implements Inherited Abstract Class", + errorCodes: ["TS2515"], + getTextChanges: (context: CodeActionContext) => { + const sourceFile = context.sourceFile; + const start = context.span.start; + const token = getTokenAtPosition(sourceFile, start); + let changesArray: { newText: string; span: { start: number, length: number } }[] = []; + + if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { + const classDeclaration = token.parent; + const startPos: number = classDeclaration.members.pos; + const classMembers: Array = getClassMembers(classDeclaration); + const trackingAddedMembers: Array = []; + const extendsClause = ts.getClassExtendsHeritageClauseElement(classDeclaration); + changesArray = changesArray.concat(getChanges(extendsClause, classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); + } + + if (changesArray.length !== 0) { + return [{ fileName: sourceFile.fileName, textChanges: changesArray }]; + } + + Debug.fail("No Quick Fix found"); + } + }); + + function getChanges(interfaceClause: Node, existingMembers: string[], startPos: number, checker: TypeChecker, reference: boolean, trackingAddedMembers: string[]): TextChange[] { + const type = checker.getTypeAtLocation(interfaceClause); + const changesArray: TextChange[] = []; + + if (type && type.symbol && type.symbol.declarations) { + const interfaceMembers = getMembers(type.symbol.declarations[0], checker); + for (let j = 0; interfaceMembers && j < interfaceMembers.length; j++) { + if (interfaceMembers[j].name && existingMembers.indexOf(interfaceMembers[j].name.getText()) === -1) { + if (interfaceMembers[j].kind === SyntaxKind.PropertySignature) { + const interfaceProperty = interfaceMembers[j]; + if (trackingAddedMembers.indexOf(interfaceProperty.name.getText()) === -1) { + let propertyText = ""; + if (reference) { + propertyText = interfaceProperty.name.getText(); + propertyText += " : "; + propertyText += getDefaultValue(interfaceProperty.type.kind); + propertyText += ",sys.newLine"; + } + else { + propertyText = interfaceProperty.getText(); + const stringToAdd = propertyText.match(/;$/) === undefined ? ";sys.newLine" : "sys.newLine"; + propertyText += stringToAdd; + } + changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); + trackingAddedMembers.push(interfaceProperty.name.getText()); + } + } + else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature || interfaceMembers[j].kind === SyntaxKind.MethodDeclaration) { + const interfaceMethod = interfaceMembers[j]; + handleMethods(interfaceMethod, startPos, reference, trackingAddedMembers, changesArray); + } + } + } + } + + if (reference && existingMembers.length === 0 && changesArray.length > 0) { + let lastValue = changesArray[changesArray.length - 1].newText; + lastValue = lastValue.substr(0, lastValue.length - 12); + lastValue = lastValue + " sys.newLine"; + changesArray[changesArray.length - 1].newText = lastValue; + } + + return changesArray; + } + + function getMembers(declaration: InterfaceDeclaration, checker: TypeChecker): TypeElement[] { + const clauses = getInterfaceBaseTypeNodes(declaration); + let result: TypeElement[] = []; + for (let i = 0; clauses && i < clauses.length; i++) { + const type = checker.getTypeAtLocation(clauses[i]); + if (type && type.symbol && type.symbol.declarations) { + result = result.concat(getMembers(type.symbol.declarations[0], checker)); + } + } + + if (declaration.members) { + result = result.concat(declaration.members); + } + + return result; + } + + function getClassMembers(classDeclaration: ClassDeclaration): string[] { + const classMembers: string[] = []; + for (let i = 0; classDeclaration.members && i < classDeclaration.members.length; i++) { + if (classDeclaration.members[i].name) { + classMembers.push(classDeclaration.members[i].name.getText()); + } + } + return classMembers; + } + + function getMembersAndStartPosFromReference(variableDeclaration: VariableDeclaration): { startPos: number, members: string[] } { + const children = variableDeclaration.getChildren(); + const variableMembers: string[] = []; + let startPos = 0; + + for (let i = 0; i < children.length; i++) { + if (children[i].kind === SyntaxKind.ObjectLiteralExpression) { + startPos = children[i].pos + 1; + const properties = (children[i]).properties; + for (let j = 0; properties && j < properties.length; j++) { + if (properties[j].name) { + variableMembers.push(properties[j].name.getText()); + } + } + } + } + + return { startPos: startPos, members: variableMembers }; + } + + function getDefaultValue(kind: SyntaxKind): string { + switch (kind) { + case SyntaxKind.StringKeyword: + return '""'; + case SyntaxKind.BooleanKeyword: + return "false"; + case SyntaxKind.NumberKeyword: + return "0"; + } + return "null"; + } + + function handleMethods(interfaceMethod: MethodSignature, startPos: number, isReference: boolean, trackingAddedMembers: string[], changesArray: TextChange[]) { + if (trackingAddedMembers.indexOf(interfaceMethod.name.getText())) { + const methodName = interfaceMethod.name.getText(); + const typeParameterArray: Array = []; + for (let i = 0; interfaceMethod.typeParameters && i < interfaceMethod.typeParameters.length; i++) { + typeParameterArray.push(interfaceMethod.typeParameters[i].getText()); + } + const parameterArray: Array = []; + for (let j = 0; interfaceMethod.parameters && j < interfaceMethod.parameters.length; j++) { + parameterArray.push(interfaceMethod.parameters[j].getText()); + } + const methodBody = "throw new Error('Method not Implemented');"; + + let methodText = methodName; + if (typeParameterArray.length > 0) { + methodText += "<"; + } + for (let k = 0; k < typeParameterArray.length; k++) { + methodText += typeParameterArray[k]; + if (k !== typeParameterArray.length - 1) { + methodText += ","; + } + } + if (typeParameterArray.length > 0) { + methodText += ">"; + } + methodText += "("; + for (let k = 0; k < parameterArray.length; k++) { + methodText += parameterArray[k]; + if (k !== parameterArray.length - 1) { + methodText += ","; + } + } + methodText += ")"; + methodText += "{sys.newLine "; + methodText += methodBody; + methodText += "sys.newLine"; + methodText = isReference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); + changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); + trackingAddedMembers.push(interfaceMethod.name.getText()); + } + } +} diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index f4f5916567cae..ee89d554726e4 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -3,124 +3,136 @@ namespace ts.codeFix { registerCodeFix({ name: "Remove Unused Identifiers", errorCodes: ["TS6133"], - getTextChanges: (sourceFile: SourceFile, start: number, end: number) => { + getTextChanges: (context: CodeActionContext) => { + const sourceFile = context.sourceFile; + const start = context.span.start; const token = getTokenAtPosition(sourceFile, start); if (token.kind === ts.SyntaxKind.Identifier) { if (token.parent.kind === ts.SyntaxKind.VariableDeclaration) { if (token.parent.parent.parent.kind === SyntaxKind.ForStatement) { - var forStatement = token.parent.parent.parent; - var initializer = forStatement.initializer; + const forStatement = token.parent.parent.parent; + const initializer = forStatement.initializer; if (initializer.declarations.length === 1) { - return [{ newText: "", span: { start: initializer.pos, length: initializer.end - initializer.pos } }]; - } else { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: initializer.pos, length: initializer.end - initializer.pos } }] }]; + } + else { if (initializer.declarations[0] === token.parent) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }]; - } else { - return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }] }]; + } + else { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; } } } else if (token.parent.parent.parent.kind === SyntaxKind.ForInStatement) { - var forInStatement = token.parent.parent.parent; - var initializer = forInStatement.initializer; - return [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }]; + const forInStatement = token.parent.parent.parent; + const initializer = forInStatement.initializer; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }] }]; } else if (token.parent.parent.parent.kind === SyntaxKind.ForOfStatement) { - var forOfStatement = token.parent.parent.parent; - var initializer = forOfStatement.initializer; - return [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }]; + const forOfStatement = token.parent.parent.parent; + const initializer = forOfStatement.initializer; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }] }]; } else if (token.parent.parent.kind === SyntaxKind.CatchClause) { - var catchClause = token.parent.parent; - var parameter = catchClause.variableDeclaration.getChildren()[0]; - return [{ newText: "", span: { start: parameter.pos, length: parameter.end - parameter.pos } }]; + const catchClause = token.parent.parent; + const parameter = catchClause.variableDeclaration.getChildren()[0]; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: parameter.pos, length: parameter.end - parameter.pos } }] }]; } else { - var variableStatement = token.parent.parent.parent; + const variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return [{ newText: "", span: { start: variableStatement.pos, length: variableStatement.end - variableStatement.pos } }]; - } else { - var declarations = variableStatement.declarationList.declarations; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: variableStatement.pos, length: variableStatement.end - variableStatement.pos } }] }]; + } + else { + const declarations = variableStatement.declarationList.declarations; if (declarations[0].name === token) { - return [{ newText: "", span: { start: token.parent.pos + 1, length: token.parent.end - token.parent.pos } }]; - } else { - return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos + 1, length: token.parent.end - token.parent.pos } }] }]; + } + else { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; } } } } - if (token.parent.kind === SyntaxKind.FunctionDeclaration || - token.parent.kind === SyntaxKind.ClassDeclaration || + if (token.parent.kind === SyntaxKind.FunctionDeclaration || + token.parent.kind === SyntaxKind.ClassDeclaration || token.parent.kind === SyntaxKind.InterfaceDeclaration || - token.parent.kind === SyntaxKind.MethodDeclaration || - token.parent.kind === SyntaxKind.ModuleDeclaration || - token.parent.kind === SyntaxKind.PropertyDeclaration || + token.parent.kind === SyntaxKind.MethodDeclaration || + token.parent.kind === SyntaxKind.ModuleDeclaration || + token.parent.kind === SyntaxKind.PropertyDeclaration || token.parent.kind === SyntaxKind.ArrowFunction) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; } if (token.parent.kind === SyntaxKind.TypeParameter) { - var typeParameters = (token.parent.parent).typeParameters; + const typeParameters = (token.parent.parent).typeParameters; if (typeParameters.length === 1) { - return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 2 } }]; - } else { - if(typeParameters[0] === token.parent) { - return [{ newText: "", span: { start: token.parent.pos , length: token.parent.end - token.parent.pos + 1 } }]; - } else { - return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 2 } }] }]; + } + else { + if (typeParameters[0] === token.parent) { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }] }]; + } + else { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; } } } if (token.parent.kind === ts.SyntaxKind.Parameter) { - var functionDeclaration = token.parent.parent; - if(functionDeclaration.parameters.length === 1) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos} }]; - } else { + const functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + } + else { if (functionDeclaration.parameters[0] === token.parent) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }]; - } else { - return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }] }]; + } + else { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; } } } if (token.parent.kind === SyntaxKind.ImportSpecifier) { - var namedImports = token.parent.parent; - var elements = namedImports.elements; + const namedImports = token.parent.parent; + const elements = namedImports.elements; if (elements.length === 1) { - //Only 1 import and it is unused. So the entire line could be removed. - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; - } else { + // Only 1 import and it is unused. So the entire line could be removed. + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + } + else { if (elements[0] === token.parent) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }]; - } else { - return [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }]; + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }] }]; + } + else { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; } } } - if(token.parent.parent.kind === SyntaxKind.ImportClause || token.parent.parent.kind === SyntaxKind.ImportDeclaration) { - return [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; + if (token.parent.parent.kind === SyntaxKind.ImportClause || token.parent.parent.kind === SyntaxKind.ImportDeclaration) { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; } - if(token.parent.kind === SyntaxKind.ImportEqualsDeclaration) { - return [{ newText: "{}", span: { start: token.pos, length: token.end - token.pos } }]; + if (token.parent.kind === SyntaxKind.ImportEqualsDeclaration) { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: token.pos, length: token.end - token.pos } }] }]; } - if(token.parent.kind === SyntaxKind.EnumDeclaration) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; + if (token.parent.kind === SyntaxKind.EnumDeclaration) { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; } } - if(token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { - return [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos}}]; + if (token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; } - if(token.kind === SyntaxKind.AsteriskToken && token.parent.kind === SyntaxKind.NamespaceImport) { - return [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }]; + if (token.kind === SyntaxKind.AsteriskToken && token.parent.kind === SyntaxKind.NamespaceImport) { + return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; } Debug.fail("No Quick fix found."); diff --git a/src/services/quickfixes/interfaceFixes.ts b/src/services/quickfixes/interfaceFixes.ts deleted file mode 100644 index d505b91bae8ba..0000000000000 --- a/src/services/quickfixes/interfaceFixes.ts +++ /dev/null @@ -1,228 +0,0 @@ -/* @internal */ -namespace ts.quickFix { - registerQuickFix({ - name: "Implement Interface on Reference", - errorCode: "TS2322", - getFix: (sourceFile: SourceFile, start: number, end: number, program: Program): { newText: string; span: { start: number, length: number } }[] => { - const token = getTokenAtPosition(sourceFile, start); - let changesArray: { newText: string; span: { start: number, length: number } }[] = []; - - if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.VariableDeclaration) { - let variableDeclaration = token.parent; - let membersAndStartPosObject: { startPos: number, members: Array } = getMembersAndStartPosFromReference(variableDeclaration); - let variableMembers: Array = membersAndStartPosObject.members; - let trackingAddedMembers: Array = []; - let startPos: number = membersAndStartPosObject.startPos; - - if (variableDeclaration.type.kind === SyntaxKind.TypeReference) { - changesArray = changesArray.concat(getChanges(variableDeclaration.type, variableMembers, startPos, program, true, trackingAddedMembers)); - } - else if(variableDeclaration.type.kind === SyntaxKind.UnionType) { - let types = (variableDeclaration.type).types; - for (let i = 0; i < types.length; i++) { - changesArray = changesArray.concat(getChanges(types[i], variableMembers, startPos, program, true, trackingAddedMembers)); - } - } - } - - if (changesArray.length !== 0) - return changesArray; - - throw new Error("No Quick Fix found"); - } - }); - - registerQuickFix({ - name: "Implement Interface On Class", - errorCode: "TS2420", - getFix: (sourceFile: SourceFile, start: number, end: number, program: Program): { newText: string; span: { start: number, length: number } }[] => { - const token = getTokenAtPosition(sourceFile, start); - let changesArray: { newText: string; span: { start: number, length: number } }[] = []; - - if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { - let classDeclaration = token.parent; - let startPos: number = classDeclaration.members.pos; - let classMembers: Array = getClassMembers(classDeclaration); - let trackingAddedMembers: Array = []; - let interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration); - - for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) { - changesArray = changesArray.concat(getChanges(interfaceClauses[i], classMembers, startPos, program, false, trackingAddedMembers)); - } - } - - if (changesArray.length !== 0) - return changesArray; - - throw new Error("No Quick Fix found"); - } - }); - - registerQuickFix({ - name: "Implements Inherited Abstract Class", - errorCode: "TS2515", - getFix: (sourceFile: SourceFile, start: number, end: number, program: Program): { newText: string; span: { start: number, length: number } }[] => { - const token = getTokenAtPosition(sourceFile, start); - let changesArray: { newText: string; span: { start: number, length: number } }[] = []; - - if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { - let classDeclaration = token.parent; - let startPos: number = classDeclaration.members.pos; - let classMembers: Array = getClassMembers(classDeclaration); - let trackingAddedMembers: Array = []; - let extendsClause = ts.getClassExtendsHeritageClauseElement(classDeclaration); - changesArray = changesArray.concat(getChanges(extendsClause, classMembers, startPos, program, false, trackingAddedMembers)); - } - - if (changesArray.length !== 0) - return changesArray; - - throw new Error("No Quick Fix found"); - } - }); - - function getChanges(interfaceClause: Node, existingMembers: Array, startPos: number, program: Program, reference: boolean, trackingAddedMembers: Array): { newText: string; span: { start: number, length: number } }[] { - let type = program.getTypeChecker().getTypeAtLocation(interfaceClause); - let changesArray: { newText: string; span: { start: number, length: number } }[] = []; - - if (type && type.symbol && type.symbol.declarations) { - let interfaceMembers = getMembers(type.symbol.declarations[0], program); - for (let j = 0; interfaceMembers && j < interfaceMembers.length; j++) { - if (interfaceMembers[j].name && existingMembers.indexOf(interfaceMembers[j].name.getText()) === -1) { - if (interfaceMembers[j].kind === SyntaxKind.PropertySignature) { - let interfaceProperty = interfaceMembers[j]; - if(trackingAddedMembers.indexOf(interfaceProperty.name.getText()) === -1) { - let propertyText:string = ""; - if(reference) { - propertyText = interfaceProperty.name.getText(); - propertyText += " : "; - propertyText += getDefaultValue(interfaceProperty.type.kind) - propertyText += ",sys.newLine"; - } else { - propertyText = interfaceProperty.getText(); - let stringToAdd:string = (propertyText.match(/;$/) === null) ? ";sys.newLine" : "sys.newLine"; - propertyText += stringToAdd; - } - changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); - trackingAddedMembers.push(interfaceProperty.name.getText()); - } - } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature || interfaceMembers[j].kind === SyntaxKind.MethodDeclaration) { - let interfaceMethod = interfaceMembers[j]; - handleMethods(interfaceMethod, startPos, reference, trackingAddedMembers, changesArray); - } - } - } - } - - if(reference && existingMembers.length === 0 && changesArray.length > 0) { - let lastValue:string = changesArray[changesArray.length - 1].newText; - lastValue = lastValue.substr(0, lastValue.length - 12); - lastValue = lastValue + " sys.newLine"; - changesArray[changesArray.length - 1].newText = lastValue; - } - - return changesArray; - } - - function getMembers(declaration: InterfaceDeclaration, program: Program): Array { - let clauses = getInterfaceBaseTypeNodes(declaration); - let result = new Array(); - for (let i = 0; clauses && i < clauses.length; i++) { - let type = program.getTypeChecker().getTypeAtLocation(clauses[i]); - if (type && type.symbol && type.symbol.declarations) { - result = result.concat(getMembers(type.symbol.declarations[0], program)); - } - } - - if (declaration.members) { - result = result.concat(declaration.members); - } - - return result; - } - - function getClassMembers(classDeclaration: ClassDeclaration): Array { - let classMembers: Array = []; - for (let i = 0; classDeclaration.members && i < classDeclaration.members.length; i++) { - if (classDeclaration.members[i].name) { - classMembers.push(classDeclaration.members[i].name.getText()); - } - } - return classMembers; - } - - function getMembersAndStartPosFromReference(variableDeclaration: VariableDeclaration): { startPos: number, members: Array } { - let children: Node[] = variableDeclaration.getChildren(); - let variableMembers: Array = new Array(); - let startPos: number = 0; - - for (let i = 0; i < children.length; i++) { - if (children[i].kind === SyntaxKind.ObjectLiteralExpression) { - startPos = children[i].pos + 1; - let properties = (children[i]).properties; - for (let j = 0; properties && j < properties.length; j++) { - if (properties[j].name) { - variableMembers.push(properties[j].name.getText()); - } - } - } - } - - return { startPos: startPos, members: variableMembers }; - } - - function getDefaultValue(kind: SyntaxKind): string { - switch(kind) { - case SyntaxKind.StringKeyword: - return '""'; - case SyntaxKind.BooleanKeyword: - return "false"; - case SyntaxKind.NumberKeyword: - return "0"; - } - return "null"; - } - - function handleMethods(interfaceMethod: MethodSignature, startPos: number, reference: boolean, trackingAddedMembers: Array, changesArray: { newText: string; span: { start: number, length: number } }[]) { - if (trackingAddedMembers.indexOf(interfaceMethod.name.getText())) { - let methodName = interfaceMethod.name.getText(); - let typeParameterArray: Array = []; - for (let k = 0; interfaceMethod.typeParameters && k < interfaceMethod.typeParameters.length; k++) { - typeParameterArray.push(interfaceMethod.typeParameters[k].getText()); - } - let parameterArray: Array = []; - for (let k = 0; interfaceMethod.parameters && k < interfaceMethod.parameters.length; k++) { - parameterArray.push(interfaceMethod.parameters[k].getText()); - } - let methodBody = "throw new Error('Method not Implemented');"; - - let methodText: string = methodName; - if (typeParameterArray.length > 0) { - methodText += "<" - } - for (let k = 0; k < typeParameterArray.length; k++) { - methodText += typeParameterArray[k]; - if (k !== typeParameterArray.length - 1) { - methodText += ","; - } - } - if (typeParameterArray.length > 0) { - methodText += ">" - } - methodText += "("; - for (let k = 0; k < parameterArray.length; k++) { - methodText += parameterArray[k]; - if (k !== parameterArray.length - 1) { - methodText += ","; - } - } - methodText += ")"; - methodText += "{sys.newLine "; - methodText += methodBody; - methodText += "sys.newLine"; - methodText = reference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); - changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); - trackingAddedMembers.push(interfaceMethod.name.getText()); - } - } -} From 7397f6d3798e65d93560fc8a615c49e99fa53fdd Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 1 Jul 2016 13:42:54 -0700 Subject: [PATCH 83/90] Add codefixes to tsconfig and jake --- Jakefile.js | 8 +++++++- src/services/tsconfig.json | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 7db91abcfccb0..316608422509d 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -94,7 +94,13 @@ var servicesSources = [ "formatting/rulesMap.ts", "formatting/rulesProvider.ts", "formatting/smartIndenter.ts", - "formatting/tokenRange.ts" + "formatting/tokenRange.ts", + "codeFixes/changeExtendsToImplementsFix.ts", + "codeFixes/codeFixProvider.ts", + "codeFixes/interfaceFixes.ts", + "codeFixes/references.ts", + "codeFixes/superFixes.ts", + "codeFixes/unusedIdentifierFixes.ts" ].map(function (f) { return path.join(servicesDirectory, f); })); diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 4bf6e87d7a631..22fbff70c3729 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -49,6 +49,12 @@ "formatting/rulesMap.ts", "formatting/rulesProvider.ts", "formatting/smartIndenter.ts", - "formatting/tokenRange.ts" + "formatting/tokenRange.ts", + "codeFixes/changeExtendsToImplementsFix.ts", + "codeFixes/codeFixProvider.ts", + "codeFixes/interfaceFixes.ts", + "codeFixes/references.ts", + "codeFixes/superFixes.ts", + "codeFixes/unusedIdentifierFixes.ts" ] } From 8e2cdacd5dec7d569b27a8be1af32942d44caac9 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 1 Jul 2016 16:17:20 -0700 Subject: [PATCH 84/90] Each 'CodeFix' can now return more than one action which implements a fix through text changes --- src/compiler/diagnosticMessages.json | 22 ++++++- .../codefixes/changeExtendsToImplementsFix.ts | 22 +++++-- src/services/codefixes/codeFixProvider.ts | 39 ++++++----- src/services/codefixes/interfaceFixes.ts | 56 ++++++++++------ src/services/codefixes/superFixes.ts | 20 ++++-- .../codefixes/unusedIdentifierFixes.ts | 64 +++++++++++-------- src/services/services.ts | 12 ++-- 7 files changed, 150 insertions(+), 85 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9ed28a263316d..c1bb630263158 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3020,8 +3020,28 @@ "category": "CodeFix", "code": 90001 }, - "Make 'super()' call the first statement in the constructor.":{ + "Make 'super()' call the first statement in the constructor.": { "category": "CodeFix", "code": 90002 + }, + "Change 'extends' to 'implements'": { + "category": "CodeFix", + "code": 90003 + }, + "Remove unused identifiers": { + "category": "CodeFix", + "code": 90004 + }, + "Implement interface on reference": { + "category": "CodeFix", + "code": 90005 + }, + "Implement interface on class": { + "category": "CodeFix", + "code": 90006 + }, + "Implement inherited abstract class": { + "category": "CodeFix", + "code": 90007 } } diff --git a/src/services/codefixes/changeExtendsToImplementsFix.ts b/src/services/codefixes/changeExtendsToImplementsFix.ts index 34888a909b12b..de64556f4229b 100644 --- a/src/services/codefixes/changeExtendsToImplementsFix.ts +++ b/src/services/codefixes/changeExtendsToImplementsFix.ts @@ -1,24 +1,34 @@ /* @internal */ namespace ts.codeFix { registerCodeFix({ - name: "Change Extends to Implements", + name: "changeExtendsToImplementsFix", errorCodes: ["TS2689"], - getTextChanges: (context: CodeActionContext) => { + getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const start = context.span.start; const token = getTokenAtPosition(sourceFile, start); + const textChanges: TextChange[] = []; + if (token.kind === SyntaxKind.Identifier && token.parent.parent.kind === SyntaxKind.HeritageClause) { const children = (token.parent.parent).getChildren(); for (const child of children) { if (child.kind === SyntaxKind.ExtendsKeyword) { - return [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: "implements", span: { start: child.pos, length: child.end - child.pos } }] - }]; + textChanges.push({ newText: "implements", span: { start: child.pos, length: child.end - child.pos } }); } } } + + if (textChanges.length > 0) { + return [{ + description: getLocaleSpecificMessage(Diagnostics.Change_extends_to_implements), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; + } + Debug.fail("Failed to construct a fix."); } }); diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index fe40478f9fdf9..df72de5dc6da0 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -1,12 +1,12 @@ /* @internal */ namespace ts { - export interface CodeAction { + export interface CodeFix { name: string; errorCodes: string[]; - getTextChanges(context: CodeActionContext): FileTextChanges[]; + getCodeActions(context: CodeFixContext): CodeAction[]; } - export interface CodeActionContext { + export interface CodeFixContext { errorCode: string; sourceFile: SourceFile; span: TextSpan; @@ -14,39 +14,38 @@ namespace ts { } export namespace codeFix { - const codeActions: Map = {}; + const codeFixes: Map = {}; - export function registerCodeFix(fix: CodeAction) { - forEach(fix.errorCodes, error => { - let fixes = codeActions[error]; + export function registerCodeFix(action: CodeFix) { + forEach(action.errorCodes, error => { + let fixes = codeFixes[error]; if (!fixes) { fixes = []; - codeActions[error] = fixes; + codeFixes[error] = fixes; } - fixes.push(fix); + fixes.push(action); }); } export class CodeFixProvider { - public static getSupportedErrorCodes() { - return getKeys(codeActions); + return getKeys(codeFixes); } - public getFixes(context: CodeActionContext): CodeFix[] { - const actions = codeActions[context.errorCode]; - const fixes: CodeFix[] = []; + public getFixes(context: CodeFixContext): CodeAction[] { + const fixes = codeFixes[context.errorCode]; + let allActions: CodeAction[] = []; - Debug.assert(actions && actions.length > 0, "No fixes found for error: '${errorCode}'."); + Debug.assert(fixes && fixes.length > 0, "No fixes found for error: '${errorCode}'."); - forEach(actions, a => { - const textChanges = a.getTextChanges(context); - if (textChanges && textChanges.length > 0) { - fixes.push({ description: a.name, changes: textChanges }); + forEach(fixes, f => { + const actions = f.getCodeActions(context); + if (actions && actions.length > 0) { + allActions = allActions.concat(actions); } }); - return fixes; + return allActions; } } } diff --git a/src/services/codefixes/interfaceFixes.ts b/src/services/codefixes/interfaceFixes.ts index 3ccdd62841c73..1eb83fe5e178d 100644 --- a/src/services/codefixes/interfaceFixes.ts +++ b/src/services/codefixes/interfaceFixes.ts @@ -1,13 +1,13 @@ /* @internal */ namespace ts.codeFix { registerCodeFix({ - name: "Implement Interface on Reference", + name: "ImplementInterfaceOnReferenceFix", errorCodes: ["TS2322"], - getTextChanges: (context: CodeActionContext) => { + getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const start = context.span.start; const token = getTokenAtPosition(sourceFile, start); - let changesArray: TextChange[] = []; + let textChanges: TextChange[] = []; if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.VariableDeclaration) { const variableDeclaration = token.parent; @@ -17,18 +17,24 @@ namespace ts.codeFix { const startPos: number = membersAndStartPosObject.startPos; if (variableDeclaration.type.kind === SyntaxKind.TypeReference) { - changesArray = changesArray.concat(getChanges(variableDeclaration.type, variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers)); + textChanges = textChanges.concat(getChanges(variableDeclaration.type, variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers)); } else if (variableDeclaration.type.kind === SyntaxKind.UnionType) { const types = (variableDeclaration.type).types; for (let i = 0; i < types.length; i++) { - changesArray = changesArray.concat(getChanges(types[i], variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers)); + textChanges = textChanges.concat(getChanges(types[i], variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers)); } } } - if (changesArray.length !== 0) { - return [{ fileName: sourceFile.fileName, textChanges: changesArray }]; + if (textChanges.length !== 0) { + return [{ + description: getLocaleSpecificMessage(Diagnostics.Implement_interface_on_reference), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; } Debug.fail("No Quick Fix found"); @@ -36,13 +42,13 @@ namespace ts.codeFix { }); registerCodeFix({ - name: "Implement Interface On Class", + name: "ImplementInterfaceOnClassFix", errorCodes: ["TS2420"], - getTextChanges: (context: CodeActionContext) => { + getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const start = context.span.start; const token = getTokenAtPosition(sourceFile, start); - let changesArray: TextChange[] = []; + let textChanges: TextChange[] = []; if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { const classDeclaration = token.parent; @@ -52,12 +58,18 @@ namespace ts.codeFix { const interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration); for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) { - changesArray = changesArray.concat(getChanges(interfaceClauses[i], classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); + textChanges = textChanges.concat(getChanges(interfaceClauses[i], classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); } } - if (changesArray.length !== 0) { - return [{ fileName: sourceFile.fileName, textChanges: changesArray }]; + if (textChanges.length !== 0) { + return [{ + description: getLocaleSpecificMessage(Diagnostics.Implement_interface_on_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; } Debug.fail("No Quick Fix found"); @@ -65,13 +77,13 @@ namespace ts.codeFix { }); registerCodeFix({ - name: "Implements Inherited Abstract Class", + name: "ImplementsInheritedAbstractClassFix", errorCodes: ["TS2515"], - getTextChanges: (context: CodeActionContext) => { + getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const start = context.span.start; const token = getTokenAtPosition(sourceFile, start); - let changesArray: { newText: string; span: { start: number, length: number } }[] = []; + let textChanges: { newText: string; span: { start: number, length: number } }[] = []; if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { const classDeclaration = token.parent; @@ -79,11 +91,17 @@ namespace ts.codeFix { const classMembers: Array = getClassMembers(classDeclaration); const trackingAddedMembers: Array = []; const extendsClause = ts.getClassExtendsHeritageClauseElement(classDeclaration); - changesArray = changesArray.concat(getChanges(extendsClause, classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); + textChanges = textChanges.concat(getChanges(extendsClause, classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); } - if (changesArray.length !== 0) { - return [{ fileName: sourceFile.fileName, textChanges: changesArray }]; + if (textChanges.length !== 0) { + return [{ + description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class), + changes: [{ + fileName: sourceFile.fileName, + textChanges: textChanges + }] + }]; } Debug.fail("No Quick Fix found"); diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 681c26df95d5d..3a6ab478110cd 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -6,23 +6,26 @@ namespace ts.codeFix { } registerCodeFix({ - name: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), + name: "AddMissingSuperCallFix", errorCodes: ["TS2377"], - getTextChanges: (context: CodeActionContext) => { + getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); Debug.assert(token.kind === SyntaxKind.ConstructorKeyword, "Failed to find the constructor."); const newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }]; + return [{ + description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), + changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + }]; } }); registerCodeFix({ - name: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), + name: "MakeSuperCallTheFirstStatementInTheConstructor", errorCodes: ["TS17009"], - getTextChanges: (context: CodeActionContext) => { + getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); @@ -33,7 +36,7 @@ namespace ts.codeFix { Debug.assert(!!superCall, "Failed to find super call."); const newPosition = getOpenBraceEnd(constructor, sourceFile); - return [{ + const changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), span: { start: newPosition, length: 0 } @@ -44,6 +47,11 @@ namespace ts.codeFix { }] }]; + return [{ + description: getLocaleSpecificMessage(Diagnostics.Make_super_call_the_first_statement_in_the_constructor), + changes + }]; + function findSuperCall(n: Node): Node { if (n.kind === SyntaxKind.ExpressionStatement && isSuperCallExpression((n).expression)) { return n; diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index ee89d554726e4..e3b9a804c1302 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -1,57 +1,57 @@ /* @internal */ namespace ts.codeFix { registerCodeFix({ - name: "Remove Unused Identifiers", + name: "RemoveUnusedIdentifiersFix", errorCodes: ["TS6133"], - getTextChanges: (context: CodeActionContext) => { + getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const start = context.span.start; const token = getTokenAtPosition(sourceFile, start); - if (token.kind === ts.SyntaxKind.Identifier) { + if (token.kind === ts.SyntaxKind.Identifier) { if (token.parent.kind === ts.SyntaxKind.VariableDeclaration) { if (token.parent.parent.parent.kind === SyntaxKind.ForStatement) { const forStatement = token.parent.parent.parent; const initializer = forStatement.initializer; if (initializer.declarations.length === 1) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: initializer.pos, length: initializer.end - initializer.pos } }] }]; + return createCodeFix("", initializer.pos, initializer.end - initializer.pos); } else { if (initializer.declarations[0] === token.parent) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); } else { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); } } } else if (token.parent.parent.parent.kind === SyntaxKind.ForInStatement) { const forInStatement = token.parent.parent.parent; const initializer = forInStatement.initializer; - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }] }]; + return createCodeFix("{}", initializer.declarations[0].pos, initializer.declarations[0].end - initializer.declarations[0].pos); } else if (token.parent.parent.parent.kind === SyntaxKind.ForOfStatement) { const forOfStatement = token.parent.parent.parent; const initializer = forOfStatement.initializer; - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: initializer.declarations[0].pos, length: initializer.declarations[0].end - initializer.declarations[0].pos } }] }]; + return createCodeFix("{}", initializer.declarations[0].pos, initializer.declarations[0].end - initializer.declarations[0].pos); } else if (token.parent.parent.kind === SyntaxKind.CatchClause) { const catchClause = token.parent.parent; const parameter = catchClause.variableDeclaration.getChildren()[0]; - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: parameter.pos, length: parameter.end - parameter.pos } }] }]; + return createCodeFix("", parameter.pos, parameter.end - parameter.pos); } else { const variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: variableStatement.pos, length: variableStatement.end - variableStatement.pos } }] }]; + return createCodeFix("", variableStatement.pos, variableStatement.end - variableStatement.pos); } else { const declarations = variableStatement.declarationList.declarations; if (declarations[0].name === token) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos + 1, length: token.parent.end - token.parent.pos } }] }]; + return createCodeFix("", token.parent.pos + 1, token.parent.end - token.parent.pos); } else { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); } } } @@ -64,20 +64,20 @@ namespace ts.codeFix { token.parent.kind === SyntaxKind.ModuleDeclaration || token.parent.kind === SyntaxKind.PropertyDeclaration || token.parent.kind === SyntaxKind.ArrowFunction) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); } if (token.parent.kind === SyntaxKind.TypeParameter) { const typeParameters = (token.parent.parent).typeParameters; if (typeParameters.length === 1) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 2 } }] }]; + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); } else { if (typeParameters[0] === token.parent) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); } else { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); } } } @@ -85,14 +85,14 @@ namespace ts.codeFix { if (token.parent.kind === ts.SyntaxKind.Parameter) { const functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); } else { if (functionDeclaration.parameters[0] === token.parent) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); } else { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); } } } @@ -102,40 +102,50 @@ namespace ts.codeFix { const elements = namedImports.elements; if (elements.length === 1) { // Only 1 import and it is unused. So the entire line could be removed. - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); } else { if (elements[0] === token.parent) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); } else { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos - 1, length: token.parent.end - token.parent.pos + 1 } }] }]; + return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); } } } if (token.parent.parent.kind === SyntaxKind.ImportClause || token.parent.parent.kind === SyntaxKind.ImportDeclaration) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + return createCodeFix("{}", token.parent.pos, token.parent.end - token.parent.pos); } if (token.parent.kind === SyntaxKind.ImportEqualsDeclaration) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: token.pos, length: token.end - token.pos } }] }]; + return createCodeFix("{}", token.pos, token.end - token.pos); } if (token.parent.kind === SyntaxKind.EnumDeclaration) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); } } if (token.kind === SyntaxKind.PrivateKeyword && token.parent.kind === SyntaxKind.PropertyDeclaration) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos); } if (token.kind === SyntaxKind.AsteriskToken && token.parent.kind === SyntaxKind.NamespaceImport) { - return [{ fileName: sourceFile.fileName, textChanges: [{ newText: "{}", span: { start: token.parent.pos, length: token.parent.end - token.parent.pos } }] }]; + return createCodeFix("{}", token.parent.pos, token.parent.end - token.parent.pos); } Debug.fail("No Quick fix found."); + + function createCodeFix(newText: string, start: number, length: number): CodeAction[] { + return [{ + description: getLocaleSpecificMessage(Diagnostics.Remove_unused_identifiers), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ newText, span: { start, length } }] + }] + }]; + } } }); } diff --git a/src/services/services.ts b/src/services/services.ts index e6c8601450413..97cafb1f64a57 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1150,7 +1150,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeFix[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[]; getEmitOutput(fileName: string): EmitOutput; @@ -1203,10 +1203,10 @@ namespace ts { textChanges: TextChange[]; } - export interface CodeFix { - /** Description of the code fix to display in the UI of the editor */ + export interface CodeAction { + /** Description of the code action to display in the UI of the editor */ description: string; - /** Text changes to apply to each file as part of the code fix */ + /** Text changes to apply to each file as part of the code action */ changes: FileTextChanges[]; } @@ -7705,11 +7705,11 @@ namespace ts { return []; } - function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeFix[] { + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const checker = program.getTypeChecker(); - let allFixes: CodeFix[] = []; + let allFixes: CodeAction[] = []; forEach(errorCodes, error => { const context = { From 81a590128b89a85906eae64bfff73f668074f8d2 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 1 Jul 2016 17:10:20 -0700 Subject: [PATCH 85/90] code cleanup --- src/services/codefixes/interfaceFixes.ts | 45 ++++++++++++++---------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/services/codefixes/interfaceFixes.ts b/src/services/codefixes/interfaceFixes.ts index 1eb83fe5e178d..1c36c5f93efbb 100644 --- a/src/services/codefixes/interfaceFixes.ts +++ b/src/services/codefixes/interfaceFixes.ts @@ -27,7 +27,7 @@ namespace ts.codeFix { } } - if (textChanges.length !== 0) { + if (textChanges.length > 0) { return [{ description: getLocaleSpecificMessage(Diagnostics.Implement_interface_on_reference), changes: [{ @@ -53,8 +53,8 @@ namespace ts.codeFix { if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { const classDeclaration = token.parent; const startPos: number = classDeclaration.members.pos; - const classMembers: Array = getClassMembers(classDeclaration); - const trackingAddedMembers: Array = []; + const classMembers = getClassMembers(classDeclaration); + const trackingAddedMembers: string[] = []; const interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration); for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) { @@ -62,7 +62,7 @@ namespace ts.codeFix { } } - if (textChanges.length !== 0) { + if (textChanges.length > 0) { return [{ description: getLocaleSpecificMessage(Diagnostics.Implement_interface_on_class), changes: [{ @@ -83,18 +83,18 @@ namespace ts.codeFix { const sourceFile = context.sourceFile; const start = context.span.start; const token = getTokenAtPosition(sourceFile, start); - let textChanges: { newText: string; span: { start: number, length: number } }[] = []; + let textChanges: TextChange[] = []; if (token.kind === SyntaxKind.Identifier && token.parent.kind === SyntaxKind.ClassDeclaration) { const classDeclaration = token.parent; - const startPos: number = classDeclaration.members.pos; - const classMembers: Array = getClassMembers(classDeclaration); - const trackingAddedMembers: Array = []; + const startPos = classDeclaration.members.pos; + const classMembers = getClassMembers(classDeclaration); + const trackingAddedMembers: string[] = []; const extendsClause = ts.getClassExtendsHeritageClauseElement(classDeclaration); textChanges = textChanges.concat(getChanges(extendsClause, classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); } - if (textChanges.length !== 0) { + if (textChanges.length > 0) { return [{ description: getLocaleSpecificMessage(Diagnostics.Implement_inherited_abstract_class), changes: [{ @@ -121,10 +121,7 @@ namespace ts.codeFix { if (trackingAddedMembers.indexOf(interfaceProperty.name.getText()) === -1) { let propertyText = ""; if (reference) { - propertyText = interfaceProperty.name.getText(); - propertyText += " : "; - propertyText += getDefaultValue(interfaceProperty.type.kind); - propertyText += ",sys.newLine"; + propertyText = `${interfaceProperty.name.getText()} : ${getDefaultValue(interfaceProperty.type.kind)},sys.newLine`; } else { propertyText = interfaceProperty.getText(); @@ -146,7 +143,7 @@ namespace ts.codeFix { if (reference && existingMembers.length === 0 && changesArray.length > 0) { let lastValue = changesArray[changesArray.length - 1].newText; lastValue = lastValue.substr(0, lastValue.length - 12); - lastValue = lastValue + " sys.newLine"; + lastValue += " sys.newLine"; changesArray[changesArray.length - 1].newText = lastValue; } @@ -212,32 +209,40 @@ namespace ts.codeFix { return "null"; } - function handleMethods(interfaceMethod: MethodSignature, startPos: number, isReference: boolean, trackingAddedMembers: string[], changesArray: TextChange[]) { + function handleMethods(interfaceMethod: MethodSignature, startPos: number, isReference: boolean, trackingAddedMembers: string[], textChanges: TextChange[]) { + + const methodBody = "throw new Error('Method not Implemented');"; + if (trackingAddedMembers.indexOf(interfaceMethod.name.getText())) { const methodName = interfaceMethod.name.getText(); - const typeParameterArray: Array = []; + const typeParameterArray: string[] = []; + for (let i = 0; interfaceMethod.typeParameters && i < interfaceMethod.typeParameters.length; i++) { typeParameterArray.push(interfaceMethod.typeParameters[i].getText()); } - const parameterArray: Array = []; + + const parameterArray: string[] = []; for (let j = 0; interfaceMethod.parameters && j < interfaceMethod.parameters.length; j++) { parameterArray.push(interfaceMethod.parameters[j].getText()); } - const methodBody = "throw new Error('Method not Implemented');"; + let methodText = methodName; if (typeParameterArray.length > 0) { methodText += "<"; } + for (let k = 0; k < typeParameterArray.length; k++) { methodText += typeParameterArray[k]; if (k !== typeParameterArray.length - 1) { methodText += ","; } } + if (typeParameterArray.length > 0) { methodText += ">"; } + methodText += "("; for (let k = 0; k < parameterArray.length; k++) { methodText += parameterArray[k]; @@ -245,12 +250,14 @@ namespace ts.codeFix { methodText += ","; } } + methodText += ")"; methodText += "{sys.newLine "; methodText += methodBody; methodText += "sys.newLine"; methodText = isReference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); - changesArray.push({ newText: methodText, span: { start: startPos, length: 0 } }); + + textChanges.push({ newText: methodText, span: { start: startPos, length: 0 } }); trackingAddedMembers.push(interfaceMethod.name.getText()); } } From 35fcbb8d9bfa7099a22677294b7cc3e1c8c6bbfe Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 1 Jul 2016 17:28:24 -0700 Subject: [PATCH 86/90] Code clean up after renaming --- src/harness/fourslash.ts | 68 --------------------------- src/harness/harnessLanguageService.ts | 2 +- src/server/client.ts | 2 +- 3 files changed, 2 insertions(+), 70 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 6df7e118d9f59..bdf043621e8e8 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2073,59 +2073,6 @@ namespace FourSlash { } } - public verifyGetScriptLexicalStructureListCount(expected: number) { - const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - const actual = this.getNavigationBarItemsCount(items); - - if (expected !== actual) { - this.raiseError(`verifyGetScriptLexicalStructureListCount failed - found: ${actual} navigation items, expected: ${expected}.`); - } - } - - private getNavigationBarItemsCount(items: ts.NavigationBarItem[]) { - let result = 0; - if (items) { - for (let i = 0, n = items.length; i < n; i++) { - result++; - result += this.getNavigationBarItemsCount(items[i].childItems); - } - } - - return result; - } - - public verifyGetScriptLexicalStructureListContains(name: string, kind: string) { - const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - - if (!items || items.length === 0) { - this.raiseError("verifyGetScriptLexicalStructureListContains failed - found 0 navigation items, expected at least one."); - } - - if (this.navigationBarItemsContains(items, name, kind)) { - return; - } - - const missingItem = { name: name, kind: kind }; - this.raiseError(`verifyGetScriptLexicalStructureListContains failed - could not find the item: ${JSON.stringify(missingItem, undefined, 2)} in the returned list: (${JSON.stringify(items, undefined, 2)})`); - } - - private navigationBarItemsContains(items: ts.NavigationBarItem[], name: string, kind: string) { - if (items) { - for (let i = 0; i < items.length; i++) { - const item = items[i]; - if (item && item.text === name && item.kind === kind) { - return true; - } - - if (this.navigationBarItemsContains(item.childItems, name, kind)) { - return true; - } - } - } - - return false; - } - public printNavigationItems(searchValue: string) { const items = this.languageService.getNavigateToItems(searchValue); const length = items && items.length; @@ -3162,21 +3109,6 @@ namespace FourSlashInterface { this.state.verifyCodeFixAtPosition(expectedText); } - public getScriptLexicalStructureListCount(count: number) { - this.state.verifyGetScriptLexicalStructureListCount(count); - } - - // TODO: figure out what to do with the unused arguments. - public getScriptLexicalStructureListContains( - name: string, - kind: string, - fileName?: string, - parentName?: string, - isAdditionalSpan?: boolean, - markerPosition?: number) { - this.state.verifyGetScriptLexicalStructureListContains(name, kind); - } - public navigationBar(json: any) { this.state.verifyNavigationBar(json); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8f8f36504c35b..e07c71c6b5157 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -453,7 +453,7 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeFix[] { + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeAction[] { return unwrapJSONCallResult(this.shim.getCodeFixesAtPosition(fileName, start, end, JSON.stringify(errorCodes))); } getEmitOutput(fileName: string): ts.EmitOutput { diff --git a/src/server/client.ts b/src/server/client.ts index d5aca60ff6e30..3c8a07c8cdf23 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -592,7 +592,7 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeFix[] { + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeAction[] { throw new Error("Not Implemented Yet."); } From 02fcf9fe0a4abe4b3cf3e466d1933765aca7ce42 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 7 Jul 2016 16:32:19 -0700 Subject: [PATCH 87/90] Change API and fix FourSlash --- src/harness/fourslash.ts | 28 ++++++++++++------ .../codefixes/changeExtendsToImplementsFix.ts | 2 +- src/services/codefixes/codeFixProvider.ts | 1 + src/services/codefixes/interfaceFixes.ts | 29 ++++++++----------- src/services/codefixes/superFixes.ts | 1 - src/services/services.ts | 3 +- tests/cases/fourslash/fourslash.ts | 3 +- tests/cases/fourslash/superFix1.ts | 11 ++----- tests/cases/fourslash/superFix2.ts | 14 ++------- 9 files changed, 42 insertions(+), 50 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index bdf043621e8e8..029f0d1a10c5c 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1478,7 +1478,7 @@ namespace FourSlash { if (isFormattingEdit) { const newContent = this.getFileContent(fileName); - if (newContent.replace(/\s/g, "") !== oldContent.replace(/\s/g, "")) { + if (this.removeWhitespace(newContent) !== this.removeWhitespace(oldContent)) { this.raiseError("Formatting operation destroyed non-whitespace content"); } } @@ -1545,7 +1545,7 @@ namespace FourSlash { } private removeWhitespace(text: string): string { - return text.replace(/[ \r\n\t]/g, ""); + return text.replace(/\s/g, ""); } public goToBOF() { @@ -1866,6 +1866,12 @@ namespace FourSlash { } public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { + + const ranges = this.getRanges(); + if (ranges.length == 0) { + this.raiseError("At least one range should be specified in the testfile.") + } + const fileName = this.activeFile.fileName; const diagnostics = this.getDiagnostics(fileName); @@ -1889,12 +1895,8 @@ namespace FourSlash { this.raiseError("More than 1 codefix returned."); } - - // todo: handle multiple files, probably need to set the cursor in the test file, and loop over all the files - - this.applyEdits(actual[0].changes[0].fileName, actual[0].changes[0].textChanges, /*isFormattingEdit*/ false); - const actualText = this.getFileContent(actual[0].changes[0].fileName); + const actualText = this.rangeText(ranges[0]); if (this.removeWhitespace(actualText) !== this.removeWhitespace(expectedText)) { this.raiseError(`Actual text doesn't match expected text. Actual: '${actualText}' Expected: '${expectedText}'`); @@ -3105,8 +3107,16 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } - public codeFixAtPosition(expectedText: string) { - this.state.verifyCodeFixAtPosition(expectedText); + public codeFixAtPosition(expectedText: string): void; + public codeFixAtPosition(expectedChanges: { file: string, expectedText: string }[]): void; + public codeFixAtPosition(expected: string | { file: string, expectedText: string }[]) { + if (typeof expected === "string") { + this.state.verifyCodeFixAtPosition(expected); + } + else { + // assume it actually is the other thing + + } } public navigationBar(json: any) { diff --git a/src/services/codefixes/changeExtendsToImplementsFix.ts b/src/services/codefixes/changeExtendsToImplementsFix.ts index de64556f4229b..ceabb20895196 100644 --- a/src/services/codefixes/changeExtendsToImplementsFix.ts +++ b/src/services/codefixes/changeExtendsToImplementsFix.ts @@ -14,7 +14,7 @@ namespace ts.codeFix { const children = (token.parent.parent).getChildren(); for (const child of children) { if (child.kind === SyntaxKind.ExtendsKeyword) { - textChanges.push({ newText: "implements", span: { start: child.pos, length: child.end - child.pos } }); + textChanges.push({ newText: " implements", span: { start: child.pos, length: child.end - child.pos } }); } } } diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index df72de5dc6da0..ca877aef46aca 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -11,6 +11,7 @@ namespace ts { sourceFile: SourceFile; span: TextSpan; checker: TypeChecker; + newLineCharacter: string; } export namespace codeFix { diff --git a/src/services/codefixes/interfaceFixes.ts b/src/services/codefixes/interfaceFixes.ts index 1c36c5f93efbb..c9a7c77d54d02 100644 --- a/src/services/codefixes/interfaceFixes.ts +++ b/src/services/codefixes/interfaceFixes.ts @@ -17,12 +17,12 @@ namespace ts.codeFix { const startPos: number = membersAndStartPosObject.startPos; if (variableDeclaration.type.kind === SyntaxKind.TypeReference) { - textChanges = textChanges.concat(getChanges(variableDeclaration.type, variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers)); + textChanges = textChanges.concat(getChanges(variableDeclaration.type, variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers, context.newLineCharacter)); } else if (variableDeclaration.type.kind === SyntaxKind.UnionType) { const types = (variableDeclaration.type).types; for (let i = 0; i < types.length; i++) { - textChanges = textChanges.concat(getChanges(types[i], variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers)); + textChanges = textChanges.concat(getChanges(types[i], variableMembers, startPos, context.checker, /*reference*/ true, trackingAddedMembers, context.newLineCharacter)); } } } @@ -58,7 +58,7 @@ namespace ts.codeFix { const interfaceClauses = ts.getClassImplementsHeritageClauseElements(classDeclaration); for (let i = 0; interfaceClauses && i < interfaceClauses.length; i++) { - textChanges = textChanges.concat(getChanges(interfaceClauses[i], classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); + textChanges = textChanges.concat(getChanges(interfaceClauses[i], classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers, context.newLineCharacter)); } } @@ -91,7 +91,7 @@ namespace ts.codeFix { const classMembers = getClassMembers(classDeclaration); const trackingAddedMembers: string[] = []; const extendsClause = ts.getClassExtendsHeritageClauseElement(classDeclaration); - textChanges = textChanges.concat(getChanges(extendsClause, classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers)); + textChanges = textChanges.concat(getChanges(extendsClause, classMembers, startPos, context.checker, /*reference*/ false, trackingAddedMembers, context.newLineCharacter)); } if (textChanges.length > 0) { @@ -108,7 +108,7 @@ namespace ts.codeFix { } }); - function getChanges(interfaceClause: Node, existingMembers: string[], startPos: number, checker: TypeChecker, reference: boolean, trackingAddedMembers: string[]): TextChange[] { + function getChanges(interfaceClause: Node, existingMembers: string[], startPos: number, checker: TypeChecker, reference: boolean, trackingAddedMembers: string[], newLineCharacter: string): TextChange[] { const type = checker.getTypeAtLocation(interfaceClause); const changesArray: TextChange[] = []; @@ -121,11 +121,11 @@ namespace ts.codeFix { if (trackingAddedMembers.indexOf(interfaceProperty.name.getText()) === -1) { let propertyText = ""; if (reference) { - propertyText = `${interfaceProperty.name.getText()} : ${getDefaultValue(interfaceProperty.type.kind)},sys.newLine`; + propertyText = `${interfaceProperty.name.getText()} : ${getDefaultValue(interfaceProperty.type.kind)},${newLineCharacter}`; } else { propertyText = interfaceProperty.getText(); - const stringToAdd = propertyText.match(/;$/) === undefined ? ";sys.newLine" : "sys.newLine"; + const stringToAdd = propertyText.match(/;$/) === undefined ? `;${newLineCharacter}` : newLineCharacter; propertyText += stringToAdd; } changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); @@ -134,7 +134,7 @@ namespace ts.codeFix { } else if (interfaceMembers[j].kind === SyntaxKind.MethodSignature || interfaceMembers[j].kind === SyntaxKind.MethodDeclaration) { const interfaceMethod = interfaceMembers[j]; - handleMethods(interfaceMethod, startPos, reference, trackingAddedMembers, changesArray); + handleMethods(interfaceMethod, startPos, reference, trackingAddedMembers, changesArray, newLineCharacter); } } } @@ -142,8 +142,7 @@ namespace ts.codeFix { if (reference && existingMembers.length === 0 && changesArray.length > 0) { let lastValue = changesArray[changesArray.length - 1].newText; - lastValue = lastValue.substr(0, lastValue.length - 12); - lastValue += " sys.newLine"; + lastValue = `${lastValue.substr(0, lastValue.length - 12)} ${newLineCharacter}`; changesArray[changesArray.length - 1].newText = lastValue; } @@ -209,7 +208,7 @@ namespace ts.codeFix { return "null"; } - function handleMethods(interfaceMethod: MethodSignature, startPos: number, isReference: boolean, trackingAddedMembers: string[], textChanges: TextChange[]) { + function handleMethods(interfaceMethod: MethodSignature, startPos: number, isReference: boolean, trackingAddedMembers: string[], textChanges: TextChange[], newLineCharacter:string) { const methodBody = "throw new Error('Method not Implemented');"; @@ -226,7 +225,6 @@ namespace ts.codeFix { parameterArray.push(interfaceMethod.parameters[j].getText()); } - let methodText = methodName; if (typeParameterArray.length > 0) { methodText += "<"; @@ -251,11 +249,8 @@ namespace ts.codeFix { } } - methodText += ")"; - methodText += "{sys.newLine "; - methodText += methodBody; - methodText += "sys.newLine"; - methodText = isReference ? methodText.concat("},sys.newLine") : methodText.concat("}sys.newLine"); + methodText += `){${newLineCharacter}${methodBody}${newLineCharacter}`; + methodText = isReference ? methodText.concat(`},${newLineCharacter}`) : methodText.concat(`}${newLineCharacter}`); textChanges.push({ newText: methodText, span: { start: startPos, length: 0 } }); trackingAddedMembers.push(interfaceMethod.name.getText()); diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 3a6ab478110cd..2c6a67de513b2 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -14,7 +14,6 @@ namespace ts.codeFix { Debug.assert(token.kind === SyntaxKind.ConstructorKeyword, "Failed to find the constructor."); const newPosition = getOpenBraceEnd(token.parent, sourceFile); - return [{ description: getLocaleSpecificMessage(Diagnostics.Add_missing_super_call), changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] diff --git a/src/services/services.ts b/src/services/services.ts index 8aa326929ab99..adda5c3879b35 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -7714,7 +7714,8 @@ namespace ts { errorCode: error, sourceFile: sourceFile, span: { start, length: end - start }, - checker: checker + checker: checker, + newLineCharacter: getNewLineOrDefaultFromHost(host) }; const fixes = codeFixProvider.getFixes(context); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index b0e59fbbf14da..961af18282e73 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -192,7 +192,8 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; - codeFixAtPosition(expectedText: string); + codeFixAtPosition(expectedText: string): void; + codeFixAtPosition(expectedChanges: { file: string, expectedText: string }[]): void; navigationBar(json: any): void; navigationItemsListCount(count: number, searchValue: string, matchKind?: string): void; diff --git a/tests/cases/fourslash/superFix1.ts b/tests/cases/fourslash/superFix1.ts index bfde1c0a57d31..7fbe2cb4fd7bd 100644 --- a/tests/cases/fourslash/superFix1.ts +++ b/tests/cases/fourslash/superFix1.ts @@ -3,15 +3,8 @@ ////class Base{ ////} ////class C extends Base{ -//// constructor() {/*0*/ +//// constructor() {[| |] //// } ////} -verify.codeFixAtPosition(` -class Base { -} -class C extends Base { - constructor() { - super(); - } -}`); +verify.codeFixAtPosition('super();'); diff --git a/tests/cases/fourslash/superFix2.ts b/tests/cases/fourslash/superFix2.ts index 49afc6061a2c0..880b5d43167c4 100644 --- a/tests/cases/fourslash/superFix2.ts +++ b/tests/cases/fourslash/superFix2.ts @@ -4,18 +4,10 @@ ////} ////class C extends Base{ //// private a:number; -//// constructor() { +//// constructor() {[| //// this.a = 12; -//// super(); +//// super();|] //// } ////} -verify.codeFixAtPosition(`class Base { -} -class C extends Base { - private a: number; - constructor() { - super(); - this.a = 12; - } -}`); +verify.codeFixAtPosition("super(); this.a = 12;"); \ No newline at end of file From d4f0e1398f239f821b6922cf0fe3cf0acfb4e11f Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 8 Jul 2016 17:36:29 -0700 Subject: [PATCH 88/90] Change FourSlash API Fix up all the tests --- src/harness/fourslash.ts | 12 ++------- .../fourslash/changeExtendsToImplementsFS1.ts | 9 +++---- .../fourslash/changeExtendsToImplementsFS2.ts | 9 +++---- tests/cases/fourslash/fourslash.ts | 3 +-- .../fourslash/unImplementedInterface1.ts | 25 +++++++++++-------- .../fourslash/unImplementedInterface10.ts | 19 ++++++++------ .../fourslash/unImplementedInterface11.ts | 22 ++++++++-------- .../fourslash/unImplementedInterface12.ts | 22 ++++++++-------- .../fourslash/unImplementedInterface13.ts | 24 ++++++++++-------- .../fourslash/unImplementedInterface14.ts | 19 ++++++++------ .../fourslash/unImplementedInterface15.ts | 16 +++++++----- .../fourslash/unImplementedInterface16.ts | 13 +++++----- .../fourslash/unImplementedInterface17.ts | 14 +++++------ .../fourslash/unImplementedInterface18.ts | 13 +++++----- .../fourslash/unImplementedInterface19.ts | 18 ++++++------- .../fourslash/unImplementedInterface2.ts | 23 +++++++++-------- .../fourslash/unImplementedInterface20.ts | 17 +++++++------ .../fourslash/unImplementedInterface21.ts | 17 +++++++------ .../fourslash/unImplementedInterface22.ts | 13 +++++----- .../fourslash/unImplementedInterface23.ts | 17 +++++++------ .../fourslash/unImplementedInterface24.ts | 13 +++++----- .../fourslash/unImplementedInterface25.ts | 17 +++++++------ .../fourslash/unImplementedInterface26.ts | 15 +++++------ .../fourslash/unImplementedInterface27.ts | 19 +++++++------- .../fourslash/unImplementedInterface28.ts | 22 +++++++++------- .../fourslash/unImplementedInterface29.ts | 18 +++++++------ .../fourslash/unImplementedInterface3.ts | 23 +++++++++-------- .../fourslash/unImplementedInterface30.ts | 22 ++++++++-------- .../fourslash/unImplementedInterface31.ts | 22 ++++++++-------- .../fourslash/unImplementedInterface32.ts | 22 ++++++++-------- .../fourslash/unImplementedInterface33.ts | 22 ++++++++-------- .../fourslash/unImplementedInterface34.ts | 15 ++++++----- .../fourslash/unImplementedInterface35.ts | 17 +++++++------ .../fourslash/unImplementedInterface36.ts | 21 +++++++++------- .../fourslash/unImplementedInterface37.ts | 21 +++++++++------- .../fourslash/unImplementedInterface38.ts | 12 +++++---- .../fourslash/unImplementedInterface4.ts | 25 +++++++++++-------- .../fourslash/unImplementedInterface5.ts | 25 +++++++++++-------- .../fourslash/unImplementedInterface6.ts | 17 +++++++------ .../fourslash/unImplementedInterface7.ts | 17 +++++++------ .../fourslash/unImplementedInterface8.ts | 17 +++++++------ .../fourslash/unImplementedInterface9.ts | 20 ++++++++------- .../fourslash/unusedClassInNamespace1.ts | 9 +++---- .../fourslash/unusedClassInNamespace2.ts | 11 ++++---- .../fourslash/unusedClassInNamespace3.ts | 7 +++--- .../fourslash/unusedClassInNamespace4.ts | 9 +++---- .../fourslash/unusedClassInNamespace5.ts | 11 ++++---- .../fourslash/unusedClassInNamespace6.ts | 11 ++++---- .../fourslash/unusedConstantInFunction1.ts | 10 +++----- .../cases/fourslash/unusedEnumInFunction1.ts | 7 +++--- .../fourslash/unusedFunctionInNamespace1.ts | 7 +++--- .../fourslash/unusedFunctionInNamespace2.ts | 11 ++++---- .../fourslash/unusedFunctionInNamespace3.ts | 9 +++---- .../fourslash/unusedFunctionInNamespace4.ts | 9 +++---- .../fourslash/unusedFunctionInNamespace5.ts | 22 +++++----------- tests/cases/fourslash/unusedImports10FS.ts | 15 ++--------- tests/cases/fourslash/unusedImports1FS.ts | 6 ++--- tests/cases/fourslash/unusedImports2FS.ts | 13 +++------- tests/cases/fourslash/unusedImports3FS.ts | 9 ++----- tests/cases/fourslash/unusedImports4FS.ts | 10 ++------ tests/cases/fourslash/unusedImports5FS.ts | 10 ++------ tests/cases/fourslash/unusedImports6FS.ts | 6 ++--- tests/cases/fourslash/unusedImports7FS.ts | 6 ++--- tests/cases/fourslash/unusedImports8FS.ts | 10 ++------ tests/cases/fourslash/unusedImports9FS.ts | 6 ++--- .../fourslash/unusedInterfaceInNamespace1.ts | 6 ++--- .../fourslash/unusedInterfaceInNamespace2.ts | 11 +++----- .../fourslash/unusedLocalsInFunction1.ts | 6 ++--- .../fourslash/unusedLocalsInFunction2.ts | 8 ++---- .../fourslash/unusedLocalsInFunction3.ts | 9 ++----- .../fourslash/unusedLocalsInFunction4.ts | 9 ++----- .../fourslash/unusedLocalsInMethodFS1.ts | 10 ++------ .../fourslash/unusedLocalsInMethodFS2.ts | 10 ++------ .../fourslash/unusedLocalsinConstructorFS1.ts | 11 +++----- .../fourslash/unusedLocalsinConstructorFS2.ts | 14 +++-------- tests/cases/fourslash/unusedMethodInClass1.ts | 6 ++--- tests/cases/fourslash/unusedMethodInClass2.ts | 8 +++--- tests/cases/fourslash/unusedMethodInClass3.ts | 6 ++--- tests/cases/fourslash/unusedMethodInClass4.ts | 11 +++----- .../fourslash/unusedNamespaceInNamespace.ts | 4 +-- .../fourslash/unusedParameterInCatch1.ts | 8 ++---- .../unusedParameterInConstructor1.ts | 8 ++---- .../fourslash/unusedParameterInFunction1.ts | 6 ++--- .../fourslash/unusedParameterInFunction2.ts | 7 ++---- .../fourslash/unusedParameterInFunction3.ts | 7 ++---- .../fourslash/unusedParameterInFunction4.ts | 8 ++---- .../fourslash/unusedParameterInLambda1.ts | 8 ++---- .../fourslash/unusedTypeParametersInClass1.ts | 6 ++--- .../fourslash/unusedTypeParametersInClass2.ts | 7 ++---- .../fourslash/unusedTypeParametersInClass3.ts | 8 ++---- .../unusedTypeParametersInFunction1.ts | 6 ++--- .../unusedTypeParametersInFunction2.ts | 6 ++--- .../unusedTypeParametersInFunction3.ts | 6 ++--- .../unusedTypeParametersInInterface1.ts | 7 ++---- .../unusedTypeParametersInLambda1.ts | 8 ++---- .../unusedTypeParametersInLambda2.ts | 8 ++---- .../unusedTypeParametersInLambda3.ts | 9 ++----- .../unusedTypeParametersInLambda4.ts | 10 ++------ .../unusedTypeParametersInMethod1.ts | 8 ++---- .../unusedTypeParametersInMethod2.ts | 8 ++---- .../unusedTypeParametersInMethods1.ts | 8 ++---- .../cases/fourslash/unusedVariableInBlocks.ts | 12 +++------ .../cases/fourslash/unusedVariableInClass1.ts | 8 +++--- .../cases/fourslash/unusedVariableInClass2.ts | 9 +++---- .../cases/fourslash/unusedVariableInClass3.ts | 10 +++----- .../fourslash/unusedVariableInForLoop1FS.ts | 10 ++------ .../fourslash/unusedVariableInForLoop2FS.ts | 10 ++------ .../fourslash/unusedVariableInForLoop3FS.ts | 11 ++------ .../fourslash/unusedVariableInForLoop4FS.ts | 11 ++------ .../fourslash/unusedVariableInForLoop5FS.ts | 9 ++----- .../fourslash/unusedVariableInForLoop6FS.ts | 9 ++----- .../fourslash/unusedVariableInForLoop7FS.ts | 12 +++------ .../fourslash/unusedVariableInModule1.ts | 7 ++---- .../fourslash/unusedVariableInModule2.ts | 9 ++----- .../fourslash/unusedVariableInModule3.ts | 7 ++---- .../fourslash/unusedVariableInModule4.ts | 9 ++----- .../fourslash/unusedVariableInNamespace1.ts | 8 +++--- .../fourslash/unusedVariableInNamespace2.ts | 11 ++------ .../fourslash/unusedVariableInNamespace3.ts | 11 ++------ 119 files changed, 611 insertions(+), 819 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 029f0d1a10c5c..2a8c11e67614c 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3107,16 +3107,8 @@ namespace FourSlashInterface { this.DocCommentTemplate(/*expectedText*/ undefined, /*expectedOffset*/ undefined, /*empty*/ true); } - public codeFixAtPosition(expectedText: string): void; - public codeFixAtPosition(expectedChanges: { file: string, expectedText: string }[]): void; - public codeFixAtPosition(expected: string | { file: string, expectedText: string }[]) { - if (typeof expected === "string") { - this.state.verifyCodeFixAtPosition(expected); - } - else { - // assume it actually is the other thing - - } + public codeFixAtPosition(expectedText: string, errorCode?: number): void { + this.state.verifyCodeFixAtPosition(expectedText, errorCode); } public navigationBar(json: any) { diff --git a/tests/cases/fourslash/changeExtendsToImplementsFS1.ts b/tests/cases/fourslash/changeExtendsToImplementsFS1.ts index 4a76bf8b4e7ed..a5b9a6375b6fa 100644 --- a/tests/cases/fourslash/changeExtendsToImplementsFS1.ts +++ b/tests/cases/fourslash/changeExtendsToImplementsFS1.ts @@ -1,9 +1,6 @@ /// -//// interface I1 {} -//// class c1 /*0*/extends/*1*/ I1{} +//// interface I1 {} +//// [|class c1 extends I1|]{} -verify.codeFixAtPosition(` -interface I1 {} -class c1 implements I1{} -`); \ No newline at end of file +verify.codeFixAtPosition("class c1 implements I1"); \ No newline at end of file diff --git a/tests/cases/fourslash/changeExtendsToImplementsFS2.ts b/tests/cases/fourslash/changeExtendsToImplementsFS2.ts index 9d7f3d7680118..b63ab3032eb9a 100644 --- a/tests/cases/fourslash/changeExtendsToImplementsFS2.ts +++ b/tests/cases/fourslash/changeExtendsToImplementsFS2.ts @@ -1,9 +1,6 @@ /// -//// interface I1 {} -//// class c1 /*0*/extends/*1*/ I1{} +////interface I1 {} +////[|class c1 extends I1|]{} -verify.codeFixAtPosition(` -interface I1 {} -class c1 implements I1{} -`); \ No newline at end of file +verify.codeFixAtPosition("class c1 implements I1"); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 961af18282e73..ee0d4d100d3ca 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -192,8 +192,7 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; - codeFixAtPosition(expectedText: string): void; - codeFixAtPosition(expectedChanges: { file: string, expectedText: string }[]): void; + codeFixAtPosition(expectedText: string, errorCode?: number): void; navigationBar(json: any): void; navigationItemsListCount(count: number, searchValue: string, matchKind?: string): void; diff --git a/tests/cases/fourslash/unImplementedInterface1.ts b/tests/cases/fourslash/unImplementedInterface1.ts index 4f7219daac29c..b07db08f12a81 100644 --- a/tests/cases/fourslash/unImplementedInterface1.ts +++ b/tests/cases/fourslash/unImplementedInterface1.ts @@ -1,15 +1,18 @@ /// -//// namespace N1 { -//// export interface I1 { -//// f1(); -//// } -//// } -//// interface I1 { -//// f1(); -//// } +//// namespace N1 { +//// export interface I1 { +//// f1(); +//// } +//// } +//// interface I1 { +//// f1(); +//// } //// -//// class C1 implements N1.I1 {/*0*//*1*/ -//// } +//// class C1 implements N1.I1 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface10.ts b/tests/cases/fourslash/unImplementedInterface10.ts index 4ed197fd25d23..aa61cbc1836d7 100644 --- a/tests/cases/fourslash/unImplementedInterface10.ts +++ b/tests/cases/fourslash/unImplementedInterface10.ts @@ -1,15 +1,18 @@ /// -//// interface I1 { -//// f1() -//// } +//// interface I1 { +//// f1() +//// } //// -//// interface I2 extends I1 { +//// interface I2 extends I1 { //// -//// } +//// } //// //// -//// class C1 implements I2 {/*0*//*1*/ -//// } +//// class C1 implements I2 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface11.ts b/tests/cases/fourslash/unImplementedInterface11.ts index 9fae38f33b6ff..3c819f6b56e2c 100644 --- a/tests/cases/fourslash/unImplementedInterface11.ts +++ b/tests/cases/fourslash/unImplementedInterface11.ts @@ -1,17 +1,19 @@ /// -//// interface I1 { +//// interface I1 { //// -//// } +//// } //// -//// interface I2 extends I1 { -//// f1(); -//// } +//// interface I2 extends I1 { +//// f1(); +//// } //// -//// interface I3 extends I2 {} +//// interface I3 extends I2 {} //// -//// -//// class C1 implements I3 {/*0*//*1*/ -//// } +//// class C1 implements I3 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface12.ts b/tests/cases/fourslash/unImplementedInterface12.ts index 6c9a96f6e9786..4e9e428fd6d1d 100644 --- a/tests/cases/fourslash/unImplementedInterface12.ts +++ b/tests/cases/fourslash/unImplementedInterface12.ts @@ -1,17 +1,19 @@ /// -//// interface I1 { +//// interface I1 { //// -//// } +//// } //// -//// interface I2 { -//// f1(); -//// } +//// interface I2 { +//// f1(); +//// } //// -//// interface I3 extends I2, I1 {} +//// interface I3 extends I2, I1 {} //// -//// -//// class C1 implements I3 {/*0*//*1*/ -//// } +//// class C1 implements I3 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface13.ts b/tests/cases/fourslash/unImplementedInterface13.ts index 1a7d7796e88a5..fdb0fa1230c04 100644 --- a/tests/cases/fourslash/unImplementedInterface13.ts +++ b/tests/cases/fourslash/unImplementedInterface13.ts @@ -1,17 +1,19 @@ /// -//// interface I1 { -//// f1(); -//// } +//// interface I1 { +//// f1(); +//// } //// -//// interface I2 { -//// f1(); -//// } +//// interface I2 { +//// f1(); +//// } //// -//// interface I3 extends I2, I1 {} +//// interface I3 extends I2, I1 {} //// -//// -//// class C1 implements I3 {/*0*//*1*/ -//// } +//// class C1 implements I3 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface14.ts b/tests/cases/fourslash/unImplementedInterface14.ts index 8a38715f7beb0..ad55fef3cced4 100644 --- a/tests/cases/fourslash/unImplementedInterface14.ts +++ b/tests/cases/fourslash/unImplementedInterface14.ts @@ -1,13 +1,16 @@ /// -//// interface I1 { -//// f1(); -//// f2(); -//// } +//// interface I1 { +//// f1(); +//// f2(); +//// } //// //// -//// var x: I1 ={/*0*//*1*/ -//// f2() {} -//// } +//// var x: I1 ={[| +//// |]f2() {} +//// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine},sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +}, +`); diff --git a/tests/cases/fourslash/unImplementedInterface15.ts b/tests/cases/fourslash/unImplementedInterface15.ts index b1664153e6d10..0a812e04ba60f 100644 --- a/tests/cases/fourslash/unImplementedInterface15.ts +++ b/tests/cases/fourslash/unImplementedInterface15.ts @@ -1,11 +1,15 @@ /// -//// interface I1 { -//// f1(); -//// } +//// interface I1 { +//// f1(); +//// } //// +//// [|var x: I1 = { //// -//// var x: I1 ={/*0*//*1*/ -//// } +//// }|] -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); +verify.codeFixAtPosition(`var x: I1 = { +f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface16.ts b/tests/cases/fourslash/unImplementedInterface16.ts index 9c89289ff3310..ca992b1eb1e79 100644 --- a/tests/cases/fourslash/unImplementedInterface16.ts +++ b/tests/cases/fourslash/unImplementedInterface16.ts @@ -1,11 +1,12 @@ /// -//// interface I1 { -//// x:string; -//// } +//// interface I1 { +//// x:string; +//// } //// //// -//// var x: I1 ={/*0*//*1*/ -//// } +//// var x: I1 ={[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: 'x : "" sys.newLine' }); +verify.codeFixAtPosition(`x : "" +`); diff --git a/tests/cases/fourslash/unImplementedInterface17.ts b/tests/cases/fourslash/unImplementedInterface17.ts index 7d523fdde3b07..e909b60f588ff 100644 --- a/tests/cases/fourslash/unImplementedInterface17.ts +++ b/tests/cases/fourslash/unImplementedInterface17.ts @@ -1,11 +1,11 @@ /// -//// interface I1 { -//// x:number; -//// } +//// interface I1 { +//// x:number; +//// } //// -//// -//// var x: I1 ={/*0*//*1*/ -//// } +//// var x: I1 ={[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : 0 sys.newLine" }); +verify.codeFixAtPosition(`x : 0 +`); diff --git a/tests/cases/fourslash/unImplementedInterface18.ts b/tests/cases/fourslash/unImplementedInterface18.ts index 4b1261b7dd53e..9e0f9888bf3c2 100644 --- a/tests/cases/fourslash/unImplementedInterface18.ts +++ b/tests/cases/fourslash/unImplementedInterface18.ts @@ -1,11 +1,12 @@ /// -//// interface I1 { -//// x:boolean; -//// } +//// interface I1 { +//// x:boolean; +//// } //// +//// var x: I1 ={[| //// -//// var x: I1 ={/*0*//*1*/ -//// } +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : false sys.newLine" }); +verify.codeFixAtPosition(`x : false +`); diff --git a/tests/cases/fourslash/unImplementedInterface19.ts b/tests/cases/fourslash/unImplementedInterface19.ts index 0d8c293608271..de484c282d833 100644 --- a/tests/cases/fourslash/unImplementedInterface19.ts +++ b/tests/cases/fourslash/unImplementedInterface19.ts @@ -1,13 +1,13 @@ /// -//// interface I1 { -//// x:string; -//// f1(); -//// } +//// interface I1 { +//// x:string; +//// f1(); +//// } //// -//// -//// var x: I1 ={/*0*//*1*/ -//// f1(){} -//// } +//// var x: I1 ={[| +//// |]f1(){} +//// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: 'x : "",sys.newLine' }); +verify.codeFixAtPosition(`x : "", +`); diff --git a/tests/cases/fourslash/unImplementedInterface2.ts b/tests/cases/fourslash/unImplementedInterface2.ts index 9e53ad1881c99..394c54d468724 100644 --- a/tests/cases/fourslash/unImplementedInterface2.ts +++ b/tests/cases/fourslash/unImplementedInterface2.ts @@ -1,15 +1,16 @@ /// -//// namespace N1 { -//// export interface I1 { -//// x: number; -//// } -//// } -//// interface I1 { -//// f1(); -//// } +//// namespace N1 { +//// export interface I1 { +//// x: number; +//// } +//// } +//// interface I1 { +//// f1(); +//// } //// -//// class C1 implements N1.I1 {/*0*//*1*/ -//// } +//// class C1 implements N1.I1 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x: number;sys.newLine" }); +verify.codeFixAtPosition(`x: number; +`); diff --git a/tests/cases/fourslash/unImplementedInterface20.ts b/tests/cases/fourslash/unImplementedInterface20.ts index 9aed04827332f..56a707d21bad9 100644 --- a/tests/cases/fourslash/unImplementedInterface20.ts +++ b/tests/cases/fourslash/unImplementedInterface20.ts @@ -1,13 +1,14 @@ /// -//// interface I1 { -//// x:number; -//// f1(); -//// } +//// interface I1 { +//// x:number; +//// f1(); +//// } //// //// -//// var x: I1 ={/*0*//*1*/ -//// f1(){} -//// } +//// var x: I1 ={[| +//// |]f1(){} +//// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : 0,sys.newLine" }); +verify.codeFixAtPosition(`x : 0, +`); diff --git a/tests/cases/fourslash/unImplementedInterface21.ts b/tests/cases/fourslash/unImplementedInterface21.ts index f82bdd8deb98f..867c697e595c2 100644 --- a/tests/cases/fourslash/unImplementedInterface21.ts +++ b/tests/cases/fourslash/unImplementedInterface21.ts @@ -1,13 +1,14 @@ /// -//// interface I1 { -//// x:boolean; -//// f1(); -//// } +//// interface I1 { +//// x:boolean; +//// f1(); +//// } //// //// -//// var x: I1 ={/*0*//*1*/ -//// f1(){} -//// } +//// var x: I1 ={[| +//// |]f1(){} +//// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : false,sys.newLine" }); +verify.codeFixAtPosition(`x : false, +`); diff --git a/tests/cases/fourslash/unImplementedInterface22.ts b/tests/cases/fourslash/unImplementedInterface22.ts index 02a5b8f7537b9..8a51577261f5b 100644 --- a/tests/cases/fourslash/unImplementedInterface22.ts +++ b/tests/cases/fourslash/unImplementedInterface22.ts @@ -1,11 +1,12 @@ /// -//// interface I1 { -//// x:[string]; -//// } +//// interface I1 { +//// x:[string]; +//// } //// //// -//// var x: I1 ={/*0*//*1*/ -//// } +//// var x: I1 ={[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null sys.newLine" }); +verify.codeFixAtPosition(`x : null +`); diff --git a/tests/cases/fourslash/unImplementedInterface23.ts b/tests/cases/fourslash/unImplementedInterface23.ts index 2ea9416d3f405..8d00689a446ab 100644 --- a/tests/cases/fourslash/unImplementedInterface23.ts +++ b/tests/cases/fourslash/unImplementedInterface23.ts @@ -1,13 +1,14 @@ /// -//// interface I1 { -//// x:[string]; -//// f1(); -//// } +//// interface I1 { +//// x:[string]; +//// f1(); +//// } //// //// -//// var x: I1 ={/*0*//*1*/ -//// f1(){} -//// } +//// var x: I1 ={[| +//// |]f1(){} +//// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null,sys.newLine" }); +verify.codeFixAtPosition(`x : null, +`); diff --git a/tests/cases/fourslash/unImplementedInterface24.ts b/tests/cases/fourslash/unImplementedInterface24.ts index 9365de0c792c0..c206789b7f2a4 100644 --- a/tests/cases/fourslash/unImplementedInterface24.ts +++ b/tests/cases/fourslash/unImplementedInterface24.ts @@ -1,11 +1,12 @@ /// -//// interface I1 { -//// x:Array; -//// } +//// interface I1 { +//// x:Array; +//// } //// //// -//// var x: I1 ={/*0*//*1*/ -//// } +//// var x: I1 ={[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null sys.newLine" }); +verify.codeFixAtPosition(`x : null +`); diff --git a/tests/cases/fourslash/unImplementedInterface25.ts b/tests/cases/fourslash/unImplementedInterface25.ts index 3659ed3512ffd..6b2b809efaa8c 100644 --- a/tests/cases/fourslash/unImplementedInterface25.ts +++ b/tests/cases/fourslash/unImplementedInterface25.ts @@ -1,13 +1,14 @@ /// -//// interface I1 { -//// x:Array; -//// f1(); -//// } +//// interface I1 { +//// x:Array; +//// f1(); +//// } //// //// -//// var x: I1 ={/*0*//*1*/ -//// f1(){} -//// } +//// var x: I1 ={[| +//// |]f1(){} +//// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null,sys.newLine" }); +verify.codeFixAtPosition(`x : null, +`); diff --git a/tests/cases/fourslash/unImplementedInterface26.ts b/tests/cases/fourslash/unImplementedInterface26.ts index fa11a73dbb777..a7136f0e70fc4 100644 --- a/tests/cases/fourslash/unImplementedInterface26.ts +++ b/tests/cases/fourslash/unImplementedInterface26.ts @@ -1,13 +1,14 @@ /// -//// interface I1 { -//// x:T; -//// } +//// interface I1 { +//// x:T; +//// } //// -//// class T {} +//// class T {} //// //// -//// var x: I1 ={/*0*//*1*/ -//// } +//// var x: I1 ={[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null sys.newLine" }); +verify.codeFixAtPosition(`x : null +`); diff --git a/tests/cases/fourslash/unImplementedInterface27.ts b/tests/cases/fourslash/unImplementedInterface27.ts index bf674e43e053f..fc12cb57377fb 100644 --- a/tests/cases/fourslash/unImplementedInterface27.ts +++ b/tests/cases/fourslash/unImplementedInterface27.ts @@ -1,15 +1,16 @@ /// -//// interface I1 { -//// x:T; -//// f1(); -//// } +//// interface I1 { +//// x:T; +//// f1(); +//// } //// -//// class T {} +//// class T {} //// //// -//// var x: I1 ={/*0*//*1*/ -//// f1(){} -//// } +//// var x: I1 ={[| +//// |]f1(){} +//// } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x : null,sys.newLine" }); +verify.codeFixAtPosition(`x : null, +`); diff --git a/tests/cases/fourslash/unImplementedInterface28.ts b/tests/cases/fourslash/unImplementedInterface28.ts index 1ec0e2fe56110..7a73982c043ee 100644 --- a/tests/cases/fourslash/unImplementedInterface28.ts +++ b/tests/cases/fourslash/unImplementedInterface28.ts @@ -1,14 +1,18 @@ /// -//// interface I1 { -//// f1(); -//// } +//// interface I1 { +//// f1(); +//// } //// -//// interface I2 { -//// f2(); -//// } +//// interface I2 { +//// f2(); +//// } //// -//// var x: I1|I2 ={/*0*//*1*/ -//// } +//// var x: I1|I2 ={[| +//// +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface29.ts b/tests/cases/fourslash/unImplementedInterface29.ts index b23ef932c58a9..c2719c2e7f94f 100644 --- a/tests/cases/fourslash/unImplementedInterface29.ts +++ b/tests/cases/fourslash/unImplementedInterface29.ts @@ -1,12 +1,14 @@ /// -//// abstract class C1 { -//// f1(){} -//// } +//// abstract class C1 { +//// f1(){} +//// } //// -//// class C2 implements C1 {/*0*//*1*/ -//// f2(){} -//// } +//// class C2 implements C1 {[| +//// |]f2(){} +//// } - -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface3.ts b/tests/cases/fourslash/unImplementedInterface3.ts index 5f60acee7ca1c..19354ce1c948c 100644 --- a/tests/cases/fourslash/unImplementedInterface3.ts +++ b/tests/cases/fourslash/unImplementedInterface3.ts @@ -1,15 +1,16 @@ /// -//// namespace N1 { -//// export interface I1 { -//// x: number -//// } -//// } -//// interface I1 { -//// f1(); -//// } +//// namespace N1 { +//// export interface I1 { +//// x: number +//// } +//// } +//// interface I1 { +//// f1(); +//// } //// -//// class C1 implements N1.I1 {/*0*//*1*/ -//// } +//// class C1 implements N1.I1 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "x: number;sys.newLine" }); +verify.codeFixAtPosition(`x: number; +`); diff --git a/tests/cases/fourslash/unImplementedInterface30.ts b/tests/cases/fourslash/unImplementedInterface30.ts index 84f96bac3ee8b..71addef195b48 100644 --- a/tests/cases/fourslash/unImplementedInterface30.ts +++ b/tests/cases/fourslash/unImplementedInterface30.ts @@ -1,16 +1,18 @@ /// -//// abstract class C1 { -//// f1(){} -//// } +//// abstract class C1 { +//// f1(){} +//// } //// -//// abstract class C2 extends C1 { +//// abstract class C2 extends C1 { //// -//// } +//// } //// -//// class C3 implements C2 {/*0*//*1*/ -//// f2(){} -//// } +//// class C3 implements C2 {[| +//// |]f2(){} +//// } - -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface31.ts b/tests/cases/fourslash/unImplementedInterface31.ts index cbffb92977db1..d56e44911b533 100644 --- a/tests/cases/fourslash/unImplementedInterface31.ts +++ b/tests/cases/fourslash/unImplementedInterface31.ts @@ -1,16 +1,18 @@ /// -//// abstract class C1 { -//// abstract f1(); -//// } +//// abstract class C1 { +//// abstract f1(); +//// } //// -//// abstract class C2 extends C1 { +//// abstract class C2 extends C1 { //// -//// } +//// } //// -//// class C3 implements C2 {/*0*//*1*/ -//// f2(){} -//// } +//// class C3 implements C2 {[| +//// |]f2(){} +//// } - -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface32.ts b/tests/cases/fourslash/unImplementedInterface32.ts index 49aad350a6f10..825224f448b53 100644 --- a/tests/cases/fourslash/unImplementedInterface32.ts +++ b/tests/cases/fourslash/unImplementedInterface32.ts @@ -1,16 +1,18 @@ /// -//// abstract class C1 { -//// abstract f1(); -//// } +//// abstract class C1 { +//// abstract f1(); +//// } //// -//// abstract class C2 extends C1 { +//// abstract class C2 extends C1 { //// -//// } +//// } //// -//// class C3 implements C2 {/*0*//*1*/ -//// f2(){} -//// } +//// class C3 implements C2 {[| +//// |]f2(){} +//// } - -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface33.ts b/tests/cases/fourslash/unImplementedInterface33.ts index f4dcd796878c8..7c3a647ce40f8 100644 --- a/tests/cases/fourslash/unImplementedInterface33.ts +++ b/tests/cases/fourslash/unImplementedInterface33.ts @@ -1,16 +1,18 @@ /// -//// abstract class C1 { -//// abstract f1(); -//// } +//// abstract class C1 { +//// abstract f1(); +//// } //// -//// abstract class C2 extends C1 { +//// abstract class C2 extends C1 { //// -//// } +//// } //// -//// class C3 implements C2 {/*0*//*1*/ -//// f2(){} -//// } +//// class C3 implements C2 {[| +//// |]f2(){} +//// } - -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface34.ts b/tests/cases/fourslash/unImplementedInterface34.ts index 43efe85ccd9ac..ab7a4f30beadf 100644 --- a/tests/cases/fourslash/unImplementedInterface34.ts +++ b/tests/cases/fourslash/unImplementedInterface34.ts @@ -1,11 +1,14 @@ /// -//// abstract class C1 { -//// abstract f1(); -//// } +//// abstract class C1 { +//// abstract f1(); +//// } //// -//// class C2 extends C1 {/*0*//*1*/ +//// class C2 extends C1 {[| //// -//// } +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface35.ts b/tests/cases/fourslash/unImplementedInterface35.ts index 90f7e3e323158..66d47491c4199 100644 --- a/tests/cases/fourslash/unImplementedInterface35.ts +++ b/tests/cases/fourslash/unImplementedInterface35.ts @@ -1,13 +1,16 @@ /// -//// abstract class C1 { -//// abstract f1(); -//// } +//// abstract class C1 { +//// abstract f1(); +//// } //// -//// interface I1 extends C1 {} +//// interface I1 extends C1 {} //// -//// class C2 implements I1 {/*0*//*1*/ +//// class C2 implements I1 {[| //// -//// } +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface36.ts b/tests/cases/fourslash/unImplementedInterface36.ts index f9b9b00de0579..3871414428efe 100644 --- a/tests/cases/fourslash/unImplementedInterface36.ts +++ b/tests/cases/fourslash/unImplementedInterface36.ts @@ -1,17 +1,20 @@ /// -//// abstract class C1 { +//// abstract class C1 { //// -//// } +//// } //// -//// abstract class C2 { -//// abstract f1(); -//// } +//// abstract class C2 { +//// abstract f1(); +//// } //// -//// interface I1 extends C1, C2 {} +//// interface I1 extends C1, C2 {} //// -//// class C3 implements I1 {/*0*//*1*/ +//// class C3 implements I1 {[| //// -//// } +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface37.ts b/tests/cases/fourslash/unImplementedInterface37.ts index cda6749e33fe8..2032f2d346192 100644 --- a/tests/cases/fourslash/unImplementedInterface37.ts +++ b/tests/cases/fourslash/unImplementedInterface37.ts @@ -1,17 +1,20 @@ /// -//// abstract class C1 { -//// abstract f1(); -//// } +//// abstract class C1 { +//// abstract f1(); +//// } //// -//// abstract class C2 extends C1{ +//// abstract class C2 extends C1{ //// -//// } +//// } //// -//// interface I1 extends C2 {} +//// interface I1 extends C2 {} //// -//// class C3 implements I1 {/*0*//*1*/ +//// class C3 implements I1 {[| //// -//// } +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface38.ts b/tests/cases/fourslash/unImplementedInterface38.ts index 51f6c2252147a..00efd46c7f6e4 100644 --- a/tests/cases/fourslash/unImplementedInterface38.ts +++ b/tests/cases/fourslash/unImplementedInterface38.ts @@ -1,9 +1,11 @@ /// -//// abstract class C2 { -//// abstract f1(); -//// } +//// abstract class C2 { +//// abstract f1(); +//// } //// -//// var x: C2 = {/*0*//*1*/} +//// var x: C2 = { [| |] } -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine} sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +}`); diff --git a/tests/cases/fourslash/unImplementedInterface4.ts b/tests/cases/fourslash/unImplementedInterface4.ts index 95f9a2db90a09..6e4e64c18d108 100644 --- a/tests/cases/fourslash/unImplementedInterface4.ts +++ b/tests/cases/fourslash/unImplementedInterface4.ts @@ -1,15 +1,18 @@ /// -//// namespace N1 { -//// export interface I1 { -//// f1() -//// } -//// } -//// interface I1 { -//// f1(); -//// } +//// namespace N1 { +//// export interface I1 { +//// f1() +//// } +//// } +//// interface I1 { +//// f1(); +//// } //// -//// class C1 implements N1.I1 {/*0*//*1*/ -//// } +//// class C1 implements N1.I1 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface5.ts b/tests/cases/fourslash/unImplementedInterface5.ts index 180e6346e6ae5..59b3ba8519947 100644 --- a/tests/cases/fourslash/unImplementedInterface5.ts +++ b/tests/cases/fourslash/unImplementedInterface5.ts @@ -1,15 +1,18 @@ /// -//// namespace N1 { -//// export interface I1 { -//// f1(x: number, y: string) -//// } -//// } -//// interface I1 { -//// f1(); -//// } +//// namespace N1 { +//// export interface I1 { +//// f1(x: number, y: string) +//// } +//// } +//// interface I1 { +//// f1(); +//// } //// -//// class C1 implements N1.I1 {/*0*//*1*/ -//// } +//// class C1 implements N1.I1 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number,y: string){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(x: number,y: string){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface6.ts b/tests/cases/fourslash/unImplementedInterface6.ts index 1b41d3b2e440a..2310e05fbb019 100644 --- a/tests/cases/fourslash/unImplementedInterface6.ts +++ b/tests/cases/fourslash/unImplementedInterface6.ts @@ -1,12 +1,15 @@ /// -//// interface I1 { -//// f1(x: number, y: T); -//// } +//// interface I1 { +//// f1(x: number, y: T); +//// } //// -//// class T {} +//// class T {} //// -//// class C1 implements I1 {/*0*//*1*/ -//// } +//// class C1 implements I1 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number,y: T){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(x: number,y: T){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface7.ts b/tests/cases/fourslash/unImplementedInterface7.ts index bec4f5531dec9..125f3e1ffeb50 100644 --- a/tests/cases/fourslash/unImplementedInterface7.ts +++ b/tests/cases/fourslash/unImplementedInterface7.ts @@ -1,12 +1,15 @@ /// -//// interface I1 { -//// f1(x: number, y: C2); -//// } +//// interface I1 { +//// f1(x: number, y: C2); +//// } //// -//// class C2 {} +//// class C2 {} //// -//// class C1 implements I1 {/*0*//*1*/ -//// } +//// class C1 implements I1 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number,y: C2){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(x: number,y: C2){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface8.ts b/tests/cases/fourslash/unImplementedInterface8.ts index 970c968ef1875..2df93c6d7d915 100644 --- a/tests/cases/fourslash/unImplementedInterface8.ts +++ b/tests/cases/fourslash/unImplementedInterface8.ts @@ -1,12 +1,15 @@ /// -//// interface I1 { -//// f1(x: number, y: C2); -//// } +//// interface I1 { +//// f1(x: number, y: C2); +//// } //// -//// class C2 {} +//// class C2 {} //// -//// class C1 implements I1 {/*0*//*1*/ -//// } +//// class C1 implements I1 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(x: number,y: C2){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(x: number,y: C2){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unImplementedInterface9.ts b/tests/cases/fourslash/unImplementedInterface9.ts index bfaa87ea51c0e..5c869996773ad 100644 --- a/tests/cases/fourslash/unImplementedInterface9.ts +++ b/tests/cases/fourslash/unImplementedInterface9.ts @@ -1,15 +1,17 @@ /// -//// interface I1 { +//// interface I1 { //// -//// } +//// } //// -//// interface I2 extends I1 { -//// f1(); -//// } +//// interface I2 extends I1 { +//// f1(); +//// } //// -//// -//// class C1 implements I2 {/*0*//*1*/ -//// } +//// class C1 implements I2 {[| +//// |]} -verify.codeFixAtPosition({ span: { start: 0, end: 0 }, newText: "f1(){sys.newLine throw new Error('Method not Implemented');sys.newLine}sys.newLine" }); +verify.codeFixAtPosition(`f1(){ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unusedClassInNamespace1.ts b/tests/cases/fourslash/unusedClassInNamespace1.ts index 2f79362f55a7e..586202ab0c7d4 100644 --- a/tests/cases/fourslash/unusedClassInNamespace1.ts +++ b/tests/cases/fourslash/unusedClassInNamespace1.ts @@ -1,11 +1,10 @@ /// // @noUnusedLocals: true -////namespace greeter {/*0*/ +//// [| namespace greeter { //// class class1 { -//// }/*1*/ -////} +//// } +//// } |] -verify.codeFixAtPosition(` -namespace greeter { +verify.codeFixAtPosition(`namespace greeter { }`); diff --git a/tests/cases/fourslash/unusedClassInNamespace2.ts b/tests/cases/fourslash/unusedClassInNamespace2.ts index 81763971c11c2..c182f4e3655dc 100644 --- a/tests/cases/fourslash/unusedClassInNamespace2.ts +++ b/tests/cases/fourslash/unusedClassInNamespace2.ts @@ -1,15 +1,14 @@ /// // @noUnusedLocals: true -////namespace greeter { +//// [| namespace greeter { //// export class class2 { -//// }/*0*/ +//// } //// class class1 { -//// }/*1*/ -////} +//// } +//// } |] -verify.codeFixAtPosition(` -namespace greeter { +verify.codeFixAtPosition(`namespace greeter { export class class2 { } }`); diff --git a/tests/cases/fourslash/unusedClassInNamespace3.ts b/tests/cases/fourslash/unusedClassInNamespace3.ts index 12e9e355d7e0c..6102f744717d6 100644 --- a/tests/cases/fourslash/unusedClassInNamespace3.ts +++ b/tests/cases/fourslash/unusedClassInNamespace3.ts @@ -2,12 +2,11 @@ // @noUnusedLocals: true // @noUnusedParameters:true -////namespace Validation {/*0*/ +//// [| namespace Validation { //// class c1 { //// //// }/*1*/ -////} +//// } |] -verify.codeFixAtPosition(` -namespace Validation { +verify.codeFixAtPosition(`namespace Validation { }`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedClassInNamespace4.ts b/tests/cases/fourslash/unusedClassInNamespace4.ts index dffb0eca31ce7..79701a5e0e20f 100644 --- a/tests/cases/fourslash/unusedClassInNamespace4.ts +++ b/tests/cases/fourslash/unusedClassInNamespace4.ts @@ -3,18 +3,17 @@ // @noUnusedLocals: true // @noUnusedParameters:true -////namespace Validation {/*0*/ +//// [| namespace Validation { //// class c1 { //// -//// }/*1*/ +//// } //// //// export class c2 { //// //// } -////} +//// } |] -verify.codeFixAtPosition(` -namespace Validation { +verify.codeFixAtPosition(`namespace Validation { export class c2 { } }`); diff --git a/tests/cases/fourslash/unusedClassInNamespace5.ts b/tests/cases/fourslash/unusedClassInNamespace5.ts index 2d7dead616110..80d8fe857bd12 100644 --- a/tests/cases/fourslash/unusedClassInNamespace5.ts +++ b/tests/cases/fourslash/unusedClassInNamespace5.ts @@ -3,22 +3,21 @@ // @noUnusedLocals: true // @noUnusedParameters:true -////namespace Validation { +//// [| namespace Validation { //// class c1 { //// //// } //// //// export class c2 { //// -//// }/*0*/ +//// } //// //// class c3 extends c1 { //// -//// }/*1*/ -////} +//// } +////} |] -verify.codeFixAtPosition(` -namespace Validation { +verify.codeFixAtPosition(`namespace Validation { class c1 { } diff --git a/tests/cases/fourslash/unusedClassInNamespace6.ts b/tests/cases/fourslash/unusedClassInNamespace6.ts index 1a2da68204415..5db5b1aefa65d 100644 --- a/tests/cases/fourslash/unusedClassInNamespace6.ts +++ b/tests/cases/fourslash/unusedClassInNamespace6.ts @@ -2,22 +2,21 @@ // @noUnusedLocals: true // @noUnusedParameters:true -////namespace Validation { +//// [| namespace Validation { //// class c1 { //// //// } //// //// export class c2 { //// -//// }/*0*/ +//// } //// //// class c3 { //// public x: c1; -//// }/*1*/ -////} +//// } +////} |] -verify.codeFixAtPosition(` -namespace Validation { +verify.codeFixAtPosition(`namespace Validation { class c1 { } diff --git a/tests/cases/fourslash/unusedConstantInFunction1.ts b/tests/cases/fourslash/unusedConstantInFunction1.ts index 3e7932a8afd30..df37325780997 100644 --- a/tests/cases/fourslash/unusedConstantInFunction1.ts +++ b/tests/cases/fourslash/unusedConstantInFunction1.ts @@ -1,12 +1,10 @@ /// // @noUnusedLocals: true -//// function f1 () { +//// [| function f1 () { //// const x: string = "x"; -//// } +//// } |] -verify.codeFixAtPosition(` -function f1 () { -} -`); +verify.codeFixAtPosition(`function f1 () { +}`); diff --git a/tests/cases/fourslash/unusedEnumInFunction1.ts b/tests/cases/fourslash/unusedEnumInFunction1.ts index c68d1eb48ec46..1d88f07ebf76b 100644 --- a/tests/cases/fourslash/unusedEnumInFunction1.ts +++ b/tests/cases/fourslash/unusedEnumInFunction1.ts @@ -1,12 +1,11 @@ /// // @noUnusedLocals: true -//// function f1 () { +//// [| function f1 () { //// enum Directions { Up, Down} -//// } +//// } |] -verify.codeFixAtPosition(` -function f1 () { +verify.codeFixAtPosition(`function f1 () { } `); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace1.ts b/tests/cases/fourslash/unusedFunctionInNamespace1.ts index f91cb99f3002b..e0f6b2e18ac15 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace1.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace1.ts @@ -1,11 +1,10 @@ /// // @noUnusedLocals: true -////namespace greeter {/*0*/ +//// [| namespace greeter { //// function function1() { //// }/*1*/ -////} +//// } |] -verify.codeFixAtPosition(` -namespace greeter { +verify.codeFixAtPosition(`namespace greeter { }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace2.ts b/tests/cases/fourslash/unusedFunctionInNamespace2.ts index f2a9251dbf4d8..c823777048e2e 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace2.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace2.ts @@ -1,15 +1,14 @@ /// // @noUnusedLocals: true -////namespace greeter { +//// [| namespace greeter { //// export function function2() { -//// }/*0*/ +//// } //// function function1() { -//// }/*1*/ -////} +//// } +////} |] -verify.codeFixAtPosition(` -namespace greeter { +verify.codeFixAtPosition(`namespace greeter { export function function2() { } }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace3.ts b/tests/cases/fourslash/unusedFunctionInNamespace3.ts index dc707609ecc74..144e9f325b444 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace3.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace3.ts @@ -3,11 +3,10 @@ // @noUnusedLocals: true // @noUnusedParameters:true -////namespace Validation {/*0*/ +//// [| namespace Validation { //// function function1() { -//// }/*1*/ -////} +//// } +////} |] -verify.codeFixAtPosition(` -namespace Validation { +verify.codeFixAtPosition(`namespace Validation { }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace4.ts b/tests/cases/fourslash/unusedFunctionInNamespace4.ts index 280160cc3a219..5b5995da9c745 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace4.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace4.ts @@ -2,11 +2,10 @@ // @noUnusedLocals: true // @noUnusedParameters:true -////namespace Validation {/*0*/ +//// [| namespace Validation { //// var function1 = function() { -//// }/*1*/ -////} +//// } +////} |] -verify.codeFixAtPosition(` -namespace Validation { +verify.codeFixAtPosition(`namespace Validation { }`); diff --git a/tests/cases/fourslash/unusedFunctionInNamespace5.ts b/tests/cases/fourslash/unusedFunctionInNamespace5.ts index c4daa52290b1e..fa1eed2364a51 100644 --- a/tests/cases/fourslash/unusedFunctionInNamespace5.ts +++ b/tests/cases/fourslash/unusedFunctionInNamespace5.ts @@ -10,29 +10,19 @@ //// //// } //// -//// function function3() { +//// [| function function3() { //// function1(); -//// }/*0*/ +//// } //// //// function function4() { //// -//// }/*1*/ +//// } //// -//// export let a = function3; +//// exp ort let a = function3; |] ////} -verify.codeFixAtPosition(` -namespace Validation { - var function1 = function() { - } - - export function function2() { - - } - - function function3() { +verify.codeFixAtPosition(`function function3() { function1(); } - export let a = function3; -}`); + export let a = function3;`, 6133); diff --git a/tests/cases/fourslash/unusedImports10FS.ts b/tests/cases/fourslash/unusedImports10FS.ts index e20330c3a559f..2eb923c9b8fbc 100644 --- a/tests/cases/fourslash/unusedImports10FS.ts +++ b/tests/cases/fourslash/unusedImports10FS.ts @@ -9,19 +9,8 @@ //// } //// module B { -//// import a = A; +//// [|import a = A;|] //// } -verify.codeFixAtPosition(` -module A { - export class Calculator { - public handelChar() { - } - } -} - -module B { - import {} = A; -} -`); +verify.codeFixAtPosition(" import {} = A;"); diff --git a/tests/cases/fourslash/unusedImports1FS.ts b/tests/cases/fourslash/unusedImports1FS.ts index fb5fbac1dbe7c..c3ae198d876dc 100644 --- a/tests/cases/fourslash/unusedImports1FS.ts +++ b/tests/cases/fourslash/unusedImports1FS.ts @@ -2,13 +2,11 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import {/*0*/Calculator/*1*/} from "./file1" +//// [| import {/*0*/Calculator/*1*/} from "./file1" |] // @Filename: file1.ts //// export class Calculator { //// //// } -verify.codeFixAtPosition(` -import {} from "./file1" -`); +verify.codeFixAtPosition(`import {} from "./file1"`); diff --git a/tests/cases/fourslash/unusedImports2FS.ts b/tests/cases/fourslash/unusedImports2FS.ts index 30a606b737c9e..a7144d1eb4976 100644 --- a/tests/cases/fourslash/unusedImports2FS.ts +++ b/tests/cases/fourslash/unusedImports2FS.ts @@ -2,8 +2,8 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import {Calculator} from "./file1" -//// import {/*0*/test/*1*/} from "./file1" +//// [| import {Calculator} from "./file1" +//// import {test} from "./file1" |] //// var x = new Calculator(); //// x.handleChar(); @@ -16,10 +16,5 @@ //// //// } -verify.codeFixAtPosition(` -import {Calculator} from "./file1" -import {} from "./file1" - -var x = new Calculator(); -x.handleChar(); -`); +verify.codeFixAtPosition(`import {Calculator} from "./file1" +import {} from "./file1"`); diff --git a/tests/cases/fourslash/unusedImports3FS.ts b/tests/cases/fourslash/unusedImports3FS.ts index 54c28f0fe7fc0..f030232dc1e5b 100644 --- a/tests/cases/fourslash/unusedImports3FS.ts +++ b/tests/cases/fourslash/unusedImports3FS.ts @@ -2,7 +2,7 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import {/*0*/Calculator,/*1*/ test, test2} from "./file1" +////[| import {/*0*/Calculator,/*1*/ test, test2} from "./file1" |] //// test(); //// test2(); @@ -20,10 +20,5 @@ //// //// } -verify.codeFixAtPosition(` -import {test, test2} from "./file1" - -test(); -test2(); -`); +verify.codeFixAtPosition(`import {test, test2} from "./file1"`); diff --git a/tests/cases/fourslash/unusedImports4FS.ts b/tests/cases/fourslash/unusedImports4FS.ts index 638144a383fcb..ab37928eb0164 100644 --- a/tests/cases/fourslash/unusedImports4FS.ts +++ b/tests/cases/fourslash/unusedImports4FS.ts @@ -2,7 +2,7 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import {Calculator/*0*/, test/*1*/, test2} from "./file1" +//// [| import {Calculator/*0*/, test/*1*/, test2} from "./file1" |] //// //// var x = new Calculator(); //// x.handleChar(); @@ -21,10 +21,4 @@ //// //// } -verify.codeFixAtPosition(` -import {Calculator, test2} from "./file1" - -var x = new Calculator(); -x.handleChar(); -test2(); -`); \ No newline at end of file +verify.codeFixAtPosition(`import {Calculator, test2} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports5FS.ts b/tests/cases/fourslash/unusedImports5FS.ts index d637488c4a200..1d68f6ae64383 100644 --- a/tests/cases/fourslash/unusedImports5FS.ts +++ b/tests/cases/fourslash/unusedImports5FS.ts @@ -2,7 +2,7 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import {Calculator, test/*0*/, test2/*1*/} from "./file1" +//// [| import {Calculator, test, test2} from "./file1" |] //// //// var x = new Calculator(); //// x.handleChar(); @@ -21,10 +21,4 @@ //// //// } -verify.codeFixAtPosition(` -import {Calculator, test} from "./file1" - -var x = new Calculator(); -x.handleChar(); -test(); -`); \ No newline at end of file +verify.codeFixAtPosition(`import {Calculator, test} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports6FS.ts b/tests/cases/fourslash/unusedImports6FS.ts index 2c5d3674eced7..c8e1af9231389 100644 --- a/tests/cases/fourslash/unusedImports6FS.ts +++ b/tests/cases/fourslash/unusedImports6FS.ts @@ -2,7 +2,7 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import d from "./file1" +//// [| import d from "./file1" |] // @Filename: file1.ts //// export class Calculator { @@ -17,6 +17,4 @@ //// //// } -verify.codeFixAtPosition(` -import {} from "./file1" -`); \ No newline at end of file +verify.codeFixAtPosition(`import {} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports7FS.ts b/tests/cases/fourslash/unusedImports7FS.ts index f3ec8c5a2261f..6dc0886e8ffbe 100644 --- a/tests/cases/fourslash/unusedImports7FS.ts +++ b/tests/cases/fourslash/unusedImports7FS.ts @@ -2,7 +2,7 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import * as n from "./file1" +//// [| import * as n from "./file1" |] // @Filename: file1.ts //// export class Calculator { @@ -17,6 +17,4 @@ //// //// } -verify.codeFixAtPosition(` -import {} from "./file1" -`); \ No newline at end of file +verify.codeFixAtPosition(`import {} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports8FS.ts b/tests/cases/fourslash/unusedImports8FS.ts index 9677ba1354d26..02564e359895d 100644 --- a/tests/cases/fourslash/unusedImports8FS.ts +++ b/tests/cases/fourslash/unusedImports8FS.ts @@ -2,7 +2,7 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import {Calculator as calc, test as t1, test2 as t2} from "./file1" +//// [|import {Calculator as calc, test as t1, test2 as t2} from "./file1"|] //// //// var x = new calc(); //// x.handleChar(); @@ -21,10 +21,4 @@ //// //// } -verify.codeFixAtPosition(` -import {Calculator as calc, test as t1} from "./file1" - -var x = new calc(); -x.handleChar(); -t1(); -`); \ No newline at end of file +verify.codeFixAtPosition(`import {Calculator as calc, test as t1} from "./file1"`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedImports9FS.ts b/tests/cases/fourslash/unusedImports9FS.ts index aaeb2545dba63..2ba30c95bb718 100644 --- a/tests/cases/fourslash/unusedImports9FS.ts +++ b/tests/cases/fourslash/unusedImports9FS.ts @@ -2,7 +2,7 @@ // @noUnusedLocals: true // @Filename: file2.ts -//// import c = require('./file1') +//// [|import c = require('./file1')|] // @Filename: file1.ts //// export class Calculator { @@ -17,6 +17,4 @@ //// //// } -verify.codeFixAtPosition(` -import {} = require('./file1') -`); +verify.codeFixAtPosition("import {} = require('./file1')"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts index db4e789018325..8d07a8c79121e 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace1.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace1.ts @@ -1,10 +1,10 @@ /// // @noUnusedLocals: true -////namespace greeter {/*0*/ +//// [| namespace greeter { //// interface interface1 { -//// }/*1*/ -////} +//// } +////} |] verify.codeFixAtPosition(` namespace greeter { diff --git a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts index 4b3ad5232edea..baa46c65a0ce6 100644 --- a/tests/cases/fourslash/unusedInterfaceInNamespace2.ts +++ b/tests/cases/fourslash/unusedInterfaceInNamespace2.ts @@ -2,14 +2,11 @@ // @noUnusedLocals: true ////namespace greeter { -//// export interface interface2 { -//// }/*0*/ +//// [| export interface interface2 { +//// } //// interface interface1 { -//// }/*1*/ +//// } |] ////} -verify.codeFixAtPosition(` -namespace greeter { - export interface interface2 { - } +verify.codeFixAtPosition(`export interface interface2 { }`); diff --git a/tests/cases/fourslash/unusedLocalsInFunction1.ts b/tests/cases/fourslash/unusedLocalsInFunction1.ts index 2f5693e8ea8f3..2edd7c176e7dd 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction1.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction1.ts @@ -1,9 +1,9 @@ /// // @noUnusedLocals: true -////function greeter() {/*0*/ -//// var x = 0;/*1*/ -////} +//// [| function greeter() { +//// var x = 0; +////} |] verify.codeFixAtPosition(` function greeter() { diff --git a/tests/cases/fourslash/unusedLocalsInFunction2.ts b/tests/cases/fourslash/unusedLocalsInFunction2.ts index 87001b1952120..b8f5a650aa7e8 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction2.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction2.ts @@ -2,12 +2,8 @@ // @noUnusedLocals: true ////function greeter() { -//// var x/*0*/, y = 0/*1*/; +//// [| var x, y = 0; |] //// x++; ////} -verify.codeFixAtPosition(` -function greeter() { - var x; - x++; -}`); +verify.codeFixAtPosition("var x;"); diff --git a/tests/cases/fourslash/unusedLocalsInFunction3.ts b/tests/cases/fourslash/unusedLocalsInFunction3.ts index 5c222a617dddb..93303bec0e5cc 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction3.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction3.ts @@ -2,14 +2,9 @@ // @noUnusedLocals: true ////function greeter() { -//// var x/*0*/, y = 0/*1*/,z = 1; +//// [| var x, y = 0,z = 1; |] //// x++; //// z++; ////} -verify.codeFixAtPosition(` -function greeter() { - var x,z = 1; - x++; - z++; -}`); +verify.codeFixAtPosition("var x,z = 1;"); diff --git a/tests/cases/fourslash/unusedLocalsInFunction4.ts b/tests/cases/fourslash/unusedLocalsInFunction4.ts index 4f228ca633ee6..54d3223f23608 100644 --- a/tests/cases/fourslash/unusedLocalsInFunction4.ts +++ b/tests/cases/fourslash/unusedLocalsInFunction4.ts @@ -2,14 +2,9 @@ // @noUnusedLocals: true ////function greeter() { -//// var /*0*/ x,/*1*/ y = 0,z = 1; +//// [| var x,y = 0,z = 1; |] //// y++; //// z++; ////} -verify.codeFixAtPosition(` -function greeter() { - var y = 0,z = 1; - y++; - z++; -}`); +verify.codeFixAtPosition("var y = 0,z = 1;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts index ab171cdbeafe6..43b782ce2661a 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS1.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS1.ts @@ -4,15 +4,9 @@ // @noUnusedParameters: true ////class greeter { //// public function1() { -//// var /*0*/x,/*1*/ y = 10; +//// [| var /*0*/x,/*1*/ y = 10; |] //// y++; //// } ////} -verify.codeFixAtPosition(` -class greeter { - public function1() { - var y = 10; - y++; - } -}`); +verify.codeFixAtPosition("var y = 10;"); diff --git a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts index 678d0e85522b9..322cfad394007 100644 --- a/tests/cases/fourslash/unusedLocalsInMethodFS2.ts +++ b/tests/cases/fourslash/unusedLocalsInMethodFS2.ts @@ -4,15 +4,9 @@ // @noUnusedParameters: true ////class greeter { //// public function1() { -//// var /*0*/x,/*1*/ y; +//// [| var x, y; |] //// y = 1; //// } ////} -verify.codeFixAtPosition(` -class greeter { - public function1() { - var y; - y = 1; - } -}`); +verify.codeFixAtPosition("var y;"); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts index af8d4c04db4d7..412b599b780a9 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS1.ts @@ -3,13 +3,10 @@ // @noUnusedLocals: true // @noUnusedParameters:true ////class greeter { -//// constructor() {/*0*/ -//// var unused = 20;/*1*/ -//// } +//// [| constructor() { +//// var unused = 20; +//// } |] ////} -verify.codeFixAtPosition(` -class greeter { - constructor() { - } +verify.codeFixAtPosition(`constructor() { }`); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts index 53683506fbc54..77ea6ed5a4cc1 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts @@ -3,17 +3,11 @@ // @noUnusedLocals: true // @noUnusedParameters: true ////class greeter { -//// constructor() {/*0*/ -//// var unused = 20;/*1*/ -//// var used = "dummy"; +//// constructor() { +//// [| var unused = 20; +//// var used = "dummy"; |] //// used = used + "second part"; //// } ////} -verify.codeFixAtPosition(` -class greeter { - constructor() { - var used = "dummy"; - used = used + "second part"; - } -}`); +verify.codeFixAtPosition(`var used = "dummy";`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedMethodInClass1.ts b/tests/cases/fourslash/unusedMethodInClass1.ts index 300112498a30c..7795a4d15303e 100644 --- a/tests/cases/fourslash/unusedMethodInClass1.ts +++ b/tests/cases/fourslash/unusedMethodInClass1.ts @@ -1,10 +1,10 @@ /// // @noUnusedLocals: true -////class greeter {/*0*/ +////[| class greeter { //// private function1() { -//// }/*1*/ -////} +//// } +////} |] verify.codeFixAtPosition(` class greeter { diff --git a/tests/cases/fourslash/unusedMethodInClass2.ts b/tests/cases/fourslash/unusedMethodInClass2.ts index c108bfd642885..24b6fe155efb5 100644 --- a/tests/cases/fourslash/unusedMethodInClass2.ts +++ b/tests/cases/fourslash/unusedMethodInClass2.ts @@ -1,12 +1,12 @@ /// // @noUnusedLocals: true -////class greeter { +//// [| class greeter { //// public function2() { -//// }/*0*/ +//// } //// private function1() { -//// }/*1*/ -////} +//// } +////} |] verify.codeFixAtPosition(` class greeter { diff --git a/tests/cases/fourslash/unusedMethodInClass3.ts b/tests/cases/fourslash/unusedMethodInClass3.ts index 1c520ebb6a978..eab535fb5af66 100644 --- a/tests/cases/fourslash/unusedMethodInClass3.ts +++ b/tests/cases/fourslash/unusedMethodInClass3.ts @@ -1,10 +1,10 @@ /// // @noUnusedLocals: true -////class greeter {/*0*/ +////[|class greeter { //// private function1 = function() { -//// }/*1*/ -////} +//// } +////} |] verify.codeFixAtPosition(` class greeter { diff --git a/tests/cases/fourslash/unusedMethodInClass4.ts b/tests/cases/fourslash/unusedMethodInClass4.ts index ace5a52c6a2bd..ee27ec331eb84 100644 --- a/tests/cases/fourslash/unusedMethodInClass4.ts +++ b/tests/cases/fourslash/unusedMethodInClass4.ts @@ -2,14 +2,11 @@ // @noUnusedLocals: true ////class greeter { -//// public function2(){ -//// }/*0*/ +//// [|public function2(){ +//// } //// private function1 = function() { -//// }/*1*/ +//// } |] ////} -verify.codeFixAtPosition(` -class greeter { - public function2(){ - } +verify.codeFixAtPosition(`public function2(){ }`); diff --git a/tests/cases/fourslash/unusedNamespaceInNamespace.ts b/tests/cases/fourslash/unusedNamespaceInNamespace.ts index a550fa2f925fc..41fe162ef1564 100644 --- a/tests/cases/fourslash/unusedNamespaceInNamespace.ts +++ b/tests/cases/fourslash/unusedNamespaceInNamespace.ts @@ -1,10 +1,10 @@ /// // @noUnusedLocals: true -//// namespace A { +//// [|namespace A { //// namespace B { //// } -//// } +//// }|] verify.codeFixAtPosition(` namespace A { diff --git a/tests/cases/fourslash/unusedParameterInCatch1.ts b/tests/cases/fourslash/unusedParameterInCatch1.ts index 2dc2f1f273e48..da24d2aef0322 100644 --- a/tests/cases/fourslash/unusedParameterInCatch1.ts +++ b/tests/cases/fourslash/unusedParameterInCatch1.ts @@ -3,11 +3,7 @@ // @noUnusedLocals: true // @noUnusedParameters: true //// function f1() { -//// try {} catch(ex) {} +//// try {} [|catch(ex)|] {} //// } -verify.codeFixAtPosition(` -function f1() { -try {} catch() {} -} -`); +verify.codeFixAtPosition("catch()"); diff --git a/tests/cases/fourslash/unusedParameterInConstructor1.ts b/tests/cases/fourslash/unusedParameterInConstructor1.ts index f5a0108c76f28..f53c6d3e8bdde 100644 --- a/tests/cases/fourslash/unusedParameterInConstructor1.ts +++ b/tests/cases/fourslash/unusedParameterInConstructor1.ts @@ -2,11 +2,7 @@ // @noUnusedLocals: true //// class C1 { -//// constructor(private p1: string, public p2: boolean, public p3: any, p5) { p5; } +//// [|constructor(private p1: string, public p2: boolean, public p3: any, p5)|] { p5; } //// } -verify.codeFixAtPosition(` -class C1 { - constructor(public p2: boolean, public p3: any, p5) { p5; } -} -`); \ No newline at end of file +verify.codeFixAtPosition("constructor(public p2: boolean, public p3: any, p5)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction1.ts b/tests/cases/fourslash/unusedParameterInFunction1.ts index 93017d0fcd0d4..2243af9f5f553 100644 --- a/tests/cases/fourslash/unusedParameterInFunction1.ts +++ b/tests/cases/fourslash/unusedParameterInFunction1.ts @@ -1,9 +1,7 @@ /// // @noUnusedParameters: true -////function greeter(/*0*/ x/*1*/) { +////function [|greeter( x)|] { ////} -verify.codeFixAtPosition(` -function greeter() { -}`); +verify.codeFixAtPosition("greeter()"); diff --git a/tests/cases/fourslash/unusedParameterInFunction2.ts b/tests/cases/fourslash/unusedParameterInFunction2.ts index 0404981063a04..493eafc572223 100644 --- a/tests/cases/fourslash/unusedParameterInFunction2.ts +++ b/tests/cases/fourslash/unusedParameterInFunction2.ts @@ -1,11 +1,8 @@ /// // @noUnusedParameters: true -////function greeter(x/*0*/,y/*1*/) { +////function [|greeter(x,y)|] { //// x++; ////} -verify.codeFixAtPosition(` -function greeter(x) { - x++; -}`); +verify.codeFixAtPosition("greeter(x)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction3.ts b/tests/cases/fourslash/unusedParameterInFunction3.ts index cd0eec3fd747b..6d79ba071b450 100644 --- a/tests/cases/fourslash/unusedParameterInFunction3.ts +++ b/tests/cases/fourslash/unusedParameterInFunction3.ts @@ -1,11 +1,8 @@ /// // @noUnusedParameters: true -////function greeter(/*0*/x,/*1*/y) { +////function [|greeter(x,y)|] { //// y++; ////} -verify.codeFixAtPosition(` -function greeter(y) { - y++; -}`); +verify.codeFixAtPosition("greeter(y)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInFunction4.ts b/tests/cases/fourslash/unusedParameterInFunction4.ts index 8955f07bb44b2..b536543fb6d59 100644 --- a/tests/cases/fourslash/unusedParameterInFunction4.ts +++ b/tests/cases/fourslash/unusedParameterInFunction4.ts @@ -1,13 +1,9 @@ /// // @noUnusedParameters: true -////function greeter(x/*0*/,y/*1*/,z) { +////[|function greeter(x,y,z) |] { //// x++; //// z++; ////} -verify.codeFixAtPosition(` -function greeter(x,z) { - x++; - z++; -}`); +verify.codeFixAtPosition("function greeter(x,z)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInLambda1.ts b/tests/cases/fourslash/unusedParameterInLambda1.ts index 8fe5ed5172134..c462b7425694d 100644 --- a/tests/cases/fourslash/unusedParameterInLambda1.ts +++ b/tests/cases/fourslash/unusedParameterInLambda1.ts @@ -3,11 +3,7 @@ // @noUnusedLocals: true // @noUnusedParameters: true //// function f1() { -//// return (x:number) => {} +//// [|return (x:number) => {}|] //// } -verify.codeFixAtPosition(` -function f1() { - return () => {} -} -`); +verify.codeFixAtPosition("return () => {}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInClass1.ts b/tests/cases/fourslash/unusedTypeParametersInClass1.ts index b4a397c1ac6c8..ab654a5150e73 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass1.ts @@ -1,9 +1,7 @@ /// // @noUnusedLocals: true -////class greeter/*0*//*1*/ { +////[|class greeter |] { ////} -verify.codeFixAtPosition(` -class greeter { -}`); +verify.codeFixAtPosition("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass2.ts b/tests/cases/fourslash/unusedTypeParametersInClass2.ts index acbf100f38714..8e860c10e049b 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass2.ts @@ -1,11 +1,8 @@ /// // @noUnusedLocals: true -////class greeter { +////[|class greeter |] { //// public a: X; ////} -verify.codeFixAtPosition(` -class greeter { - public a: X; -}`); +verify.codeFixAtPosition("class greeter"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInClass3.ts b/tests/cases/fourslash/unusedTypeParametersInClass3.ts index 33f5a6c948601..75ae98f53e0ed 100644 --- a/tests/cases/fourslash/unusedTypeParametersInClass3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInClass3.ts @@ -1,13 +1,9 @@ /// // @noUnusedLocals: true -////class greeter { +////[|class greeter |] { //// public a: X; //// public b: Z; ////} -verify.codeFixAtPosition(` -class greeter { - public a: X; - public b: Z; -}`); +verify.codeFixAtPosition("class greeter"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts index fc464f6feb5cd..7177ed41c8445 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction1.ts @@ -1,8 +1,6 @@ /// // @noUnusedLocals: true -//// function f1() {} +//// [|function f1() {}|] -verify.codeFixAtPosition(` -function f1() {} -`); +verify.codeFixAtPosition("function f1() {}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts index 5f9476f655a8f..344ae303c75df 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction2.ts @@ -1,8 +1,6 @@ /// // @noUnusedLocals: true -//// function f1(a: X) {a} +//// [|function f1(a: X) {a}|] -verify.codeFixAtPosition(` -function f1(a: X) {a} -`); +verify.codeFixAtPosition("function f1(a: X) {a}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts index 36e799b894cfc..746b174db18d9 100644 --- a/tests/cases/fourslash/unusedTypeParametersInFunction3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInFunction3.ts @@ -1,8 +1,6 @@ /// // @noUnusedLocals: true -//// function f1(a: X) {a;var b:Z;b} +//// [|function f1(a: X) {a;var b:Z;b}|] -verify.codeFixAtPosition(` -function f1(a: X) {a;var b:Z;b} -`); +verify.codeFixAtPosition("function f1(a: X) {a;var b:Z;b}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts index 96d7749424361..70d8bc7800cd8 100644 --- a/tests/cases/fourslash/unusedTypeParametersInInterface1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInInterface1.ts @@ -2,9 +2,6 @@ // @noUnusedLocals: true // @noUnusedParameters: true -//// interface I {} +//// [|interface I {}|] - -verify.codeFixAtPosition(` -interface I {} -`); +verify.codeFixAtPosition("interface I {}"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts index bd8a8ee16b784..73d7067236850 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda1.ts @@ -3,11 +3,7 @@ // @noUnusedLocals: true // @noUnusedParameters: true //// function f1() { -//// return (x:number) => {x} +//// [|return (x:number) => {x}|] //// } -verify.codeFixAtPosition(` -function f1() { - return (x:number) => {x} -} -`); +verify.codeFixAtPosition("return (x:number) => {x}"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts index b649fef3333d1..77c802f5c44f3 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda2.ts @@ -3,11 +3,7 @@ // @noUnusedLocals: true // @noUnusedParameters: true //// var x : { -//// new (a: T): void; +//// [|new (a: T): void;|] //// } -verify.codeFixAtPosition(` -var x : { - new (a: T): void; -} -`); +verify.codeFixAtPosition("new (a: T): void;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts index 23b993b996d40..0ecb0338be2ce 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda3.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda3.ts @@ -4,12 +4,7 @@ // @noUnusedParameters: true //// class A { public x: Dummy } //// var x : { -//// new (a: T): A; +//// [|new (a: T): A;|] //// } -verify.codeFixAtPosition(` -class A { public x: Dummy } -var x : { - new (a: T): A; -} -`); +verify.codeFixAtPosition("new (a: T): A;"); diff --git a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts index 38783defc253b..5a226fc9005ef 100644 --- a/tests/cases/fourslash/unusedTypeParametersInLambda4.ts +++ b/tests/cases/fourslash/unusedTypeParametersInLambda4.ts @@ -4,12 +4,6 @@ //// class A { //// public x: T; //// } -//// var y: new (a:T)=>void; - -verify.codeFixAtPosition(` -class A { - public x: T; -} -var y: new (a:T)=>void; -`); +//// [|var y: new (a:T)=>void;|] +verify.codeFixAtPosition("var y: new (a:T)=>void;"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts index d92a17a3f115b..7a9f04147d617 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethod1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethod1.ts @@ -2,11 +2,7 @@ // @noUnusedLocals: true //// class C1 { -//// f1() {} +//// [|f1()|] {} //// } -verify.codeFixAtPosition(` -class C1 { - f1() {} -} -`); \ No newline at end of file +verify.codeFixAtPosition("f1()"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts index cb5861dc8a17c..3650cfbad98a0 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethod2.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethod2.ts @@ -2,11 +2,7 @@ // @noUnusedLocals: true //// class C1 { -//// f1(a: U) {a;} +//// [|f1(a: U)|] {a;} //// } -verify.codeFixAtPosition(` -class C1 { - f1(a: U) {a;} -} -`); \ No newline at end of file +verify.codeFixAtPosition("f1(a: U)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts index 652d6c20e79b7..cb9b965ca4d45 100644 --- a/tests/cases/fourslash/unusedTypeParametersInMethods1.ts +++ b/tests/cases/fourslash/unusedTypeParametersInMethods1.ts @@ -2,11 +2,7 @@ // @noUnusedLocals: true //// class A { -//// public f1(a: X) { a; var b: Z; b } +//// [|public f1(a: X)|] { a; var b: Z; b } //// } -verify.codeFixAtPosition(` -class A { - public f1(a: X) { a; var b: Z; b } -} -`); +verify.codeFixAtPosition("public f1(a: X)"); diff --git a/tests/cases/fourslash/unusedVariableInBlocks.ts b/tests/cases/fourslash/unusedVariableInBlocks.ts index 0a9cfe6f91dc4..e9dedaef31eb0 100644 --- a/tests/cases/fourslash/unusedVariableInBlocks.ts +++ b/tests/cases/fourslash/unusedVariableInBlocks.ts @@ -2,18 +2,14 @@ // @noUnusedLocals: true //// function f1 () { -//// let x = 10; +//// [|let x = 10; //// { //// let x = 11; //// } -//// x; +//// x;|] //// } -verify.codeFixAtPosition(` -function f1 () { - let x = 10; +verify.codeFixAtPosition(`let x = 10; { } - x; -} -`); + x;`); diff --git a/tests/cases/fourslash/unusedVariableInClass1.ts b/tests/cases/fourslash/unusedVariableInClass1.ts index 426af6e5bee48..82bb99016efd5 100644 --- a/tests/cases/fourslash/unusedVariableInClass1.ts +++ b/tests/cases/fourslash/unusedVariableInClass1.ts @@ -1,10 +1,8 @@ /// // @noUnusedLocals: true -////class greeter {/*0*/ -//// private greeting: string;/*1*/ +////class greeter { +//// [|private greeting: string;|] ////} -verify.codeFixAtPosition(` -class greeter { -}`); +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInClass2.ts b/tests/cases/fourslash/unusedVariableInClass2.ts index 771e93dd75071..c971092584a53 100644 --- a/tests/cases/fourslash/unusedVariableInClass2.ts +++ b/tests/cases/fourslash/unusedVariableInClass2.ts @@ -2,11 +2,8 @@ // @noUnusedLocals: true ////class greeter { -//// public greeting1;/*0*/ -//// private greeting: string;/*1*/ +//// [|public greeting1; +//// private greeting: string;|] ////} -verify.codeFixAtPosition(` -class greeter { - public greeting1; -}`); +verify.codeFixAtPosition("public greeting1;"); diff --git a/tests/cases/fourslash/unusedVariableInClass3.ts b/tests/cases/fourslash/unusedVariableInClass3.ts index e8281a53e762a..8d2a62e7175b9 100644 --- a/tests/cases/fourslash/unusedVariableInClass3.ts +++ b/tests/cases/fourslash/unusedVariableInClass3.ts @@ -1,10 +1,8 @@ /// // @noUnusedLocals: true -////class greeter {/*0*/ -//// private X = function() {};/*1*/ -////} +////class greeter {[| +//// private X = function() {}; +////|]} -verify.codeFixAtPosition(` -class greeter { -}`); +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts index f8644a1a90418..0ee02ab43632d 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop1FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop1FS.ts @@ -2,16 +2,10 @@ // @noUnusedLocals: true //// function f1 () { -//// for(var i = 0; ;) { +//// [|for(var i = 0; ;) |]{ //// //// } //// } -verify.codeFixAtPosition(` -function f1 () { - for(; ;) { - - } -} -`); +verify.codeFixAtPosition("for(; ;)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts index 30c34546d909c..1b1a0798c0445 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop2FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop2FS.ts @@ -2,15 +2,9 @@ // @noUnusedLocals: true //// function f1 () { -//// for(var i = 0, j= 0; ;i++) { +//// [|for(var i = 0, j= 0; ;i++)|] { //// //// } //// } -verify.codeFixAtPosition(` -function f1 () { - for(var i = 0; ;i++) { - - } -} -`); +verify.codeFixAtPosition("for(var i = 0; ;i++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts index 10014ffa5cbe0..4eed9599b1513 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop3FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop3FS.ts @@ -2,16 +2,9 @@ // @noUnusedLocals: true //// function f1 () { -//// for(var i = 0, j= 0, k=0; ;i++, k++) { +//// [|for(var i = 0, j= 0, k=0; ;i++, k++)|] { //// //// } //// } -verify.codeFixAtPosition(` -function f1 () { - for(var i = 0, k=0; ;i++,k++) { - - } -} -`); - +verify.codeFixAtPosition("for(var i = 0, k=0; ;i++,k++)"); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts index 648a2fdd07bb0..76e551612ba79 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop4FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop4FS.ts @@ -2,16 +2,9 @@ // @noUnusedLocals: true //// function f1 () { -//// for(var i = 0, j= 0, k=0; ;j++, k++) { +//// [|for(var i = 0, j= 0, k=0; ;j++, k++) |]{ //// //// } //// } -verify.codeFixAtPosition(` -function f1 () { - for(var j = 0, k=0; ;j++,k++) { - - } -} -`); - +verify.codeFixAtPosition("for(var j = 0, k=0; ;j++,k++)"); diff --git a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts index bf8698aad2635..60369da522d17 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop5FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop5FS.ts @@ -2,15 +2,10 @@ // @noUnusedLocals: true //// function f1 () { -//// for (const elem in ["a", "b", "c"]) { +//// for ([|const elem in|] ["a", "b", "c"]) { //// //// } //// } -verify.codeFixAtPosition(` -function f1 () { - for (const {} in ["a", "b", "c"]) { - } -} -`); +verify.codeFixAtPosition("const {} in "); diff --git a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts index f48233f2c2ab8..4187c3141b547 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop6FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop6FS.ts @@ -2,15 +2,10 @@ // @noUnusedLocals: true //// function f1 () { -//// for (const elem of ["a", "b", "c"]) { +//// for ([|const elem of|] ["a", "b", "c"]) { //// //// } //// } -verify.codeFixAtPosition(` -function f1 () { - for (const {} of ["a", "b", "c"]) { - } -} -`); +verify.codeFixAtPosition("const {} of "); diff --git a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts index d1af8351b2db9..8fd0fee735e27 100644 --- a/tests/cases/fourslash/unusedVariableInForLoop7FS.ts +++ b/tests/cases/fourslash/unusedVariableInForLoop7FS.ts @@ -4,15 +4,9 @@ //// function f1 () { //// for (const elem of ["a", "b", "c"]) { //// elem; -//// var x = 20; -//// } +//// [|var x = 20;|] //// } +////} //// -verify.codeFixAtPosition(` -function f1 () { - for (const elem of ["a", "b", "c"]) { - elem; - } -} -`); +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule1.ts b/tests/cases/fourslash/unusedVariableInModule1.ts index d4c3e71fba354..011434ce098df 100644 --- a/tests/cases/fourslash/unusedVariableInModule1.ts +++ b/tests/cases/fourslash/unusedVariableInModule1.ts @@ -3,10 +3,7 @@ // @noUnusedLocals: true // @noUnusedParameters: true //// export {} -//// var x: string; +//// [|var x: string;|] //// export var y: string; -verify.codeFixAtPosition(` -export {} -export var y: string; -`); +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule2.ts b/tests/cases/fourslash/unusedVariableInModule2.ts index dec89920d5ebb..09108ab1ee0f9 100644 --- a/tests/cases/fourslash/unusedVariableInModule2.ts +++ b/tests/cases/fourslash/unusedVariableInModule2.ts @@ -3,13 +3,8 @@ // @noUnusedLocals: true // @noUnusedParameters: true //// export {} -//// var x: string, y: number; +//// [|var x: string, y: number;|] //// y; //// export var y: string; -verify.codeFixAtPosition(` -export {} -var y: number; -y; -export var y: string; -`); +verify.codeFixAtPosition("var y: number;", 6133); diff --git a/tests/cases/fourslash/unusedVariableInModule3.ts b/tests/cases/fourslash/unusedVariableInModule3.ts index cd7c52ed91aeb..bffffc768d355 100644 --- a/tests/cases/fourslash/unusedVariableInModule3.ts +++ b/tests/cases/fourslash/unusedVariableInModule3.ts @@ -3,10 +3,7 @@ // @noUnusedLocals: true // @noUnusedParameters: true //// export {} -//// var x = function f1() {} +//// [|var x = function f1() {}|] //// export var y: string; -verify.codeFixAtPosition(` -export {} -export var y: string; -`); +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInModule4.ts b/tests/cases/fourslash/unusedVariableInModule4.ts index d4e4a1e5426e6..6a1be9fe5b89a 100644 --- a/tests/cases/fourslash/unusedVariableInModule4.ts +++ b/tests/cases/fourslash/unusedVariableInModule4.ts @@ -3,13 +3,8 @@ // @noUnusedLocals: true // @noUnusedParameters: true //// export {} -//// var x = function f1(m: number) {} +//// [|var x = function f1(m: number) {}|] //// x; //// export var y: string; -verify.codeFixAtPosition(` -export {} -var x = function f1() {} -x; -export var y: string; -`); +verify.codeFixAtPosition(`var x = function f1() {}`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace1.ts b/tests/cases/fourslash/unusedVariableInNamespace1.ts index 5e13e1d5681c6..caf778bc0da76 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace1.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace1.ts @@ -1,10 +1,8 @@ /// // @noUnusedLocals: true -////namespace greeter {/*0*/ -//// let a = "dummy entry";/*1*/ +////namespace greeter { +//// [|let a = "dummy entry";|] ////} -verify.codeFixAtPosition(` -namespace greeter { -}`); +verify.codeFixAtPosition(""); diff --git a/tests/cases/fourslash/unusedVariableInNamespace2.ts b/tests/cases/fourslash/unusedVariableInNamespace2.ts index 990787098d2a9..fbb9e2d6a0c2b 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace2.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace2.ts @@ -2,18 +2,11 @@ // @noUnusedLocals: true ////namespace greeter { -//// let a = "dummy entry"/*0*/, b/*1*/, c = 0; +//// [|let a = "dummy entry", b, c = 0;|] //// export function function1() { //// a = "dummy"; //// c++; //// } ////} -verify.codeFixAtPosition(` -namespace greeter { - let a = "dummy entry", c = 0; - export function function1() { - a = "dummy"; - c++; - } -}`); +verify.codeFixAtPosition(`let a = "dummy entry", c = 0;`); diff --git a/tests/cases/fourslash/unusedVariableInNamespace3.ts b/tests/cases/fourslash/unusedVariableInNamespace3.ts index f58d0a581da0b..33e501d0c0def 100644 --- a/tests/cases/fourslash/unusedVariableInNamespace3.ts +++ b/tests/cases/fourslash/unusedVariableInNamespace3.ts @@ -2,18 +2,11 @@ // @noUnusedLocals: true ////namespace greeter { -//// let a = "dummy entry", b/*0*/, c = 0/*1*/; +//// [|let a = "dummy entry", b, c = 0;|] //// export function function1() { //// a = "dummy"; //// b = 0; //// } ////} -verify.codeFixAtPosition(` -namespace greeter { - let a = "dummy entry", b; - export function function1() { - a = "dummy"; - b = 0; - } -}`); +verify.codeFixAtPosition(`let a = "dummy entry", b;`); From 62c4badefaa3cf59dc802b7c9fc295cfe3d4b146 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 8 Jul 2016 17:41:29 -0700 Subject: [PATCH 89/90] Linter fixes --- src/harness/fourslash.ts | 2 +- src/services/codefixes/interfaceFixes.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2a8c11e67614c..91597d7f5931e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1869,7 +1869,7 @@ namespace FourSlash { const ranges = this.getRanges(); if (ranges.length == 0) { - this.raiseError("At least one range should be specified in the testfile.") + this.raiseError("At least one range should be specified in the testfile."); } const fileName = this.activeFile.fileName; diff --git a/src/services/codefixes/interfaceFixes.ts b/src/services/codefixes/interfaceFixes.ts index c9a7c77d54d02..f046bde0f85f3 100644 --- a/src/services/codefixes/interfaceFixes.ts +++ b/src/services/codefixes/interfaceFixes.ts @@ -208,7 +208,7 @@ namespace ts.codeFix { return "null"; } - function handleMethods(interfaceMethod: MethodSignature, startPos: number, isReference: boolean, trackingAddedMembers: string[], textChanges: TextChange[], newLineCharacter:string) { + function handleMethods(interfaceMethod: MethodSignature, startPos: number, isReference: boolean, trackingAddedMembers: string[], textChanges: TextChange[], newLineCharacter: string) { const methodBody = "throw new Error('Method not Implemented');"; From 5bd7458b25ffc7c2e815a1f107c4c73ffce83858 Mon Sep 17 00:00:00 2001 From: Sarangan Rajamanickam Date: Mon, 11 Jul 2016 15:12:09 -0700 Subject: [PATCH 90/90] Fixes due to API Changes Fixes due to API Changes --- src/services/codefixes/interfaceFixes.ts | 15 +++++++++++---- .../fourslash/unImplementedInterface15.ts | 8 ++++---- .../fourslash/unImplementedInterface28.ts | 7 +++++-- .../fourslash/unImplementedInterface38.ts | 2 +- .../fourslash/unImplementedInterface39.ts | 18 ++++++++++++++++++ .../fourslash/unusedLocalsinConstructorFS2.ts | 15 ++++++++++----- .../cases/fourslash/unusedParameterInCatch1.ts | 9 --------- 7 files changed, 49 insertions(+), 25 deletions(-) create mode 100644 tests/cases/fourslash/unImplementedInterface39.ts delete mode 100644 tests/cases/fourslash/unusedParameterInCatch1.ts diff --git a/src/services/codefixes/interfaceFixes.ts b/src/services/codefixes/interfaceFixes.ts index f046bde0f85f3..6b8c9e028e43a 100644 --- a/src/services/codefixes/interfaceFixes.ts +++ b/src/services/codefixes/interfaceFixes.ts @@ -125,7 +125,7 @@ namespace ts.codeFix { } else { propertyText = interfaceProperty.getText(); - const stringToAdd = propertyText.match(/;$/) === undefined ? `;${newLineCharacter}` : newLineCharacter; + const stringToAdd = !(propertyText.match(/;$/)) ? `;${newLineCharacter}` : newLineCharacter; propertyText += stringToAdd; } changesArray.push({ newText: propertyText, span: { start: startPos, length: 0 } }); @@ -142,7 +142,7 @@ namespace ts.codeFix { if (reference && existingMembers.length === 0 && changesArray.length > 0) { let lastValue = changesArray[changesArray.length - 1].newText; - lastValue = `${lastValue.substr(0, lastValue.length - 12)} ${newLineCharacter}`; + lastValue = `${lastValue.substr(0, lastValue.length - (newLineCharacter.length + 1))} ${newLineCharacter}`; changesArray[changesArray.length - 1].newText = lastValue; } @@ -183,8 +183,10 @@ namespace ts.codeFix { for (let i = 0; i < children.length; i++) { if (children[i].kind === SyntaxKind.ObjectLiteralExpression) { - startPos = children[i].pos + 1; const properties = (children[i]).properties; + if (properties) { + startPos = properties.pos; + } for (let j = 0; properties && j < properties.length; j++) { if (properties[j].name) { variableMembers.push(properties[j].name.getText()); @@ -249,7 +251,12 @@ namespace ts.codeFix { } } - methodText += `){${newLineCharacter}${methodBody}${newLineCharacter}`; + methodText += `)`; + if (interfaceMethod.type) { + methodText += ":" + interfaceMethod.type.getText(); + } + + methodText += `{${newLineCharacter}${methodBody}${newLineCharacter}`; methodText = isReference ? methodText.concat(`},${newLineCharacter}`) : methodText.concat(`}${newLineCharacter}`); textChanges.push({ newText: methodText, span: { start: startPos, length: 0 } }); diff --git a/tests/cases/fourslash/unImplementedInterface15.ts b/tests/cases/fourslash/unImplementedInterface15.ts index 0a812e04ba60f..e68f7171ee5a7 100644 --- a/tests/cases/fourslash/unImplementedInterface15.ts +++ b/tests/cases/fourslash/unImplementedInterface15.ts @@ -4,12 +4,12 @@ //// f1(); //// } //// -//// [|var x: I1 = { +//// var x: I1 = {[| //// -//// }|] +//// |]} -verify.codeFixAtPosition(`var x: I1 = { +verify.codeFixAtPosition(` f1(){ throw new Error('Method not Implemented'); -} +} `); diff --git a/tests/cases/fourslash/unImplementedInterface28.ts b/tests/cases/fourslash/unImplementedInterface28.ts index 7a73982c043ee..16cbe47b26cbe 100644 --- a/tests/cases/fourslash/unImplementedInterface28.ts +++ b/tests/cases/fourslash/unImplementedInterface28.ts @@ -9,10 +9,13 @@ //// } //// //// var x: I1|I2 ={[| -//// +//// //// |]} verify.codeFixAtPosition(`f1(){ throw new Error('Method not Implemented'); -} +} +f2(){ + throw new Error('Method not Implemented'); +} `); diff --git a/tests/cases/fourslash/unImplementedInterface38.ts b/tests/cases/fourslash/unImplementedInterface38.ts index 00efd46c7f6e4..c60b9922ef859 100644 --- a/tests/cases/fourslash/unImplementedInterface38.ts +++ b/tests/cases/fourslash/unImplementedInterface38.ts @@ -4,7 +4,7 @@ //// abstract f1(); //// } //// -//// var x: C2 = { [| |] } +//// var x: C2 = {[| |]} verify.codeFixAtPosition(`f1(){ throw new Error('Method not Implemented'); diff --git a/tests/cases/fourslash/unImplementedInterface39.ts b/tests/cases/fourslash/unImplementedInterface39.ts new file mode 100644 index 0000000000000..ae85d02b8a392 --- /dev/null +++ b/tests/cases/fourslash/unImplementedInterface39.ts @@ -0,0 +1,18 @@ +/// + +//// namespace N1 { +//// export interface I1 { +//// f1():string; +//// } +//// } +//// interface I1 { +//// f1(); +//// } +//// +//// class C1 implements N1.I1 {[| +//// |]} + +verify.codeFixAtPosition(`f1():string{ + throw new Error('Method not Implemented'); +} +`); diff --git a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts index 77ea6ed5a4cc1..eff9b7c8d54b5 100644 --- a/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts +++ b/tests/cases/fourslash/unusedLocalsinConstructorFS2.ts @@ -3,11 +3,16 @@ // @noUnusedLocals: true // @noUnusedParameters: true ////class greeter { -//// constructor() { -//// [| var unused = 20; -//// var used = "dummy"; |] +//// [|constructor() { +//// var unused = 20; +//// var used = "dummy"; //// used = used + "second part"; -//// } +//// }|] ////} -verify.codeFixAtPosition(`var used = "dummy";`); \ No newline at end of file +verify.codeFixAtPosition(` + constructor() { + var used = "dummy"; + used = used + "second part"; + } +`); \ No newline at end of file diff --git a/tests/cases/fourslash/unusedParameterInCatch1.ts b/tests/cases/fourslash/unusedParameterInCatch1.ts deleted file mode 100644 index da24d2aef0322..0000000000000 --- a/tests/cases/fourslash/unusedParameterInCatch1.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// - -// @noUnusedLocals: true -// @noUnusedParameters: true -//// function f1() { -//// try {} [|catch(ex)|] {} -//// } - -verify.codeFixAtPosition("catch()");