2.0.1 • Published 9 months ago

ts-check-files v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

tscf

结合 lint-staged 使用 Typescript Compiler API 对 git 改动的文件进行类型检测

使用

1. lint-staged

.lintstagedrc.json

{
  "*.ts?(x)": "tscf"
}

2. lefthook

lefthook.yaml

pre-commit:
  parallel: true
  commands:
    tsc:
      glob: "*.{ts,tsx}"
      run: npx --no-install tscf {staged_files}

安装

npm install ts-check-files -D

cli

1. 语法

tscf [<file> <glob> ...] [--cwd <directory>]

2. 使用

tscf src/a.ts src/b.ts

nodejs api

1. 类型声明

declare function tscf(args: {
  files: string[];
  cwd?: string;
}): Promise<[null, string] | [string, null]>;

2. 使用

import tscf from "ts-check-files";

const [error, message] = await tscf({
  files,
  cwd,
});

if (error) {
  console.error(error);
  process.exit(1);
}

console.log(message);
2.0.1

9 months ago

2.0.0

9 months ago

1.0.1

10 months ago

1.0.0

10 months ago