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.

4.1.2 has mis-configured Typescript definition

See original GitHub issue

Chalks 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:closed
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Qix-commented, Oct 22, 2021

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?

1reaction
Qix-commented, Oct 22, 2021

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?

Read more comments on GitHub >

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

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