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.

*d.ts module export format: default or '='

See original GitHub issue

Hi 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:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
dasacommented, Sep 20, 2016

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

2reactions
nickcamcommented, Sep 20, 2016

Just found out the current typings will work in my case when setting the following compilerOption.

"allowSyntheticDefaultImports": true

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.

Read more comments on GitHub >

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

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