TypeScript compiler validation of lib/index.d.ts #784
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've noticed that there were some lingering errors in the typescript declaration file and that it's really easy to make these small syntax errors when editing the file.
When you then try to use this project in a TypeScript application you will have a lot of trouble because your TypeScript compiler (
tsc
) will always throw them as errors.This PR introduces typescript as a devDependency and adds a
tsconfig.json
to configure the compiler to be fairly strict and only look atlib/index.d.ts
without scanning for other files.Further, a new npm task is added to
package.json
calledvalidate-ts-declarations
which just startstsc
with the options specified in tsconfig.json.The validate-ts-declarations command is also added as a prerequisite for
build-lib
. This means that generating thedist/
folder will fail iflib/index.d.ts
is broken.Note: This does not mean that the build will fail because the type declarations don't accurately reflect the actual code. It just checks that the present declarations are valid TypeScript.
Also the compiler will not produce any output files. It will either silently complete or throw compiler errors of the form:
I think it would really help to have this in the project in order to make it easier and safer to contribute missing TypeScript declarations.