Skip to content

sdk-generator: no JavaScript reserved word at a TypeScript binding - #10011

Open
olety wants to merge 3 commits into
mainfrom
opus-mainfix/sdk-ts-reserved-word-identifiers
Open

olety wants to merge 3 commits into
mainfrom
opus-mainfix/sdk-ts-reserved-word-identifiers

Conversation

@olety

@olety olety commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What

The TypeScript twin of #9995 (the generated Python SDK's def continue, which broke the 21 Nov nightly e2e build). The TypeScript emitters write verb-table names unescaped at positions where JavaScript binds a name, and a reserved word there does not parse:

  • the facade's parameters, for a typed binding and for a generic-door verb (facade-verbs.ts), and the values each body passes on;
  • the native client's interface parameters (native-verbs.ts);
  • the JSON-wire body's destructure, const { <field>, ...rest } = request;
  • the code-mode catalog's roots, bare verbs and self members, declared as declare const, declare function, const, function or namespace.

No PR-time job parses the generated TypeScript, so a row with an argument named default, delete or new would fail only at the nightly e2e. Today's table names no reserved word at any of these positions (checked over all 1601 rows), so no output changes.

Change (crates/oneiron-sdk-generator)

  • src/generate/common.rs: JS_RESERVED_WORDS: ECMAScript's reserved words, the ones strict (module) code adds, and arguments and eval, 48 names. Also is_js_reserved, and js_binding_names, which allocates the names of one binding list: a name binds as it is unless it is a reserved word or one of the list's fixed names; such a name takes a trailing underscore (default_, as fix(sdk-generator): escape Python hard keywords in namespace properties and parameters #9995 does for a Python keyword), and more until no other name of the list has it (default beside default_ binds default__). ts_callable_member writes an interface or type-literal member named new as a property of function type (new: (params) => result), since new( there opens a construct signature.
  • src/generate/emit_ts.rs: js_binding_names at every binding list (typed-binding and generic-door facade parameters, the JSON-wire destructure, native interface parameters), and each body reads those bindings. A facade list's fixed names are TS_BODY_READS, every name the verb body reads beside its bindings (host, facadeCall, facadeClient, JSON, keyedJson, itemFromWire), plus opts with options, or rest, result and the request in the JSON-wire block, so no field or parameter shadows the helper the call goes through. A renamed wire field destructures as default: default_, and the request is rebuilt from that binding. Object keys, property accesses (opts.default) and type members keep the name, which is legal there.
  • src/catalog_fragment.rs: a root, bare verb or self member named by a reserved word is refused with a GenerateError naming the row. Code mode calls the verb by that name, so it cannot be renamed. A reserved word deeper in a path stays a member name (vault.export works as today).

TypeScript contextual words (type, declare, async, of) are valid binding names, so they stay. The Rust emitters need no change: cargo already rejects a reserved word there at PR time. Swift and Kotlin come from uniffi-bindgen, which quotes keywords.

Tests

  • Unit: common::tests::js_binding_names_suffix_exactly_the_reserved_and_fixed_names, emit_ts::tests::a_reserved_wire_field_destructures_into_a_binding_of_its_own (with the emitter's own fixed names: keyedJson, JSON, host ... are renamed), emit_ts::tests::a_facade_parameter_named_like_a_body_read_is_renamed, catalog_fragment::tests::a_reserved_word_binding_is_refused_and_a_reserved_member_stays (refusals for delete, new.zz, self.default, self.let.zz, self.think.static; zz.delete and self.zz.export stay members; a leaf zz.new is written new: (input: ...) => ...).
  • crates/oneiron-sdk-generator/tests/sdk_typescript_reserved_word_bindings.rs runs the generator on the repository through its public outputs entry. It scans facade-verbs.ts (parameter lists and destructures), native-verbs.ts (interface parameters) and the catalog fragment (declarations), and fails on any binding that is a reserved word, on a facade binding that takes a name the body reads (read from the generated file's value imports), and on a callable member named new. It also pins its own parser on each form.
    • cargo test --locked -p oneiron-sdk-generator --all-features --test sdk_typescript_reserved_word_bindings
    • It passes on today's table at main and at this head: it guards the escape, since today's table hits nothing.
  • Red pin opus-mainfix/proof-sdk-ts-reserved-red-r3 (main 4317485 plus the catalog test and the scan test only): the catalog test is expected to fail on delete, because main emits declare function delete.
  • Output identity: the generator's --out-dir output is expected to be byte-identical at main and at this head.

Stored change

None. The generated SDK files are build outputs and are not checked in. No verb row changes.

FIX-LIST [SDK-TS-RESERVED-WORD-IDENTIFIERS].

FIX-LIST [SDK-TS-RESERVED-WORD-IDENTIFIERS], the TypeScript twin of
[PY-SDK-GENERATED-KEYWORD-METHOD] (#9995). The TypeScript emitters wrote
verb-table names unescaped where JavaScript binds a name: the facade's
parameters (typed binding and generic door), the native client's interface
parameters, the JSON-wire destructure, and the code-mode catalog's roots,
bare verbs and self members. A reserved word there does not parse, and no
PR-time job parses the generated TypeScript.

- common.rs: JS_RESERVED_WORDS (ECMAScript reserved words, the strict-mode
  ones, arguments and eval), is_js_reserved and js_binding_name, which gives
  a reserved word a trailing underscore.
- emit_ts.rs: js_binding_name at every binding position and at every use of
  that binding; a reserved wire field destructures as `field: field_`.
  Keys, property accesses and type members keep the name, which is legal.
- catalog_fragment.rs: a root, bare verb or self member named by a reserved
  word is refused (GenerateError), since code mode calls it by that name.
- tests: unit tests for the escape, the destructure entry and the catalog
  refusal; sdk_typescript_reserved_word_bindings scans the generated
  facade-verbs.ts, native-verbs.ts and catalog fragment for a reserved
  binding over the real verb table.

Today's table names no reserved word at these positions, so no output
changes.
@greptile-apps

greptile-apps Bot commented Nov 20, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository. Configure in Code Review Settings.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

  • Run on-demand review

This review includes 5 billable files and costs up to $1.25.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 50 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 151 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4317485 and 12dc222.

Files selected for processing: 5

  • crates/oneiron-sdk-generator/src/catalog_fragment.rs
  • crates/oneiron-sdk-generator/src/generate/common.rs
  • crates/oneiron-sdk-generator/src/generate/emit_ts.rs
  • crates/oneiron-sdk-generator/src/generate/emit_ts/tests.rs
  • crates/oneiron-sdk-generator/tests/sdk_typescript_reserved_word_bindings.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…ember

Review round 1 of #10011 (two P1s):

- Suffixing could bind two inputs alike: fields `default` and `default_`
  both bound `default_`, and so did native arguments with those names.
  js_binding_names now allocates one binding list at a time: a name that
  binds as it is keeps it, and a reserved word, or a name the emitter binds
  or reads in that scope itself (`host`; `opts` with options; `rest`,
  `result` and the request in the JSON-wire block), takes `_`, then one more
  until no other name of the list has it. The facade parameters, generic-door
  parameters, wire destructure and native interface parameters each use it,
  and the call bodies reuse those bindings. The options and JSON-wire bodies
  now read the first parameter's binding rather than its raw row name.
- In a type literal or interface, `new(...)` is a construct signature, not a
  method. A catalog leaf named `new` is now a property of its call type
  (`new: (input: ...) => ...`), and so is a native interface member `new`
  (ts_callable_member). The catalog readback still counts it.

The whole-table scan also fails on a callable member named `new` in the
native interface or the catalog. Today's table has no `new` segment and no
argument or field named host, opts, rest or result, so no output changes.
first_item lost its last caller and is removed.
Review round 2 of #10011: a JSON-wire field named `keyedJson` destructured into a
binding of its own name, so the body's `keyedJson(...)` called the field string,
not the imported helper. The same held for a parameter or field named
`facadeCall`, `facadeClient`, `JSON` or `itemFromWire`.

TS_BODY_READS lists every name a facade verb body reads beside its bindings
(host, the two symbols, the key-value.js helpers, JSON). The three binding lists
(typed binding parameters, the JSON-wire destructure, generic-door parameters)
take them as fixed names, so such a name gets the trailing underscore. The unit
tests use the emitter's own fixed lists; the whole-table scan also flags a facade
binding that takes a body read, read from the generated file's value imports.
Today's table names none, so the generated output does not change.

This branch has not been deployed

No deployments
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.

1 participant