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

type CamelCasedPropertiesDeep converting Record into {} #475

Closed
salomaoluiz opened this issue Sep 28, 2022 · 0 comments · Fixed by #531
Closed

type CamelCasedPropertiesDeep converting Record into {} #475

salomaoluiz opened this issue Sep 28, 2022 · 0 comments · Fixed by #531

Comments

@salomaoluiz
Copy link

salomaoluiz commented Sep 28, 2022

In my tests I'm using the CamelCasedPropertiesDeep to convert the returns of an API, and we have a property that returns an object with some languages and their respective translations, we type this return as title: Record<string, string> but when we use the CamelCasedPropertiesDeep it returns the type as title: {} and when we try to get the language like: title[acceptedLanguage] we got a error TS (7053).

Example Used:

interface APIReturn {
	title: Record<string, string>
}

class API {
	get = (): Promise<CamelCasedPropertiesDeep<APIReturn>> => Promise.resolve({
		title: {
			en: "English Translate"
		}
	})
}

const translate = (apiReturn: AsyncReturnType<API['get']>, acceptedLanguage: string) => apiReturn.title[acceptedLanguage]

Is this an error on the type or can we use another type instead of Record to type this title?

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