-
Notifications
You must be signed in to change notification settings - Fork 28
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a type-casting annotation #12
Conversation
Thanks for the PR! It seems to be a useful feature. I checked out your branch, but the generated output is not as expected. 1. Everything between the parentheses are set as type
import { MyType } from 'my-package';
import OtherType from 'other-package';
export class Product {
attributes: MyType, my-package;
otherAttributes: OtherType, other-package, default | null;
} 2. Two default imports from the same package raises error
This could be bypassed by setting any following appearance just to |
Sorry @Brakebein for the insufficient QA. Fixed the bugs you reported and added some usage to your sample |
Can you please also test and fix the following cases with relative paths:
In my case, I get following output: import { Prisma } from '@prisma/client';
import { MyType } from 'my-package';
export class Product {
attributes: MyType, my-package;
otherAttributes: Prisma.JsonValue;
} I think it's beacuse the following RegEx doesn't contain any dots (and slashes): const ANNOTATION_PARAMS_REGEX = /(?:\(([_A-Za-z0-9\-\, ]*)\))?/; |
@Brakebein Done! Added a proper unit test for this new and old behavior with |
Thanks! It looks okay now. |
Thank you @Brakebein - this package is a real help to us integrating Prisma into Nest at work and I'm happy to contribute back things we would find useful. Really appreciate you taking the time to both listen to the suggestions and help make my PRs better and more sound. |
Adds an annotation
@DtoCastType
that can be used to override the type of a field in the generated entities.