milesj / emojibase

🎮 A collection of lightweight, up-to-date, pre-generated, specification compliant, localized emoji JSON datasets, regex patterns, and more.
https://emojibase.dev
MIT License
465 stars 38 forks source link

RequestInit type not available in non-DOM (pure-Node) environment #151

Open threema-danilo opened 1 year ago

threema-danilo commented 1 year ago

I'm using emojibase-data to generate an emoji picker. This script runs in a NodeJS environment, so the DOM types aren't available.

SInce #139, emojibase-data includes types that extend RequestInit. This type is not available in a non-DOM context:

../../node_modules/emojibase/dts/types.d.ts:106:46 - error TS2304: Cannot find name 'RequestInit'.

106 export interface FetchFromCDNOptions extends RequestInit {
                                                 ~~~~~~~~~~~

In TypeScript, this type is defined in lib/lib.dom.d.ts and lib/lib.webworker.d.ts.

Maybe the package could be restructured somehow, so that these CDN fetching types are only included when importing the full emojibase package, but not when importing only emojibase-data?

threema-danilo commented 1 year ago

When not using CDN, this can be worked around with the following definition in the project:

declare global {
    export interface RequestInit {}
}