-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Typescript doesnt allow creating module definitions for certain types of ES6 imports #6656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As a workaround, you can add a line: declare module 'react-bootstrap-switch'
{
import React = require("react");
class Switch extends React.Component<{onColor?:string},{}> {
}
module Switch { } // <----
export = Switch;
} |
@pdeva Just a question, but why must you import that way? If's it's using |
we want to have 100% ES6 code. |
ES6 modules cannot represent a CJS module that assigns to module.exports. So basically you're writing ES6 code that isn't valid ES6 - it only works when transpiled to ES5 because the ES5 transpilation of If you do still want to write it as an ES6 import, then it would be |
I think @Arnavion has addressed this pretty clearly (thanks!). Closing as by design. |
There is a library I use,
'react-bootstrap-switch'
, that needs to be imported the following way in TypeScript:It seems currently TypeScript doesnt allow creating a module definition for a library that exports like this.
If I do this:
It results in this error:
The text was updated successfully, but these errors were encountered: