Skip to content

Follow tsc's same-line rule for TS class member and parameter modifiers - #38706

Closed
robobun wants to merge 7 commits into
mainfrom
farm/9972a7be/ts-modifier-newline
Closed

robobun wants to merge 7 commits into
mainfrom
farm/9972a7be/ts-modifier-newline

Conversation

@robobun

@robobun robobun commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • In a .ts class body, public, private, protected, readonly or override alone on a line is dropped. With public on one line and a = 1 on the next, Object.keys(new C()) is ["a"]. tsc 6.0.2 and node 26 give ["public","a"].
  • constructor(readonly⏎ x) becomes a parameter property (this.x = x). ⏎ is a line break. tsc rejects it (TS1005).
  • Neither site checks p.lexer.has_newline_before: parse_property.rs:477 and parse_fn.rs:255 in src/js_parser/parse/.

Fix

  • Both sites take the word as a modifier only when no line break follows it. Otherwise it is the property key or the parameter name.
  • This is the rule of tsc. static, get and set do not change.
  • The runtime transpiler cache version goes from 43 to 44, so the fix reaches cached files.
  • Verified: test/bundler/transpiler/transpiler.test.js (fails on bun 1.4.3-canary.1). Notes lists the other suites.

Background

  • A parameter property is a constructor parameter with one of these words before its name. It also declares a field.
  • p.lexer.has_newline_before is true when a line break precedes the current token.
  • The runtime transpiler cache stores the printed text of a file. A build reads only entries of its own version.

Downsides

  • Behavior change: a class with such a line gets a field of that name, as tsc emits. esbuild 0.21.5 drops the word.
  • New syntax error: constructor(readonly⏎ x) fails with Expected ")" but found "x". Bun 1.4.3-canary.1 and esbuild 0.21.5 accept it.
  • New cache version: bun transpiles each cached file once more. That costs +2 ms for 88 KB and +174 ms for 9.1 MB (Notes).
Notes

The snippet.

class C {
  public
  a = 1
  readonly
  b = 2
}
console.log(JSON.stringify(Object.keys(new C())));
bun 1.4.4, main da867c60bf          ["a","b"]
this branch                         ["public","a","readonly","b"]
node v26.3.0 (type stripping)       ["public","a","readonly","b"]
tsc 6.0.2 transpileModule           class C { public; a = 1; readonly; b = 2; }
esbuild 0.21.5 transform            class C { a = 1; b = 2; }

The rule of tsc. The grammar of tsc (nextTokenIsOnSameLineAndCanFollowModifier) accepts these words as modifiers only when the member name is on the same line. Otherwise each word is a field named public, readonly, and so on. parseParameterWorker reads the modifiers of a parameter through the same function. static, get and set are the exceptions and bind across a line break. esbuild, which this code descends from, has the same difference from tsc at both sites.

What the fix does in a class body. With a line break after the word, the arm falls through to the normal key path. The word becomes a field of that name, and the class field code ends it with ASI (expect_or_insert_semicolon reads the same has_newline_before). The next line is parsed as its own member. Mixed forms give the member list of tsc: public⏎static⏎x gives public; static x;, static⏎public⏎x gives static public; x;, and public static⏎x still gives static x;.

What the fix does in a constructor. parse_fn parses the first identifier of a parameter as a binding. The loop took that identifier as a modifier when a name or a pattern followed it, and parsed the binding again. With a line break before that name, the loop now stops. The identifier stays the parameter, and the parameter list then needs , or ).

