czerny czerny - 5 months ago 126
Node.js Question

How to import node module in Typescript without type definitions?

When I try to import node.js module in Typescript like this:

import co = require('co');
import co from 'co';


without providing type definitions, both lines reports same error:

error TS2307: Cannot find module 'co'.


How to import it correctly?

Answer

The trick is to use purely JavaScript notation:

const co = require('co');
Comments