Keep is/extends inline for multi-argument template heritage#11011
Keep is/extends inline for multi-argument template heritage#11011oha-4 wants to merge 3 commits into
is/extends inline for multi-argument template heritage#11011Conversation
commit: |
|
All changed packages have been documented.
Show changes
|
0922558 to
ce6a4b5
Compare
A model/scalar heritage clause (`is X` / `extends X`) wrapped the keyword and
the template reference in one `group(indent(...))`. Prettier measures that
group against the full flat width of the template argument list, so it broke
and pushed the keyword onto its own indented line even when the declaration
line was short:
model Picked
is PickProperties<
Sample,
...
>;
`printHeritageClause` now keeps the keyword inline when the base is a template
reference with multiple (breakable) arguments, letting the argument list
control the line break:
model Picked is PickProperties<
Sample,
...
>;
Single-argument and non-template bases keep breaking the keyword when the
declaration is too long.
Fixes the `is`-breaking part of microsoft#11009.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ce6a4b5 to
e3b7b82
Compare
Apply the new `is`/`extends` inline formatting (microsoft#11009) to committed artifacts that the formatter now reformats: the http-client-java test spec arm-customization.tsp and the 1.11 release-notes embedded example. Whitespace only, no semantic change. Also update the regenerated `crossLanguageVersion` hash in azure-resourcemanager-armcustomization-generated_metadata.json, which is whitespace-sensitive to the reformatted spec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
e3b7b82 to
95e7383
Compare
There was a problem hiding this comment.
I'll ask the java team what is going on here if the CI still fails, but you shouldn't be changing those files in that pr
There was a problem hiding this comment.
Thanks for catching this, and for offering to check with the java team — much appreciated! I've reverted the *_metadata.json change so it's out of this PR. The arm-customization.tsp reformat stays since format:check enforces it.
For reference, earlier formatter PRs (#10556, #10558) reformatted these same Java test specs with no metadata change — crossLanguageVersion was added later (#10674), so reformatting had no hash impact back then. This PR is the first formatter change to hit that coupling.
Heads up: I expect RegenCheck to fail, because tcgc derives crossLanguageVersion from the raw .tsp source text (computeCrossLanguageVersion in package.ts), so the whitespace-only reformat changes the hash. Could you check with the java team on the right way to handle this?
Keep azure-resourcemanager-armcustomization-generated_metadata.json out of this formatter PR as requested. The arm-customization.tsp reformat stays (required by format:check); leaving the regenerated crossLanguageVersion hash reverted lets CI surface the RegenCheck behavior for the java team. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fixes the
is-breaking part of #11009 (the blank-line/over-indent part is addressed separately in #11010).Problem
When a model/scalar heritage clause (
is X/extends X) references a template with multiple arguments, the formatter wrapped the keyword and the template reference in a singlegroup(indent(...)). Prettier measures that group against the full flat width of the template argument list, so the group broke and pushed the keyword onto its own indented line — even when the declaration line itself was short:Fix
printHeritageClausenow keeps the keyword on the declaration line when the base is a template reference with multiple (breakable) arguments, and lets the template argument list control the line break:Single-argument (hugged) and non-template bases keep the previous behavior of breaking the keyword onto its own line when the declaration is too long.
Tests
model is,model extends, andscalar extendsinformatter.test.ts.http-client-javatest spec (arm-customization.tsp) that contained the old output (whitespace only, no semantic change).prettier --check "**/*.tsp"all pass locally.🤖 Generated with Claude Code