Reputation: 11444
I have a large project that is mostly JavaScript. I would like to add some TypeScript. Things are mostly working fine. However, I have a large number of paths aliases and packages. So, when I
import foo = require('foo');
This will, in runtime, rely on a path configuration, say
require.config({
paths: {
foo: 'foobar/baz/js/quux'
}
});
So, predictably, the compiler gives me:
error TS2307: Cannot find module 'foo'
Is there any way that I could load in my requirejs configuration so that the compiler will be happy? Alternatively, is there a way that I suppress/ignore the error? The output JavaScript looks and runs fine. If I suppress the error, I wonder what I would be losing ... Can I specify where to find all my modules?
Upvotes: 0
Views: 197
Reputation: 997
You can declare your own module in a definition file:
// my-modules.d.ts
declare module "foo" {
}
This way, gulp-typescript will not complain as long as the my-modules.d.ts
file compiles with the rest.
Upvotes: 1
Reputation: 276269
is there any way that I could load in my requirejs configuration so that the compiler will be happy?
Not yet. Look out for https://github.com/Microsoft/TypeScript/issues/5039
Alternatively, is there a way that I suppress/ignore the error?
Only if you want to be completely unsafe aka any
:
var foo:any = require('foo');
Upvotes: 0