Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
widen type, index signature, and add tests
- Loading branch information
Arthur Ozga
committed
Feb 16, 2017
1 parent
a4cf12e
commit f2770a1
Showing
10 changed files
with
108 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
tests/cases/fourslash/codeFixUndeclaredIndexSignatureNumericLiteral.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
//// [|class A { | ||
//// constructor() { | ||
//// this.x = 10; | ||
//// } | ||
//// }|] | ||
|
||
verify.rangeAfterCodeFix(` | ||
class A { | ||
[name: string]: number; | ||
constructor() { | ||
this.x = 10; | ||
} | ||
} | ||
`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 1); |
20 changes: 20 additions & 0 deletions
20
tests/cases/fourslash/codeFixUndeclaredPropertyFunctionEmptyClass.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
//// [|class A { | ||
//// constructor() { | ||
//// this.x = function(x: number, y?: A){ | ||
//// return x > 0 ? x : y; | ||
//// } | ||
//// } | ||
//// }|] | ||
|
||
verify.rangeAfterCodeFix(` | ||
class A { | ||
x: (x: number, y?: A) => A; | ||
constructor() { | ||
this.x = function(x: number, y?: A){ | ||
return x > 0 ? x : y; | ||
} | ||
} | ||
} | ||
`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); |
22 changes: 22 additions & 0 deletions
22
tests/cases/fourslash/codeFixUndeclaredPropertyFunctionNonEmptyClass.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
//// [|class A { | ||
//// y: number; | ||
//// constructor(public a: number) { | ||
//// this.x = function(x: number, y?: A){ | ||
//// return x > 0 ? x : y; | ||
//// } | ||
//// } | ||
//// }|] | ||
|
||
verify.rangeAfterCodeFix(` | ||
class A { | ||
x: (x: number, y?: A) => number | A; | ||
y: number; | ||
constructor(public a: number) { | ||
this.x = function(x: number, y?: A){ | ||
return x > 0 ? x : y; | ||
} | ||
} | ||
} | ||
`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/cases/fourslash/codeFixUndeclaredPropertyObjectLiteralStrictNullChecks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
// @strictNullChecks: true | ||
|
||
//// [|class A { | ||
//// constructor() { | ||
//// let e: any = 10; | ||
//// this.x = { a: 10, b: "hello", c: undefined, d: null, e: e }; | ||
//// } | ||
//// }|] | ||
|
||
verify.rangeAfterCodeFix(` | ||
class A { | ||
x: { a: number; b: string; c: undefined; d: null; e: any; }; | ||
constructor() { | ||
let e: any = 10; | ||
this.x = { a: 10, b: "hello", c: undefined, d: null, e: e }; | ||
} | ||
} | ||
`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); |
17 changes: 17 additions & 0 deletions
17
tests/cases/fourslash/codeFixUndeclaredPropertyThisType.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/// <reference path='fourslash.ts' /> | ||
|
||
//// [|class A { | ||
//// constructor() { | ||
//// this.mythis = this; | ||
//// } | ||
//// }|] | ||
|
||
verify.rangeAfterCodeFix(` | ||
class A { | ||
mythis: this; | ||
constructor() { | ||
this.mythis = this; | ||
} | ||
} | ||
`, /*includeWhiteSpace*/ false, /*errorCode*/ undefined, /*index*/ 0); |