// a.ts
import { b } from "./b"
export const a = [b]
// b.ts
import { a } from "./a"
export const b = [a]
或
// a.ts
import { b1 } from "./b"
export const a1 = 123
export const a2 = [b1]
// b.ts
import { a2 } from "./a"
export const b1 = 312
export const b2 = [a2]
类似上述代码则会造成以下异常error
解决办法:
解开文件之间的循环依赖即可,切忌文件之间不可相互依赖
// a.ts
import { b1 } from "./b"
export const a1 = 123
export const a2 = [b1]
// b.ts
import { a2 } from "./a"
export const b2 = [a2]
// c.ts
export const b1 = 312
标签:typescript,const,ts,依赖,export,b1,error,import,a2
From: https://www.cnblogs.com/Kidrue/p/17015145.html