Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bconnorwhite/types-tsconfig
Type checking for tsconfig.json
https://github.com/bconnorwhite/types-tsconfig
Last synced: about 2 months ago
JSON representation
Type checking for tsconfig.json
- Host: GitHub
- URL: https://github.com/bconnorwhite/types-tsconfig
- Owner: bconnorwhite
- Created: 2020-09-08T02:34:00.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-05-05T22:49:54.000Z (5 months ago)
- Last Synced: 2024-07-13T07:05:21.899Z (2 months ago)
- Language: TypeScript
- Size: 188 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
Type checking for tsconfig.json.
_If I should maintain this repo, please ⭐️_
_DM me on [Twitter](https://twitter.com/bconnorwhite) if you have questions or suggestions._
---
This package uses [zod]() to parse and type-guard a TSConfigJSON object.
## Installation
```sh
yarn add types-tsconfig
``````sh
npm install types-tsconfig
``````sh
pnpm add types-tsconfig
```## Usage
The `isTSConfigJSON` function is a type guard that checks if an object is a valid `TSConfigJSON` object.
```ts
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.
```ts
import { parseTSConfigJSON, TSConfigJSON } from "types-tsconfig";const config = {
invalid: "config"
};const result = parseTSConfigJSON(config); // undefined
```Additionally, a constant `fileName` is exported as "tsconfig.json":
```ts
import { fileName } from "types-tsconfig";console.log(fileName); // "tsconfig.json"
```
Dependencies
- [type-fest](https://www.npmjs.com/package/type-fest): A collection of essential TypeScript types
- [zod](https://www.npmjs.com/package/zod): TypeScript-first schema declaration and validation library with static type inference
Dev Dependencies
- [autorepo](https://www.npmjs.com/package/autorepo): Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.
License
[MIT](https://opensource.org/licenses/MIT) - _MIT License_
## Related Projects
- [types-json](https://www.npmjs.com/package/types-json): Type checking for JSON objects
- [types-pkg-json](https://www.npmjs.com/package/types-pkg-json): Type checking for package.json
- [types-eslintrc](https://www.npmjs.com/package/types-eslintrc): Type checking for .eslintrc.json