Skip to content Skip to sidebar Skip to footer

How To Extends Class From Other Js File Without Declaration File

3th Javascript Lib // publish at npm event-emitter export default class EventEmitter{ emit(){ // do something } on(){ // do something } } Typescript File import Ev

Solution 1:

In order to suppress the type check errors you will need to provide a declaration file to TypeScript. If you use popular npm packages the chances are very high that you can find the typings for it on DefinitelyTyped.

You can install DefinitelyTyped typings from their npm @typings private package for TypeScript 2.x or use the typings package manager for TypeScript 1.x.

Example:

// for TypeScript 2.x or you can still use typings
npm install @types/angularjs

// for TypeScript 1.x
npm install -g typings
typings install angularjs --save

In case you can't find typings for your package, you can easily write them. Just follow this guide from the TypeScript documentation on how to write declaration files.

Afterwards, feel free to publish them! The community will be really thankful.

Cheers!

Post a Comment for "How To Extends Class From Other Js File Without Declaration File"