I'd like to use Angular 2 with TypeScript in my Play project. I'm using the sbt-typescript
plugin and the angular2
WebJAR. When Play extracts the WebJAR, it puts it in target/web/public/main/lib/angular2
. What I should be able to do in my app/assets/js/components/test.ts
file is something like
import {Component} from 'angular2/core';
but tsc is unable to resolve that, and I don't see any setting to tell it where to look.
Is this even currently possible? Would having a child project for just the TypeScript stuff make it easier?
It is in fact currently possible to resolve Javascript/Typescript modules from your webjars dependencies. I've created a demo Play application that shows how.
See https://github.com/joost-de-vries/play-angular2-typescript
It uses a different sbt-typescript plugin that customises the module resolution. Thus working around the shortcoming that bpervan mentions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With