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 resulting object properties correctly when using change-case/keys #341

Open
dnjstrom opened this issue May 10, 2024 · 4 comments
Open

Comments

@dnjstrom
Copy link

When using change-case/keys I would love for the resulting object to be typed correctly without having to do an explicit cast. Currently all transformations produce unknown.

import { camelCase } from "change-case/keys"
import type { CamelCasedProperties } from 'type-fest';

const snake_cased = { foo_bar: 1 }

// Preferably the cast could be left off on the line below
const camelCased = camelCase(snake_cased) as CamelCasedProperties<typeof snake_cased>

console.log(camelCased.fooBar) // => 1
@hxtruong6

This comment was marked as off-topic.

@blakeembrey

This comment was marked as off-topic.

@blakeembrey
Copy link
Owner

blakeembrey commented Jun 5, 2024

I think I closed a past issue on the complexity on typing these, but I think it could be good to have available. I would accept a PR if anyone wants to attempt this.

Previous issue: #294.

@hxtruong6

This comment was marked as resolved.

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

No branches or pull requests

3 participants