-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suppress no implicit any errors #1418
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0a1eabc
Add new compiler flag to suppress noImplicitAny errors for object access
mhegazy 06e73d3
Commandline definitions use a property "paramType" to specify the nam…
mhegazy b0574cb
Respond to code review comments
mhegazy d2c7c01
Respond to code review commments
mhegazy 774c061
Merge branch 'release-1.4' into suppressNoImplicitAnyErrors
mhegazy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
81 changes: 81 additions & 0 deletions
81
tests/baselines/reference/noImplicitAnyIndexingSuppressed.js
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,81 @@ | ||
//// [noImplicitAnyIndexingSuppressed.ts] | ||
|
||
enum MyEmusEnum { | ||
emu | ||
} | ||
|
||
// Should be okay; should be a string. | ||
var strRepresentation1 = MyEmusEnum[0] | ||
|
||
// Should be okay; should be a string. | ||
var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu] | ||
|
||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var strRepresentation3 = MyEmusEnum["monehh"]; | ||
|
||
// Should be okay; should be a MyEmusEnum | ||
var strRepresentation4 = MyEmusEnum["emu"]; | ||
|
||
|
||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var x = {}["hi"]; | ||
|
||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var y = {}[10]; | ||
|
||
var hi: any = "hi"; | ||
|
||
var emptyObj = {}; | ||
|
||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var z1 = emptyObj[hi]; | ||
var z2 = (<any>emptyObj)[hi]; | ||
|
||
interface MyMap<T> { | ||
[key: string]: T; | ||
} | ||
|
||
var m: MyMap<number> = { | ||
"0": 0, | ||
"1": 1, | ||
"2": 2, | ||
"Okay that's enough for today.": NaN | ||
}; | ||
|
||
var mResult1 = m[MyEmusEnum.emu]; | ||
var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]]; | ||
var mResult3 = m[hi]; | ||
|
||
|
||
|
||
//// [noImplicitAnyIndexingSuppressed.js] | ||
var MyEmusEnum; | ||
(function (MyEmusEnum) { | ||
MyEmusEnum[MyEmusEnum["emu"] = 0] = "emu"; | ||
})(MyEmusEnum || (MyEmusEnum = {})); | ||
// Should be okay; should be a string. | ||
var strRepresentation1 = MyEmusEnum[0]; | ||
// Should be okay; should be a string. | ||
var strRepresentation2 = MyEmusEnum[0 /* emu */]; | ||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var strRepresentation3 = MyEmusEnum["monehh"]; | ||
// Should be okay; should be a MyEmusEnum | ||
var strRepresentation4 = 0 /* "emu" */; | ||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var x = {}["hi"]; | ||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var y = {}[10]; | ||
var hi = "hi"; | ||
var emptyObj = {}; | ||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var z1 = emptyObj[hi]; | ||
var z2 = emptyObj[hi]; | ||
var m = { | ||
"0": 0, | ||
"1": 1, | ||
"2": 2, | ||
"Okay that's enough for today.": NaN | ||
}; | ||
var mResult1 = m[0 /* emu */]; | ||
var mResult2 = m[MyEmusEnum[0 /* emu */]]; | ||
var mResult3 = m[hi]; |
118 changes: 118 additions & 0 deletions
118
tests/baselines/reference/noImplicitAnyIndexingSuppressed.types
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,118 @@ | ||
=== tests/cases/compiler/noImplicitAnyIndexingSuppressed.ts === | ||
|
||
enum MyEmusEnum { | ||
>MyEmusEnum : MyEmusEnum | ||
|
||
emu | ||
>emu : MyEmusEnum | ||
} | ||
|
||
// Should be okay; should be a string. | ||
var strRepresentation1 = MyEmusEnum[0] | ||
>strRepresentation1 : string | ||
>MyEmusEnum[0] : string | ||
>MyEmusEnum : typeof MyEmusEnum | ||
|
||
// Should be okay; should be a string. | ||
var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu] | ||
>strRepresentation2 : string | ||
>MyEmusEnum[MyEmusEnum.emu] : string | ||
>MyEmusEnum : typeof MyEmusEnum | ||
>MyEmusEnum.emu : MyEmusEnum | ||
>MyEmusEnum : typeof MyEmusEnum | ||
>emu : MyEmusEnum | ||
|
||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var strRepresentation3 = MyEmusEnum["monehh"]; | ||
>strRepresentation3 : any | ||
>MyEmusEnum["monehh"] : any | ||
>MyEmusEnum : typeof MyEmusEnum | ||
|
||
// Should be okay; should be a MyEmusEnum | ||
var strRepresentation4 = MyEmusEnum["emu"]; | ||
>strRepresentation4 : MyEmusEnum | ||
>MyEmusEnum["emu"] : MyEmusEnum | ||
>MyEmusEnum : typeof MyEmusEnum | ||
|
||
|
||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var x = {}["hi"]; | ||
>x : any | ||
>{}["hi"] : any | ||
>{} : {} | ||
|
||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var y = {}[10]; | ||
>y : any | ||
>{}[10] : any | ||
>{} : {} | ||
|
||
var hi: any = "hi"; | ||
>hi : any | ||
|
||
var emptyObj = {}; | ||
>emptyObj : {} | ||
>{} : {} | ||
|
||
// Should be okay, as we suppress implicit 'any' property access checks | ||
var z1 = emptyObj[hi]; | ||
>z1 : any | ||
>emptyObj[hi] : any | ||
>emptyObj : {} | ||
>hi : any | ||
|
||
var z2 = (<any>emptyObj)[hi]; | ||
>z2 : any | ||
>(<any>emptyObj)[hi] : any | ||
>(<any>emptyObj) : any | ||
><any>emptyObj : any | ||
>emptyObj : {} | ||
>hi : any | ||
|
||
interface MyMap<T> { | ||
>MyMap : MyMap<T> | ||
>T : T | ||
|
||
[key: string]: T; | ||
>key : string | ||
>T : T | ||
} | ||
|
||
var m: MyMap<number> = { | ||
>m : MyMap<number> | ||
>MyMap : MyMap<T> | ||
>{ "0": 0, "1": 1, "2": 2, "Okay that's enough for today.": NaN} : { [x: string]: number; "0": number; "1": number; "2": number; "Okay that's enough for today.": number; } | ||
|
||
"0": 0, | ||
"1": 1, | ||
"2": 2, | ||
"Okay that's enough for today.": NaN | ||
>NaN : number | ||
|
||
}; | ||
|
||
var mResult1 = m[MyEmusEnum.emu]; | ||
>mResult1 : number | ||
>m[MyEmusEnum.emu] : number | ||
>m : MyMap<number> | ||
>MyEmusEnum.emu : MyEmusEnum | ||
>MyEmusEnum : typeof MyEmusEnum | ||
>emu : MyEmusEnum | ||
|
||
var mResult2 = m[MyEmusEnum[MyEmusEnum.emu]]; | ||
>mResult2 : number | ||
>m[MyEmusEnum[MyEmusEnum.emu]] : number | ||
>m : MyMap<number> | ||
>MyEmusEnum[MyEmusEnum.emu] : string | ||
>MyEmusEnum : typeof MyEmusEnum | ||
>MyEmusEnum.emu : MyEmusEnum | ||
>MyEmusEnum : typeof MyEmusEnum | ||
>emu : MyEmusEnum | ||
|
||
var mResult3 = m[hi]; | ||
>mResult3 : number | ||
>m[hi] : number | ||
>m : MyMap<number> | ||
>hi : any | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would might be better as
"Suppress noImplicitAny errors for indexing objects lacking index signatures."