Skip to content

feat: group php namespace to ts namespaces#15

Open
rick-bongers wants to merge 1 commit intovagebnd:mainfrom
rick-bongers:namespaces
Open

feat: group php namespace to ts namespaces#15
rick-bongers wants to merge 1 commit intovagebnd:mainfrom
rick-bongers:namespaces

Conversation

@rick-bongers
Copy link
Contributor

@rick-bongers rick-bongers commented Mar 17, 2026

This pull request introduces a significant improvement to the TypeScript interface generation process from Laravel models and resources. The main change is the addition of namespace grouping, so all generated TypeScript types are now wrapped in appropriate declare namespace blocks based on their PHP namespaces. This ensures clearer organization, prevents naming collisions, and improves type references. The pull request also updates formatting and test expectations to reflect these changes.

Feature request
This PR is the followup based on the feature request: #14

Namespace Grouping & Type Reference Improvements:

  • Typescript types are now grouped and wrapped in declare namespace blocks, determined by their PHP class namespaces, both in the generator and in the expected output.
  • Type references for Laravel resources now include the namespace, e.g., Vagebond.Runtype.Tests.Fakes.Resources.ProductResourceType, instead of just ProductResourceType.

Formatting Enhancements:

  • Types and properties are indented within the namespace block for improved readability and consistency.
  • Test expectations updated to match the new formatting and namespace usage.

Upcoming Enhancements:

  • Support for mergeWhen helper method. In this case the property should marked conditionally undefined
  • Support for whenLoaded helper method. In this case the property should marked conditionally undefined
  • Support for when helper method. In this case the property should marked conditionally undefined

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