Skip to content

@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.

Install via npm
npm install --save-dev @onerepo/plugin-typescript
function typescript(opts): Plugin;

Include the typescript plugin in your oneRepo plugin setup:

onerepo.config.ts
import { typescript } from '@onerepo/plugin-typescript';
export default {
plugins: [typescript()],
};
ParameterType
optsOptions
type Options: {
name: string;
tsconfig: string;
useProjectReferences: boolean;
};

Options for configuring the TypeScript plugin for oneRepo.

onerepo.config.js
export default {
plugins: [
typescript({
tsconfig: 'tsconfig.base.json',
}),
],
};
optional name: string;

The name of the typescript command.

  • Default: ['tsc', 'typescript', 'typecheck']
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'
optional useProjectReferences: boolean;

Use TypeScript Project References. Setting to true will automatically sync dependency project references to your tsconfig.

  • Default: false
./onerepo.config.ts
import type { Config } from 'onerepo';
export default {
tasks: {
'pre-commit': {
serial: ['$0 tsc'],
},
'pre-merge': {
serial: ['$0 tsc'],
},
},
} satisfies Config;

Aliases: one typescript, one typecheck

Sync TS project references

Terminal window
one tsc [options...]

Checks for the existence of tsconfig.json file and batches running tsc --noEmit in each Workspace.

OptionTypeDescription
--affectedbooleanSelect all affected Workspaces. If no other inputs are chosen, this will default to true.
--all, -abooleanRun across all Workspaces
--prettyboolean, default: trueControl TypeScript’s --pretty flag.
--stagedbooleanUse 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, -warrayList of Workspace names to run against
Advanced options
OptionTypeDescription
--from-refstringGit ref to start looking for affected files or Workspaces
--show-advancedbooleanPair with --help to show advanced options.
--through-refstringGit ref to start looking for affected files or Workspaces
--tsconfigstring, default: "tsconfig.json"The filename of the tsconfig to find in each Workspace.
--use-project-references, --project-references, --project-refsbooleanAutomatically sync and use typescript project references