Let's say I have an import like import AltContainer from 'alt-container';
. How would you set up a declaration for that? The documentation shows how to achieve this for a module that exports functions but there's no example for this particular case.
If the exports of the module is itself a function, you can declare a function named exports
from the module.
lib/mymodule.js:
declare module "mymodule" {
declare function exports(foo: string): void;
}
index.js
import f from "mymodule";
f(0); // error: number ~> string
Put something like this in a file in your libs
directory:
declare module 'alt-container' {
declare function hello(foo: string): number;
}
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.