question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript dom reference causes failure in non-DOM contexts

See original GitHub issue

The 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:closed
  • Created 5 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
felixfbeckercommented, Sep 30, 2018

@dex4er “a lot of troubles and incompatibilities” is an over-exaggeration. There was a new feature added to delay in 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 delay is a library mainly for Node and don’t seem anything indicating it is, nor a reason why it should be.

AbortSignal is 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, like URL or setTimeout.

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 delay from also supporting other cancellation tokens in the future if TC39 specifies one too (although I don’t see that happening anytime soon).

0reactions
dex4ercommented, Sep 29, 2018

I don’t agree that delay should use any of cancel metod: ClearablePromise or AbortController. There is no standard method for canceling Promise in NodeJS or ECMA yet. As far as delay is 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 delay can be used with AbortSignal but in the end it caused that this simple delay module (shouldn’t be more that util.promisify(setTimeout)? caused a lot of troubles and incompatibilities.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found