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
Map,Set ... in ES5 target #3290
Labels
Question
An issue which isn't directly actionable in code
Comments
@LimeStreem we removed some IE-specific types from the library in 1.5.0-beta. you can just define the type in one of your files like: interface Map<K, V> {
clear(): void;
delete(key: K): boolean;
forEach(callbackfn: (value: V, index: K, map: Map<K, V>) => void, thisArg?: any): void;
get(key: K): V;
has(key: K): boolean;
set(key: K, value: V): Map<K, V>;
size: number;
}
declare var Map: {
new <K, V>(): Map<K, V>;
prototype: Map<any, any>;
}
interface Set<T> {
add(value: T): Set<T>;
clear(): void;
delete(value: T): boolean;
forEach(callbackfn: (value: T, index: T, set: Set<T>) => void, thisArg?: any): void;
has(value: T): boolean;
size: number;
}
declare var Set: {
new <T>(): Set<T>;
prototype: Set<any>;
} |
Wow, I appreciate you to write this code snippet! 😆 |
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
After update the typescript compiler from version 1.4.1 to 1.5.0 beta, the source code included in my project became to make error log such as 'Map is not found'.
Thus, I researched this problem, and I reached an conclusion. The lib.d.ts became not to contain Map and Set definitions except ES6 being selected in tsconfig.json.
Actually, Map and Set is specification of ES6. It is natural that we can't use Map and Set in the project targeting ES5 or lower.
But we could use Map and Set even if I select ES5 as the target before typescript 1.4.1.
I know that making it being enabled to use Map and Set in the project that is made for ES5 contains risk.
Because there is some of browsers not supporting Map and Set.
However, I think it is better to make some of property of configuration that is for switching to use these definitions or not. Don't you think so?
The text was updated successfully, but these errors were encountered: