Create a New TypeScript Application
To start a new Ember project with TypeScript, add the --typescript flag when you run ember new:
ember new my-typescript-app --typescript
Using the --typescript flag changes the output of ember new in a few ways:
TypeScript Project Files
Project files will be generated with .ts extensions instead of .js.
Packages to Support TypeScript
In addition to the usual packages added with ember new, the following packages will be added at their current "latest" value:
typescript– tooling to support TypeScript type checking and compilation.@tsconfig/ember– a shared TypeScript configuration for Ember apps.@typescript-eslint/*– ESLint support for TypeScript.@types/qunit- TypeScript type definitions for QUnit.@types/rsvp- TypeScript type definitions for RSVP.@warp-drive/core-types- shared core types, type utilities and constants for the WarpDrive and EmberData packages.
Zoey says...
Files and Config to Support TypeScript
In addition to the usual files added with ember new, we also add:
tsconfig.json– configuration to set up TypeScript for your projecttypes/global.d.ts– the location for any global type declarations you need to writeapp/config/environment.d.ts– a basic set of types defined for the contents of yourconfig/environment.jsfile
Additionally:
package.jsonwill have alint:typesscript to check types with the command line.ember-cli-build.jswill be configured to transform TypeScript at build-time..ember-clihasisTypeScriptProjectset to true, which will force the blueprint generators to generate TypeScript rather than JavaScript by default..eslintrc.jswill be configured for TypeScript.
Convert an Existing App to TypeScript
To convert an existing app to TypeScript, you'll need to make the changes described above manually (for now). To facilitate this, we've included a converting guide.