How to use typescript modules w/ browserify?

一曲冷凌霜 提交于 2019-12-05 06:10:51

You can fix this for any class by making declarations which tell Typescript how to parse an external class.

Fortunately for you, this has already been done for a large number of libraries.

Include this as a reference in your file.

https://github.com/borisyankov/DefinitelyTyped/tree/master/browserify

Thanks to @AlexB for his reply. Adding the def to the top of my app.ts like I show below solved this issue

///<reference path='../typings/node.d.ts' />

var Hello:any = require('hello.js').Hello;

Update

It's also worth a mention ... if you don't want/care to have the typing information you can omit it as follows

declare var require:any;

var Hello:any = require('hello.js').Hello;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!