与TypeScript中的全局类型冲突

与TypeScript中的全局类型冲突,typescript,global,declare,name-collision,Typescript,Global,Declare,Name Collision,我想在TypeScript中使用我自己的全局类型(不使用导入,使用声明类型)。例如: // File with global types. declare type Function<TParameter, TResult> = (parameter: TParameter) => TResult // Another file. const someMethod = (callback: Function<number, string>) => { ...

我想在TypeScript中使用我自己的全局类型(不使用
导入
,使用
声明类型
)。例如:

// File with global types.
declare type Function<TParameter, TResult> = (parameter: TParameter) => TResult

// Another file.
const someMethod = (callback: Function<number, string>) => { ... }

您可以使用
--noLib
从编译器中排除默认lib,并定义自己的类型,但这意味着替换所有定义。。(ts还取决于某些类型的存在,因此它可能不适用于特定类型)我认为您应该更改类型名称尝试重写ts库是一件坏事
// File with global types
declare type MyTypes.Function<TParameter, TResult> = (parameter: TParameter) => TResult

// Another file.
const someMethod = (callback: MyTypes.Function<number, string>) => { ... }