Skip to content

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Jul 15, 2025

This PR adds typescript to the repo to type-check the JS interface of Sentry CLI. I decided to build on top of the already existing JSDoc type annotations but actually enforce them by running TS.

This also surfaced an incorrect type annotation which I fixed as well, along with adding some minor annotations that were necessary. In light of #2606, I also had to ignore a type error but we'll fix this in the next major.

Added a type checking job to CI, which IIUC should also be required after #2599.

closes #2604

@Lms24 Lms24 marked this pull request as ready for review July 15, 2025 13:31
@Lms24 Lms24 requested a review from szokeasaurusrex as a code owner July 15, 2025 13:31
@Lms24 Lms24 requested review from RulaKhaled and andreiborza July 15, 2025 13:32
@Lms24 Lms24 self-assigned this Jul 15, 2025
Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Lukas! I have a few questions. Also, I am not sure that the type checker is indeed required following this change. I'll do some experimenting to verify

Copy link
Member

@szokeasaurusrex szokeasaurusrex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for adding this!

One final question though (non-blocking for this PR): Does the type checker enforce that everything has types declared (at least, that the public API does)? Or, is it possible that we could expose something which is untyped?

@Lms24
Copy link
Member Author

Lms24 commented Jul 15, 2025

One final question though (non-blocking for this PR): Does the type checker enforce that everything has types declared (at least, that the public API does)? Or, is it possible that we could expose something which is untyped?

It doesn't enforce that the types are declared publicly (i.e. for library consumers). At least not in the current setup. We could change this eventually though, by telling typescript to not only type-check but also emit type declaration files. Might be a nice follow-up but I don't have time for this today anymore. Opened #2617 to track.

Within the codebase, typescript simply infers the types of all non-explicitly annotated variables and exports. So if I have something like

module.exports.x = "foo"

TS will infer that x is of type string and apply the inferred type if x is consumed in any other module.

@Lms24 Lms24 merged commit dd8926f into master Jul 15, 2025
26 checks passed
@Lms24 Lms24 deleted the lms/chore-tsc branch July 15, 2025 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable Type Checking in JS Interface

4 participants