Skip to content

Commit 4021504

Browse files
committed
Add TypeScript typings
1 parent 35e17fd commit 4021504

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

index.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import * as React from 'react';
2+
3+
export function clearLog(): void;
4+
5+
export function resetInstanceIdCounters(): void;
6+
7+
export class VisualizerProvider extends React.Component<{}, {}> {}
8+
9+
export class Log extends React.Component<{}, {}> {}
10+
11+
export interface TraceProps {
12+
trace: (msg: string) => void,
13+
LifecyclePanel : React.SFC
14+
}
15+
16+
// Diff / Omit from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766
17+
type Diff<T extends string, U extends string> =
18+
({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];
19+
20+
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>
21+
22+
// Simpler TypeScript 2.8+ definition of Omit (disabled for now to support lower TypeScript versions)
23+
// export type Omit<T, K extends keyof T> = Pick<T, Diff<keyof T, K>>;
24+
25+
export function traceLifecycle<P extends TraceProps>(
26+
component: React.ComponentClass<P>
27+
): React.ComponentClass<Omit<P, keyof TraceProps>>;

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "react-lifecycle-visualizer",
33
"version": "2.0.0-beta.3",
44
"description": "Visualizer for React lifecycle methods",
5-
"main": "dist/index.js",
5+
"main": "./dist/index.js",
6+
"typings": "./index.d.ts",
67
"scripts": {
78
"lint": "eslint --ext js,jsx --max-warnings 0 src test examples",
89
"test": "npm run lint && jest",

0 commit comments

Comments
 (0)