• This repository has been archived on 27/Nov/2023
  • Stars
    star
    238
  • Rank 168,935 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

More Repositories

1

vscode-commitizen

Visual Studio Code Commitizen Support
TypeScript
240
star
2

jreact

react.js on server-side java (with rhino or nashorn)
Java
168
star
3

vscode-github

:octocat: GitHub Support for vscode
TypeScript
130
star
4

tscodeshift

tscodeshift is a toolkit for running codemods over multiple TS files
TypeScript
53
star
5

tsdi

Dependency Injection container (IoC) for TypeScript
TypeScript
52
star
6

pretend

A decorator based http webservice client written in typescript
TypeScript
40
star
7

ts-emitter

Emitting typescript AST back to typescript
TypeScript
38
star
8

vscode-jira

JIRA integration for vscode
TypeScript
25
star
9

Smaller

A minification service for javascript and stylesheets supporting typescript, coffeescript, closure-compiler, uglifyjs, lessjs, cssembed, ycssmin and yuicompressor.
JavaScript
23
star
10

jreact-examples

Java
9
star
11

m3ujs

Create m3u files
TypeScript
9
star
12

jsonast

a json to ast parser which allows error recovery
TypeScript
9
star
13

queue-ts

A promise based worker queue with limited concurrency
TypeScript
8
star
14

html-webpack-exclude-empty-assets-plugin

JavaScript
7
star
15

tastatur

input and keyboard handling in javascript
TypeScript
6
star
16

vscode-ava-runner

This plugin executes ava in a background process and informs the user about tests execution in the status bar.
TypeScript
5
star
17

patternplate-transform-typescript

TypeScript transform for patternplate
TypeScript
4
star
18

smaller-dev-server

A development server utilizing smaller to have the plugins for local development.
Java
4
star
19

id3v2

Reads ID3v2 metadata
TypeScript
3
star
20

hinkelstein

Tools and scripts for monorepositories
TypeScript
3
star
21

json-config

JSON Config is an OSGi Configuration Admin extension supporting JSON files as configuration data
Java
3
star
22

topological-promise-queue

Run promises in order of a directed acyclic graph
JavaScript
3
star
23

react-ssr-renderer

React server-side rendering without special APIs
JavaScript
3
star
24

ankara

Code coverage tool leveraging babylon to cover es6/es7 and strawman proposals.
TypeScript
2
star
25

minificator-maven-plugin

Google Closure Compiler, LessCSS und EmbedCSS Mojos
Java
2
star
26

native-engine

jv8 is a java binding for googles v8 javascript engine
Java
2
star
27

JsonXssCleaner

JSON parser wich cleans strings from XSS hacks (means tags, quotes...).
Java
2
star
28

tipi-template-typescript

This is a tipi-cli template for typescript projects
JavaScript
2
star
29

rezensent

The rezensent is a github app which help managing big pull requests in a repository divided by code ownership rules
TypeScript
2
star
30

hazelcast-clusterstore

Implements a Hazelcast MapStore backed by another hazelcast instance. This could be used to backup a whole map to another cluster to get around cluster blackouts.
Java
1
star
31

vscode-webpack

Run webpack in code and track errors
TypeScript
1
star
32

harhar

a har execution enviroment
Groovy
1
star
33

yarn-tree

CLI to create a full tree of dependencies (like yarn list)
JavaScript
1
star
34

TimeTracker

JavaScript
1
star
35

node.js-bridge

node.js Bridge is a inter-process communication bridge between the bundled node.js and the executing JVM.
Java
1
star
36

coderetreat-playground

💻 This is a playground to practice TDD/BDD
JavaScript
1
star
37

changelog-maven-plugin

Java
1
star
38

OSGi-Rhino

The rhino javascript engine by mozilla wrapped with an OSGi Manifest
1
star
39

webpack-multi-app-test

JavaScript
1
star
40

convert-to-h264

A simple bash script converting video files to h264
Shell
1
star
41

edl-editor

GTK based editor to create edit decision list in xbmc-extended mplayer format. This is gstreamer based and should handle all gstreamer codecs.
Python
1
star
42

webdriver-ts

A lowlevel webdriver implementation in typescript
TypeScript
1
star