Thoughts on mixing typescript & js code in Ionic 2

beta.17
I was wondering if someone has gone down the path where they are developing the app using both JS as well as typescript. Currently the webpack definition from the templates compiles either only ts or only js. I realize with beta.18 this will change with the move from webpack to browserify. Want to hear comments from other ionites if they have broached this topic before.

What’s the need of just JS or TS? JS is valid TS so you could just write all in JS even if the ext of file is TS.

No concerns there… I was wondering how the build steps will behave.

Personally i will not be able to move to Browserify, nor i want to, that step is for new users to start easy into Ionic 2 and webpack is too powerful to go back.

The advantages to using the webpack approach is the amount of control you can have over the build process when it comes to a big app, be it generating chunks or one bundle file alone.

Also i think you can mix up TS and JS with webpack but Ionic 2 isn’t yet configured for it, though i’m not sure.

I think everything will work fine. I see both .ts and .js stanzas in the stock webpack.config.js, and you are already bringing in some .js such as the es6-shim library. I can’t think of any reason why .js in your project sources would be treated any differently.

I think the difference is when you import, for example i import TS files like:

import {TsClass} from 'tsFolder/tsFile';

But third party libraries like d3 in JS format are like:

import * as d3 from 'd3';

And i have saw the classic style somewhere, tough idk how would it play with the scope of variables:

var extLib = require('pathTo/extLib');