TypeScript Type Definitions
This package contains types for the global and pure versions of core-js.
Although core-js is a JavaScript standard library polyfill, the built-in TypeScript types are often not sufficient.
Additional types are needed for:
- features that are already in JavaScript but not yet in TypeScript’s standard types;
- proposals, including those already implemented in JavaScript engines;
- explicit imports of features from the pure version.
It is shipped as a separate package because we cannot guarantee stable behavior with future TypeScript releases, including minor ones.
Installation
npm install --save @core-js/types@4.0.0-alpha.0
Usage
You must include at least the ES6 types in your tsconfig.json because our types are built on top of the ES6 type definitions
and DOM lib for the global version if you use something related (see DOM types section):
{
"compilerOptions": {
"lib": [
"es2025",
"dom"
],
"types": [
"@core-js/types"
]
}
}
You can also import the types directly into your files instead of specifying core-js types in your tsconfig.json:
import '@core-js/types';
@core-js/types includes all types and entry points for the global version, but it is recommended to select only the subset you actually use.
Usage of subsets
There are four main subsets:
@core-js/types/actual- types for all actual features, including stable ECMAScript, web standards and Stage 3 ECMAScript proposals;@core-js/types/es- types for stable ECMAScript features only;@core-js/types/stable- types for stable ECMAScript and web standards features;@core-js/types/full- types for all features, including proposals.
You can import them the same way as the main package. For example, to use only the stable subset, add this to your tsconfig.json:
{
"compilerOptions": {
"types": [
"@core-js/types/stable"
]
}
}
or import it directly in your files:
import '@core-js/types/stable';
Usage of specific features
If you need types only for specific features, you can import them like this:
{
"compilerOptions": {
"types": [
"@core-js/types/proposals/joint-iteration",
"@core-js/types/web/structured-clone"
]
}
}
or import them directly in your files:
import '@core-js/types/proposals/joint-iteration';
import '@core-js/types/web/structured-clone';
You can find types for specific features on the corresponding pages in the documentation.
Types for the pure version
Base usage
Add this to your tsconfig.json, keeping in mind that ES types (at least ES6) are required:
{
"compilerOptions": {
"lib": [
"es2025"
],
"types": [
"@core-js/types/pure"
]
}
}
Then, when you import from the pure entry points, the corresponding types are picked up automatically:
import $findLast from '@core-js/pure/full/array/find-last';
$findLast([1, 3, 4, 2], v => v > 2); // => 4
Namespace usage in the pure version
If you need to use multiple methods from the same namespace, you can add @core-js/types/pure to tsconfig.json and import the entire namespace:
import $array from '@core-js/pure/full/array';
$array.findLast([1, 3, 4, 2], v => v > 2);
$array.flatMap([1, 2, 3], x => [x, x * 2]);
(note that this is not recommended since tree shaking does not properly work in this case)
DOM types
Some of the global types for web standards work correctly only with the DOM lib.
You need to add DOM types to the lib section of your tsconfig.json in addition to @core-js/types. For example:
{
"compilerOptions": {
"types": [
"@core-js/types"
],
"lib": [
"es2025",
"dom"
]
}
}
In the pure version, you can use these types without adding the DOM lib.