mirror of
https://github.com/lancedikson/bowser
synced 2026-10-09 04:12:31 +00:00
Dual packaging, without breaking existing consumers (#628)
Co-authored-by: Yasumasa Ashida <ys.ashida@gmail.com>
This commit is contained in:
33
index.d.mts
Normal file
33
index.d.mts
Normal file
@@ -0,0 +1,33 @@
|
||||
// ESM type definitions for Bowser v2.
|
||||
//
|
||||
// `index.d.ts` uses `export =`, which describes the CommonJS/UMD shape of
|
||||
// `es5.js` (`module.exports = Bowser`). It is reached via the `require`
|
||||
// condition and stays the source of truth for the type declarations.
|
||||
//
|
||||
// This file describes `bowser.mjs`, which is a real ES module: it has a default
|
||||
// export *and* the `parse` / `getParser` named exports. It is reached via the
|
||||
// `import` condition. Declaring it separately is what keeps the types honest
|
||||
// for `moduleResolution: node16`/`bundler` consumers — reusing `index.d.ts` for
|
||||
// both conditions would describe an ES module with CommonJS types.
|
||||
|
||||
import Bowser = require('./index.js');
|
||||
|
||||
export default Bowser;
|
||||
|
||||
export declare const parse: typeof Bowser.parse;
|
||||
export declare const getParser: typeof Bowser.getParser;
|
||||
|
||||
// BROWSER_MAP / ENGINE_MAP / OS_MAP / PLATFORMS_MAP are *not* named exports of
|
||||
// bowser.mjs — they exist only as static getters on the class. Declaring them
|
||||
// here would let TypeScript accept `import { BROWSER_MAP } from 'bowser'`,
|
||||
// which throws at runtime. Reach them via the default export instead.
|
||||
|
||||
export type ClientHints = Bowser.ClientHints;
|
||||
export type Parser = Bowser.Parser.Parser;
|
||||
export type ParsedResult = Bowser.Parser.ParsedResult;
|
||||
export type Details = Bowser.Parser.Details;
|
||||
export type BrowserDetails = Bowser.Parser.BrowserDetails;
|
||||
export type EngineDetails = Bowser.Parser.EngineDetails;
|
||||
export type OSDetails = Bowser.Parser.OSDetails;
|
||||
export type PlatformDetails = Bowser.Parser.PlatformDetails;
|
||||
export type checkTree = Bowser.Parser.checkTree;
|
||||
Reference in New Issue
Block a user