Problems using
Closed this issue · 6 comments
I've been using the delay
module in a typescript module (@google-cloud/profiler
).
I'd previously used the type definitions from DefinitelyTyped, so @types/delay
, without issue. But when I try to use version 3.1.0 of this module (and use the types from this latest version), my module no longer compiles, and I get errors like:
ts/test/test-time-profiler.ts:65:16 - error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof import("/usr/local/google/home/nolanmar/cloud-profiler-nodejs-working/cloud-profiler-nodejs/node_modules/delay/index")' has no compatible call signatures.
65 await delay(2 * durationMillis);
~~~~~~~~~~~~~~~~~~~~~~~~~
Is this expected? Any advice for how I can migrate to version 3.1.0 of `delay?
/cc @dmitry-korolev as I see the types were added by them.
Hey @nolanmar511.
Please, tell your typescript version. I'll check this issue ASAP.
@nolanmar511 How are you importing it?
@nolanmar511 @ofrobots
Since version 3.1.0 delay uses default export both in commonjs style and es6 style. TS doesn't allow mixing them so we had to choose one to use in the declaration file.
See https://github.com/sindresorhus/typescript-definition-style-guide
So now you have to import delay
as normal defaul import: import delay from 'delay'
.
This looks like a breaking change to me :/
Didn't notice this change because I always use allowSyntheticDefaultImports
in my projects.
@dmitry-korolev It's not a breaking change. I can't be responsible for externally created type definitions.
Relevant: microsoft/TypeScript#19283