Practic TsConfig Builder - v1.0.0
    Preparing search index...

    Practic TsConfig Builder - v1.0.0

    @practic/tsconfig-builder

    A visual tsconfig.json editor for React, built from the official schema and validated by TypeScript itself.

    npm types license

    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.

    • 📚 Every option TypeScript reads: top-level fields, compilerOptions, watchOptions, typeAcquisition, and buildOptions, each with its schema documentation.
    • 🛡️ Validated by TypeScript. Values go through the compiler's public converters, and rejected edits show its message.
    • 🎛️ An editor for each type.
      • Choices are radios, and lists of choices (such as lib) are checkboxes.
      • Booleans, numbers and plain strings get their own controls.
      • String lists take one item per line, and objects such as paths take JSON.
    • 🔗 Linked preview. Every key in the generated file links to its option and opens it.
    • 🔤 Sorted output. Keys and order-free lists are alphabetical. Order-sensitive values keep their order.
    • 📋 Copy button for the generated file.
    • 🧩 Compound components. You own the layout, and the parts handle state, editing and validation.

    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.

    What validates each section
    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.
    • TypeScript normalises relative paths: ./src is written as src.
    • Aliases convert to the same value, so es6 is written as es2015.
    Known restrictions
    • ts-node options are left out: they configure another tool.
    • Options newer than the bundled TypeScript are listed but rejected when edited.
    • Raw HTML in the schema's documentation is shown as text.

    MIT © Felipe Penno. See LICENSE.