4

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
  • Exact same issue here. Things like structuredClone are not yet defined in @types, causing problems for TS. Did you ever resolve this issue? Commented Feb 18, 2022 at 13:45

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Instead of providing a local shim, why don't people update the @types/core-js itself? 🤔...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.