Code Monkey home page Code Monkey logo

proptypes-to-ts-declarations's People

Contributors

jcenturion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

book777

proptypes-to-ts-declarations's Issues

Does not parse enum numbers correctly

react-docgen parses enums incorrectly,

Heading.propTypes = {
  size: size: PropTypes.oneOf([1, 2, 3])
}

is parsed as:

"type": {
  "name": "enum",
  "value": [
    { "value": "1", "computed": false },
    { "value": "2", "computed": false },
    { "value": "3", "computed": false },
  ]
}

=

type headingSizeEnum = "1" | "2" | "3";

losing the information about the type of values inside the enum

It might make sense to add a custom resolver for enums to identify number from string?

const isNumber = value => {
  const parsedValue = Number(value)
  /*
    Number("42") => 42
    Number("42px") => NaN

    We can use isNaN to detect if the parsed value
    is not a number
  */
  if (isNaN(parsedValue)) return false
  return true
}

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.