Pregunta

The code runs, but the compile error is driving me nuts.

I have got the following line in my .ts file. Unfortunately the LINQ library does not yet have a d.ts file. So it's causing compile error, even though the javascript runs as designed.

import linq = require('linq');

Which is defined already in require.js bootstrap as follow:

define('linq', ['jquery','linq'], function($,linq) {
    return Enumerable; });

I don't need typescript to act like it knows more than the coder. If that's the case might as well throw it aside and stick with native javascript. Again the code works, but the compile check does not.

Any idea how to fix my code or tell the ts compiler to get outta the way?

¿Fue útil?

Solución

Just do the following

declare module 'linq'{
   var foo:any;
   export = foo;
}

in a new .d.ts and then you are good to go.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top