Skip to content

fix(extractor): report unsupported StyleX APIs as located errors - #905

Merged
owjs3901 merged 1 commit into
mainfrom
fix/stylex-unsupported-api
Nov 14, 2026
Merged

owjs3901 merged 1 commit into
mainfrom
fix/stylex-unsupported-api

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

SX-10 (covers SX-09 when and SX-11 env). Before this change, a @stylexjs/stylex export outside STYLEX_EXPORTS was skipped in visit_import_declaration and no diagnostic was given. The import stayed on @stylexjs/stylex, so the call ran at runtime and threw because no StyleX compiler had run. A named import like import { when } from '@stylexjs/stylex' and a member read on the whole-package import like stylex.when.ancestor(...), stylex.env or stylex.defaultMarker() are now located build errors. Each error names the API and lists what Devup UI compiles (#682).

  • scope::lookup::stylex_member reads the member name off the namespace. The check runs in visit_expression, so a when used as a computed key inside stylex.create() is still reported.
  • test_stylex_import_unknown_named used to snapshot the residue, where unknownFunction stayed imported from @stylexjs/stylex. It now asserts the error, and its snapshot is removed.
  • The StyleX migration doc gets an "Unsupported APIs" section.

New build error:

  • `@stylexjs/stylex` `when` is not compiled by Devup UI, so it would stay a StyleX call at runtime, which throws with no StyleX compiler run. Fix: use only `create`, `props`, …

Refs #690

Test plan

  • cargo test -p extractor --lib -- stylex sx (2244 passed)
  • New snapshot stylex_unsupported_api_is_located_error reviewed: named, aliased, default namespace, * as namespace, and computed key inside create()
  • cargo clippy -p extractor --all-targets -- -D warnings, cargo fmt --all
  • CI: full test suite + tarpaulin 100%

🤖 Generated with Claude Code

A `@stylexjs/stylex` export outside the compiled set (`when`, `env`,
`defaultMarker`, ...) was dropped from the bindings with no diagnostic, so
its calls stayed StyleX calls that throw at runtime. Importing it by name,
or reading it as a member of the package imported whole, is now a located
build error naming the API and listing what Devup UI compiles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
libs/extractor/src/lib.rs 100.00% <ø> (ø)
libs/extractor/src/scope/lookup.rs 100.00% <ø> (ø)
libs/extractor/src/stylex.rs 100.00% <100.00%> (ø)
libs/extractor/src/visit.rs 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@owjs3901
owjs3901 merged commit c651afa into main Nov 14, 2026
27 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.

1 participant