ember-cli-typescript provides specialized CLI commands for managing TypeScript declaration files during addon publishing workflows.
Generates TypeScript declaration files from TypeScript sources in preparation for publishing. This command is essential for addon authors who want to publish type definitions along with their compiled JavaScript.
interface PrecompileCommand {
name: "ts:precompile";
works: "insideProject";
description: "Generates declaration files from TypeScript sources in preparation for publishing.";
availableOptions: Array<{ name: "manifest-path"; type: StringConstructor; default: "dist/.ts-precompile-manifest" }>;
run(options: { manifestPath: string }): Promise<void>;
}Usage:
# Generate declaration files with default manifest path
ember ts:precompile
# Generate declaration files with custom manifest path
ember ts:precompile --manifest-path=custom/path/manifest.jsonProcess:
Requirements:
Cleans up compiled JavaScript and declaration files that were generated by the ts:precompile command. Uses the manifest file to know exactly which files to remove.
interface CleanCommand {
name: "ts:clean";
works: "insideProject";
description: "Cleans up compiled JS and declaration files generated by `ember ts:precompile`.";
availableOptions: Array<{ name: "manifest-path"; type: StringConstructor; default: "dist/.ts-precompile-manifest" }>;
run(options: { manifestPath: string }): void;
}Usage:
# Clean files using default manifest path
ember ts:clean
# Clean files using custom manifest path
ember ts:clean --manifest-path=custom/path/manifest.jsonProcess:
ts:precompileHelper function for creating type-safe Ember CLI command configurations.
/**
* Configuration helper for defining Ember CLI commands with proper typing
* @param options - Command configuration object
* @returns Same configuration object with proper typing
*/
function command<T extends ExtendOptions<Command>>(
options: T & ExtendThisType<Command, T>
): T;Usage Example:
import { command } from "ember-cli-typescript/ts/lib/utilities/ember-cli-entities";
export default command({
name: "my-command",
works: "insideProject",
description: "My custom command",
run() {
// Command implementation
}
});// Default path for the precompile manifest file
const PRECOMPILE_MANIFEST: "dist/.ts-precompile-manifest";These commands are typically integrated into addon publishing workflows:
package.json scripts:
{
"scripts": {
"prepack": "ember ts:precompile",
"postpack": "ember ts:clean"
}
}This ensures declaration files are generated before publishing and cleaned up afterward, keeping the development directory clean while providing types to consumers.