Closed
Description
I am working with typescript 1.6.2 and trying to write some newer sections of code with it. The problem is, I need to consume other native JavaScript code I have already writen and am not prepared to convert to TypeScript just yet.
So I would like to do something like this (where lib/helper.js is a file I'm not ready to convert to TS yet):
var helper = require('../lib/helper');
When I try to compile this, I get an error: error TS2304: Cannot find name 'require'
To get around this I add:
declare function require(path: string) : any;
var helper = require('../lib/helper');
Is there a way to have TypeScript use an untyped common JS file without this "hack"? Without it, it seems that TypeScript is only good for new projects or 100% adoption. I would like to see a path that allows me to casually convert my very large project to it a piece at a time.