Uh oh!
There was an error while loading. Please reload this page.
Generate TypeScript definitions from source - #189
Open
aron wants to merge 5 commits into
Open
Conversation
aron
marked this pull request as ready for review
January 15, 2024 20:42
aronforce-pushed
the
typescript-definitions
branch
2 times, most recently
from
January 23, 2024 12:13
1195d8a to
cac159fComparearon
commented
Jan 23, 2024
ContributorAuthor
@mattt I've rebased this on main to remove the dependency on the singleton branch. The only files I'm not 100% sure about is the changes to |
aron
commented
Jan 23, 2024
ContributorAuthor
Gonna close and reopen to try and trigger the tests... |
aronforce-pushed
the
typescript-definitions
branch
2 times, most recently
from
March 18, 2024 13:33
da24d4e to
207f0b9Comparearon
commented
Mar 18, 2024
ContributorAuthor
@mattt spent some time getting this up-to-date, would be good to get it in before we make any further API changes (like the deployments branch). |
aronforce-pushed
the
typescript-definitions
branch
from
March 19, 2024 05:29
bb9dc45 to
43678ddCompareWe now have basic and `:integration` flavors of the common commands `lint` and `test` as well as an `:all` flavor that will run everything. We also now ensure that the types are built before running integration tests as well as part of the packaging workflow via `prepack`.
aronforce-pushed
the
typescript-definitions
branch
from
March 19, 2024 14:10
43678dd to
6b6eb15Comparemattt
approved these changes
May 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
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 our types are hand written. They differ from the jsdoc types in the source code in that a) they're missing documentation and b) the types are often inconsistent. Rather than manually sync the two it felt simpler to use
tscto generate the types for us from the JS source code and reduce the burden of manually keeping the types up-to-date with the source code.This PR now uses the type annotations found in the jsdoc for all of the files and generates a
./dist/typesdirectory. This has the benefits of:The drawbacks are mostly that it's very easy to mess up the type annotations which will then fail silently and default to
any, which is about on par with handwriting them anyway.To mitigate this we do our best to unit test the types in the
./integrations/typescript/types.test.tsfile which creates typed instances of the main primitives and will cause tsc errors if the types become out of sync. TheAssertFalsehelper allows us to catch cases where we've accidentally messed up the@typedefexport in index.js.