Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ Will generate the following stylesheet:

![Stylesheet example](./stylesheet-example-grid.png "Stylesheet example")

## Contributions
The typescript is pretty complex and there are many different way how
to define components and their props so it's realy hard to support all
diferent use cases. That means only one thing, contributions are highly
welcome. Just keep in mind that each PR should also include tests for
the part it's fixing.

## Thanks to contributors

@JocD Jacques Dukes - complete support for functional components and much more
Expand Down
6 changes: 1 addition & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
{
"name": "react-docgen-typescript",
"version": "0.0.11",
"version": "0.0.12",
"description": "",
"main": "lib/index.js",
"scripts": {
"tsc": "tsc",
"prepublish": "tsc -d",
"test": "tsc && mocha ./lib/**/__tests__/**.js",
"test:debug": "tsc && mocha --debug ./lib/**/__tests__/**.js",
"example": "tsc && node ./node_modules/react-styleguidist/bin/styleguidist server --config ./examples/react-styleguidist-example/styleguide.config.js",
"example:webpack": "webpack --config ./examples/react-styleguidist-example/webpack.config.js",
"print": "npm run tsc && node ./lib/print.js",
"print:sample1": "npm run tsc && node ./lib/print.js ./src/__tests__/data/ColumnHigherOrderComponent.tsx simple"
},
"author": "pvasek",
"license": "MIT",
"dependencies": {
"awesome-typescript-loader": "^3.0.8",
"typescript": "^2.2.1"
},
"devDependencies": {
"@types/chai": "^3.4.35",
Expand Down
38 changes: 38 additions & 0 deletions src/__tests__/data/FlippableImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import * as React from 'react';

/** Props comment */
export type Props = React.HTMLAttributes<HTMLImageElement> & {
/** whether the image is flipped horizontally */
isFlippedX?: boolean;
/** whether the image is flipped vertically */
isFlippedY?: boolean;
}

/** An enhanced image component */
export const FlippableImage = (props: Props) => {
const {
src,
isFlippedX = false,
isFlippedY = false,
style,
...rest,
} = props;

let transform = '';
if (isFlippedX) {
transform += ` scale(-1, 1)`;
}
if (isFlippedY) {
transform += ` scale(1, -1)`;
}

return (
<img
src={src || undefined}
style={{ ...style, transform }}
{...rest}
/>
);
};

export default FlippableImage;
14 changes: 14 additions & 0 deletions src/__tests__/data/transformAST.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { externalHoc } from './transformAST_hoc';
import * as React from 'react';

const unexportedVar = 10;
export const exportedVar = 10;
Expand Down Expand Up @@ -29,6 +30,11 @@ export interface ExportedInterface {
prop2: string;
}

export interface ExportedInheritedInterface extends ExportedInterface {
/** ownProp1 comment */
ownProp1: string;
}

export class OurBaseClass<T1, T2> {
}

Expand Down Expand Up @@ -65,3 +71,11 @@ export const exportedExternalHoc1 = externalHoc(ExportedClass);

/** exportedExternalHoc2 comment */
export const exportedExternalHoc2 = externalHoc(exportedFunction);

/** exported intersection type */
export type ExportedType1 = React.HTMLAttributes<HTMLImageElement> & {
/** the first property */
prop1: "value1" | "value2";
/** the second property */
prop2: number;
};
Loading