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

patch(typegen): stops defaultMaximumTruncationLength getter error #47

Merged
merged 2 commits into from
Nov 22, 2023

Conversation

Tbhesswebber
Copy link
Contributor

This PR prevents the error mentioned in #44 from occurring for TypeScript versions >= 5. I don't know that it's actually solving the underlying problem that modifying defaultMaximumTruncationLength was attempting to solve in the latest versions. According to this long-standing issue, it sounds like there hasn't ever been a way to actually modify this value, although that could just be referring to the public configuration options.

I'm more than happy to modify this, but it feels like patching the functionality is likely the most valuable path to move forward quickly rather than trying to identify the "right" way to do this.

Closes #44

src/typegen.ts Outdated
Comment on lines 14 to 16
if (!/^5\.\d$/.test(ts.versionMajorMinor)) {
(ts as any).defaultMaximumTruncationLength = Infinity
}
Copy link
Member

Choose a reason for hiding this comment

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

This makes sense and thank for the fix! Though now I wonder what'll happen when TS 6 comes out. It'll likely work the same way as 5. Thus it might be better here to check that parseInt(ts.versionMajorMinor.split('.')[0]) < 5 or something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense - fixed it!

Have you had any kind of conversation with the TypeScript team about what they consider to be the proper way to do what this code is trying to do? You can't be the only person parsing TypeScript ASTs and running into this problem...

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! v3.3.3 is out with the fix.

And no, I haven't had any contact with the TS team. Things are mostly stable and working, until some TS upgrade changes things again. 🤷

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.

Getting compilation error while running kea-typegen write
2 participants