
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
delta-tsc-check
Advanced tools
English Documentation | 中文文档 | demo
Incremental detection tool based on TSC implementation
In modern development and build environments, developers often adopt compilers not implemented in JavaScript, such as esbuild, to improve compilation speed and efficiency. While these tools indeed provide a lightning-fast compilation experience, they typically lack TypeScript (TS) type checking capabilities. This means TypeScript type-related errors may not be caught during the compilation stage, potentially leading to an accumulation of type issues in the codebase.
To address this pain point, the tsc-check tool was created. It focuses on providing fast, incremental TypeScript type checking to ensure all type errors are caught before code commits or merges.
Incremental code checking during the pre-commit stage:
tsc-check for incremental checking, which only checks the types of changed files. This significantly reduces the time spent checking while ensuring each commit is type-safe.lint-staged, tsc-check can be run automatically during the commit stage to ensure code quality.Command-line individual file check:
tsc-check, it is easy to perform type checking on a single file.。Code validation on the pipeline::
tsc-check can be used as a step on the pipeline to perform type checking.npm i delta-tsc-check -D
npx tsc-check --files a.ts b.ts src/*.ts
// lint-staged.config.cjs
const path = require('path');
const { performMultiTSCheck } = require('delta-tsc-check');
const eslintignorePath = path.join(__dirname, '.eslintignore');
module.exports = {
'**/*.{ts,tsx}': async (filenames) => {
// Generate tsc-related execution commands
const commands = await performMultiTSCheck({ filenames, lintstaged: true });
// Other commands such as eslint
if (commands) {
commands.push(`prettier ${filenames.join(' ')} --write`);
commands.push(`eslint --ignore-path ${eslintignorePath} ${filenames.join(' ')} --fix --quiet --cache`);
return commands;
}
},
};
The configuration file is named tsc-check.config.json, which can mainly be used to configure
// tsc-check.config.json
{
"include": [], // Generally global declaration files. Refer to the include field of tsconfig.json
"debug": true, // Debugging mode
"monorepo": true, // Whether it is a monorepo
}
Usage instructions for the performMultiTSCheck API
performMultiTSCheck is a function that executes multiple TypeScript checks within the lint-staged hook. This function belongs to the delta-tsc-check library, which allows you to run the TypeScript compiler (tsc) to check for type errors when code changes and compiles only changed files for improved performance.
import { performMultiTSCheck } from 'delta-tsc-check';
// 函数签名
async function performMultiTSCheck({
filenames
lintstaged = false
debug = false
include = []
}): Promise<{ commands?: string[], error: Error }> {
// ...
}
string[]): An array of filenames that need TypeScript checking.boolean): Whether to run in a lint-staged environment. If true, the function will return a command array compatible with lint-staged.commands and error properties. commands is an array of strings that includes the commands to be executed.Usage instructions for the tsc-check
tsc-check is a command-line tool for performing type checking with the TypeScript compiler (tsc), and it can be integrated with lint-staged to perform type checking only on changed files. It offers several options to customize the execution behavior.
tsc-check [options]
--files, -f
--debug, -d
--debug--lintstaged, -l
lint-staged environment. This will adjust the command's output and behavior to be compatible with lint-staged.--lintstagedtsc-check --files myfile.ts
tsc-check --files file1.ts file2.ts
// or
tsc-check --files *.ts
If you have used tsc-check in your lint-staged configuration, you can specify the options like this:
{
- "*.{ts,tsx}": ["tsc-check --lintstaged --files"]
+ "*.{ts,tsx}": ["tsc-check --files"]
}
tsc-check --files myfile.ts --debug
FAQs
Incremental detection tool based on TSC implementation
The npm package delta-tsc-check receives a total of 1 weekly downloads. As such, delta-tsc-check popularity was classified as not popular.
We found that delta-tsc-check demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.