Rui*_* Ma 5 typescript eslint es6-module-loader
我遇到下面的代码片段,其中包含对类型引用的循环导入依赖。
// Foo.ts
import { Bar } from './Bar';
export interface Foo {
isBarOK: (bar: Bar) => boolean;
}
// Bar.ts
import { Foo } form './Foo';
export class Bar {
protected readonly foo: Foo;
}
Run Code Online (Sandbox Code Playgroud)
这是一个简化版本,但它解释了我遇到的情况。tsc编译代码没有问题,但我收到了import/no-cycle ESLint 规则的警告。我们可以看到这一点Foo并Bar互相参考以进行打字。这是一个不好的做法吗?它意味着什么影响?
| 归档时间: |
|
| 查看次数: |
1833 次 |
| 最近记录: |