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.

Minor version 2.2 is breaking for TypeScript consumers

See original GitHub issue

https://github.com/sourcegraph/javascript-typescript-langserver/issues/371 https://travis-ci.org/sourcegraph/javascript-typescript-langserver/jobs/289329597#L1487-L1490

src/logging.ts(72,40): error TS2339: Property 'grey' does not exist on type 'typeof "/home/travis/build/sourcegraph/javascript-typescript-langserver/node_modules/chalk/types/...'.
src/logging.ts(80,40): error TS2339: Property 'bgCyan' does not exist on type 'typeof "/home/travis/build/sourcegraph/javascript-typescript-langserver/node_modules/chalk/types/...'.
src/logging.ts(88,40): error TS2339: Property 'bgYellow' does not exist on type 'typeof "/home/travis/build/sourcegraph/javascript-typescript-langserver/node_modules/chalk/types/...'.
src/logging.ts(96,40): error TS2339: Property 'bgRed' does not exist on type 'typeof "/home/travis/build/sourcegraph/javascript-typescript-langserver/node_modules/chalk/types/...'.

Before 2.2, with @types/chalk, it was possible to import chalk like this:

https://github.com/sourcegraph/javascript-typescript-langserver/blob/6fcc4e1df9283dbd84db9411aa26e9f49556cb50/src/logging.ts#L2

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/05ac46f9a9307d43e082b7cec4b32f40df3a3b58/types/chalk/index.d.ts#L6

2.2 brings its own types, which override @types/chalk, but they don’t allow this import (only a defaut import):

https://github.com/chalk/chalk/blob/d86db88e778fa856f4d6f5f68c588750ca06b822/types/index.d.ts#L90

Although it seems to work at runtime and appears semantically correct / correct in regard to the JS:

https://github.com/chalk/chalk/blob/d86db88e778fa856f4d6f5f68c588750ca06b822/index.js#L219

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:41 (19 by maintainers)

github_iconTop GitHub Comments

13reactions
sindresorhuscommented, Oct 18, 2017

Obligatory XKCD:

workflow
4reactions
mceachencommented, Oct 24, 2017

@sindresorhus thanks for Chalk and your other contributions!

You may not appreciate it, and I know you didn’t author it, but @types/chalk for all intents and purposes was the “official” Chalk API for TypeScript users. Creating an index.d.ts that differs from that API is a breaking change, by definition. The other commenters on this issue are evidence to this effect.

Also, I’ve used upwards of 100 typed packages over the past year, and this typing is the first to require a non-namespaced import chalk from "chalk" style. I’d expect a good deal of issues or questions to arise from this.

For other people wondering why chalk broke for them with a minor release, as stated above, change

import * as chalk from "chalk"

to

import chalk from "chalk"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 3.9
The function's types declare that it takes two string s so that other TypeScript users can get type-checking errors, but it also does...
Read more >
node.js - How to relate a version of @types to ... - Stack Overflow
Because the minor version shouldn't represent breaking changes, in theory, you can use the highest 2.x.y definition file available for a 2.a.b.c ...
Read more >
About semantic versioning - npm Docs
Backward compatible new features, Minor release, Increment the middle digit and reset last digit to zero, 1.1.0. Changes that break backward compatibility ...
Read more >
Firebase Admin Node.js SDK Release Notes - Google
Breaking change: Dropped support for Node.js 12. Developers should use Node.js 14 or higher when deploying the Admin SDK. Breaking change: Upgraded TypeScript...
Read more >
Changelog - Cypress Documentation
Breaking Changes: Cypress dropped support for Node.js 12, 15 and 17. Those versions have reached end-of-life. Installing Cypress on your system ...
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