-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Importing default module fails when using ES6 syntax #3337
Comments
You should use import * as fs from 'fs'; You can use your syntax if the module has a default export. Example: // foo.ts
export default class Foo {
}
// bar.ts
import Foo from './foo';
new Foo(); |
Thanks! Closing this. |
I suggest making the existing Take the import tape from 'tape' Fails with |
+1 |
We talked a lot about whether we can (or should) make export= and export default the same thing. You can see the discussion and conclusions here: #2242 (comment) |
I used
And the error message becomes:
|
Setting "target" to "es5" and
will work just fine, however this syntax will cause error with target = es6 |
What is wrong with:
game.ts:
I get the error:
|
export default class Game { |
@mhegazy I am not wanting to use a default export here. |
Is it If it is |
can you share your code then. the error is only shown if you have a default import. |
@mhegazy sorry please bear with me, I need to upload my local code after fixing smth. |
@mhegazy switching to tsc vs ts-loader+webpack has fixed it for me. |
I have tried importing
fs
module usingimport fs from 'fs'
but this gives an error: `Module 'path' has no default export.'.import fs = require('fs');
works but this is not ES6 syntax. I would like to stick with ES6 syntax because it is getting more and more popular and therefore easier to understand.Are there any plans for supporting ES6 modules that import the entire TypeScript module?
The text was updated successfully, but these errors were encountered: