假设我有这个:
import type { Collection } from './x.types.js';
import type { Collection } from './y.types.js';
Run Code Online (Sandbox Code Playgroud)
我想像这样导入两者:
import type * as XTypes from './x.types.js';
import type * as YTypes from './y.types.js';
Run Code Online (Sandbox Code Playgroud)
因为在我的代码中我将有一个名称空间,我可以轻松地识别它们来自哪里,并且我不会有任何声明冲突。
const something = (collection: Xtypes.collection) => {}
const something2 = (collection: Ytypes.collection) => {}
Run Code Online (Sandbox Code Playgroud)