microsoft / microsoft/TypeScript
importing merged declorations in js files
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
### 🔎 Search Terms
is a type and cannot be imported in JavaScript files;
JSDoc;
Import;
Declaration Merging.
### 🕗 Version & Regression Information
- This is the behavior in every version I tried (v5.8.3 - Nightly)
### 💻 Code
```ts
// @filename: foo.impl.js
/**
* @import { Foo } from "./foo.js"
*/
/**
* @returns { Foo }
*/
export function alloc() {
return {
prop1: 42,
prop2: "lorem ipsum"
}
}
// @filename: foo.js
export * as Foo from "./foo.impl.js"
/**
* @typedef Foo
* @prop { number } prop1
* @prop { string } prop2
*/
// @filename: index.js
import { Foo } from "./foo.js"
// ^^^ 'Foo' is a type and cannot be imported in JavaScript files. Use 'import("./foo.js").Foo' in a JSDoc type annotation.ts(18042)
const foo = Foo.alloc();
```
### 🙁 Actual behavior
tsc/lsp emmits error
### 🙂 Expected behavior
no error
### Additional information about the issue
same example works fine using ts files
贡献指南
调研方向
使用 tsc 或 language service,通过 foo.impl.js、foo.js 和 index.js 重现该示例,然后跟踪对 Foo 的 import 进行的诊断,并将其与正常工作的 TypeScript 文件情况进行比较。完成的标准是 JavaScript 示例不报告 import 错误,并且 Foo.alloc() 仍可使用。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100