Skip to content

7.28.0 Regression on TypeScript transform when passing references #17434

@aldobarr

Description

@aldobarr

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

<div ref={sortable?.ref}>

Configuration file name

No response

Configuration

Vite config. I'm not sure which "how are you using babel?" I should have put with vite but that's what I'm using in my solid-js project.

import tailwindcss from '@tailwindcss/vite';
import laravel from 'laravel-vite-plugin';
import devtools from 'solid-devtools/vite';
import { defineConfig } from 'vite';
import lucidePreprocess from 'vite-plugin-lucide-preprocess';
import solidPlugin from 'vite-plugin-solid';

export default defineConfig(({ mode }) => {
	const plugins = [
		lucidePreprocess(),
		laravel({
			input: ['resources/js/index.tsx'],
			refresh: true,
		}),
		tailwindcss(),
	];

	const build = {
		target: 'esnext',
	};

	if (mode === 'development') {
		plugins.push(
			devtools({
				autoname: true,
				locator: {
					targetIDE: 'vscode',
					componentLocation: true,
					jsxLocation: true,
				},
			}),
		);

		build.sourcemap = true;
	}

	plugins.push(
		solidPlugin(),
	);

	return {
		plugins: plugins,
		build: build,
	};
});

Current and expected behavior

The above reference pass should work. The sortable var is from
import { createSortable } from '@thisbeyond/solid-dnd';

This was transpiling just fine on version 7.27.X but on 7.28.0 it's now broken with this error:

error during build:
[vite:esbuild] Transform failed with 1 error:
/home/workspaces/resources/js/components/deckbuilder/Category.tsx:115:55: ERROR: Invalid assignment target
file: /home/workspaces/resources/js/components/deckbuilder/Category.tsx:115:55

Invalid assignment target
113|        _el$5 = _el$.firstChild;
114|      var _ref$ = sortable?.ref;
115|      typeof _ref$ === "function" ? _$use(_ref$, _el$) : sortable?.ref = _el$;
   |                                                         ^
116|      _$insert(_el$, _$createComponent(Show, {
117|        get when() {

In fact, simply downgrading @babel/types to 7.27.7 is enough to restore functionality without downgrading any of my other @babel dependencies.

Environment

System:
OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
Binaries:
Node: 24.1.0 - /usr/bin/node
Yarn: 1.22.19 - /mnt/Roaming/npm/yarn
npm: 11.4.2 - /usr/bin/npm
pnpm: 10.12.1 - /usr/bin/pnpm

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions