Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typescript definitions for core-js@3

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?

like image 844
pseudosudo Avatar asked Aug 30 '25 17:08

pseudosudo


1 Answers

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.

like image 186
FullStackFool Avatar answered Sep 02 '25 10:09

FullStackFool