DefinitelyTyped/types/console-ui/console-ui-tests.ts
Manuel Thalmann 59e7099918 Refactor the type-declaration of inquirer (#36708)
* Refactor incorrect tests

* Add export-statements to the exported components

* Add a base-class for prompt-modules

* Externalize the Prompts-type

* Externalize the Separator-class

* Move the ChoiceOption-type to a new namespace "poll"

* Rename the ChoiceOption-type to ChoiceOptions

* Add a choice base-type

* Move ChoiceType to the poll-namespace

* Rename the ChoiceType-type

* Reorder the types

* Convert types to interfaces

* Rename the qeustion-type to "DistinctQuestion"

* Add types for representing optional object-keys

* Add a type for dynamic question-properties

* Fix some question-options

* Ad the `filter`-methjod to the QuestionCommon-interface

* Move uestionCommon to the poll-namespace

* Rename QuestionCommon to Question

* Refactor the question-types

* Refactor the Questions-type

* Rename Questions to QuestionCollection

* Rearrange the namespaces

* Add a type-option to the Question-interface

* Add a ScreenManager-class

* Rework visibility of ScreenManager-members

* Add a Prompt-class

* Force all generic answers to extend Answers

* Add an interface for basic prompts

* Add a PromptConstrructor type

* Add types for the paginator

* Rework the event-submission of prompts

* Fix the type of the run-callback

* Add a generic parameter for the type of answer

* Add types for the Checkbox-prompt

* Make the type of the checkbox-prompt generic

* Add a module for the checkbox-prompt

* Fix js-doc

* Add missing import

* Fix typo

* Add types for the confirm-prompt

* Remove the generic answer-type

* Rework the checkbox-prompt

* Add an editor-prompt

* Add the Choice-class

* Move the choice-class to another directory

* Add a separator-interface

* Fix the separator-class

* Add a choices-class

* Add the separator-type

* Move the objects to the correct location

* Move all external modules to the proper place

* Fix the PromptModule interface

* Convert all internal components to internal modules

* Rework the prompt-type

* Make the choices public

* Fix the editor-prompt

* Move all external modules into the index-file

* Move all remaining modules into the index-file

* Fix incorrect choices-module

* Export the DynamicQuestionProperty

* Add a question-map

* Fix the choicebase-type

* Fix asynchronously fetched question-options

* Improve the handling of choices

* Add an expand-prompt

* Intuitively rework the prompts

* Rework the expand-prompt

* Add the input-prompt

* Add trhe list-prompt

* Refactor all prompts

* Fix incorrect module-export

* Fix the prompt-constructor

* Fix the handling of the question-options

* Add the number-prompt

* Add the password-prompt

* Add the rawlist-prompt

* Add ui-classes

* Add all remaining types

* Fix the generic types

* Remove unnecessary types

* Rework the type-declarations according to tslint

* Complete the docs

* Order the imports

* Add a new author-tag

* Increase the major-version

* Import all unused files

* Fix the AsyncDynamicQuestionProperty

* Improve the docs

* Remove the poll-namespace

* Fix the inquirer-types according to tslint

* Fix dependent type-declarations

* Remove the index-signature from the choice-class

* Fix the constructor of the prompt-ui

* Add tests

* Simplify the PromptCollection-type

* Rearrange the file-header

* Add an interface for the bottom-bar options

* Make the log-stream public

* Complete the docs of the choice-class

* Add a validator-type

* Add a choice-collection type

* Add a Transformer-type

* Fix the PromptModule-type

* Add all inquirer code-examples

* Fix incorrect code

* Rework the way to import the example-files

* Fix dependent types
2019-07-31 10:17:47 -07:00

61 lines
1.4 KiB
TypeScript

import { DistinctQuestion } from 'inquirer';
import UI = require('console-ui');
new UI({
inputStream: process.stdin,
outputStream: process.stderr,
errorStream: process.stdout,
writeLevel: 'DEBUG',
ci: false
});
const ui = new UI();
ui.write(); // $ExpectError
ui.write('hello');
ui.write('hello', 'DEBUG');
ui.write('hello', 'INFO');
ui.write('hello', 'WARNING');
ui.write('hello', 'ERROR');
ui.write('hello', 'NONEXISTENT'); // $ExpectError
ui.writeLine(); // $ExpectError
ui.writeLine('hello');
ui.writeLine('hello', 'DEBUG');
ui.writeLine('hello', 'INFO');
ui.writeLine('hello', 'WARNING');
ui.writeLine('hello', 'ERROR');
ui.writeLine('hello', 'NONEXISTENT'); // $ExpectError
ui.writeDebugLine('hello');
ui.writeWarnLine('hello');
ui.writeWarnLine('hello', true);
ui.writeWarnLine('hello', false, true);
ui.writeDeprecateLine('hello');
ui.writeDeprecateLine('hello', true);
ui.writeDeprecateLine('hello', false, true);
ui.writeError(new Error('boom!'));
ui.writeError('boom!'); // $ExpectError
ui.setWriteLevel('DEBUG');
ui.setWriteLevel('INFO');
ui.setWriteLevel('WARNING');
ui.setWriteLevel('ERROR');
ui.setWriteLevel('NONEXISTENT'); // $ExpectError
ui.startProgress('hello');
ui.stopProgress();
ui.stopProgress('hello'); // $ExpectError
const question: DistinctQuestion<{ answer: boolean }> = {
message: 'Yes / No?',
type: 'confirm'
};
ui.prompt(question).then(result => {
result.answer; // $ExpectType boolean
});