Avraam Mavridis Avraam Mavridis - 1 year ago 98
Javascript Question

Install npm package that does not have typings

I am using Typescript 2.1. I am trying to install an npm package that doesn't have typings (


If I do:

import * as Reactable from 'reactable'
typescript complains that cannot find this module.

If I do:

const Reactable = require('reactable')
typescript complains that
is forbidden.

If I do the weird syntax that suggested in another post:

import Reactable = require('reactable');
typescript complains that
assignment cannot be used to target es2015 modules.

Is there any way to import npm packages that do not have typings?

Answer Source

You'll need to declare something about what you're using. For example

declare module "reactable" {
    interface ReactableProps {

    interface ReactableState {

    class reactable extends React.Component< ReactableProps, ReactableState> { }

You can start with just what you're using and need the IDE to support, and slowly add things up.

You can check the Writing Declaration Files for more info on how to do so.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download