This project is designed to enable the JSDoc @throws
type-checking and documentation-enforcement rules provided by eslint-plugin-explicit-exceptions to be used with frequently used functions and libraries.
# For @types/*, i.e. @types/node
npm install --save-dev @types-with-exceptions/node
# For built-in lib replacement
npm install --save-dev @types-with-exceptions/lib
tsconfig.json
{
// ...
+ "typeRoots": [
+ "node_modules/@types",
+ "node_modules/@types-with-exceptions"
+ ],
+ "libReplacement": true,
// ...
}
You can either open an issue to request work or create a PR with your changes.
To open an issue: Click New issue, then include the target package name and example code in your issue.
To submit a PR: Follow the steps below.
- Fork repository
- Check if the package you want to modify exists in the
types
directory.- If it does not exist, add the desired package to the
registry.yaml
file. - Run
pnpm run sync
to apply the changes.
- If it does not exist, add the desired package to the
- Modify the relevant
*.d.ts
file(s) in thetypes
directory and commit. - (Optional) Add tests in the
tests
directory. Refer to rule-tester. - Create a PR.
# Simplified
node: 'npm:@types/node'
# ^1 ^2 ^3
# 1: The top-level key is used as the package name. For instance, `node` becomes `@types-with-exceptions/node`
# 2: Specifies where to fetch the package from. (Currently, only npm is supported.)
# 3: Package name
# Advanced
lib-es5:
from: 'npm:typescript'
copy:
'index.d.ts': 'lib/lib.es5.d.ts'
# You can copy files individually from the package using:
# <destination file path>: <source file path>
# And to comply with the license, README, LICENSE, etc. are copied by default without needing to specify them separately.