-
-
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.
Add typescript declarations for core-js-compat
Reuse it for the core-js-builder declarations to prevent duplicated code Signed-off-by: Ferdinand Thiessen <[email protected]>
- Loading branch information
Showing
3 changed files
with
98 additions
and
44 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
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,93 @@ | ||
type StringOrRegExp = string | RegExp; | ||
|
||
type Modules = StringOrRegExp | readonly StringOrRegExp[]; | ||
|
||
type ModuleName = string; | ||
|
||
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'; | ||
|
||
type BrowserslistQuery = string | ReadonlyArray<string>; | ||
|
||
type Environments = { | ||
[target in Target]?: string | number; | ||
}; | ||
|
||
type Targets = Environments & { | ||
browsers?: Environments | BrowserslistQuery, | ||
esmodules?: boolean, | ||
}; | ||
|
||
type Options = { | ||
/** 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 TargetVersion = string; | ||
|
||
type Output = { | ||
/** array of required modules */ | ||
list: ModuleName[], | ||
/** object with targets for each module */ | ||
targets: { | ||
[module: ModuleName]: { | ||
[target in Target]?: TargetVersion | ||
} | ||
} | ||
} | ||
|
||
type CompatData = { | ||
[module: ModuleName]: { | ||
[target in Target]?: TargetVersion | ||
} | ||
}; | ||
|
||
declare const ExportedCompatObject: { | ||
compat(options?: Options): Output, | ||
|
||
/** The subset of modules which available in the passed `core-js` version */ | ||
getModulesListForTargetVersion(version: string): readonly ModuleName[], | ||
|
||
/** Full list compatibility data */ | ||
data: CompatData, | ||
|
||
/** map of modules by `core-js` entry points */ | ||
entries: {[entry_point: string]: readonly ModuleName[]}, | ||
|
||
/** Full list of modules */ | ||
modules: readonly ModuleName[] | ||
} | ||
|
||
export = ExportedCompatObject |
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