Skip to content

Latest commit

 

History

History
121 lines (89 loc) · 2.53 KB

File metadata and controls

121 lines (89 loc) · 2.53 KB
CleevioX Logo

TSCONFIG

NPM Version

TypeScript configuration used on CleevioX projects

Installation

bun add --dev @cleeviox/tsconfig typescript

In a monorepo, install the package in the root, then create configs in each workspace.

Usage

Use one of the following configurations by creating a tsconfig.json file relative to its root based on your need:

Library

Used for workspaces, which contain pieces of code, which are meant to be reusable, for instance packages/utils.

{
  "extends": "@cleeviox/tsconfig/library",
  "include": ["**/*.js", "**/*.ts", "**/*.tsx"],
  "exclude": ["dist", "node_modules"]
}

If you intend to distribute your workspace, you should also add a tsconfig.build.json file, which actually emits files:

{
  "compilerOptions": {
    "noEmit": false,
    "outDir": "./dist",
    "rootDir": "./src"
  },
  "extends": "./tsconfig.json",
  "include": ["./src"],
  "references": []
}

Then build your package by specifying which config to use:

# package.json
"scripts": {
    "build": "tsc --build tsconfig.build.json"
  }

App

Used for react applications.

{
  "extends": "@cleeviox/tsconfig/app",
  "include": ["**/*.js", "**/*.ts", "**/*.tsx"],
  "exclude": ["build", "node_modules"]
}

Node.js

Used for nodejs projects which do not rely on any frameworks. For nestjs use this config

{
  "extends": "@cleeviox/tsconfig/nodejs",
  "include": ["**/*.js", "**/*.ts", "**/*.tsx"],
  "exclude": ["build", "node_modules"]
}

Next.js

Used for nestjs projects:

{
  "extends": "@cleeviox/tsconfig/nextjs",
  "include": [".next/types/**/*.ts", "**/*.js", "**/*.ts", "**/*.tsx"],
  "exclude": [".next/**/*.js", "node_modules"]
}

Nest.js

Used for nextjs projects:

{
  "extends": "@cleeviox/tsconfig/nestjs",
  "include": ["**/*.js", "**/*.ts"],
  "exclude": ["build", "node_modules"]
}

Root

If your project is a monorepo, use this configuration for the project root only. Every subsequent workspace then has its own tsconfig.json file, chosen from the above configs based on its purpose.

{
  "extends": "@cleeviox/tsconfig",
  "include": ["./*.js", "./*.ts"],
  "exclude": ["node_modules"]
}