Typescript dom reference causes failure in non-DOM contexts
See original GitHub issueThe lib reference to dom https://github.com/sindresorhus/delay/blob/34e50092c96d05f3d248130212a163a22570618f/index.d.ts#L1 prevents this from being properly usable within non-DOM contexts such as react-native.
node_modules/typescript/lib/lib.dom.d.ts:17604:6 - error TS2300: Duplicate identifier 'RequestInfo'.
17604 type RequestInfo = Request | string;
~~~~~~~~~~~
node_modules/@types/react-native/globals.d.ts:92:14
92 declare type RequestInfo = Request | string;
~~~~~~~~~~~
RequestInfo' was also declared here.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (8 by maintainers)
Top Results From Across the Web
Documentation - DOM Manipulation - TypeScript
The Document Object Model (DOM) is a programming interface implemented by browsers in order to make static websites functional. The DOM API can...
Read more >expose requestIdleCallback (or similar) API to non-DOM JS ...
It may be useful to have a requestIdleCallback-style API in non-DOM contexts so that code that can't easily be moved off of performance-critical...
Read more >Why does jQuery or a DOM method such as getElementById ...
Many questions are asked about why a certain DOM element is not found and the reason is often because the JavaScript code is...
Read more >Changelog - Cypress Documentation
Fixed TypeScript types for testIsolation . Fixes #23911; Sessions will no longer be stored if validation fails which will prevent a previously failed...
Read more >React | IntelliJ IDEA Documentation - JetBrains
React is a JavaScript library for building complex interactive User Interfaces ... such as className or classID , and non-DOM attributes, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@dex4er “a lot of troubles and incompatibilities” is an over-exaggeration. There was a new feature added to
delayin a major version. The way the typings were written caused errors in the new major version for TypeScript users with a certain tsconfig (a subset of the whole user base). Within a single day of the issue being reported there is a PR with a fix.I wasn’t aware
delayis a library mainly for Node and don’t seem anything indicating it is, nor a reason why it should be.AbortSignalis not “non-standard”. It’s specced in the DOM standard, but that doesn’t matter - so are many other things that can be used in Node too, likeURLorsetTimeout.How exactly can this “conflict with other non-standard libraries”?
This feature is not a proof of concept. It is something that I am using in code that runs in the browser.
It’s optional. You don’t have to provide an AbortSignal. But if you have one, you can supply it now. And since it’s an option, there is nothing preventing
delayfrom also supporting other cancellation tokens in the future if TC39 specifies one too (although I don’t see that happening anytime soon).I don’t agree that
delayshould use any of cancel metod: ClearablePromise or AbortController. There is no standard method for canceling Promise in NodeJS or ECMA yet. As far asdelayis a library mainly for Node and still is no consensus how to cancel promises (see https://github.com/tc39/proposal-cancellation/issues/22) then it would be better to remove any non-standard features which can conflict with other non-standard libraries.BTW, it makes me sad that NodeJS’s EventEmitter has nothing in common with DOM’s signals. Maybe it is better to wait for some standardisation?
I guess you want to make a proof of concept that
delaycan be used withAbortSignalbut in the end it caused that this simpledelaymodule (shouldn’t be more thatutil.promisify(setTimeout)?caused a lot of troubles and incompatibilities.