-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Be more lenient about iteration when lib=es5 / noLib
#63070
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
...lines/reference/arrayIterationLibES5TargetDifferent(nolib=false,target=es2015).errors.txt
This file contains hidden or 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 @@ | ||
| arrayIterationLibES5TargetDifferent.ts(15,17): error TS2495: Type 'number' is not an array type or a string type. | ||
| arrayIterationLibES5TargetDifferent.ts(21,17): error TS2495: Type '{ foo: string; }' is not an array type or a string type. | ||
|
|
||
|
|
||
| ==== arrayIterationLibES5TargetDifferent.ts (2 errors) ==== | ||
| declare function log(message?: any): void; | ||
|
|
||
| for (const x of [1, 2, 3]) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const aString: string; | ||
|
|
||
| for (const x of aString) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const aNumber: number; | ||
|
|
||
| for (const x of aNumber) { | ||
| ~~~~~~~ | ||
| !!! error TS2495: Type 'number' is not an array type or a string type. | ||
| log(x); | ||
| } | ||
|
|
||
| declare const anObject: { foo: string }; | ||
|
|
||
| for (const x of anObject) { | ||
| ~~~~~~~~ | ||
| !!! error TS2495: Type '{ foo: string; }' is not an array type or a string type. | ||
| log(x); | ||
| } |
41 changes: 41 additions & 0 deletions
41
tests/baselines/reference/arrayIterationLibES5TargetDifferent(nolib=false,target=es2015).js
This file contains hidden or 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,41 @@ | ||
| //// [tests/cases/compiler/arrayIterationLibES5TargetDifferent.ts] //// | ||
|
|
||
| //// [arrayIterationLibES5TargetDifferent.ts] | ||
| declare function log(message?: any): void; | ||
|
|
||
| for (const x of [1, 2, 3]) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const aString: string; | ||
|
|
||
| for (const x of aString) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const aNumber: number; | ||
|
|
||
| for (const x of aNumber) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const anObject: { foo: string }; | ||
|
|
||
| for (const x of anObject) { | ||
| log(x); | ||
| } | ||
|
|
||
| //// [arrayIterationLibES5TargetDifferent.js] | ||
| "use strict"; | ||
| for (const x of [1, 2, 3]) { | ||
| log(x); | ||
| } | ||
| for (const x of aString) { | ||
| log(x); | ||
| } | ||
| for (const x of aNumber) { | ||
| log(x); | ||
| } | ||
| for (const x of anObject) { | ||
| log(x); | ||
| } |
51 changes: 51 additions & 0 deletions
51
...aselines/reference/arrayIterationLibES5TargetDifferent(nolib=false,target=es2015).symbols
This file contains hidden or 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,51 @@ | ||
| //// [tests/cases/compiler/arrayIterationLibES5TargetDifferent.ts] //// | ||
|
|
||
| === arrayIterationLibES5TargetDifferent.ts === | ||
| declare function log(message?: any): void; | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >message : Symbol(message, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 21)) | ||
|
|
||
| for (const x of [1, 2, 3]) { | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 2, 10)) | ||
|
|
||
| log(x); | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 2, 10)) | ||
| } | ||
|
|
||
| declare const aString: string; | ||
| >aString : Symbol(aString, Decl(arrayIterationLibES5TargetDifferent.ts, 6, 13)) | ||
|
|
||
| for (const x of aString) { | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 8, 10)) | ||
| >aString : Symbol(aString, Decl(arrayIterationLibES5TargetDifferent.ts, 6, 13)) | ||
|
|
||
| log(x); | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 8, 10)) | ||
| } | ||
|
|
||
| declare const aNumber: number; | ||
| >aNumber : Symbol(aNumber, Decl(arrayIterationLibES5TargetDifferent.ts, 12, 13)) | ||
|
|
||
| for (const x of aNumber) { | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 14, 10)) | ||
| >aNumber : Symbol(aNumber, Decl(arrayIterationLibES5TargetDifferent.ts, 12, 13)) | ||
|
|
||
| log(x); | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 14, 10)) | ||
| } | ||
|
|
||
| declare const anObject: { foo: string }; | ||
| >anObject : Symbol(anObject, Decl(arrayIterationLibES5TargetDifferent.ts, 18, 13)) | ||
| >foo : Symbol(foo, Decl(arrayIterationLibES5TargetDifferent.ts, 18, 25)) | ||
|
|
||
| for (const x of anObject) { | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 20, 10)) | ||
| >anObject : Symbol(anObject, Decl(arrayIterationLibES5TargetDifferent.ts, 18, 13)) | ||
|
|
||
| log(x); | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 20, 10)) | ||
| } |
88 changes: 88 additions & 0 deletions
88
.../baselines/reference/arrayIterationLibES5TargetDifferent(nolib=false,target=es2015).types
This file contains hidden or 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,88 @@ | ||
| //// [tests/cases/compiler/arrayIterationLibES5TargetDifferent.ts] //// | ||
|
|
||
| === arrayIterationLibES5TargetDifferent.ts === | ||
| declare function log(message?: any): void; | ||
| >log : (message?: any) => void | ||
| > : ^ ^^^ ^^^^^ | ||
| >message : any | ||
| > : ^^^ | ||
|
|
||
| for (const x of [1, 2, 3]) { | ||
| >x : number | ||
| > : ^^^^^^ | ||
| >[1, 2, 3] : number[] | ||
| > : ^^^^^^^^ | ||
| >1 : 1 | ||
| > : ^ | ||
| >2 : 2 | ||
| > : ^ | ||
| >3 : 3 | ||
| > : ^ | ||
|
|
||
| log(x); | ||
| >log(x) : void | ||
| > : ^^^^ | ||
| >log : (message?: any) => void | ||
| > : ^ ^^^ ^^^^^ | ||
| >x : number | ||
| > : ^^^^^^ | ||
| } | ||
|
|
||
| declare const aString: string; | ||
| >aString : string | ||
| > : ^^^^^^ | ||
|
|
||
| for (const x of aString) { | ||
| >x : string | ||
| > : ^^^^^^ | ||
| >aString : string | ||
| > : ^^^^^^ | ||
|
|
||
| log(x); | ||
| >log(x) : void | ||
| > : ^^^^ | ||
| >log : (message?: any) => void | ||
| > : ^ ^^^ ^^^^^ | ||
| >x : string | ||
| > : ^^^^^^ | ||
| } | ||
|
|
||
| declare const aNumber: number; | ||
| >aNumber : number | ||
| > : ^^^^^^ | ||
|
|
||
| for (const x of aNumber) { | ||
| >x : any | ||
| > : ^^^ | ||
| >aNumber : number | ||
| > : ^^^^^^ | ||
|
|
||
| log(x); | ||
| >log(x) : void | ||
| > : ^^^^ | ||
| >log : (message?: any) => void | ||
| > : ^ ^^^ ^^^^^ | ||
| >x : any | ||
| > : ^^^ | ||
| } | ||
|
|
||
| declare const anObject: { foo: string }; | ||
| >anObject : { foo: string; } | ||
| > : ^^^^^^^ ^^^ | ||
| >foo : string | ||
| > : ^^^^^^ | ||
|
|
||
| for (const x of anObject) { | ||
| >x : any | ||
| > : ^^^ | ||
| >anObject : { foo: string; } | ||
| > : ^^^^^^^ ^^^ | ||
|
|
||
| log(x); | ||
| >log(x) : void | ||
| > : ^^^^ | ||
| >log : (message?: any) => void | ||
| > : ^ ^^^ ^^^^^ | ||
| >x : any | ||
| > : ^^^ | ||
| } |
32 changes: 32 additions & 0 deletions
32
...aselines/reference/arrayIterationLibES5TargetDifferent(nolib=false,target=es5).errors.txt
This file contains hidden or 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 @@ | ||
| arrayIterationLibES5TargetDifferent.ts(15,17): error TS2495: Type 'number' is not an array type or a string type. | ||
| arrayIterationLibES5TargetDifferent.ts(21,17): error TS2495: Type '{ foo: string; }' is not an array type or a string type. | ||
|
|
||
|
|
||
| ==== arrayIterationLibES5TargetDifferent.ts (2 errors) ==== | ||
| declare function log(message?: any): void; | ||
|
|
||
| for (const x of [1, 2, 3]) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const aString: string; | ||
|
|
||
| for (const x of aString) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const aNumber: number; | ||
|
|
||
| for (const x of aNumber) { | ||
| ~~~~~~~ | ||
| !!! error TS2495: Type 'number' is not an array type or a string type. | ||
| log(x); | ||
| } | ||
|
|
||
| declare const anObject: { foo: string }; | ||
|
|
||
| for (const x of anObject) { | ||
| ~~~~~~~~ | ||
| !!! error TS2495: Type '{ foo: string; }' is not an array type or a string type. | ||
| log(x); | ||
| } |
45 changes: 45 additions & 0 deletions
45
tests/baselines/reference/arrayIterationLibES5TargetDifferent(nolib=false,target=es5).js
This file contains hidden or 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,45 @@ | ||
| //// [tests/cases/compiler/arrayIterationLibES5TargetDifferent.ts] //// | ||
|
|
||
| //// [arrayIterationLibES5TargetDifferent.ts] | ||
| declare function log(message?: any): void; | ||
|
|
||
| for (const x of [1, 2, 3]) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const aString: string; | ||
|
|
||
| for (const x of aString) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const aNumber: number; | ||
|
|
||
| for (const x of aNumber) { | ||
| log(x); | ||
| } | ||
|
|
||
| declare const anObject: { foo: string }; | ||
|
|
||
| for (const x of anObject) { | ||
| log(x); | ||
| } | ||
|
|
||
| //// [arrayIterationLibES5TargetDifferent.js] | ||
| "use strict"; | ||
| for (var _i = 0, _a = [1, 2, 3]; _i < _a.length; _i++) { | ||
| var x = _a[_i]; | ||
| log(x); | ||
| } | ||
| for (var _b = 0, aString_1 = aString; _b < aString_1.length; _b++) { | ||
| var x = aString_1[_b]; | ||
| log(x); | ||
| } | ||
| for (var _c = 0, aNumber_1 = aNumber; _c < aNumber_1.length; _c++) { | ||
| var x = aNumber_1[_c]; | ||
| log(x); | ||
| } | ||
| for (var _d = 0, anObject_1 = anObject; _d < anObject_1.length; _d++) { | ||
| var x = anObject_1[_d]; | ||
| log(x); | ||
| } |
51 changes: 51 additions & 0 deletions
51
...s/baselines/reference/arrayIterationLibES5TargetDifferent(nolib=false,target=es5).symbols
This file contains hidden or 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,51 @@ | ||
| //// [tests/cases/compiler/arrayIterationLibES5TargetDifferent.ts] //// | ||
|
|
||
| === arrayIterationLibES5TargetDifferent.ts === | ||
| declare function log(message?: any): void; | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >message : Symbol(message, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 21)) | ||
|
|
||
| for (const x of [1, 2, 3]) { | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 2, 10)) | ||
|
|
||
| log(x); | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 2, 10)) | ||
| } | ||
|
|
||
| declare const aString: string; | ||
| >aString : Symbol(aString, Decl(arrayIterationLibES5TargetDifferent.ts, 6, 13)) | ||
|
|
||
| for (const x of aString) { | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 8, 10)) | ||
| >aString : Symbol(aString, Decl(arrayIterationLibES5TargetDifferent.ts, 6, 13)) | ||
|
|
||
| log(x); | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 8, 10)) | ||
| } | ||
|
|
||
| declare const aNumber: number; | ||
| >aNumber : Symbol(aNumber, Decl(arrayIterationLibES5TargetDifferent.ts, 12, 13)) | ||
|
|
||
| for (const x of aNumber) { | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 14, 10)) | ||
| >aNumber : Symbol(aNumber, Decl(arrayIterationLibES5TargetDifferent.ts, 12, 13)) | ||
|
|
||
| log(x); | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 14, 10)) | ||
| } | ||
|
|
||
| declare const anObject: { foo: string }; | ||
| >anObject : Symbol(anObject, Decl(arrayIterationLibES5TargetDifferent.ts, 18, 13)) | ||
| >foo : Symbol(foo, Decl(arrayIterationLibES5TargetDifferent.ts, 18, 25)) | ||
|
|
||
| for (const x of anObject) { | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 20, 10)) | ||
| >anObject : Symbol(anObject, Decl(arrayIterationLibES5TargetDifferent.ts, 18, 13)) | ||
|
|
||
| log(x); | ||
| >log : Symbol(log, Decl(arrayIterationLibES5TargetDifferent.ts, 0, 0)) | ||
| >x : Symbol(x, Decl(arrayIterationLibES5TargetDifferent.ts, 20, 10)) | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.