All Projects → KnisterPeter → React To Typescript Definitions

KnisterPeter / React To Typescript Definitions

Licence: mit
Create typescript definitions files (d.ts) from react components

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to React To Typescript Definitions

Rapidyaml
Rapid YAML - a library to parse and emit YAML, and do it fast.
Stars: ✭ 183 (-10.29%)
Mutual labels:  parser
Expressionevaluator
A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts
Stars: ✭ 194 (-4.9%)
Mutual labels:  parser
Lief
Authors
Stars: ✭ 2,730 (+1238.24%)
Mutual labels:  parser
Thepiratebay
💀 The Pirate Bay node.js client
Stars: ✭ 191 (-6.37%)
Mutual labels:  parser
Diagon
Interactive ASCII art diagram generators. 🌟
Stars: ✭ 189 (-7.35%)
Mutual labels:  parser
Tatsu
竜 TatSu generates Python parsers from grammars in a variation of EBNF
Stars: ✭ 198 (-2.94%)
Mutual labels:  parser
M3u8parser
A light weight M3U8 parser. Support X-Key & X-Session-Key.
Stars: ✭ 187 (-8.33%)
Mutual labels:  parser
Graphql Parser
A graphql query language and schema definition language parser and formatter for rust
Stars: ✭ 203 (-0.49%)
Mutual labels:  parser
Pytimeparse
A small Python module to parse various kinds of time expressions.
Stars: ✭ 195 (-4.41%)
Mutual labels:  parser
Php Textile
Textile markup language parser for PHP
Stars: ✭ 200 (-1.96%)
Mutual labels:  parser
Swiftparsec
A parser combinator library written in the Swift programming language.
Stars: ✭ 192 (-5.88%)
Mutual labels:  parser
Device Detector Js
A precise user agent parser and device detector written in TypeScript
Stars: ✭ 193 (-5.39%)
Mutual labels:  parser
Xdpw
XD Pascal: A small embeddable self-hosting Pascal compiler for Windows. Supports Go-style methods and interfaces
Stars: ✭ 199 (-2.45%)
Mutual labels:  parser
Getjs
A tool to fastly get all javascript sources/files
Stars: ✭ 190 (-6.86%)
Mutual labels:  parser
Insect
High precision scientific calculator with support for physical units
Stars: ✭ 2,469 (+1110.29%)
Mutual labels:  parser
Readability
Readability is Elixir library for extracting and curating articles.
Stars: ✭ 188 (-7.84%)
Mutual labels:  parser
Cub
The Cub Programming Language
Stars: ✭ 198 (-2.94%)
Mutual labels:  parser
Jssoup
JavaScript + BeautifulSoup = JSSoup
Stars: ✭ 203 (-0.49%)
Mutual labels:  parser
Email address
The EmailAddress Gem to work with and validate email addresses.
Stars: ✭ 199 (-2.45%)
Mutual labels:  parser
Goparsec
Parser combinator in Go. If there are any cross platform issues or backward compatibility issues, please reach out.
Stars: ✭ 198 (-2.94%)
Mutual labels:  parser

react-to-typescript-definitions

GitHub license npm Travis codecovCommitizen friendly Standard Version renovate badge

Create typescript definitions files (d.ts) from react components.

Features

  • ES6 and ES7 class syntax
  • Most PropTypes
    • any, array, bool, func, number, object, string, node, element, oneOfType, arrayOf, symbol, shape
  • Partial support for oneOf PropType
  • required PropTypes
  • instanceOf PropTypes (when using API and giving a resolve function)
  • jsdoc

Usage

Installation

Install as npm package:

npm install react-to-typescript-definitions --save-dev

or

npm install -g react-to-typescript-definitions

CLI

Usage
  $ react2dts [--module-name <name> | --top-level-module]

react2dts reads from stdin to process a file.

Options
  --module-name, --name  name of the module to create
  --top-level-module     if the created module should live in top-level

Examples
  $ cat <some/react/component.jsx> |react2dts --module-name module-name

  $ cat <some/react/component.jsx> |react2dts --top-level-module

API

Functions:

/**
 * Returns the typescript definition for the given file.
 *
 * @param name The name of the generated module
 * @param path The path to the file to parse
 * @param options The options to use
 * @return The type definition as string
 */
function generateFromFile(name, path, options)
/**
 * Returns the typescript definition for the given source.
 *
 * @param name The name of the generated module
 * @param code The code to parse
 * @param options The options to use
 * @return The type definition as string
 */
function generateFromSource(name, code, options)
/**
 * Returns the typescript definition for the given babylon AST object.
 *
 * @param name The name of the generated module
 * @param ast The babylon ASt to parse
 * @param options The options to use
 * @return The type definition as string
 */
function generateFromAst(name, ast, options)

Options:

  • instanceOfResolver
    A function which gets a type name (as string) and should return the path to the file defining the type or undefined if the type is not resolvable. This function is required to generate instanceOf PropTypes.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].