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.

TS declaration file introduces breaking change

See original GitHub issue

The included https://github.com/cryptocoinjs/base-x/blob/master/src/index.d.ts differs from the one at https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/base-x/index.d.ts, which means, this introduces a breaking change. Other packages (like bs58) use ^3.0.2 as their version string for this package, which will install 3.0.6 and break, because the other package doesn’t expect such a breaking change in a patch release.

I would suggest unpublishing v3.0.6 and republishing it as 4.0.0, or overwriting v3.0.6 with the type definition of DefinitelyTyped.

Another more complicated option would be to overwrite 3.0.6 with 3.0.5 and republishing the package with your new typescript declaration under 4.0.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
junderwcommented, Sep 5, 2019

This is weird… the results are not consistent for me.

Running with --traceResolution shows that it’s picking up both… and I don’t know what causes it to choose one over the other.

Your repro steps did fail to build, though. If I try doing things like remove base-x as a direct dependency to your repo, or use npm run scripts instead of the command directly it was working and not working intermittently… removing strict also made it work, then adding strict back and it still worked.

it is very wonky… but imo, we should be the ones to manage the type definitions. I have a PR on bs58 and will consider doing something similar for bs58check.

======== Resolving module 'base-x' from '/tmp/bs58-typescript-bug/node_modules/@types/bs58/index.d.ts'. ========
Loading module 'base-x' from 'node_modules' folder, target file type 'TypeScript'.
Found 'package.json' at '/tmp/bs58-typescript-bug/node_modules/base-x/package.json'.
File '/tmp/bs58-typescript-bug/node_modules/base-x.ts' does not exist.
File '/tmp/bs58-typescript-bug/node_modules/base-x.tsx' does not exist.
File '/tmp/bs58-typescript-bug/node_modules/base-x.d.ts' does not exist.
'package.json' has 'types' field 'src/index.d.ts' that references '/tmp/bs58-typescript-bug/node_modules/base-x/src/index.d.ts'.
File '/tmp/bs58-typescript-bug/node_modules/base-x/src/index.d.ts' exist - use it as a name resolution result.
Resolving real path for '/tmp/bs58-typescript-bug/node_modules/base-x/src/index.d.ts', result '/tmp/bs58-typescript-bug/node_modules/base-x/src/index.d.ts'.
======== Module name 'base-x' was successfully resolved to '/tmp/bs58-typescript-bug/node_modules/base-x/src/index.d.ts' with Package ID 'base-x/src/index.d.ts@3.0.6'. ========

======== Resolving type reference directive 'base-x', containing file '/tmp/bs58-typescript-bug/__inferred type names__.ts', root directory '/tmp/bs58-typescript-bug/node_modules/@types'. ========
Found 'package.json' at '/tmp/bs58-typescript-bug/node_modules/@types/base-x/package.json'.
'package.json' has 'types' field 'index' that references '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index'.
File '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index' does not exist.
Loading module as file / folder, candidate module location '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index', target file type 'TypeScript'.
File '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index.ts' does not exist.
File '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index.tsx' does not exist.
File '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index.d.ts' exist - use it as a name resolution result.
Resolving real path for '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index.d.ts', result '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index.d.ts'.
======== Type reference directive 'base-x' was successfully resolved to '/tmp/bs58-typescript-bug/node_modules/@types/base-x/index.d.ts' with Package ID '@types/base-x/index.d.ts@3.0.0', primary: true. ========
0reactions
tjweldecommented, Sep 5, 2019

What were the steps you did, where typescript is trying to resolve the conflict of multiple types and uses the DefinetelyTyped ones?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Breaking Changes · microsoft/TypeScript Wiki - GitHub
TypeScript now shows JavaScript syntax and binding errors in your file, such as using incorrect modifiers, duplicate declarations, and more.
Read more >
Documentation - Modules .d.ts - TypeScript
Note that using export default in your .d.ts files requires ... Add the template inside the braces of the declare module, and see...
Read more >
Is adding a d.ts file to a JavaScript npm package a breaking ...
SemVer states. Given a version number MAJOR.MINOR.PATCH, increment the: MAJOR version when you make incompatible API changes,; MINOR version ...
Read more >
Semantic Versioning for TypeScript Types
This is a breaking change for value exports ( let , const , class , function ) independent of types, but removing exported...
Read more >
Announcing TypeScript 4.2 - Microsoft Developer Blogs
Likewise, if we get the declaration file output ( .d.ts output) for ... TypeScript 4.2 contains some breaking changes, but we believe they ......
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