Skip to content

fix: throw a clear error for unsupported transform functions (closes #644)#757

Open
Vitalini wants to merge 1 commit into
vercel:mainfrom
Vitalini:fix/transform-unsupported-error
Open

fix: throw a clear error for unsupported transform functions (closes #644)#757
Vitalini wants to merge 1 commit into
vercel:mainfrom
Vitalini:fix/transform-unsupported-error

Conversation

@Vitalini

Copy link
Copy Markdown

Summary

Fixes #644.

Previously, using an unsupported transform function like translateZ(1px), translate3d(...), rotateX(...), perspective(...) or matrix(...) produced a cryptic downstream error such as Y[r] is not a function from the css-to-react-native parser, paired with the misleading hint that only absolute lengths were supported.

This change validates transform function names up-front against the list of functions actually implemented by builder/transform.ts (plus the shorthand forms that css-to-react-native unfolds) and throws an explicit error that names the offending function and lists the supported set.

Before

Y[r] is not a function
  in CSS rule `transform: translateZ(1px)`. Only absolute lengths such as `10px` are supported.

After

`transform: translateZ()` is not supported. Supported transform functions: translate, translateX, translateY, scale, scaleX, scaleY, rotate, skewX, skewY.

Test plan

  • Added two cases in test/error.test.tsx:
    • single unsupported function (translateZ)
    • list with one unsupported function mixed in with a supported one (rotate(45deg) rotateX(30deg))
  • All existing error and transform tests continue to pass (test/error.test.tsx, test/transform.test.tsx — 19 passing)
  • Prettier-formatted, ESLint clean

@Vitalini Vitalini requested a review from shuding as a code owner May 15, 2026 20:22
@vercel

vercel Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
satori-playground Canceled Canceled Open in v0 Jun 12, 2026 9:49pm

Comment thread src/handler/expand.ts
'translateX',
'translateY',
'scale',
'scaleX',

@vercel vercel Bot May 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SUPPORTED_TRANSFORM_FUNCTIONS allowlist is missing skew, causing transform: skew(...) to throw an error despite being fully supported by css-to-react-native and builder/transform.ts.

Fix on Vercel

Fixes vercel#644.

Previously, using an unsupported transform function like `translateZ(1px)`,
`translate3d(...)`, `rotateX(...)`, `perspective(...)` or `matrix(...)`
produced a cryptic downstream error such as `Y[r] is not a function` from
the `css-to-react-native` parser, paired with the misleading hint that only
absolute lengths were supported.

This change validates the transform function names against the list of
functions actually implemented by `builder/transform.ts` (plus the
shorthand forms unfolded by `css-to-react-native`) and throws an explicit
error that names the offending function and lists the supported set.

Before:

  Y[r] is not a function
    in CSS rule `transform: translateZ(1px)`. Only absolute lengths
    such as `10px` are supported.

After:

  `transform: translateZ()` is not supported. Supported transform
  functions: translate, translateX, translateY, scale, scaleX, scaleY,
  rotate, skewX, skewY.

Test plan: two new cases in `test/error.test.tsx` cover a single
unsupported function and a list with one unsupported function mixed in
with a supported one. All existing error and transform tests continue to
pass.
@Vitalini Vitalini force-pushed the fix/transform-unsupported-error branch from 05dcd39 to 451b11e Compare June 12, 2026 21:49
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.

Misleading error when using translateZ(value)

1 participant