*d.ts module export format: default or '='
See original GitHub issueHi all,
Just wondering if there’s a compelling reason as to why all of the modules in *.d.ts export in this format?
declare module "esri/Map" {
import Map = __esri.Map;
export = Map;
}
I would have thought since every module only exports a single object, using a default export would be better.
declare module "esri/Map" {
import Map = __esri.Map;
export default Map;
}
Certainly makes importing easier - well in my case it does anyway, which involves systemjs/ngc/rollup for dev and prod builds of an Angular 2 app.
I realise dojo exports the same way, but is it really necessary? Would prefer to use the official typings instead of editing after importing.
Perhaps it’s possible to have multiple official typings per api?
Thanks, Nick
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Documentation - Modules .d.ts - TypeScript
A module using CommonJS patterns uses module.exports to describe the exported values. ... Note that using export default in your .d.ts files requires ......
Read more >Write a declaration file for a default export module
Instead of using export default , you should use export = . custom-typings/rivescript.d.ts declare module 'rivescript' { class RiveScript { constructor() } ...
Read more >d.ts export default with require · Issue #20526 - GitHub
This seems like a declaration file issue. the file is declared such that it has one export "default" , where as the package...
Read more >How To Use Modules in TypeScript | DigitalOcean
Another way you could have written your export was by using a default export. Every file can have at most a single default...
Read more >Content Types - ESBuild
When code in the ESM format that has a default export is converted to the CommonJS format, and then that CommonJS code is...
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 Free
Top 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
Closing this since it sounds like just using
allowSyntheticDefaultImports
is all you need. https://github.com/Microsoft/TypeScript/wiki/What's-new-in-TypeScript#support-for-default-import-interop-with-systemjsJust found out the current typings will work in my case when setting the following compilerOption.
Still think the question is valid, but certainly no point in having multiple typings files with such a simple workaround for these tools/cases. thanks.