Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5919,7 +5919,8 @@ func (c *Checker) getIteratedTypeOrElementType(use IterationUse, inputType *Type
return nil
}
// TODO: remove ScriptTargetES2015
uplevelIteration := c.languageVersion >= core.ScriptTargetES2015
iterableExists := c.getGlobalIterableType() != c.emptyGenericType
uplevelIteration := c.languageVersion >= core.ScriptTargetES2015 && iterableExists
downlevelIteration := !uplevelIteration && c.compilerOptions.DownlevelIteration == core.TSTrue
possibleOutOfBounds := c.compilerOptions.NoUncheckedIndexedAccess == core.TSTrue && use&IterationUsePossiblyOutOfBounds != 0
// Get the iterated type of an `Iterable<T>` or `IterableIterator<T>` only in ES2015
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
arrayIterationLibES5TargetDifferent.ts(3,17): error TS2488: Type 'number[]' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(9,17): error TS2488: Type 'string' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(15,17): error TS2488: Type 'number' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(21,17): error TS2488: Type '{ foo: string; }' must have a '[Symbol.iterator]()' method that returns an iterator.
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 (4 errors) ====
==== arrayIterationLibES5TargetDifferent.ts (2 errors) ====
declare function log(message?: any): void;

for (const x of [1, 2, 3]) {
~~~~~~~~~
!!! error TS2488: Type 'number[]' must have a '[Symbol.iterator]()' method that returns an iterator.
log(x);
}

declare const aString: string;

for (const x of aString) {
~~~~~~~
!!! error TS2488: Type 'string' must have a '[Symbol.iterator]()' method that returns an iterator.
log(x);
}

declare const aNumber: number;

for (const x of aNumber) {
~~~~~~~
!!! error TS2488: Type 'number' must have a '[Symbol.iterator]()' method that returns an iterator.
!!! 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 TS2488: Type '{ foo: string; }' must have a '[Symbol.iterator]()' method that returns an iterator.
!!! error TS2495: Type '{ foo: string; }' is not an array type or a string type.
log(x);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare function log(message?: any): void;
>message : any

for (const x of [1, 2, 3]) {
>x : any
>x : number
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
Expand All @@ -15,20 +15,20 @@ for (const x of [1, 2, 3]) {
log(x);
>log(x) : void
>log : (message?: any) => void
>x : any
>x : number
}

declare const aString: string;
>aString : string

for (const x of aString) {
>x : any
>x : string
>aString : string

log(x);
>log(x) : void
>log : (message?: any) => void
>x : any
>x : string
}

declare const aNumber: number;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,38 +1,32 @@
arrayIterationLibES5TargetDifferent.ts(3,17): error TS2488: Type 'number[]' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(9,17): error TS2488: Type 'string' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(15,17): error TS2488: Type 'number' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(21,17): error TS2488: Type '{ foo: string; }' must have a '[Symbol.iterator]()' method that returns an iterator.
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 (4 errors) ====
==== arrayIterationLibES5TargetDifferent.ts (2 errors) ====
declare function log(message?: any): void;

for (const x of [1, 2, 3]) {
~~~~~~~~~
!!! error TS2488: Type 'number[]' must have a '[Symbol.iterator]()' method that returns an iterator.
log(x);
}

declare const aString: string;

for (const x of aString) {
~~~~~~~
!!! error TS2488: Type 'string' must have a '[Symbol.iterator]()' method that returns an iterator.
log(x);
}

declare const aNumber: number;

for (const x of aNumber) {
~~~~~~~
!!! error TS2488: Type 'number' must have a '[Symbol.iterator]()' method that returns an iterator.
!!! 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 TS2488: Type '{ foo: string; }' must have a '[Symbol.iterator]()' method that returns an iterator.
!!! error TS2495: Type '{ foo: string; }' is not an array type or a string type.
log(x);
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ declare function log(message?: any): void;
>message : any

for (const x of [1, 2, 3]) {
>x : any
>x : number
>[1, 2, 3] : number[]
>1 : 1
>2 : 2
Expand All @@ -15,20 +15,20 @@ for (const x of [1, 2, 3]) {
log(x);
>log(x) : void
>log : (message?: any) => void
>x : any
>x : number
}

declare const aString: string;
>aString : string

for (const x of aString) {
>x : any
>x : string
>aString : string

log(x);
>log(x) : void
>log : (message?: any) => void
>x : any
>x : string
}

declare const aNumber: number;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ error TS2318: Cannot find global type 'Number'.
error TS2318: Cannot find global type 'Object'.
error TS2318: Cannot find global type 'RegExp'.
error TS2318: Cannot find global type 'String'.
arrayIterationLibES5TargetDifferent.ts(3,17): error TS2488: Type '{}' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(9,17): error TS2488: Type 'string' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(15,17): error TS2488: Type 'number' must have a '[Symbol.iterator]()' method that returns an iterator.
arrayIterationLibES5TargetDifferent.ts(21,17): error TS2488: Type '{ foo: string; }' must have a '[Symbol.iterator]()' method that returns an iterator.


!!! error TS5053: Option 'lib' cannot be specified with option 'noLib'.
Expand All @@ -26,35 +22,27 @@ arrayIterationLibES5TargetDifferent.ts(21,17): error TS2488: Type '{ foo: string
!!! error TS2318: Cannot find global type 'Object'.
!!! error TS2318: Cannot find global type 'RegExp'.
!!! error TS2318: Cannot find global type 'String'.
==== arrayIterationLibES5TargetDifferent.ts (4 errors) ====
==== arrayIterationLibES5TargetDifferent.ts (0 errors) ====
declare function log(message?: any): void;

for (const x of [1, 2, 3]) {
~~~~~~~~~
!!! error TS2488: Type '{}' must have a '[Symbol.iterator]()' method that returns an iterator.
log(x);
}

declare const aString: string;

for (const x of aString) {
~~~~~~~
!!! error TS2488: Type 'string' must have a '[Symbol.iterator]()' method that returns an iterator.
log(x);
}

declare const aNumber: number;

for (const x of aNumber) {
~~~~~~~
!!! error TS2488: Type 'number' must have a '[Symbol.iterator]()' method that returns an iterator.
log(x);
}

declare const anObject: { foo: string };

for (const x of anObject) {
~~~~~~~~
!!! error TS2488: Type '{ foo: string; }' must have a '[Symbol.iterator]()' method that returns an iterator.
log(x);
}
Loading
Loading