typescript declare:`export function` 和 `export type .. lambda` 有什么区别?
typescript declare: what is the difference between `export function` and `export type .. lambda`?
导出有什么区别:
index.d.ts
declare module '@my/customs'{
export function ModuleFactory(environment:any): any
}
和
declare module '@my/customs'{
export type ModuleFactory = (environment: any) => any;
}
当我注释函数时 ModuleFactory(environment){..}
仅在第一个有效时,第二个 return 打字稿错误
TS2693: "'ModuleFactory' only refers to a type, but is being used as a value here.",
如果你指出应该用第二个选项注释的 TS“东西”,我会理解其中的区别。
相当于第一个文件的 Lambda 是
declare module '@my/customs'{
type ModuleFactoryFn = (environment: any) => any;
export const ModuleFactory: ModuleFactoryFn;
}
导出有什么区别:
index.d.ts
declare module '@my/customs'{
export function ModuleFactory(environment:any): any
}
和
declare module '@my/customs'{
export type ModuleFactory = (environment: any) => any;
}
当我注释函数时 ModuleFactory(environment){..}
仅在第一个有效时,第二个 return 打字稿错误
TS2693: "'ModuleFactory' only refers to a type, but is being used as a value here.",
如果你指出应该用第二个选项注释的 TS“东西”,我会理解其中的区别。
相当于第一个文件的 Lambda 是
declare module '@my/customs'{
type ModuleFactoryFn = (environment: any) => any;
export const ModuleFactory: ModuleFactoryFn;
}