-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[ts] Module 'xxx' has no default export. #19
Labels
Comments
因为有的模块没有 import * as fs from 'fs'; |
自己写的模块也会存在这个问题: // foo.ts
const foo1 = 'foo1';
const foo2 = 'foo2';
export {
foo1,
foo2
}
// bar.ts
import foo from './foo';
// [ts] Module '"./foo"' has no default export. 必须得这么写才行: // foo.ts
const foo1 = 'foo1';
const foo2 = 'foo2';
export {
foo1,
foo2
}
// bar.ts
import * as foo from './foo'; 或者将 // foo.ts
const foo1 = 'foo1';
const foo2 = 'foo2';
export default {
foo1,
foo2
}
// bar.ts
import foo from './foo'; |
另外,可以在 {
"compilerOptions": {
"allowSyntheticDefaultImports": true
}
} 这样即使没有 |
楼上正解 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
为什么引用一些模块的时候,会报如下错误?
The text was updated successfully, but these errors were encountered: