简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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