diff --git a/tests/cases/fourslash/codeFixUndeclaredClassInstance.ts b/tests/cases/fourslash/codeFixUndeclaredClassInstance.ts new file mode 100644 index 00000000000..024ec144092 --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredClassInstance.ts @@ -0,0 +1,22 @@ +/// + +//// class A { +//// a: number; +//// b: string; +//// constructor(public x: any) {} +//// } +//// [|class B { +//// constructor() { +//// this.x = new A(3); +//// } +//// }|] + +verify.rangeAfterCodeFix(` +class B { + x: A; + + constructor() { + this.x = new A(3); + } +} +`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredClassInstanceWithTypeParams.ts b/tests/cases/fourslash/codeFixUndeclaredClassInstanceWithTypeParams.ts new file mode 100644 index 00000000000..34e359feea8 --- /dev/null +++ b/tests/cases/fourslash/codeFixUndeclaredClassInstanceWithTypeParams.ts @@ -0,0 +1,22 @@ +/// + +//// class A { +//// a: number; +//// b: string; +//// constructor(public x: T) {} +//// } +//// [|class B { +//// constructor() { +//// this.x = new A(3); +//// } +//// }|] + +verify.rangeAfterCodeFix(` +class B { + x: A; + + constructor() { + this.x = new A(3); + } +} +`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredPropertyNumericLiteral.ts b/tests/cases/fourslash/codeFixUndeclaredPropertyNumericLiteral.ts index bb11d9e76e1..eaae355904b 100644 --- a/tests/cases/fourslash/codeFixUndeclaredPropertyNumericLiteral.ts +++ b/tests/cases/fourslash/codeFixUndeclaredPropertyNumericLiteral.ts @@ -14,4 +14,4 @@ class A { this.x = 10; } } -`); \ No newline at end of file +`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteral.ts b/tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteral.ts index bc19f792fb3..3f5c5f99887 100644 --- a/tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteral.ts +++ b/tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteral.ts @@ -8,10 +8,10 @@ verify.rangeAfterCodeFix(` class A { - x: { a: number, b: string }; - + x: { a: number; b: string; }; + constructor() { - this.x = 10; + this.x = { a: 10, b: "hello" }; } } -`); \ No newline at end of file +`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index fda5b1a30cd..34afb71ec85 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -225,7 +225,7 @@ declare namespace FourSlashInterface { noMatchingBracePositionInCurrentFile(bracePosition: number): void; DocCommentTemplate(expectedText: string, expectedOffset: number, empty?: boolean): void; noDocCommentTemplate(): void; - rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number): void; + rangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number): void; importFixAtPosition(expectedTextArray: string[], errorCode?: number): void; navigationBar(json: any): void;