-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core-js-compat: Add more typescript types
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
- Loading branch information
Showing
4 changed files
with
86 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { ModuleName, Target, TargetVersion } from "./shared"; | ||
|
||
type StringOrRegExp = string | RegExp; | ||
|
||
type Modules = StringOrRegExp | readonly StringOrRegExp[]; | ||
|
||
type BrowserslistQuery = string | ReadonlyArray<string>; | ||
|
||
type Environments = { | ||
[target in Target]?: string | number; | ||
}; | ||
|
||
type Targets = Environments & { | ||
browsers?: Environments | BrowserslistQuery, | ||
esmodules?: boolean, | ||
}; | ||
|
||
type CompatOptions = { | ||
/** entry / module / namespace / an array of them, by default - all `core-js` modules */ | ||
modules?: Modules, | ||
/** a blacklist, entry / module / namespace / an array of them, by default - empty list */ | ||
exclude?: Modules, | ||
/** optional browserslist or core-js-compat format query */ | ||
targets?: Targets | BrowserslistQuery, | ||
/** used `core-js` version, by default the latest */ | ||
version?: string, | ||
/** inverse of the result, shows modules that are NOT required for the target environment */ | ||
inverse?: boolean, | ||
/** | ||
* @deprecated use `modules` instead | ||
*/ | ||
filter?: Modules | ||
}; | ||
|
||
type CompatOutput = { | ||
/** array of required modules */ | ||
list: ModuleName[], | ||
/** object with targets for each module */ | ||
targets: { | ||
[module: ModuleName]: { | ||
[target in Target]?: TargetVersion | ||
} | ||
} | ||
} | ||
|
||
declare function compat(options?: CompatOptions): CompatOutput; | ||
|
||
export = compat; |
5 changes: 5 additions & 0 deletions
5
packages/core-js-compat/get-modules-list-for-target-version.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { ModuleName, TargetVersion } from "./shared"; | ||
|
||
declare function getModulesListForTargetVersion(version: TargetVersion): readonly ModuleName[]; | ||
|
||
export = getModulesListForTargetVersion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
export type ModuleName = string; | ||
|
||
export type Target = | ||
| 'android' | ||
| 'bun' | ||
| 'chrome' | ||
| 'chrome-android' | ||
| 'deno' | ||
| 'edge' | ||
| 'electron' | ||
| 'firefox' | ||
| 'firefox-android' | ||
| 'hermes' | ||
| 'ie' | ||
| 'ios' | ||
| 'node' | ||
| 'opera' | ||
| 'opera-android' | ||
| 'phantom' | ||
| 'quest' | ||
| 'react-native' | ||
| 'rhino' | ||
| 'safari' | ||
| 'samsung'; | ||
|
||
export type TargetVersion = string; |