parameter list                      tsc 6.0.2            bun 1.4.3-canary.1                   this branch
(readonly⏎ x)                       TS1005               parameter property x                 Expected ")" but found "x"
(private⏎ x: number)                TS1005               parameter property x                 Expected ")" but found "x"
(public readonly⏎ x)                TS1005               parameter property x                 Expected ")" but found "x"
(override⏎ x)                       TS1005               parameter property x                 Expected ")" but found "x"
(readonly // c⏎ x)                  TS1005               parameter property x                 Expected ")" but found "x"
(readonly /*⏎*/ x)                  TS1005               parameter property x                 Expected ")" but found "x"
(protected⏎ {a})                    TS1005               Expected identifier but found "{"    Expected ")" but found "{"
(readonly x)                        parameter property   same                                 same
(⏎ private readonly x: number,⏎)    parameter property   same                                 same
(readonly /* c */ x)                parameter property   same                                 same
(readonly, x)                       two parameters       same                                 same
(readonly⏎, x)                      two parameters       same                                 same
(readonly⏎)                         one parameter        same                                 same
(readonly⏎ = 1)                     one parameter        same                                 same

TS1005 is "',' expected". Every input that changes is one that tsc rejects.

Where the check lives. The two sites share no helper that sees the lexer. parse_property matches PropertyModifierKeyword arms after it consumed the word. parse_fn asks is_type_script_accessibility_modifier, a lookup in a set of strings. So each site has its own check. The only other use of these words in the parser is the readonly type operator (src/js_parser/typescript.rs). tsc has no same-line rule there (let x: readonly⏎ string[] is valid), and the type is erased.

The test. "contextual keywords followed by a newline apply ASI instead of acting as modifiers" in test/bundler/transpiler/transpiler.test.js has 13 new cases for class members and 8 for constructor parameters. The first description of this PR recorded that 10 of the 13 fail on bun 1.4.0 and that each expectation was checked against tsc 6.0.2 transpileModule. Of the 8, the 5 error cases fail on bun 1.4.3-canary.1, which accepts the input. The other 3 are controls. On bun 1.4.3-canary.1 the test fails.

Cache version. EXPECTED_VERSION (src/jsc/RuntimeTranspilerCache.rs) is 43 in bun 1.4.4 and on main da867c6. The rule at the top of src/js_parser/parser.rs asks for a new version when a parser change alters what runs. Probe: a 5 KB .ts file with class C {, public, a = 1, } on four lines that prints the keys of new C(), and one cache folder. The older build runs the file first, then the new build runs it. The older build is main da867c6. Both are debug builds, with BUN_DEBUG_ENABLE_RESTORE_FROM_TRANSPILER_CACHE=1 (without it a debug build ignores a cache hit).

this branch at version 43    ["a"]             3 of 3 runs (the entry of main)
this branch at version 44    ["public","a"]    10 of 10 runs
1 KB file, either version    ["public","a"]    (under 4 KiB, not cached)

Other open PRs also change this number, and they do not all take the same one. All of them edit the same line, so each PR that lands after the first one conflicts. The rule for that rebase: take the number that main has at that time plus one, never a lower number. #47390 adds a source lint that fails when a merge lowers the number.

Cost of the new cache version. Measured on bun 1.4.4 (release, linux x64): require() of one file, a cache miss against a cache hit, 15 interleaved runs, median wall clock. The noise floor is the difference between two interleaved series of hits.

typescript.js       9,143,423 bytes   miss 296.6 ms   hit 122.9 ms   +173.7 ms   noise floor 2.6 ms
esbuild/lib/main.js    87,654 bytes   miss  17.2 ms   hit  14.9 ms     +2.2 ms   noise floor 0.2 ms

The cost occurs once per cached file, on its first run after the upgrade. It is shared with any other change in the same release that takes a new version. perf, valgrind and strace are not installed in the container, so there is no instruction count.

Cost for code without these words. None. parse_property reaches the new condition only for a key that is one of the five words. parse_fn reaches it only when a name or a pattern follows the first identifier of a constructor parameter. Each condition reads one bool of the lexer.

Merge with main. The branch has main da867c6 merged in, with no conflict. The diff against main is the two conditions, the cache version and the test.

Suites run on the branch head b3ada9a (debug build).

  • test/bundler/transpiler/transpiler.test.js: 258 pass, 1 skip, 21 todo.
  • test/bundler/esbuild/ts.test.ts, test/cli/run/transpiler-cache.test.ts, test/regression/issue/30887.test.ts, and in test/bundler/transpiler/: decorators.test.ts, decorator-metadata.test.ts, es-decorators.test.ts, es-decorators-esbuild.test.ts, property.test.ts, ts-use-define-for-class-fields.test.ts. Together: 703 pass, 17 todo.

[auto-merge] gate passed · iteration 6 · 4 files touched

fails on main (without fix)
ASAN without fix: 1 failed, 22 skipped
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/pr_gate.xml" test/bundler/transpiler/transpiler.test.js
bun test v1.4.4 (367d939d9)

test/bundler/transpiler/transpiler.test.js:
(pass) Bun.Transpiler > handles errors when parsing macros [7.07ms]
(pass) Bun.Transpiler > normalizes \r\n [6.15ms]
1
(pass) Bun.Transpiler > doesn't hang indefinitely #2746 [4.35ms]
(pass) Bun.Transpiler > property access inlining > bails out with spread [7.36ms]
(pass) Bun.Transpiler > property access inlining > bails out with multiple items [2.54ms]
(pass) Bun.Transpiler > property access inlining > works [2.03ms]
(pass) Bun.Transpiler > property access inlining > works nested [2.33ms]
(pass) Bun.Transpiler > property access inlining > bails out when the array item is an optional chain [50.62ms]
(pass) Bun.Transpiler > property access inlining > bails out or strips `this` when the index is a call/assignment target [20.56ms]
(pass) Bun.Transpiler > property access inlining > preserves runtime semantics when inlining from a literal index [403.75ms]
(pass) Bun.Transpiler > property access inlining > bails out on optional-
... (truncated)

release without fix: 33 failed, 22 skipped
bun test v1.4.3-canary.1 (367d939d9)

test/bundler/transpiler/transpiler.test.js:
(pass) Bun.Transpiler > handles errors when parsing macros [6.84ms]
(pass) Bun.Transpiler > normalizes \r\n [0.41ms]
1
(pass) Bun.Transpiler > doesn't hang indefinitely #2746 [0.19ms]
(pass) Bun.Transpiler > property access inlining > bails out with spread [0.15ms]
(pass) Bun.Transpiler > property access inlining > bails out with multiple items [0.04ms]
(pass) Bun.Transpiler > property access inlining > works [0.04ms]
(pass) Bun.Transpiler > property access inlining > works nested [0.02ms]
(pass) Bun.Transpiler > property access inlining > bails out when the array item is an optional chain [0.72ms]
(pass) Bun.Transpiler > property access inlining > bails out or strips `this` when the index is a call/assignment target [0.27ms]
(pass) Bun.Transpiler > property access inlining > preserves runtime semantics when inlining from a literal index [17.70ms]
(pass) Bun.Transpiler > property access inlining > bails out on optional-chain index into enum [0.85ms]
(pass) Bun.Transpiler > property access inlining > template literal around an inlined string enum member > member as the first part of the
... (truncated)
passes on PR (with fix)
ASAN with fix: 22 skipped
$ BUN_DEBUG_QUIET_LOGS=1 bun scripts/build.ts --profile=debug --quiet test "--reporter=junit" "--reporter-outfile=/tmp/pr_gate.xml" test/bundler/transpiler/transpiler.test.js
bun test v1.4.4 (367d939d9)

test/bundler/transpiler/transpiler.test.js:
(pass) Bun.Transpiler > handles errors when parsing macros [27.08ms]
(pass) Bun.Transpiler > normalizes \r\n [7.27ms]
1
(pass) Bun.Transpiler > doesn't hang indefinitely #2746 [5.49ms]
(pass) Bun.Transpiler > property access inlining > bails out with spread [8.94ms]
(pass) Bun.Transpiler > property access inlining > bails out with multiple items [2.71ms]
(pass) Bun.Transpiler > property access inlining > works [2.17ms]
(pass) Bun.Transpiler > property access inlining > works nested [2.49ms]
(pass) Bun.Transpiler > property access inlining > bails out when the array item is an optional chain [44.15ms]
(pass) Bun.Transpiler > property access inlining > bails out or strips `this` when the index is a call/assignment target [18.69ms]
(pass) Bun.Transpiler > property access inlining > preserves runtime semantics when inlining from a literal index [506.52ms]
(pass) Bun.Transpiler > property access inlining > bails out on optional
... (truncated)

release with fix: 22 skipped
$ bun scripts/build.ts --profile=release
[configured] bun-profile → bun (stripped)
  target       linux-x64-gnu
  build type   Release
  build dir    ./build/release
  revision     b3ada9a464
  features     lto, baseline

21 deps, 432 codegen, 1228 objects in 14751ms

ninja: Entering directory `/workspace/bun/build/release'
[1/5] fetch lolhtml
[lolhtml] up to date
[2/5] fetch rust-argon2
[rust-argon2] up to date
[2/5] cargo plan → /workspace/bun/build/release/rust-target/plan.json
301 units: 203 lib, 32 custom-build (host), 28 run custom-build, 16 proc-macro (host), 17 lib (host), 4 run custom-build (host), 1 rlib
[4/5] fetch WebKit (prebuilt)
[WebKit] fetching https://github.com/oven-sh/WebKit/releases/download/autobuild-8c6c963e3c49fe39942d9625d1fc924128fad26e/bun-webkit-linux-amd64-lto-aot.tar.gz
[WebKit] extracted to /root/.bun/build-cache/webkit-8c6c963e3c49fe39-lto-aot (11.9s)
[4/5] reconfigure
[1/7] fetch WebKit (prebuilt)
[WebKit] up to date
[1/1622] rustc bun_output_tags 
[2/1622] rustc unicode_xid 
[3/1622] rustc fnv 
[4/1622] rustc heck 
[5/1622] rustc unicode_ident 
[6/1622] rustc ident_case 
[7/1622] mkdir stamps
[8/1622] mkdir codegen
[9/1622] rust
... (truncated)
diff hotspot
src/js_parser/parse/parse_fn.rs            |  4 ++-
 src/js_parser/parse/parse_property.rs      |  1 +
 src/jsc/RuntimeTranspilerCache.rs          |  3 ++-
 test/bundler/transpiler/transpiler.test.js | 40 ++++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+), 2 deletions(-)

gate history · 3 passed · 0 rejected · iteration 6

evidence per changed file
file                                        reads  edits  tests
src/js_parser/parse/parse_fn.rs                 1      1     14
src/js_parser/parse/parse_property.rs           5      4     14
src/jsc/RuntimeTranspilerCache.rs               0      0     14
test/bundler/transpiler/transpiler.test.js      3      2     14

In a TypeScript class body, tsc only treats public, private, protected,
readonly and override as modifiers when the member name starts on the
same line. "public<newline>a = 1" declares a field named "public" and a
field "a". Bun skipped the keyword regardless of the newline, so such
fields silently disappeared from the emitted class.

Add the same has_newline_before check that the declare, abstract and
accessor arms already use. static is intentionally left alone: tsc lets
it bind across a newline.
@coderabbitai

coderabbitai Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between da867c6 and b3ada9a.

Files selected for processing: 4
  • src/js_parser/parse/parse_fn.rs
  • src/js_parser/parse/parse_property.rs
  • src/jsc/RuntimeTranspilerCache.rs
  • test/bundler/transpiler/transpiler.test.js
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@robobun

robobun commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Status: ready for review. The branch has main da867c6 merged in. The diff against main is the has_newline_before check at two sites (class members and constructor parameters), the runtime transpiler cache version (43 to 44) and the test.

  • Class members: reproduced on bun 1.4.3-canary.1 with the snippet in the Notes of the description. Object.keys(new C()) prints ["a","b"]. tsc 6.0.2 emits the four fields, and node v26.3.0 prints ["public","a","readonly","b"]. This branch prints the same as node.
  • Constructor parameters: class A { constructor(readonly⏎ x) {} } (⏎ is a line break) runs on bun 1.4.3-canary.1 and sets this.x. tsc 6.0.2 reports TS1005. This branch reports Expected ")" but found "x".
  • The test in test/bundler/transpiler/transpiler.test.js ("contextual keywords followed by a newline apply ASI instead of acting as modifiers") fails on bun 1.4.3-canary.1 and passes on this branch.
  • Cache version: a 5 KB .ts file that main da867c6 ran first still printed ["a"] on this branch at version 43 (3 of 3 runs). At version 44 it prints ["public","a"] (10 of 10 runs). Both builds are debug builds.
  • CI on b3ada9a (build 135279): 184 of 188 jobs passed, and no test is red. The other 4 are the macOS x64 test jobs. No agent picked them up: they expired in the queue on each of 4 attempts, and that marks the build as failed. The macOS aarch64 test jobs passed.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — one-line guard matching the neighboring declare/abstract/accessor/async arms, aligning with tsc's nextTokenIsOnSameLineAndCanFollowModifier.

What was reviewed:

  • Fall-through path: with the newline guard failing, name becomes an EString key, is_shorthand_property is gated off by opts.is_class, and the class-field branch terminates via expect_or_insert_semicolon (ASI on the same has_newline_before).
  • static intentionally left unguarded (matches tsc); test cases cover public⏎static⏎x, static⏎public⏎x, and public static⏎x interactions.
  • Same-line readonly [key: string]: number index signature still erased — regression case is in the new tests.
  • No CODEOWNERS for src/js_parser/ or the test file.
Extended reasoning...

Overview

Adds && !p.lexer.has_newline_before to the PPrivate | PProtected | PPublic | PReadonly | POverride match arm in src/js_parser/parse/parse_property.rs, so that in a TypeScript class body these words followed by a line terminator are parsed as field names rather than dropped as modifiers of the next member. Adds 13 exp(...) cases to the existing "contextual keywords followed by a newline" block in test/bundler/transpiler/transpiler.test.js.

Security risks

None. Pure parser grammar adjustment with no I/O, allocation-size, or untrusted-length handling changes.

Level of scrutiny

Low-to-medium. The change is a single boolean conjunct that mirrors the identical guard already present on the four adjacent arms (PDeclare, PAbstract, PAccessor, PAsync) in the same match — the file's local convention is followed exactly. The behavioral semantics were cross-checked against the tsc reference (nextTokenIsOnSameLineAndCanFollowModifier) and node --strip-types per the PR description, and the fall-through path was traced: the identifier becomes an EString key, the shorthand-property branch is skipped because opts.is_class is true, and the class-field branch's expect_or_insert_semicolon inserts the ASI on the very newline that tripped the guard.

The PR notes esbuild has the same divergence; REVIEW.md says the reference implementation is the spec for ported code, but for TypeScript syntax tsc is the authority and both tsc and swc agree here, so aligning with tsc is the right call.

Other factors

  • Tests are placed alongside the existing declare/abstract/accessor newline cases in the same file (not a new file), covering all five keywords, method/computed/private-identifier followers, the static interaction in both orders, and two negative cases (same-line modifiers still erased; readonly index signature still erased).
  • PR description states 10 of the 13 new cases fail on bun 1.4.0, satisfying the "test fails without the fix" requirement.
  • No CODEOWNERS entry covers either changed file.
  • No prior human review comments on the PR.

@robobun

robobun commented Aug 14, 2026 •

Copy link
Copy Markdown
Collaborator Author
Updated 12:07 PM PT - Oct 29th, 2026

❌ @robobun, your commit b3ada9a has some failures in Build #135279 (All Failures)


🧪   To try this PR locally:

bunx bun-pr 38706

That installs a local version of the PR into your bun-38706 executable, so you can run:

bun-38706 --bun

Comment thread src/js_parser/parse/parse_property.rs Resolved
Comment thread src/js_parser/parse/parse_property.rs Resolved

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — one-line guard mirroring the neighbouring declare/abstract/accessor/async arms, with expectations cross-checked against tsc.

What was reviewed:

  • The added !p.lexer.has_newline_before matches the identical check on the four sibling arms; fall-through reaches the class-field path and terminates via ASI as described.
  • Confirmed static/get/set are unchanged (separate arms, intentionally no newline guard per tsc's grammar); same-line readonly [k: string]: T index signatures still parse.
  • 13 new cases in the existing "contextual keywords followed by a newline" test cover all five keywords, mixed static orderings, computed/private keys, and same-line control cases; mechgate shows they fail on main and pass here.
Extended reasoning...

Overview

The PR adds a single && !p.lexer.has_newline_before clause to the PPrivate | PProtected | PPublic | PReadonly | POverride arm of parse_property (src/js_parser/parse/parse_property.rs:486). This brings that arm in line with the four adjacent arms (PDeclare, PAbstract, PAccessor, PAsync) that already gate on the same flag. When a newline separates the modifier word from the next token, the arm now falls through to the ordinary property-key path, producing a field named public/readonly/etc. that the existing class-field code terminates via expect_or_insert_semicolon. 24 lines of test additions land in the existing "contextual keywords followed by a newline" test in test/bundler/transpiler/transpiler.test.js, using the same ts.expectPrinted_ helper as neighbouring abstract/accessor cases.

Security risks

None. This is a TypeScript-only parser grammar tweak with no memory management, no untrusted-length arithmetic, and no new allocation or I/O.

Level of scrutiny

Low-to-medium. The source change is one boolean clause that copies an established pattern from four sibling arms in the same match. The fix is grounded in tsc's nextTokenIsOnSameLineAndCanFollowModifier and every expected output was cross-checked against tsc 6.0.2 transpileModule and node --strip-types. static, get, and set are handled by separate arms and intentionally left alone (they do bind across a newline in tsc). The readonly [key: string]: number control case confirms same-line index signatures are unaffected.

Other factors

  • Mechgate evidence in the PR shows 10/13 new assertions fail on 1.4.0 and all pass with the fix, on both ASAN-debug and release builds.
  • The two comment-cop review threads (about a paragraph-long code comment) were addressed in 4550863, which restored the original one-line comment; both threads are marked resolved.
  • No CODEOWNERS entry covers src/js_parser/.
  • No prior claude[bot] review on this PR.

The class modifier fix changes the text that the runtime transpiler prints.
An entry that an older build wrote holds the old text. With the same version,
the new build reads that entry and the fix does not reach the file.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Beyond the inline finding, I also checked three things and ruled them out: the has_newline_before read at parse_property.rs:485 happens after p.lexer.next() on line 343, so it describes the gap after the modifier word exactly as the declare/abstract/accessor/async arms do; leaving static/get/set unguarded matches tsc's nextTokenCanFollowModifier, which only applies the same-line rule to the other modifiers, so static\n public\n x -> static public; x = 1 is the tsc shape; and the bytecode compile cache (src/jsc/NodeCompileCache.rs) is keyed by the build's git SHA, so EXPECTED_VERSION in RuntimeTranspilerCache.rs is the only format constant that needed bumping.

Extended reasoning...

The change is a one-condition parser guard in src/js_parser/parse/parse_property.rs, a runtime transpiler cache version bump 43 to 44, and 13 new transpiler test cases; it touches no security-sensitive surface. A confirmed sibling-site gap in the constructor parameter-property loop is posted inline, which is why this is a defer rather than an approval.

Comment thread src/js_parser/parse/parse_property.rs Resolved
…r name

In a constructor parameter list, tsc takes public, private, protected,
readonly and override as modifiers only when the parameter name starts on
the same line. With a line break after the word, the word is the parameter
name, and a name on the next line is a syntax error (TS1005).

The modifier loop in parse_fn did not look at the line break. It skipped
the word and emitted a parameter property. It now checks
has_newline_before, like the class member arm in parse_property.
@robobun robobun changed the title Parse TS class modifiers followed by a newline as field names Follow tsc's same-line rule for TS class member and parameter modifiers Oct 29, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — the latest push brings the constructor-parameter loop in line with the class-member arm, so both sites that treat these five words as modifiers now apply the same newline rule.

What was reviewed:

  • Traced public\n x = 1 and readonly\n [k] = 1 through parse_property.rs: the word falls through to the plain key path and expect_or_insert_semicolon ends the field on the same has_newline_before state, so [, #x, and method names on the next line all split correctly.
  • Traced readonly\n x, public readonly\n x, readonly\n, x and readonly\n = 1 through the parse_fn.rs loop: the break lands with the modifier word as the binding and the next token reported by the normal )/, check.
  • Checked the remaining PropertyModifierKeyword arms: declare, abstract, accessor, async already carry the newline guard; static/get/set intentionally do not, matching tsc.
  • EXPECTED_VERSION bump and doc line follow the existing entry format; no CODEOWNERS entry covers the changed files.
Extended reasoning...

The change adds a has_newline_before guard at the two parser sites that treat public/private/protected/readonly/override as TypeScript modifiers (class members in parse_property.rs and constructor parameter properties in parse_fn.rs), bumps the runtime transpiler cache version to 44, and adds 20 exact-output transpiler test cases. It touches no security-sensitive surface; it is a pure syntax-handling change in the TS-only parser path. The decision to approve rests on the diff being two one-line guards that copy a pattern already used by the neighboring declare/abstract/accessor/async arms, the prior inline finding about the parse_fn.rs sibling site being addressed in commit b3ada9a with its own error-case tests, and no outstanding objections from a human reviewer.

@robobun

robobun commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Closing as stale: this PR conflicts with main, and its last commit is from 2026-10-29.

The branch stays, so the work is not lost. To pick it up again, rebase the branch on main and reopen this PR.

@robobun robobun closed this Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants