Repository navigation
refactor(cli): Generate the SDK with the TypeScript AST instead of strings - #1644
Merged
Merged
Conversation
…rings Build sdk.generated.ts and sdk.generated.d.cts with ts.factory and the compiler printer, so names, string literals and JSDoc are always escaped. The SentrySDK type is built once and shared by both outputs, and createSDKMethods is annotated with it so tsc checks every implementation against the published type. Move the positionals() helper out of the emitted string into src/lib/sdk-positionals.ts, and locate SentryOptions in sdk-declarations.ts by parsing instead of brace counting. Co-Authored-By: BYK <burak.kaya@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
BYK
approved these changes
Oct 23, 2026
This branch was previously deployed
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 free
to 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.
script/generate-sdk.tsbuiltsdk.generated.tsandsdk.generated.d.ctsby interpolating command metadata into template strings. Enum values, property keys and JSDoc text (briefs, schema descriptions) went in unescaped. The implementation and the publishedSentrySDKtype were also rendered by two separate code paths:.tsconsumers gotReturnType<typeof createSDKMethods>, while the.d.ctshad hand-written overloads. That's how the streaming overloads lost their...positionalin the first place.This switches the generator to
ts.factory+ the compiler printer.typescriptis already a devDependency.ts.isIdentifierText, so keys are quoted only when they need to be. String literals and JSDoc are escaped by construction, so a*/in a brief or a"in an enum value can no longer break the file.SentrySDKtype is built once and emitted into both files.createSDKMethodsis now annotated with it, sotscchecks every generated implementation against the published type. Streaming methods are asserted to their overloaded member type because a single arrow can't express the overloads.positionals()helper moves out of the emitted string intosrc/lib/sdk-positionals.ts.sdk-declarations.tsfindsSentryOptionsby parsing the file instead of counting braces. A}in a comment or a string literal type no longer cuts it short.The published
.d.ctsis semantically identical tomain. I parsed and re-printed both files and diffed the results across all 139 commands. The only.ts-side change is thatSentrySDKis now the declared, overloaded type instead of the inferred union.The
sdk-flag-typesassertions change from{ follow: string }to{ follow: string; }because that's how the printer formats single-line type literals. New tests: property tests for the codegen helpers (arbitrary keys, enum values and JSDoc text all print as valid TS and read back unchanged), property tests forpositionals(), and a regression test for braces insideSentryOptions.via BYK.
--
View Junior Session in Sentry