Fix generated TypeScript type definitions #60
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.
Currently during build, to generate TypeScript type definitions, the packager directly calls the TypeScript compiler using the JavaScript source files as root files. Whilst this initially appeases TypeScript when SCIMMY is imported, the type definitions generated from the JSDoc annotations by the TypeScript compiler are functionally useless. When they don't just fall back to the "any" type, they often just outright get the type wrong.
This change modifies the build process so that type definitions are generated using the ostensibly-typed package, added as a devDependency, which produces declaration-merged types generated using the existing JSDoc namespace annotations. The JSDoc annotations have also been updated to produce more accurate type definitions, including through the use of generic classes, allowing resource and instance types to flow through to ingress/egress/degress handlers for the User and Group resources. Additionally, each class in the
SCIMMY.Schemas
namespace has had their default set of attributes added as class properties, exposing them to TypeScript when working with return values of ingress/egress handlers. This change should fix #45 as it will provide proper expected types when writing handlers.Additionally, the underlying classes of each singleton are now exposed as first-class exports, allowing them to be directly imported via their module names (e.g.
import {SCIMError} from "scimmy/types"
orimport {User} from "scimmy/resources"
, etc.)