I am consuming a React component called shiitake from npm into my project where I use TypeScript. That library does not have TypeScript declarations so I thought I would write o
The declaration declare module 'shiitake';
should be in a global scope. i.e. a top level declaration in a non module (where a module is a file with at least one top level import
or export
).
A declaration of the form declare module '...' { }
in a module is an augmentation. For more details see Typescript Module Augmentation.
So you want this file to look like:
declare module 'shiitake' {
import * as React from 'react';
export interface ShiitakeProps {
lines: number;
}
export default class Shiitake extends React.Component {
}
}