TypeScript声明文件。
if you want to use relative path in the import, you will need:
- put the add.d.ts next to add.js
- define the file as an external module:
1 | // add.d.ts |
i.e. loose the “declare module “add”” part.
There are two ways to define declarations for a .js module:
1 using declare module "foo"
and then you can have multiple module definitions in the same file:
1 | // mydefinitions.d.ts |
and consuming them would have to be using absolute names:
1 | // main.ts |
2 alternatively you can define as a file, where the name of the file is the name of the module
1 | // myModule.d.ts |
and consume it as a normal .ts module:
1 | import m = require("./myModule"); |