Skip to content

Commit

Permalink
Improve the TypeScript definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 26, 2018
1 parent 3e5a62f commit d37aa37
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
13 changes: 9 additions & 4 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import * as React from 'react';

export function autoBind(el: React.ReactNode, options?: any): React.ReactNode;
interface AutoBindOptions {
include?: Array<string | RegExp>
exclude?: Array<string | RegExp>
}

export function autoBind(element: React.ReactNode, options?: AutoBindOptions): React.ReactNode;

export function classNames(...args: any[]): string;
export function classNames(...args: Array<string | {[key: string]: unknown}>): string;

export function isStatelessComponent(component: React.ComponentClass): boolean;

Expand Down Expand Up @@ -31,8 +36,8 @@ export class Choose extends React.Component {
}

interface ForProps {
of: any[];
render?: (item: any, index: number) => React.ReactNode;
of: unknown[];
render?: (item: unknown, index: number) => React.ReactNode;
}

export class For extends React.Component<ForProps> {}
Expand Down
4 changes: 4 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {expectType} from 'tsd-check';
import {classNames} from '.';

expectType<string>(classNames('foo', {bar: true}));
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"scripts": {
"build": "babel index.js auto-bind.js class-names.js --out-dir=dist",
"test": "xo && ava",
"test": "xo && ava && tsd-check",
"prepublishOnly": "npm run build"
},
"files": [
Expand Down Expand Up @@ -58,6 +58,7 @@
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-test-renderer": "^16.7.0",
"tsd-check": "^0.3.0",
"xo": "^0.23.0"
},
"peerDependencies": {
Expand Down

0 comments on commit d37aa37

Please sign in to comment.