Add TypeScript export functionality for DTO classes#3
Closed
Conversation
Contributor
Author
|
@huangdijia 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
|
Thank you for your pull request. However, you have submitted this PR on the friendsofhyperf organization which is a read-only sub split of |
Copilot
AI
changed the title
[WIP] what kind of a fork is this? soft/hard? do you have plans on updating from Validated DTO for Laravel?
Add TypeScript export functionality for DTO classes
Sep 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements TypeScript export functionality that generates TypeScript interface definitions from DTO classes, bringing feature parity with the Laravel Validated DTO package as requested in the issue.
Features Added
New Export Command
A new
export:typescriptcommand that scans DTO classes and generates TypeScript interfaces:Intelligent Type Mapping
Comprehensive mapping from PHP cast types to TypeScript types:
StringCast→stringIntegerCast,FloatCast→numberBooleanCast→booleanEnumCast→ Union types (e.g.,'active' | 'inactive')DTOCast→ Interface referencesArrayCast→any[]ModelCast→objectExample Output
Given a DTO like this:
The export generates:
Technical Implementation
ExportTypescriptCommand: Console command with flexible path and output optionsTypescriptExporter: Core logic for scanning DTO classes and generating interfacesConfiguration
Added TypeScript export configuration to the DTO config file:
This implementation provides type safety for frontend applications while maintaining compatibility with the existing Hyperf ecosystem conventions.
Fixes #2.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/doctrine/deprecations/zipball/459c2f5dd3d6a4633d3b5f46ee2b1c40f57d3f38/usr/bin/php8.3 -n -c /tmp/V3jutc /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/FW4YWt /usr/bin/composer install --no-dev(http block)https://api.github.com/repos/doctrine/inflector/zipball/6d6c96277ea252fc1304627204c3d5e6e15faa3b/usr/bin/php8.3 -n -c /tmp/V3jutc /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/FW4YWt /usr/bin/composer install --no-dev(http block)https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b/usr/bin/php8.3 -n -c /tmp/V3jutc /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/FW4YWt /usr/bin/composer install --no-dev(http block)https://api.github.com/repos/doctrine/lexer/zipball/861c870e8b75f7c8f69c146c7f89cc1c0f1b49b6/usr/bin/php8.3 -n -c /tmp/FW4YWt /usr/bin/composer install --no-dev(http block)https://api.github.com/repos/hyperf/conditionable/zipball/dec9dec9dbde14e20f3d7ba000c3302381019de1/usr/bin/php8.3 -n -c /tmp/V3jutc /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/FW4YWt /usr/bin/composer install --no-dev(http block)https://api.github.com/repos/hyperf/macroable/zipball/14b0a00d3ab6c768aaa5c34222b84000bb75eb29/usr/bin/php8.3 -n -c /tmp/V3jutc /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/FW4YWt /usr/bin/composer install --no-dev(http block)https://api.github.com/repos/hyperf/tappable/zipball/f5c5d343c95238dcb3fe500876ceadc175e221f8/usr/bin/php8.3 -n -c /tmp/V3jutc /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/FW4YWt /usr/bin/composer install --no-dev(http block)https://api.github.com/repos/php-fig/http-message-util/zipball/9d94dc0154230ac39e5bf89398b324a86f63f765/usr/bin/php8.3 -n -c /tmp/V3jutc /usr/bin/composer install(http block)/usr/bin/php8.3 -n -c /tmp/FW4YWt /usr/bin/composer install --no-dev(http block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.