Typescript ambient definitions doesnt work in node unless
See original GitHub issueunless you require it as an “ecmascript module”
const { default: chalk } = require('chalk') // this will work and typescript is happy
The following provides incorrect types:
const chalk = require('chalk') // this work but typescript will shows errors with incorrect types
Would it be possible to fix the index.d.ts
so it provides correct types for commonjs (node) environment?
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Declare node module for TypeScript that is not available ...
I'm quite new to TypeScript and am trying to script a little cli app. I want to use npm~command-line-args but its definition is...
Read more >Ambient Modules in TypeScript: What they are and how to ...
An ambient declaration file is a file that describes the module's type but doesn't contain its implementation.
Read more >Documentation - Modules - TypeScript
How modules work in TypeScript. ... We call declarations that don't define an implementation “ambient”. Typically, these are defined in .d.ts files. If...
Read more >What are Ambients in TypeScript ? - GeeksforGeeks
We have to always write ambient declarations if our TypeScript code needs ... JavaScript libraries such as jQuery, AngularJS, Node.js, etc.
Read more >typescript-cheatsheet - GitHub Pages
TypeScript, like JavaScript, allows you to work with arrays of values. ... We call declarations that don't define an implementation “ambient”.
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
You were right, sorry for bothering. It was a misconfiguration in my project… Again, I am sorry and thanks for all answers. Still it is weird it was working with the
const {default: chalk} = require('chalk')
import.This doesn’t make much sense to be honest. JS is too dynamic to have great intellisense. I didn’t even know IDEs would cross the typescript/javascript boundary when doing code hinting.
Sounds like an issue specifically with your IDE as our typings haven’t caused any issues before.