GithubHelp home page GithubHelp logo

Comments (7)

sindresorhus avatar sindresorhus commented on May 17, 2024

// @g-plane

from camelcase-keys.

g-plane avatar g-plane commented on May 17, 2024

This may be able to be fixed, but the "optional" mark will be lost as the given example. For example:

type Source = { a?: string }

will become:

type Result = { a: string | undefined }

These are different in TypeScript.

from camelcase-keys.

monisnap-paul avatar monisnap-paul commented on May 17, 2024

There are actually two issues with the given example:

  1. "City" and "Country" properties in the type are not properly converted to camelcase
  2. "?" is not equivalent to "| undefined"

from camelcase-keys.

g-plane avatar g-plane commented on May 17, 2024

"?" is not equivalent to "| undefined"

I know, but we can't operate: TypeScript playground.

from camelcase-keys.

salemhilal avatar salemhilal commented on May 17, 2024

I wanted to bump this. It seems like even if { someKey?: string} is different than { someKey: string | undefined }, that's probably a level less important than having the type be { some_key?: string } but having the actual value be { someKey: string | undefined }.

If that's a cool assumption to make, I'd be open to submitting a patch for this issue.

from camelcase-keys.

RichiCoder1 avatar RichiCoder1 commented on May 17, 2024

Ironically I think this fix for this is to use the type CamelCasedPropertiesDeep from type-fest.

from camelcase-keys.

jandolezal71 avatar jandolezal71 commented on May 17, 2024

I wanted to bump this. It seems like even if { someKey?: string} is different than { someKey: string | undefined }, that's probably a level less important than having the type be { some_key?: string } but having the actual value be { someKey: string | undefined }.

If that's a cool assumption to make, I'd be open to submitting a patch for this issue.

Output type should be { someKey?: string | undefined } or { someKey?: string }.

In some cases you don't want to pass keys with undefined values explicitely.

from camelcase-keys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.