Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TypeScript uses lib: es2015 to compile itself although it is supposed to run in ES5 environments #28933

Closed
ajafff opened this issue Dec 9, 2018 · 4 comments
Labels
Bug A bug in TypeScript

Comments

@ajafff
Copy link
Contributor

ajafff commented Dec 9, 2018

AFAIK TypeScript should be able to run in ES5 environments. If it's not, you can close this issue.

tsconfig-base.json contains "lib": ["es2015"] which allows uses of ES6 features within the compiler. This is basically the reason #28918 happened in the first place.

The change was made by @weswigham in #25140.

@j-oliveras
Copy link
Contributor

@weswigham weswigham added the Bug A bug in TypeScript label Dec 10, 2018
@weswigham
Copy link
Member

weswigham commented Dec 10, 2018

The change in #25140 was just to pull in the iterator types; so changing the lib to ["es5", "es2015.iterable"] should be OK and prevent us form using es6 methods unintentionally.

@j-oliveras
Copy link
Contributor

j-oliveras commented Dec 10, 2018

I add this change to #28932.

EDIT: I can change it because of the fill usage (see my previous post). That is made by @Andy-MS on #26588.

@weswigham
Copy link
Member

 export function fill<T>(length: number, cb: (index: number) => T): T[] { 
     return new Array(length).fill(0).map((_, i) => cb(i)); 
 } 

should probably just be

export function fill<T>(length: number, cb: (index: number) => T): T[] { 
    const result = new Array(length);
    for (const i = 0; i < length; i++) {
        result[i] = cb(i);
    }
    return result;
}

the fancy .fill and .map, while a neat shorthand, are not required.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants