Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generated TypeScript type definitions #60

Merged
merged 12 commits into from
Dec 8, 2024

Conversation

sleelin
Copy link
Collaborator

@sleelin sleelin commented Dec 6, 2024

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" or import {User} from "scimmy/resources", etc.)

@sleelin sleelin added bug Something isn't working feature New feature or request labels Dec 6, 2024
@sleelin sleelin added this to the 1.3.0 milestone Dec 6, 2024
@sleelin sleelin self-assigned this Dec 6, 2024
@sleelin sleelin linked an issue Dec 6, 2024 that may be closed by this pull request
@sleelin sleelin merged commit 75dc4f5 into main Dec 8, 2024
2 checks passed
@sleelin sleelin deleted the issue/45-typescript-definitions branch December 8, 2024 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature New feature or request
Development

Successfully merging this pull request may close these issues.

Example of proper way to consume types in the callbacks?
1 participant