Skip to content
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

CamelCasedPropertiesDeep doesn't handle Tagged type correctly #889

Closed
Ghost-str opened this issue Jun 8, 2024 · 1 comment · Fixed by #890
Closed

CamelCasedPropertiesDeep doesn't handle Tagged type correctly #889

Ghost-str opened this issue Jun 8, 2024 · 1 comment · Fixed by #890

Comments

@Ghost-str
Copy link
Contributor

Ghost-str commented Jun 8, 2024

type UUID = Tagged<string, "UUID">;

 type User = {
     user_id: UUID;
 }

type Article = {
    name: string;
    view_count: number;
    author: User;
}

type MyType = CamelCasedPropertiesDeep<Article>;

Got:
image

Expected:

UUID type

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@Ghost-str
Copy link
Contributor Author

Possible solution:

export type CamelCasedPropertiesDeep<
	Value,
	Options extends CamelCaseOptions = {preserveConsecutiveUppercase: true},
> = Value extends Function
	? Value
	: Value extends UnknownArray
		? CamelCasedPropertiesArrayDeep<Value>
		: Value extends Set<infer U>
			? Set<CamelCasedPropertiesDeep<U, Options>>
			: Value extends Tag<any, any> 
				? Value
				: {
					[K in keyof Value as CamelCase<K, Options>]: CamelCasedPropertiesDeep<
					Value[K],
					Options
					>;
				};

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 a pull request may close this issue.

1 participant