Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Anyone has luck with Browserify + TypeScript while keeping source maps pointing correctly back to TypeScript? (or any other JS transpiler)


I recently also started using Browserify with Typescript (along with tds to get some ambient files for popular libraries). I got it to work after tryping countless of hacky things.

What I ended up with was a seperate ts file that is just the module, and variables I export. See this:

http://jsbin.com/gidaneja/1/edit?js,output

So I do a "<reference path=" for the ambient paths of variables. Then I declare require so I can call browserify's require. Then I create a function with it's return type being used based on ambient files I included. Then I create an export variable and call the function to set it's value. Then I can use that variable without a problem everywhere.

I tried using the whole "import lodash = require('lodash.d.ts') thing and other variations and failed miserably. This is the only thing I got to work, and its working perfectly. Email me (email should be on my profile) if it's not clear, I know the explanation was kinda vague.


Awesome, thanks! will try it :)


Happy to help. Let me know how it goes.


What problems are you having exactly? Sourcemaps work great over here.


Here is the SO question I created for this issue with more details: http://stackoverflow.com/questions/23453160/keep-original-ty...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: