-
Notifications
You must be signed in to change notification settings - Fork 70
Description
Wayfinder Version
0.1.12
Laravel Version
12.x
PHP Version
8.4.11
Description
When a controller namespace segment repeats (e.g. App\Http\Controllers\Prism\Prism\Http\Controllers...), the generated barrel file resources/js/actions/Prism/index.ts contains an import and a const with the same
identifier:
import Prism from './Prism'
const Prism = {
Prism: Object.assign(Prism, Prism),
}
export default Prism
This causes TypeScript errors:
- TS2440: Import declaration conflicts with local declaration of 'Prism'
- TS7022: 'Prism' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
- TS2448: Block-scoped variable 'Prism' used before its declaration.
Steps To Reproduce
-
Create controllers under a repeated namespace path, e.g. App\Http\Controllers\Prism\Prism\Http\Controllers\PrismChatController.
-
Ensure routes point to those controllers.
-
Run:
php artisan wayfinder:generate --path=resources/js --with-form
-
Open resources/js/actions/Prism/index.ts.
Expected Behavior
Generated barrel file should use distinct identifiers (or safe aliases) so that import and const names don’t collide.
Actual Behavior
Generated index.ts contains import Prism and const Prism = { ... }, causing TS errors and breaking pnpm run types.
Additional Context / Suggestion
The issue seems to come from barrel generation using the same safeMethod name for both import alias and the exported const. A simple fix could be to disambiguate the top-level export variable name when it matches a child
import (e.g. PrismNamespace or PrismRoot), or apply TypeScript::safeMethod differently for the exported const.