Skip to content

Fix(CSS): TypeScript narrow on aliasVariableModeResolver closure - #429

Merged
1aron merged 1 commit into
master-co:rcfrom
0Miles:fix/core-type-error
May 3, 2026
Merged

1aron merged 1 commit into
master-co:rcfrom
0Miles:fix/core-type-error

Conversation

@0Miles

@0Miles 0Miles commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Pre-existing strict-TS error in `packages/core/src/core.ts:resolveVariables`. The inner closure references an outer `let` binding that TypeScript can't prove non-undefined after the if-block assignment.

let aliasVariableModeResolver = aliasVariableModeResolvers.get(variable.name)
if (!aliasVariableModeResolver) {
    aliasVariableModeResolvers.set(variable.name, aliasVariableModeResolver = {})
}
aliasVariableModeResolver[mode as string] = () => {
    delete aliasVariableModeResolver[mode as string]   // ← TS18048 'possibly undefined'
    ...
}

Fix: pull the assignment out of the conditional and capture into a const, so the closure references a definitely-defined value.

Why this matters

Surfaces only when a downstream package (extractor) type-checks core under stricter resolution —pnpm --filter @master/css-extractor type-check was failing on every rc-based commit.

Testing

  • tsc --noEmit passes for core, extractor, and all 17 issue-resolving branches
  • 108 core test files still pass; runtime behaviour unchanged (same control flow, just type-narrowed)

@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

@0Miles is attempting to deploy a commit to the Aoyue Team on Vercel.

A member of the Team first needs to authorize it.

Pre-existing strict-TS error in core.ts:resolveVariables. The inner
closure references an outer let binding that TypeScript can't prove
non-undefined after the if-block assignment.

Pull the assignment out of the conditional and capture into a const,
so the closure references a definitely-defined value.

Surfaces only when a downstream package (extractor) type-checks core
under stricter resolution — pnpm --filter @master/css-extractor
type-check fails on every rc-based commit.

- tsc --noEmit passes for core, extractor, and all 17 issue-resolving
  branches
- 108 core test files still pass
- Runtime behaviour unchanged (same control flow, just type-narrowed)
@0Miles
0Miles force-pushed the fix/core-type-error branch from d353373 to 82beec4 Compare April 30, 2026 19:05
@0Miles
0Miles requested a review from 1aron April 30, 2026 19:10
@1aron
1aron merged commit caa84a2 into master-co:rc May 3, 2026
23 of 24 checks passed
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.

2 participants