Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

peffraimidis's avatar

Vue props defined in a page component file error (typescript)

Hello all,

I am using Laravel with Laravel Data package from Spatie inertia.js and vue.js with typescript enabled and composition API with setup.

<script setup lang='ts'>
</script>

I also installed typescript-transformer from Spatie

The end game is to create a Laravel Data Object that holds all the props of the page Component so the controller action should look like that:

	public function show(Department $department): Response  
	{  
		  return inertia('DepartmentShow', new DepartmentShowData($department));  
	}

after I create the generated.d.ts file as the Spatie documentation suggests I have a the file below:

	declare namespace App.Data {
		export type DepartmentShowData = {  
		  department: App.Data.DepartmentData;  
		  employees: Array<App.Data.EmployeeData>;  
	  	};
	}

and now inside my DepartmentShow component this works

<script setup lang='ts'>
	const props = defineProps<{
		department: App.Data.DepartmentData,
		employees: Array<App.Data.EmployeeData>
	}>()
</script>

this also works

<script setup lang='ts'>
	type Props = {
		department: App.Data.DepartmentData,
		employees: Array<App.Data.EmployeeData>
	}
	
	const props = defineProps<Props>()
</script>

and this DOESN'T

<script setup lang='ts'>
	const props = defineProps<App.Data.DepartmentShowData>()
</script>

The error I get is:

[plugin:vite:vue] [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type

/Users/effraimidis/code/one/resources/js/Pages/Organization/Departments/DepartmentShow.vue
110|  
111|  
112|  const props = defineProps<App.Data.DepartmentShowData>()
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Any help plz?

1 like
5 replies
LaryAI's avatar
Level 58

The error message suggests that the type reference App.Data.DepartmentShowData is unresolvable or an unsupported built-in utility type. To resolve this issue, you can try the following steps:

  1. Make sure that the generated.d.ts file is correctly generated and located in the appropriate directory.

  2. Check if the DepartmentShowData type is exported correctly in the generated.d.ts file. Ensure that the namespace and type declaration match the actual structure of the data.

  3. Verify that the typescript-transformer package is properly installed and configured. Follow the Spatie documentation to ensure that all necessary steps are completed.

  4. If the issue persists, you can try explicitly importing the DepartmentShowData type in your component file. Add the following line at the top of your component file:

    import { DepartmentShowData } from 'path/to/generated.d.ts';
    

    Replace 'path/to/generated.d.ts' with the actual path to the generated.d.ts file.

  5. Finally, use the imported DepartmentShowData type in the defineProps function:

    const props = defineProps<DepartmentShowData>();
    

    Make sure that the imported type matches the structure defined in the generated.d.ts file.

If the issue still persists, it might be helpful to provide more information about your project setup and versions of the packages you are using.

joseburgon's avatar

I'm facing the same issue. Well, in my case not even the first 2 approaches work :(

Eslint tell me: error 'App' is not defined no-undef

mwikala's avatar

@pefremidis Any luck with this issue? I'm experiencing it now and I would prefer not to hardcode a new type in Vue land so that it doesn't become outdated if I make changes to the Data class in PHP.

By any chance is your Data class extending anothor? This is what I'm doing and I don't get the issue when using a Data class that just extends the Base Data class in the Spatie package

1000ml's avatar

I'm also having the same issue. Has anyone figured out how to fix it?

Please or to participate in this conversation.