Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork192
Implement Class Transformation Functions with Proper Prototype Handling#1642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Co-authored-by: samchon <13158709+samchon@users.noreply.github.com>
Co-authored-by: samchon <13158709+samchon@users.noreply.github.com>
samchon left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@copilot Try again please.
…ototypeCo-authored-by: samchon <13158709+samchon@users.noreply.github.com>
The core Fixed in commit
Testing Results: constinput={name:"test",value:42};constresult=typia.misc.classTransform<SimpleClass>(input);// result instanceof SimpleClass === true// result.greet() === "Hello, test!" The implementation now uses Note: There's a remaining issue with |
Uh oh!
There was an error while loading.Please reload this page.
This PR introduces new class transformation functions
typia.misc.classTransform<T>()andtypia.misc.assertClassTransform<T>()that convert plain objects into proper class instances with correct prototype chains.Problem
Previously, there was no way to transform plain objects (like JSON data) into class instances while maintaining the class prototype chain and methods. This is commonly needed when:
Solution
The implementation generates optimized transformation code at compile-time that:
Object.create(ClassName.prototype)Object.assign(instance, input)instanceofchecks work correctlyUsage Example
Technical Details
Fixes#683
✨ Let Copilot coding agentset things up for you — coding agent works faster and does higher quality work when set up for your repo.