Skip to content

TypeScript support

Compare
Choose a tag to compare
@oligriffiths oligriffiths released this 20 Mar 18:04
· 126 commits to master since this release

The future is here, today!

Broccoli now supports a Brocfile.ts, and will auto compile this through ts-node 🎉

By default, ts-node uses TypeScript defaults for the compiler options. If you wish to add your own compiler options to make things stricter, you can add a tsconfig.json of your own and Broccoli should auto pick this up.

So now:

import merge = require('broccoli-merge-trees');
import uglify = require('broccoli-uglify-sourcemap');
import { BrocfileOptions } from 'broccoli';

export default (options: BrocfileOptions) => {
  let js = 'src/a';

  if (options.env === 'production') {
    js = uglify(js);
  }

  return merge([js, 'src/b']);
}

Should work, and your editor should get access to the types it can find.
Over time, we will push for plugin developers to define at least a type definition, and provide documentation for how to convert a plugin to TypeScript

Thanks to everyone who helped in reviewing this.