Skip to content

Xvezda/types-with-exceptions

Repository files navigation

types-with-exceptions Sync

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.

Usage

# 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,
    // ...
 }

Contributing

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.

  1. Fork repository
  2. Check if the package you want to modify exists in the types directory.
    1. If it does not exist, add the desired package to the registry.yaml file.
    2. Run pnpm run sync to apply the changes.
  3. Modify the relevant *.d.ts file(s) in the types directory and commit.
  4. (Optional) Add tests in the tests directory. Refer to rule-tester.
  5. Create a PR.

/registry.yaml

# 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.

About

TypeScript type definitions with exceptions using JSDoc

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •