Widgets
@practic/bui
@practic/bui
@practic/persist
@practic/bui-theme-editor
@practic/passkey
@practic/force-directed
@practic/force-directed
@practic/force-directed
Visual tsconfig.json editor built from the official schema and validated by TypeScript.
@practic/tsconfig-builderv1.0.0Demo ↗API docs ↗
A visual tsconfig.json editor for React, built from the official schema and validated by TypeScript itself.
tsconfig.json has hundreds of options, spread over five sections, with documentation in another tab and mistakes
found only when the compiler runs. This package puts every option on one page, with an editor suited to its type and
its documentation beside it. Every edit goes through TypeScript's own converters. Invalid values are refused with
TypeScript's message, and what the live preview shows is what TypeScript accepts.
npm install @practic/tsconfig-builder @practic/bui @base-ui/react react react-dom
Or bun add, pnpm add, yarn add.
import { Collapsible } from '@practic/bui'
import { tsConfigGetAnchorId, TsConfigBuilder, tsConfigSections, type TsConfig } from '@practic/tsconfig-builder'
import '@practic/bui/themes/barebones.css'
import { useState } from 'react'
export function TsConfigEditor() {
// typed explicitly: inferred from this literal, the state would be too narrow for `setConfig`
const [config, setConfig] = useState<TsConfig>({ compilerOptions: { strict: true } })
return (
<TsConfigBuilder.Root
config={config}
setConfig={setConfig}
>
<TsConfigBuilder.Output />
{tsConfigSections.map((section) =>
section.properties.map((property) => (
<TsConfigBuilder.Option
key={property.path}
path={property.path}
>
{/* the id the preview's links scroll to */}
<TsConfigBuilder.OptionDisclosure id={tsConfigGetAnchorId(property.path)}>
<Collapsible.Trigger>
<TsConfigBuilder.OptionLabel />
</Collapsible.Trigger>
<Collapsible.Panel>
<TsConfigBuilder.OptionControl />
<TsConfigBuilder.OptionReset />
<TsConfigBuilder.OptionError />
<TsConfigBuilder.OptionDocs />
</Collapsible.Panel>
</TsConfigBuilder.OptionDisclosure>
</TsConfigBuilder.Option>
)),
)}
</TsConfigBuilder.Root>
)
}
To use the complete editor, with layout, anchors and saved state, render Demo from
@practic/tsconfig-builder/demo instead.
compilerOptions, watchOptions, typeAcquisition, and
buildOptions, each with its schema documentation.lib) are checkboxes.paths take JSON.Import from @practic/tsconfig-builder.
| Part | Renders |
|---|---|
TsConfigBuilder.Root | No DOM. Controlled: config: TsConfig and setConfig: (config: TsConfig) => void. |
TsConfigBuilder.Option | No DOM. Scopes the option parts to one schema path, such as compilerOptions.target. |
TsConfigBuilder.OptionDisclosure | A collapsible card the preview's links open; it has data-set while the option has a value. |
TsConfigBuilder.OptionLabel | The path and its type, such as compilerOptions.strict: boolean. |
TsConfigBuilder.OptionControl | The editor for the option's type. |
TsConfigBuilder.OptionReset | Unsets the option. |
TsConfigBuilder.OptionError | Why TypeScript rejected the last edit, until an edit is accepted. |
TsConfigBuilder.OptionDocs | The option's documentation, rendered from Markdown. |
TsConfigBuilder.Output | The generated tsconfig.json, with linked keys and a copy button. |
| Helper | Description |
|---|---|
tsConfigSections | The options grouped by section, sorted, ready to map into Options. |
tsConfigParseJson(json) | Validates a tsconfig.json object: { config: TsConfig, errors: string[] }. |
tsConfigToJson(config) | Spells a TsConfig as the file would be written. |
tsConfigGetAnchorId(path) | The element id the preview links to for an option or section. |
TsConfig uses TypeScript's own types (CompilerOptions, WatchOptions, …), with enum values as TypeScript holds
them. Use tsConfigParseJson and tsConfigToJson to convert from and to the file's spelling, such as when saving.
The helpers and their types are also exported from @practic/tsconfig-builder/core, which holds no React, for server code
and scripts that read, check or write a tsconfig.json.
Peer dependencies: react and react-dom 19. The controls come from @practic/bui, which needs
@base-ui/react, and a theme such as @practic/bui/themes/barebones.css.
Tailwind CSS 4. The parts lay themselves out with Tailwind classes. Point your Tailwind stylesheet at the package, with the path relative to that stylesheet:
@import 'tailwindcss';
@source '../node_modules/@practic/tsconfig-builder';
Anchors. The preview links to # plus tsConfigGetAnchorId(path). Put those ids on your option cards, as
OptionDisclosure's id, and on section headings.
Bundle size. Validation runs the TypeScript compiler in the browser, so the package carries it: about 5 MB, or
1.1 MB gzipped. That suits tooling pages, but load it lazily (React.lazy) on pages that need to stay light.
| Section | Validated by |
|---|---|
compilerOptions | ts.convertCompilerOptionsFromJson |
typeAcquisition | ts.convertTypeAcquisitionFromJson |
watchOptions, references, files, include, exclude, compileOnSave | ts.parseJsonConfigFileContent, with no file system |
extends | A local check: a string, or a list of strings. |
buildOptions | A local check: booleans. TypeScript has no converter for it. |
./src is written as src.es6 is written as es2015.ts-node options are left out: they configure another tool.MIT © Felipe Penno. See LICENSE.