Reputation: 45451
I have a bunch of autogenerated modules that i need to reference from my typescript files.
Eg
import test = require('../templates/test')
I am generating CommonJS modules with ES5 output.
So I cant use amd-dependency
(since that works for amd modules only).
And I also cannot manually declare the module since 1. it is autogenerated and 2. it has a relative path.
Typescript 1.6 currently shows an error saying it 'Cannot find module'. How do i make it suppress this error and import?
Upvotes: 7
Views: 6129
Reputation: 558
If you want to use TypeScript imports (which are just ES6 imports), you could use this:
import * as test from '../templates/test';
and then call your API like this:
let foo = test.MY_API;
Upvotes: 0
Reputation: 276199
How do i make it suppress this error and import
If you are sure that the require
statement is valid and want to switch off any type checking on the import, you can just use node.d.ts
and do:
var test = require('../templates/test')
ie. just use var
instead of import
.
Upvotes: 9