@onerepo/plugin-typescript
Let oneRepo handle running TypeScript across Workspaces.
Avoid potential mistakes when using project references, this plugin will automatically ensure references across all tsconfig.json files are kept in sync for every run.
Installation
Section titled “Installation”npm install --save-dev @onerepo/plugin-typescriptyarn add --dev @onerepo/plugin-typescriptpnpm install --save-dev @onerepo/plugin-typescriptConfiguration
Section titled “Configuration”typescript()
Section titled “typescript()”function typescript(opts): Plugin;Include the typescript plugin in your oneRepo plugin setup:
import { typescript } from '@onerepo/plugin-typescript';
export default { plugins: [typescript()],};Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
opts | Options |
Options
Section titled “Options”type Options = { name?: string; tsconfig?: string; useProjectReferences?: boolean;};Options for configuring the TypeScript plugin for oneRepo.
export default { plugins: [ typescript({ tsconfig: 'tsconfig.base.json', }), ],};Properties
Section titled “Properties”optional name: string;The name of the typescript command.
- Default:
['tsc', 'typescript', 'typecheck']
tsconfig?
Section titled “tsconfig?”optional tsconfig: string;Use a different filename than the default tsconfig.json for type checking by default. This can always be overridden by passing --tsconfig=<filename> as an argument to the command.
- Default:
'tsconfig.json'
useProjectReferences?
Section titled “useProjectReferences?”optional useProjectReferences: boolean;Use TypeScript Project References. Setting to true will automatically sync dependency project references to your tsconfig.
- Default:
false
Recommended tasks
Section titled “Recommended tasks”import type { Config } from 'onerepo';
export default { tasks: { 'pre-commit': { serial: ['$0 tsc'], }, 'pre-merge': { serial: ['$0 tsc'], }, },} satisfies Config;Commands
Section titled “Commands”one tsc
Section titled “one tsc”Aliases: one typescript, one typecheck
Sync TS project references
one tsc [options...]Checks for the existence of tsconfig.json file and batches running tsc --noEmit in each Workspace.
| Option | Type | Description |
|---|---|---|
--affected | boolean | Select all affected Workspaces. If no other inputs are chosen, this will default to true. |
--all, -a | boolean | Run across all Workspaces |
--pretty | boolean, default: true | Control TypeScript’s --pretty flag. |
--staged | boolean | Use files on the git stage to calculate affected files or Workspaces. When unset or --no-staged, changes will be calculated from the entire branch, since its fork point. |
--workspaces, -w | array | List of Workspace names to run against |
Advanced options
| Option | Type | Description |
|---|---|---|
--from-ref | string | Git ref to start looking for affected files or Workspaces |
--show-advanced | boolean | Pair with --help to show advanced options. |
--through-ref | string | Git ref to start looking for affected files or Workspaces |
--tsconfig | string, default: "tsconfig.json" | The filename of the tsconfig to find in each Workspace. |
--use-project-references, --project-references, --project-refs | boolean | Automatically sync and use typescript project references |