包详细信息

types-tsconfig

bconnorwhite17.3kMIT2.1.1

Type checking for tsconfig.json

tsconfig, json, types, type

自述文件

types-tsconfig

NPM TypeScript Coverage Status


Type checking for tsconfig.json.


If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


This package uses zod to parse and type-guard a TSConfigJSON object.

Installation

yarn add types-tsconfig
npm install types-tsconfig
pnpm add types-tsconfig

Usage

The isTSConfigJSON function is a type guard that checks if an object is a valid TSConfigJSON object.

import { isTSConfigJSON, TSConfigJSON } from "types-tsconfig";

const config = {
  $schema: "https://json.schemastore.org/tsconfig",
  extends: "@autosoft/tsconfig",
  compilerOptions: {
    outDir: ".auto/build",
    rootDirs: [
      "source"
    ]
  },
  files: [
    "source/index.ts"
  ]
};

if(isTSConfigJSON(config)) {
  // config is TSConfigJSON
}

The parseTSConfigJSON function parses an object into a TSConfigJSON object. If the object is a valid TSConfigJSON object, it will be returned, otherwise undefined will be returned.

import { parseTSConfigJSON, TSConfigJSON  } from "types-tsconfig";

const config = {
  invalid: "config"
};

const result = parseTSConfigJSON(config); // undefined

Additionally, a constant fileName is exported as "tsconfig.json":

import { fileName } from "types-tsconfig";

console.log(fileName); // "tsconfig.json"


Dependenciesdependencies

  • type-fest: A collection of essential TypeScript types
  • zod: TypeScript-first schema declaration and validation library with static type inference


Dev Dependencies

  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.


License license

MIT - MIT License

Related Projects

更新日志

2.1.0 (2024-04-30)

2.0.2 (2023-01-11)

Bug Fixes

  • remove unused dev dependency (ebc265a)

2.0.1 (2023-01-11)

Bug Fixes

  • export full TsConfigJson namespace (f426f50)

2.0.0 (2023-01-11)

1.2.1 (2021-07-10)

Bug Fixes

1.2.0 (2020-10-09)

Features

  • exported TSConfigFileName type (a92c60b)

1.1.2 (2020-09-19)

1.1.1 (2020-09-19)

1.1.0 (2020-09-09)