Here we're importing a function myModuleFunc
from my-module
:
import { myModuleFunc } from "my-module"; // red squiggly line under "my-module"
Let's start by creating a new declaration file called my-module.d.ts
inside of the src
directory.
Inside the file, we'll use the declare module
syntax to define a module and indicate what it exports. To match the test from the challenge, we'll export a function named myModuleFunc
that returns void
:
// inside src/my-module.d.ts
declare module "my-module" {
export const myModuleFunc: () => void;
}
标签:TypeScript,myModuleFunc,module,Typescript,export,my,declare From: https://www.cnblogs.com/Answer1215/p/18349564