Repository navigation
aws: close the three resolver gaps behind 555 of the generated anys (#2205) - #2281
Merged
Merged
Conversation
…gs (#2205) Three gaps in `resolvePropertyType`/`resolveRef` account for 555 of the 754 CloudFormation Registry properties that resolved to `any`. `resolveRef` had no `array` case, so a `$ref` to a definition whose `type` is `array` fell through to `any`. CloudFormation names its list shapes constantly: `AWS::Panorama::ApplicationInstance` writes `Tags` as a `$ref` to `TagList`, whose items are the `Tag` definition one hop away. Resolve through `def.items` the way the inline `array` case already does. 502 properties. `resolvePropertyType` returned `any` on seeing `oneOf`/`anyOf` without reading what sat beside it. 44 of those properties also declare a real `type`, and the branch list relaxes that type rather than summing shapes: `AWS::AmazonMQ::Broker` writes `EngineType` as `type: "string"` beside an enum branch and two case-insensitive patterns for the same two values. Read the sibling keywords, and take a string enum branch as the narrower answer. A branch list with nothing beside it is a real sum type and still resolves to `any` (#2278). `allOf` was not handled at all. All nine occurrences are one `$ref` beside an annotation (`{ "default": "MCP" }`), which types as the `$ref` alone. Two things found while measuring. `[]` binds tighter than `|`, so the emitter's `${itemType}[]` produced `"arm64" | "x86_64"[]` — a type that accepts the bare string `"arm64"` and rejects `["arm64"]`. 62 declarations were already wrong that way and the array fix would have added more, so item unions are now parenthesized. And a list definition whose items reach the definition again would recurse without end, so the resolution path carries the definition names it has already visited. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148a4dPTErCBpmNy7J7933f
…any`s (#2205) The resolver fix narrows 787 constructor properties to 216 and, because `boundPropertyTypes` seeds reachability from the resolved type strings, brings 248 more property-type interfaces into the emitted set. The surface gains 408 entries and loses 7: `DimensionMapping`, `DocumentAttributeTarget`, `FilesystemConfiguration`, `Lambda`, `LambdaAuthorizerConfig`, `OpenIDConnectConfig` and `SourceAlgorithm` each had a bare name because only one resource emitted them, and a second resource now does, so the naming strategy prefixes both. Nothing outside `src/generated` referenced them. `chant dev surface-diff lexicons/aws` reported severity breaking against the committed baseline, which the release-time gate (#1473) would refuse to publish past, so the snapshot re-baselines here. No `--bump`: packages ship in lockstep, as in #1506. The budget test asserts the count that is left, so the next drop is a deliberate edit rather than a silent one, and checks the three properties #2205 named. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148a4dPTErCBpmNy7J7933f
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.
Closes #2205.
Three gaps in
packages/core/src/codegen/json-schema.ts, measured before and after against the pinned CloudFormation Registry archive (1,653 schemas, 44,260 spec properties).resolveRefhad noarraycaseA
$refto a definition whosetypeisarrayfell through toreturn "any".AWS::Panorama::ApplicationInstancewritesTagsas a$reftoTagList, whose items are theTagdefinition one hop away, and shipped asTags?: any. Resolving throughdef.itemsthe way the inlinearraycase already did fixes 502 properties, plus 7 that reached one throughitemsand gotany[].ApplicationInstance.Tags?: ApplicationInstance_Tag[], andApplicationInstance_Tagis a real declared class withKeyandValue.oneOf/anyOfdiscarded everything beside itresolvePropertyTypechecked the keyword first and returnedanywithout readingprop.type. 44 of the 52 direct cases also declare a realtype, and the branch list relaxes that type rather than summing shapes:Reading the sibling keywords types all 44; taking a string enum branch as the narrower answer makes 5 of them a union, all five on one resource.
AWS::AmazonMQ::Broker.EngineTypeis"ACTIVEMQ" | "RABBITMQ", andDeploymentMode,StorageType,DataReplicationModeandMaintenanceWindow.DayOfWeekcome with it. The other 39 becomestring,numberorboolean.A branch list with nothing beside it is a real sum type and still resolves to
any. Those are #2278.allOfwas not handledAll nine occurrences are one
$refbeside an annotation, which types as the$refalone:AWS::BedrockAgentCore::Gateway.ProtocolTypeisBedrockAgentCoreGateway_GatewayProtocolType, which is= "MCP". AnallOfthat intersects two real shapes has no single answer and staysany.Two things found while measuring
[]binds tighter than|, so the emitter's${itemType}[]producedArchitectures?: "arm64" | "x86_64"[]— a type that accepts the bare string"arm64"and rejects["arm64"]. 62 declarations were already wrong that way before this branch and the array fix would have added 7 more, so item unions are now parenthesized. That is the only category of change in this PR where a property's old type was notany.A list definition whose items reach the definition again would recurse without end, so the resolution path now carries the definition names it has already visited.
Counts
lexicons/aws/src/generated/index.d.ts, fromnpm run --prefix lexicons/aws generateon each side, counted withgrep -c ': any;'andgrep -c ': any\[\];':: any;: any[];Replaying the resolver over the raw schemas, the same 1,653 the generator reads, with the same patches and enum overlay applied:
$refto anarraydefinition$refto a definition that is only aoneOf/anyOfoneOf/anyOfbeside a realtypetypedeclaredallOf$refto an empty definitiononeOf/anyOfwith nothing beside it$refto a definition the schema does not declare$refto a definition that is itself a bare$refanyDiffing every one of the 44,260 resolved types, 562 changed and every one of them went from
anyorany[]to something narrower. Nothing that had a type acquired a worse one.azure is the only other lexicon that calls
resolvePropertyType. Its count is 226: any;and 500: any[];before and after, andchant dev surface-diff lexicons/azurereports no surface changes — ARM schemas do not write these three shapes. Every other lexicon imports onlyextractConstraints,primaryTypeandisEnumDefinition, none of which changed.What remains
199 properties, all listed in the table above. The 161 definition-level
oneOf/anyOfcases are genuine sum types across 61 resource types, and want a real TypeScript union, which is a change to the emitter rather than the resolver. Filed as #2278, with the residue and #2205's coverage-metric acceptance item carried over.The surface snapshot
boundPropertyTypesseeds reachability from the resolved type strings, so a definition that was only ever reached through ananyis now reachable and gets emitted. The surface gains 408 property-type entries and loses 7:DimensionMapping,DocumentAttributeTarget,FilesystemConfiguration,Lambda,LambdaAuthorizerConfig,OpenIDConnectConfigandSourceAlgorithmeach held a bare name because exactly one resource emitted them; a second resource now does, and the naming strategy prefixes both. Nothing outsidesrc/generatedreferenced them, andnpx tsc --noEmitover the repo is clean.chant dev surface-diff lexicons/awsreports severity breaking against the committed baseline. On main the same command reports severity none, so the whole delta is this branch. The release-time gate (#1473) would refuse to publish past it, so the snapshot re-baselines here, the way #1506 and #605 did. No--bump: packages ship in lockstep.Gates
Run from the worktree root.
npm run --prefix lexicons/aws generate— 1662 resources, 6194 property types (was 5946), 1626 enumsnpx tsc --noEmit— exit 0npx tsc --noEmit -p lexicons/aws/tsconfig.build.json— exit 0npx vitest run lexicons/aws packages/core/src/codegen— 170 files, 2246 passed, 2 skippednpx vitest run packages lexicons examples— 1203 files, 16839 passed, 39 skipped, exit 0npx tsx scripts/typecheck.ts—Repo-wide typecheck: 31 known failure(s), no regressions. (31 baselined)npx tsx scripts/check-lexicons.ts— every lexicon 23/23 tier-1,No untracked tier-1 failures.npx tsx packages/core/src/cli/main.ts dev check-lexicon lexicons/aws—Tier 1 — required (23/23),Tier 2 — recommended (16/17)(the one WARN isAt least 3 initTemplates, 2 templates, pre-existing),Tier 3 — thoroughness (8/9),All tier-1 checks passed.No surface-snapshot check runs incheck-lexicon; it is release-gated, anddev surface-diff lexicons/awsis the run quoted above.npx eslint packages/— 0 errors, 2 pre-existing warnings inpackages/core/src/meta/publish-metadata.test.tsnode scripts/depcheck.mjs—✓ no undeclared runtime dependencies🤖 Generated with Claude Code
https://claude.ai/code/session_0148a4dPTErCBpmNy7J7933f