Ember CLI TypeScript Blueprints
Ember CLI TypeScript Blueprints is an Ember CLI addon designed to provide TypeScript-aware blueprints for generating standard Ember CLI entities, including those for `ember-source` and `ember-data`. This package, currently at version 3.0.0, historically filled a crucial gap by enabling developers to generate TypeScript files within Ember applications before native Ember CLI support for TypeScript blueprints was available. However, the project was archived in December 2022 and is no longer maintained, as recent versions of Ember CLI (starting from Ember 4.8.0 with RFC 0724 and 0800 implementations) now offer integrated, first-party TypeScript blueprint generation. Consequently, this addon is effectively abandoned, and new Ember projects or migrations should leverage Ember's native TypeScript capabilities. The package had an irregular release cadence, with its last major update seven years ago, reflecting its deprecation in favor of core framework features.
Common errors
-
Error: Cannot find module '@types/ember-data'
cause Missing `ember-data` type definitions or an incorrect type registry setup, especially if using older `ember-cli-typescript` versions with Ember Data.fixEnsure `@types/ember-data` (if applicable for your Ember version/setup) is installed. Verify your `types/<your-app>/index.d.ts` file properly extends the `ModelRegistry` for Ember Data models. For modern Ember, ensure you're using official types and correctly extending type definitions. -
error TS2344: Type 'any' does not satisfy the constraint 'never'.
cause This error often occurs when Ember Data's `ModelRegistry` is not properly populated with your application's models, causing TypeScript to infer `keyof ModelRegistry` as `never`.fixFor each of your Ember Data models, ensure you add code to extend the `ModelRegistry` in your `types/ember-data/ember-data.d.ts` (or similar) file. Example: `declare module 'ember-data/types/registries/model' { export default interface ModelRegistry { 'my-model': MyModel; } }` -
EACCES: permission denied, unlink '/path/to/node_modules/.bin/ember'
cause NPM or Yarn cache/permissions issues during addon installation, or conflicts if multiple blueprints attempt to install the same package.fixTry clearing your npm/yarn cache (`npm cache clean --force` or `yarn cache clean`). Delete `node_modules` and `package-lock.json` (or `yarn.lock`), then reinstall. If it's a permission error, ensure proper directory permissions or run with `sudo` (use cautiously).
Warnings
- breaking The `ember-cli-typescript-blueprints` package is officially archived and no longer maintained. Modern Ember CLI versions (4.8.0 and above) provide native TypeScript blueprint support, rendering this addon obsolete. Users should transition to the built-in `--typescript` flag for `ember new` and `ember generate` commands.
- breaking Using this addon with Ember versions 4.8.0+ and their official TypeScript types may lead to conflicts. The addon's underlying `ember-cli-typescript` integration (if used) might configure `@types` packages and Array prototype extensions which are incompatible with the stable, built-in types from `ember-source`.
- gotcha Older versions of `ember-cli-typescript` (the parent ecosystem for these blueprints) shifted to using Babel for TypeScript transpilation in v2. This introduced breaking changes, such as lack of support for `const enum`, which required code modifications.
Install
-
npm install ember-cli-typescript-blueprints -
yarn add ember-cli-typescript-blueprints -
pnpm add ember-cli-typescript-blueprints
Imports
- Ember CLI Commands
ember install ember-cli-typescript-blueprints ember generate <entity-type> <name>
Quickstart
/*
This package is largely obsolete. For new Ember projects or migrating existing ones to TypeScript,
it is recommended to use Ember CLI's native TypeScript support, available in recent Ember versions.
Historically, one would install and use it as follows:
*/
// 1. Install the addon (though deprecated, this shows historical installation):
npm install --save-dev ember-cli-typescript-blueprints
// or
yarn add --dev ember-cli-typescript-blueprints
// 2. The addon's blueprints would then override default JS blueprints.
// Generating an entity would produce a TypeScript file (.ts) instead of JavaScript (.js).
// Generate a service:
// This would create `app/services/user.ts`
ember generate service user
// Generate a component:
// This would create `app/components/user-profile.ts`, `app/templates/components/user-profile.hbs`,
// and potentially `tests/integration/components/user-profile-test.ts`
ember generate component user-profile
/* Example of a generated TypeScript component file (simplified structure):
// app/components/user-profile.ts
import Component from '@glimmer/component';
interface UserProfileArgs {
userName: string;
}
export default class UserProfileComponent extends Component<UserProfileArgs> {
// Access component arguments via this.args
get greeting(): string {
return `Hello, ${this.args.userName}!`;
}
}
*/