-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
I am trying to import an existing javascript source file(not a 3rd party module) into my typescript file using import ... = require()
syntax with no success. Could you please help me point out anything I did wrong in the following isolated example?
add.js
module.exports = function (n1, n2) {
return n1 + n2;
};
add.d.ts
declare module "add" {
function add(n1: number, n2: number): number;
export = add;
}
main.ts
/// <reference path='node.d.ts' />
/// <reference path='add.d.ts' />
import add = require('./add');
console.log(add(1, 2));
When I try to compile main.ts
, I got the following error:
error TS2306: File 'add.d.ts' is not an external module.
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code