Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import in Typescript without module declaration

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?

like image 355
pdeva Avatar asked Sep 20 '15 07:09

pdeva


Video Answer


1 Answers

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.

like image 158
basarat Avatar answered Oct 22 '22 01:10

basarat