@prosomo/typescript-config
v2.2.0
Published
Shared extensible TypeScript configurations for Prosomo.
Downloads
3
Readme
@prosomo/typescript-config
Shared extensible TypeScript configurations for Prosomo.
Available configs
@prosomo/typescript-config/base.json
@prosomo/typescript-config/react.json
@prosomo/typescript-config/react-app.json
@prosomo/typescript-config/react-library.json
@prosomo/typescript-config/node.json
@prosomo/typescript-config/node-library.json
Installation
With pnpm
pnpm add --dev typescript @prosomo/typescript-config
With Yarn
yarn add --dev typescript @prosomo/typescript-config
With npm
npm install --save-dev typescript @prosomo/typescript-config
If you need Node.js support, also install @types/node
.
If you need React support, also install @types/react
.
Usage
Create a tsconfig.json
file at the root of your project, and add the desired config to the extends
parameter. See the tsconfig Docs for more details.
{
"extends": "@prosomo/typescript-config/base.json"
}
Now you can run TypeScript checks by adding a checking script to your package.json
. See the tsc CLI docs for more details.
{
"scripts": {
"check": "tsc --noEmit"
}
}
Run it:
With pnpm
pnpm check
With Yarn
yarn check
With npm
npm run check
Examples
React application
{
"extends": "@prosomo/typescript-config/react-app.json",
"compilerOptions": {
"baseUrl": "./src",
"rootDir": ".",
"paths": {
"$assets": ["assets"],
"$components": ["components"],
"$hooks": ["hooks"],
"$routes": ["routes"],
"$utils": ["utils"]
}
},
"include": ["./src/**/*"]
}
React library
This example config is assuming the library code sits in the [project root]/src
folder.
{
"extends": "@prosomo/typescript-config/react-library.json",
"compilerOptions": {
"baseUrl": "./src",
"rootDir": ".",
"outDir": "./dist"
},
"include": ["./src/**/*"]
}
Other Node projects
This config can be useful for backend servers.
{
"extends": "@prosomo/typescript-config/node.json",
"compilerOptions": {
"baseUrl": "./src",
"rootDir": ".",
"outDir": "./dist"
},
"ts-node": {
"transpileOnly": true
},
"include": ["./src/**/*"]
}