Skip to content

Commit 74b18bf

Browse files
authored
Merge pull request #13 from alex3165/master
Improve typings / test typings
2 parents 264d21f + ef5b7d2 commit 74b18bf

4 files changed

Lines changed: 52 additions & 15 deletions

File tree

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.5.3",
44
"description": "A production-focused playground for live editing React code",
55
"main": "lib/index.js",
6-
"typings": "./react-live.d.ts",
6+
"typings": "./typings/react-live.d.ts",
77
"jsnext:main": "dist/react-live.es.js",
88
"module": "dist/react-live.es.js",
99
"license": "MIT",
@@ -14,7 +14,8 @@
1414
"build:dist": "rollup -c && rollup -c --environment PRODUCTION",
1515
"build": "npm-run-all build:lib build:dist",
1616
"prepublish": "npm run build",
17-
"test": "jest"
17+
"test": "jest",
18+
"test:typings": "typings-tester --dir typings"
1819
},
1920
"dependencies": {
2021
"buble": "^0.15.2",
@@ -27,6 +28,7 @@
2728
"devDependencies": {
2829
"@kadira/storybook": "^2.35.3",
2930
"@kadira/storybook-addon-knobs": "^1.7.1",
31+
"@types/react": "^15.0.26",
3032
"babel-cli": "^6.24.0",
3133
"babel-plugin-add-module-exports": "^0.2.1",
3234
"babel-plugin-external-helpers": "^6.22.0",
@@ -47,13 +49,16 @@
4749
"rollup-plugin-node-resolve": "^2.1.1",
4850
"rollup-plugin-replace": "^1.1.1",
4951
"rollup-plugin-uglify": "^1.0.1",
50-
"rollup-plugin-visualizer": "^0.2.0"
52+
"rollup-plugin-visualizer": "^0.2.0",
53+
"typescript": "^2.3.4",
54+
"typings-tester": "^0.2.2"
5155
},
5256
"files": [
5357
"src",
5458
"lib",
5559
"dist",
56-
"react-live.css"
60+
"react-live.css",
61+
"typings/react-live.d.ts"
5762
],
5863
"author": "Phil Plückthun <phil@plckthn.me> (https://github.com/philpl)",
5964
"bugs": {

react-live.d.ts renamed to typings/react-live.d.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,10 @@ export type LiveProviderProps = HTMLAttributes<HTMLElement> & {
1010

1111
export class LiveProvider extends Component<LiveProviderProps, {}>{}
1212

13-
export interface EditorProps extends HTMLElement {
14-
onChange: React.ChangeEventHandler<HTMLElement>;
15-
onKeyDown: React.KeyboardEventHandler<HTMLElement>;
16-
onKeyUp: React.KeyboardEventHandler<HTMLElement>;
17-
onClick: React.MouseEventHandler<HTMLElement>;
18-
code: string;
19-
}
20-
21-
export function LiveEditor(props: EditorProps): any
13+
export function LiveEditor(props: HTMLAttributes<HTMLElement>): JSX.Element
2214

23-
export function LiveError(props: HTMLAttributes<HTMLElement>): any
24-
export function LivePreview(props: HTMLAttributes<HTMLElement>): any
15+
export function LiveError(props: HTMLAttributes<HTMLElement>): JSX.Element
16+
export function LivePreview(props: HTMLAttributes<HTMLElement>): JSX.Element
2517

2618
export class Editor extends Component<HTMLAttributes<HTMLElement>, {}>{}
2719

typings/test.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { LiveProvider, Editor, LiveEditor, LiveError, LivePreview, withLive } from '../';
2+
import * as React from 'react';
3+
4+
export const providerC = (
5+
<LiveProvider code={``} className="" scope="" mountStylesheet={false} noInline={false}/>
6+
);
7+
8+
export const editorC = (
9+
<Editor/>
10+
)
11+
12+
export const liveEditorC = (
13+
<LiveEditor/>
14+
);
15+
16+
export const liveErrorC = (
17+
<LiveError/>
18+
);
19+
20+
export const livePreviewC = (
21+
<LivePreview/>
22+
);
23+
24+
const Component: React.StatelessComponent<{}> = () => (
25+
<div>Hello World!</div>
26+
);
27+
28+
export const wrappedComponent = withLive(Component);

typings/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"jsx": "react",
4+
"module": "commonjs",
5+
"forceConsistentCasingInFileNames": true,
6+
"noImplicitReturns": true,
7+
"noImplicitThis": true,
8+
"noImplicitAny": true,
9+
"strictNullChecks": true,
10+
"noUnusedLocals": true
11+
}
12+
}

0 commit comments

Comments
 (0)