diff --git a/types/ink-select-input/index.d.ts b/types/ink-select-input/index.d.ts index 2654084e25..6f511e304b 100644 --- a/types/ink-select-input/index.d.ts +++ b/types/ink-select-input/index.d.ts @@ -1,25 +1,28 @@ -// Type definitions for ink-select-input 2.0 +// Type definitions for ink-select-input 3.0 // Project: https://github.com/vadimdemedes/ink-select-input#readme // Definitions by: Ɓukasz Ostrowski +// Jakub Satnik // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import { Component, InkComponent } from 'ink'; +import { Component } from 'react'; -interface ItemOfSelectInput { +export interface ItemOfSelectInput { label: string; value: any; + key?: string | number; } -interface SelectInputProps { +export interface SelectInputProps { focus?: boolean; - indicatorComponent?: InkComponent; - itemComponent?: InkComponent; + indicatorComponent?: Component; + itemComponent?: Component; items?: ReadonlyArray; limit?: number; + initialIndex?: number; onSelect?: (item: T) => void; } declare class SelectInput extends Component { } -export = SelectInput; +export default SelectInput; diff --git a/types/ink-select-input/ink-select-input-tests.tsx b/types/ink-select-input/ink-select-input-tests.tsx index da29f9918e..fd80d43394 100644 --- a/types/ink-select-input/ink-select-input-tests.tsx +++ b/types/ink-select-input/ink-select-input-tests.tsx @@ -1,32 +1,31 @@ -/** @jsx h */ -import { h, InkComponent } from 'ink'; -import SelectInput from 'ink-select-input'; +import * as React from 'react'; + +// tslint:disable-next-line:import-name +import SelectInput, { ItemOfSelectInput } from 'ink-select-input'; // NOTE: `import SelectInput = require('ink-select-input');` will work as well. // If importing using ES6 default import as above, // `allowSyntheticDefaultImports` flag in compiler options needs to be set to `true` -interface DemoItem { - label: string; - value: string; +const items: ReadonlyArray = [ + { + label: 'First', + value: 'first', + key: 0, + }, + { + label: 'Second', + value: 'second', + }, + { + label: 'Third', + value: 'third', + }, +]; + +class Demo extends React.PureComponent { + handleSelect = (item: ItemOfSelectInput) => {}; + + render() { + return ; + } } - -const items: ReadonlyArray = [{ - label: 'First', - value: 'first' -}, -{ - label: 'Second', - value: 'second' -}, -{ - label: 'Third', - value: 'third' -}]; - -const Demo: InkComponent = () => { - const handleSelect = (item: DemoItem) => { - console.log(item); - }; - - return ; -};