fix(types): preserve macro resolve unions#1903
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR fixes a type-level regression where macro resolves returning unions of different object shapes were incorrectly inferred as ChangesUnion object merge for macro resolve typing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/types.tsOops! Something went wrong! :( ESLint: 9.39.4 Error: ESLint configuration in --config » plugin:sonarjs/recommended is invalid:
Referenced from: /.eslintrc.json ... [truncated 291 characters] ... /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2952:16) test/types/macro.tsOops! Something went wrong! :( ESLint: 9.39.4 Error: ESLint configuration in --config » plugin:sonarjs/recommended is invalid:
Referenced from: /.eslintrc.json ... [truncated 291 characters] ... /node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2952:16) 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. Comment |
Summary
resolveinstead of intersecting them intoneverresolvereturns different object shapesFixes #1891
Reproduction
A macro
resolvereturning{ user: { id } } | { user: { id }, admin: true }previously inferreduserasneverinside the route handler. The new type test verifiesuserremains{ id: string }andadminremainsboolean | undefined.Boundary report
Tests
bun run test:typesbun test test/macro/macro.test.tsbun testbun run test:importsbun run buildbun run test:nodeNote:
bun run testexecutestest:nodewithout buildingdistfirst in this checkout, sotest:nodefails from missingdist/index.jsunlessbun run buildruns first. After building,bun run test:nodepasses.Summary by CodeRabbit