diff --git a/types/reach__combobox/index.d.ts b/types/reach__combobox/index.d.ts new file mode 100644 index 0000000000..da90d9541a --- /dev/null +++ b/types/reach__combobox/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for @reach/combobox 0.1 +// Project: https://github.com/reach/reach-ui +// Definitions by: Harry Hedger +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export type Omit = Pick>; + +export interface ComboboxProps extends Omit, 'onSelect'> { + children?: React.ReactNode; + onSelect?: (value: string) => void; + openOnFocus?: boolean; + as?: string; +} + +export interface ComboboxInputProps extends React.HTMLProps { + selectOnClick?: boolean; + autocomplete?: boolean; + value?: string; + as?: string; +} + +export interface ComboboxPopoverProps extends React.HTMLProps { + portal?: boolean; +} + +export interface ComboboxListProps extends React.HTMLProps { + persistSelection?: boolean; + as?: string; +} + +export interface ComboboxOptionProps extends React.HTMLProps { + children?: React.ReactNode; + value: string; +} + +export const Combobox: React.FC; +export const ComboboxInput: React.FC; +export const ComboboxPopover: React.FC; +export const ComboboxList: React.FC; +export const ComboboxOption: React.FC; +export const ComboboxOptionText: React.FC; diff --git a/types/reach__combobox/reach__combobox-tests.tsx b/types/reach__combobox/reach__combobox-tests.tsx new file mode 100644 index 0000000000..97a0fcd563 --- /dev/null +++ b/types/reach__combobox/reach__combobox-tests.tsx @@ -0,0 +1,36 @@ +import { + Combobox, + ComboboxInput, + ComboboxPopover, + ComboboxList, + ComboboxOption, + ComboboxOptionText, +} from '@reach/combobox'; + +import * as React from 'react'; +import { render } from 'react-dom'; + +const GoodExample = () => ( + + + + + + + + + + + + +); + +render(, document.getElementById('app')); +render(, document.getElementById('app')); +render(, document.getElementById('app')); +render(, document.getElementById('app')); +render(, document.getElementById('app')); +render(, document.getElementById('app')); + +// $ExpectError +render(, document.getElementById('app')); diff --git a/types/reach__combobox/tsconfig.json b/types/reach__combobox/tsconfig.json new file mode 100644 index 0000000000..e4a10c5048 --- /dev/null +++ b/types/reach__combobox/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@reach/combobox": ["reach__combobox"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "reach__combobox-tests.tsx" + ] +} diff --git a/types/reach__combobox/tslint.json b/types/reach__combobox/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/reach__combobox/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }