microsoft / microsoft/TypeScript
"export = { }" vs "let a = { }; export = a", causes discrepancy in import behavior
未关闭
还没有人认领这个 Issue。
Needs Investigation
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.4k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 117
描述
TypeScript Version: 3.9.5
Search Terms: I searched import related bug labels
Code
//module a
export = {
name: 'zzxoto'
};
//module b
const EX = { name: 'zzxoto' };
export = EX;
//////////////////////////////////////////////////////////////////
//when importing a
//this gives error:
//This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.ts(2497)
import { name } from './a';
//this works
import A from './a';
A.name;
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//when importing b
//this works
import { name } from './b';
//this works too
import B from './b';
B.name
//////////////////////////////////////////////////////////////////
//tsconfig.json
{
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"strict": false,
"strictNullChecks": true,
"allowJs": false,
"esModuleInterop": true
},
"include": ["**/*.ts"]
}
Expected behavior:
There should be no descrepancy while import module a vs module b.
Actual behavior:
Described above.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
使用报告中的模块 a 和 b,以及 TypeScript 3.9.5 和提供的 tsconfig.json,重现该差异。在 esModuleInterop 下比较命名导入和默认导入,然后验证等效的导出形式是否产生一致的导入行为。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100