I need to use some core-js@3 polyfills from within TypeScript. However, @types/core-js provides definitions for [email protected] only, and it seems that core-js@3 is sufficiently different from 2 that most type definitions are outdated.
Is there some accepted workaround to this?
1 Answer
A shim can help here. For instance, if you need typings for structuredClone:
// shims/core-js.d.ts
declare module 'core-js/actual/structured-clone' {
export default function structuredClone<T>(value: T): T;
}
Note: This omits the transfer property as it's not something I personally intend to use.
1 Comment
tryforceful
Instead of providing a local shim, why don't people update the @types/core-js itself? 🤔...
structuredCloneare not yet defined in @types, causing problems for TS. Did you ever resolve this issue?