6
votes

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?

2
Seems like a pathing issue. If not, can you provide a brief example from the auto generated modules and mention the paths they are saved relevant to the file that uses them?AlexStack
it is not a pathing issue. as i described, the issue simply is that a 'typescript' module has not been declared for the above module, which is obvious since it was auto generated. the question asks how to suppress typescript errors for modules without typescript definition.pdeva

2 Answers

8
votes

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.

0
votes

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;