@langri-sha/tsconfig
v3.0.0
Published
A set of TypeScript configuration files, focused on type-checking all your TypeScript and JavaScript modules
Maintainers
Readme
@langri-sha/tsconfig
Shared TypeScript configurations that type-check TypeScript and JavaScript alike, with variants for monorepos, React and Emotion.
Usage
Install the necessary dependencies:
npm install -D typescript @langri-sha/tsconfigThen extend the base configuration:
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@langri-sha/tsconfig"
}To combine configurations, list them in this order — later entries win:
- A base:
@langri-sha/tsconfig,@langri-sha/tsconfig/project.jsonfor a package inside a monorepo, or@langri-sha/tsconfig/build.jsonfor a library that emits, React or Emotion ones included. @langri-sha/tsconfig/react.jsonfor React.@langri-sha/tsconfig/emotion.jsonfor Emotion, which also needsreact.json.
For example, an Emotion app inside a monorepo:
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": [
"@langri-sha/tsconfig/project.json",
"@langri-sha/tsconfig/react.json",
"@langri-sha/tsconfig/emotion.json"
]
}The monorepo's root tsconfig.json extends the base and lists each package as a
project reference:
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@langri-sha/tsconfig",
"references": [{ "path": "./packages/app" }]
}Strictness and module options
TypeScript 6 or 7 is required. On top of their defaults, which include strict,
the base sets, among others:
verbatimModuleSyntax: import types with atypemodifier. An import whose every named binding is an inlinetype, as inimport { type Name } from 'module', still leavesimport {} from 'module'in the output;import type { Name } from 'module'drops it.erasableSyntaxOnly: no enums, namespaces with values, parameter properties or angle-bracket type assertions. Set it tofalsein a package that needs them.noImplicitReturnsandmoduleDetection: "force".lib: ["ES2025"], which doesn't declare APIs Node 24 lacks, such asTemporal.
Emitting
The base only type-checks. It doesn't set rootDir, which TypeScript 6 no
longer infers, so a project that emits through it fails with TS5011 when its
sources sit in a subdirectory such as src. A project that emits JavaScript or
declarations extends @langri-sha/tsconfig/build.json instead, which sets
rootDir to src:
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@langri-sha/tsconfig/build.json",
"include": ["src"]
}See
Contributing
See CONTRIBUTING.md in langri-sha/github.
