Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does TypeScript module resolution in Play work?

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?

like image 909
Isvara Avatar asked Nov 09 '22 21:11

Isvara


1 Answers

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.

like image 157
Joost de Vries Avatar answered Nov 15 '22 06:11

Joost de Vries