4.1.2 has mis-configured Typescript definition
See original GitHub issueChalks types are not next to the main entrypoint file and thus TSC fails to compile them.
$ tsc
src/index.ts(3,19): error TS2307: Cannot find module 'chalk' or its corresponding type declarations.
https://codesandbox.io/s/ts-http-chalk-bug-lq2qz?file=/src/index.ts https://unpkg.com/browse/chalk@4.1.2/package.json
Workarounds from bad to worse
- Run this after the npm install hook, i.e. the install or prepare script:
#!/bin/bash
set -euo pipefail
sed -i '8s/"source",/"\.\/source\/index\.js",\n"types": "\.\/index\.d\.ts",/' node_modules/chalk/package.json
- Maybe: Manually reference chalk’s types in an ambient declaration…
- I can’t get this to work in practice with a triple-slash directive
- Ambient type
declare module 'chalk'
. Treats chalk as if it has no types. - move the node_modules/chalk/index.d.ts to node_modules/chalk/source/
- modify node_modules/chalk/package.json with
"types": "index.d.ts"
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
[TypeScript] Unable to override type of request.user #51 - GitHub
Not sure if this is an actual bug or a typescript misconfiguration on my side but I haven't found a way to properly...
Read more >Documentation - TypeScript 4.1
It has the same syntax as template literal strings in JavaScript, but is used in type positions. When you use it with concrete...
Read more >TypeScript 4.1.2 (stable) has been released! - Reddit
TypeScript is a language for application-scale JavaScript development. ... typed react definitions don't have a jsx runtime module.
Read more >Changelog - Cypress Documentation
Fixed an issue where an internal TypeScript type was exposed globally. Fixes #23333. ... Upgraded eventemitter2 from 4.1.2 to 6.4.2 .
Read more >Protect your Software at the Source - Fortify Taxonomy
NET Misconfiguration Type Mismatch Cross-Frame Scripting ADF Faces Bad Practices ... Buffer overflow is probably the best known form of software security ...
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 FreeTop 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
Top GitHub Comments
This is a bug with v4 though, it’s definitely something we should address prior to v5. Maybe we just do a patchfix branch and consider v4 frozen?
I see something has changed since that release. We already do what you’re asking - it just hasn’t been published yet.
@sindresorhus are we safe to cut a release?