czerny czerny - 1 year ago 201
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 Source

The trick is to use purely JavaScript notation:

const co = require('co');