1.0.0-typescript-configs-beta.22 • Published 5 years ago

typescript-configs-beta v1.0.0-typescript-configs-beta.22

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

@shopify/typescript-configs

In TypeScript, the configuration file can extend from a base file. This package provided a few common base configuration files to simplify TypeScript project setup.

To read more about how this extensibility works. See typescript hadnbook.

Below are two documentation we have also found useful to have on hand while setting up a configuration file.

Installation

$ yarn add --dev @shopify/typescript-configs

Usage

React Application Project

To start, create a tsconfig.json in the root of your project.

A typical setup where the application sit in [project root]/app folder is as follow:

{
  "extends": "./node_modules/@shopify/typescript-configs/application.json",
  "compilerOptions": {
    "baseUrl": ".",
    "rootDir": ".",
    "paths": {"*": ["*", "app/*"]}
  },
  "include": ["./app/**/*", "./client/**/*", "./server/**/*", "./tests/**/*"]
}

React Library Project

Similarly for a react library project. Create a tsconfig.json in the root of your project with a setup below assuming the library code sit in [project root]/src folder.

{
  "extends": "./node_modules/@shopify/typescript-configs/library.json",
  "compilerOptions": {
    "baseUrl": "./src",
    "rootDir": "."
  },
  "include": ["./src/**/*"]
}

Project that run in the browser

A configuration file is provided that included styles setup and a more conservative build target.

{
  "extends": "../node_modules/@shopify/typescript-configs/dom.json",
  "compilerOptions": {
    "baseUrl": ".",
    "rootDir": "."
  }
}

All Other Project

A base configuration file is also provided if the above does not fit your need.

{
  "extends": "../node_modules/@shopify/typescript-configs/base.json",
  "compilerOptions": {
    "baseUrl": ".",
    "rootDir": "."
  }
}