-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
[Bug Report] every property is cloned to required type even if there are optional property. #628
Comments
this controller have another bug
// success case
@core.TypedException<"404 Not Found">(nest.HttpStatus.NOT_FOUND)
@core.TypedRoute.Get("success")
async successCase(): Promise<string> {
return "success";
}
// fail case
@core.TypedException<ErrorCode.NotFound>(nest.HttpStatus.NOT_FOUND)
@core.TypedRoute.Get("fail")
async failCase(): Promise<string> {
return "fail";
}
namespace ErrorCode {
export type NotFound = "404 Not Found";
} |
Fix #628 - enhance test programs of DTO clone mode.
Upgrade to v2.1.4, then everything would be fine. |
bug condition UtilType Partial is not work. another small bug) |
Show me the difference name clone type case please. |
i think, it need another issue and features project. because this bug is related with tsconfig. so i will make it tonight! |
@samchon |
No problem when May I always define the Original typenestia/test/features/clone-and-propagate/src/controllers/UserNormalsController.ts Lines 75 to 77 in 795d9d5
Cloned type
|
can you add test project to nestia/test/features/clone-and-exact-optional-property? i think, now in test project can show this bug.
interface IOriginal {
a:string;
b:string;
c:string;
d:string;
/** @format email */
email: string | null;
created_at: ( string & typia.tags.Format<'date-time'>) | null;
original_optional?: boolean;
undefinable_attr: string | undefined;
}
interface IPartialInterface extends Partial<Pick<IOriginal,"a" | "email" | "created_at" | "original_optional" | "undefinable_attr">> {};
type IPartialType = Partial<Pick<IOriginal,"b" | "email" | "created_at" | "original_optional" | "undefinable_attr">>;
namespace IOriginal {
export interface IPartialInterface extends Partial<Pick<IOriginal,"c" | "email" | "created_at" | "original_optional" | "undefinable_attr">> {};
export type IPartialType = Partial<Pick<IOriginal,"d" | "email" | "created_at" | "original_optional" | "undefinable_attr">>;
}
export type IOriginal = {
a: string;
b: string;
c: string;
d: string;
email: null | (string & Format<"email">);
created_at: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr: undefined | string;
}
export namespace IOriginal {
export type IPartialInterface = {
email?: null | (string & Format<"email">);
created_at?: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr?: undefined | string;
c?: string;
}
}
export type IPartialInterface = {
email?: null | (string & Format<"email">);
created_at?: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr?: undefined | string;
a?: string;
}
export type PartialPickIOriginaldemailcreated_atoriginal_optionalundefinable_attr = {
d?: string;
email?: null | (string & Format<"email">);
created_at?: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr?: undefined | string;
}
export type PartialPickIOriginalemailcreated_atoriginal_optionalundefinable_attrb = {
email?: null | (string & Format<"email">);
created_at?: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr?: undefined | string;
b?: string;
}
export type IOriginal = {
a: string;
b: string;
c: string;
d: string;
email: null | (string & Format<"email">);
created_at: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr: undefined | string;
}
export namespace IOriginal {
export type IPartialInterface = {
email: null | (string & Format<"email">);
created_at: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr: undefined | string;
c: string;
}
}
export type IPartialInterface = {
email: null | (string & Format<"email">);
created_at: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr: undefined | string;
a: string;
}
export type PartialPickIOriginaldemailcreated_atoriginal_optionalundefinable_attr = {
d: string;
email: null | (string & Format<"email">);
created_at: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr: undefined | string;
}
export type PartialPickIOriginalemailcreated_atoriginal_optionalundefinable_attrb = {
email: null | (string & Format<"email">);
created_at: null | (string & Format<"date-time">);
original_optional?: boolean;
undefinable_attr: undefined | string;
b: string;
} |
Change to branch |
Then let's make every optional or undefindable to be It would be better if considering the frontend environments. |
but and this bug is appear when |
About the partial type, I will check typia again. |
now clone-and-propagate project show this bug. (original interface is IUser.IUpdate in UserNormalsController.ts) Cloned typeExpected typeexport type PartialPickIUsernameemailnullable_attroptional_attr = {
name?: string;
email?: null | (string & Format<"email">);
nullable_attr?: null | string;
optional_attr?: string;
} |
…tial<T>` and `Required<T>` types. If user configured `tsconfig.json` to turn on `exactOptionalPropertyTypes` option, and use `Partial<T>` or `Required<T>` type, `typia` could not identify whether each property is optional or not. This PR fixes such bug, by enhancing analyzer of TypeScript types. Also, turned on the `exactOptionalPropertyTypes` option tor enhancing type safety for this case.
Fix samchon/nestia#628 - `exactOptionalPropertyTypes`'s with `Partial<T>` and `Required<T>` types.
Bug Report
DTO's original property is optional. but in generated DTO, all property is required.
I write a test controller that replace UserNormalsController.ts in test/features/clone/src/controllers
this controller test
comment tag transformed to special tag
When namespaced DTO type comes,
@nestia/sdk
had taken a mistake that writing only the deepest type even in the top or middle level namespaced types.When
clone
mode being used in SDK generator, it was not possible to clone recursive DTO type.In propagation mode use with TypedException decorator, target T type had not been cloned.
optional property is cloned required property
use HttpCode decorator
The text was updated successfully, but these errors were encountered: