简体   繁体   English

具有默认导出功能的打字稿环境声明

[英]Typescript ambient declaration with function as default export

I'm trying to shim the types for the express syntax for locale in my project, but am unsure how to do it as it is a function as a default export, not an object. 我正在尝试对项目中的语言环境的Express语法进行填充,但是不确定如何执行此操作,因为它是默认导出功能,而不是对象。

Currently I have this which stops typescript from erroring but doesn't give me types: 目前,我有此功能可以防止打字稿出错,但不能提供类型:

declare module 'locale';

I tried this, but it didn't work: 我试过了,但是没有用:

declare function locale(supported: string[], def: string): void;

What do I need to do? 我需要做什么? I can't find any useful documentation here. 我在这里找不到任何有用的文档。

Try this: 尝试这个:

declare module 'locale' {
  export default function locale(supported: string[], def: string): void;
}

Also: official documentation on the topic 另: 关于该主题的官方文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM