railsware / js-routes

Brings Rails named routes to javascript
http://railsware.github.io/js-routes/
MIT License
1.61k stars 151 forks source link

No default export in Typescript definitions file #286

Closed utricularian closed 3 years ago

utricularian commented 3 years ago

Prior to the Typescript update (which is awesome), I was able to consume my routes file like this:

import Routes from 'config/backendRoutes'

Converting the file to Typescript, I now get:

"export 'default' (imported as 'Routes') was not found in 'file/that/was/generated'

I can get around this by doing the following:

import * as Routes from 'config/backendRoutes'

Is it possible to add a default export in the .d.ts file?

bogdan commented 3 years ago

This is a part of ESM module system: default export makes it impossible to use ESM tree shaking. See https://github.com/railsware/js-routes/blob/master/VERSION_2_UPGRADE.md for more info.

bogdan commented 3 years ago

I've added a note that typescript definitions are only capable with ESM module type in Readme. Not much else I can do at the moment.