Proposal : Augment resources typing #58
Closed
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.
Hello ! 👋
I'm just discovering this library (thanks for the awesome work !) and I was struggling with callback typing. I saw the issue #45 and I wanted to share a potential solution.
Disclaimer : this PR is draft, the test is only done for the SCIMMY.Resources.User.ingress function.
Since the SCIMMY.Resources.User extends SCIMMY.Types.Resource and bring some override, I notice that typescript handle it better if we define a specific callback type for IngressHandler.
I also changed the return type of SCIMMY.Resources.declare by adding a dynamic type based on the declared type.
Here is an example that you can use in VSCode to test augmented typing.
Here is an example on how VSCode display the type for ingress.
![image](https://private-user-images.githubusercontent.com/6912564/378740374-384349b7-c177-4213-86aa-71652f763d60.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNDkxMTksIm5iZiI6MTczOTE0ODgxOSwicGF0aCI6Ii82OTEyNTY0LzM3ODc0MDM3NC0zODQzNDliNy1jMTc3LTQyMTMtODZhYS03MTY1MmY3NjNkNjAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTBUMDA1MzM5WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Nzk1NTU1MzE5YjI0MzEwMmMzOWU4MWU5Y2VmOTRjZWFkMWI0MzBmY2ViZTkyYTY4YTY0OGU4NTk2Zjk4NTE4MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.9QVpc_VXF0zbn0ulo0UUue_MeebGKtnCy_gUCGnOApY)