-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixAddMissingMember: Support interface and don't crash on type parameter
- Loading branch information
Andy Hanson
committed
Jul 27, 2018
1 parent
0227997
commit c0e3731
Showing
6 changed files
with
105 additions
and
65 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
32 changes: 32 additions & 0 deletions
32
tests/cases/fourslash/codeFixAddMissingMember_typeParameter.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,32 @@ | ||
////interface I {} | ||
//// | ||
////function f<T>(t: T): number { | ||
//// return t.foo; | ||
////} | ||
//// | ||
////function g<T extends I>(t: T): number { | ||
//// return t.bar; | ||
////} | ||
|
||
// No code fix for "foo" | ||
|
||
verify.codeFixAvailable([ | ||
{ description: "Declare property 'bar'" }, { description: "Add index signature for property 'bar'" }, | ||
]) | ||
|
||
verify.codeFix({ | ||
description: "Declare property 'bar'", | ||
index: 0, | ||
newFileContent: | ||
`interface I { | ||
bar: any; | ||
} | ||
function f<T>(t: T): number { | ||
return t.foo; | ||
} | ||
function g<T extends I>(t: T): number { | ||
return t.bar; | ||
}`, | ||
}); |
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