I have a TypeScript project which is compiled with "target": "es5". I use core-js's Set so I have core-js and @types/core-js installed in my project.
However, since the core-js d.ts includes a global declaration of Set and Map (and other ES6 features), the TypeScript compiler allows me use them, which obviously won't work in an old browser.
I can't exclude the core.d.ts from build because I obviously need it for the interfaces.
Is there a way for the compiler to prevent me from using ES6 features and still use core-js and its corresponding type definitions?
Set. But I don't want to use core-js as a global replacement but rather as a library. So I haveimport * as CoreSet from "core-js/library/fn/set";in the file which needs it. So I can donew CoreSet<number>(). But the problem is that I can also donew Set<number>()and it compiles perfectly, and then fails in the browser.