Skip to content

Commit 178d8e5

Browse files
committed
Fixing some typigns issues.
1 parent 6a4b65e commit 178d8e5

12 files changed

Lines changed: 581 additions & 2 deletions

File tree

‎apps/rush-lib/tsconfig.json‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
{
2-
"extends": "./node_modules/@microsoft/rush-stack/includes/tsconfig-node.json"
2+
"extends": "./node_modules/@microsoft/rush-stack/includes/tsconfig-node.json",
3+
"include": [
4+
"./typings/tsd.d.ts",
5+
"./src/**/*.ts",
6+
"./src/**/*.tsx"
7+
]
38
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Type definitions for glob-escape 0.0.1
2+
// Definitions by: pgonzal
3+
4+
declare module "glob-escape" {
5+
6+
function escapeGlob(glob: string): string;
7+
function escapeGlob(glob: string[]): string[];
8+
9+
export = escapeGlob;
10+
}
Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
// Type definitions for Inquirer.js
2+
// Project: https://github.com/SBoudrias/Inquirer.js
3+
// Definitions by: Qubo <https://github.com/tkQubo>
4+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5+
6+
/// <reference path="../through/through.d.ts" />
7+
8+
declare module "inquirer" {
9+
import through = require('through');
10+
11+
namespace inquirer {
12+
type Prompts = { [name: string]: PromptModule };
13+
type ChoiceType = string|objects.ChoiceOption|objects.Separator;
14+
type Questions = Question|Question[];
15+
16+
interface Inquirer {
17+
restoreDefaultPrompts(): void;
18+
/**
19+
* Expose helper functions on the top level for easiest usage by common users
20+
* @param name
21+
* @param prompt
22+
*/
23+
registerPrompt(name: string, prompt: PromptModule): void;
24+
/**
25+
* Create a new self-contained prompt module.
26+
*/
27+
createPromptModule(): PromptModule;
28+
/**
29+
* Public CLI helper interface
30+
* @param questions Questions settings array
31+
* @param cb Callback being passed the user answers
32+
* @return
33+
*/
34+
prompt(questions: Questions): Promise<any>;
35+
prompts: Prompts;
36+
Separator: objects.SeparatorStatic;
37+
ui: {
38+
BottomBar: ui.BottomBar;
39+
Prompt: ui.Prompt;
40+
}
41+
}
42+
43+
interface PromptModule {
44+
(questions: Questions): Promise<any>;
45+
/**
46+
* Register a prompt type
47+
* @param name Prompt type name
48+
* @param prompt Prompt constructor
49+
*/
50+
registerPrompt(name: string, prompt: PromptModule): ui.Prompt;
51+
/**
52+
* Register the defaults provider prompts
53+
*/
54+
restoreDefaultPrompts(): void;
55+
}
56+
57+
interface Question {
58+
/**
59+
* Type of the prompt.
60+
* Possible values:
61+
* <ul>
62+
* <li>input</li>
63+
* <li>confirm</li>
64+
* <li>list</li>
65+
* <li>rawlist</li>
66+
* <li>password</li>
67+
* </ul>
68+
* @defaults: 'input'
69+
*/
70+
type?: string;
71+
/**
72+
* The name to use when storing the answer in the anwers hash.
73+
*/
74+
name?: string;
75+
/**
76+
* The question to print. If defined as a function,
77+
* the first parameter will be the current inquirer session answers.
78+
*/
79+
message?: string|((answers: Answers) => string);
80+
/**
81+
* Default value(s) to use if nothing is entered, or a function that returns the default value(s).
82+
* If defined as a function, the first parameter will be the current inquirer session answers.
83+
*/
84+
default?: any|((answers: Answers) => any);
85+
/**
86+
* Choices array or a function returning a choices array. If defined as a function,
87+
* the first parameter will be the current inquirer session answers.
88+
* Array values can be simple strings, or objects containing a name (to display) and a value properties
89+
* (to save in the answers hash). Values can also be a Separator.
90+
*/
91+
choices?: ChoiceType[]|((answers: Answers) => ChoiceType[]);
92+
/**
93+
* Receive the user input and should return true if the value is valid, and an error message (String)
94+
* otherwise. If false is returned, a default error message is provided.
95+
*/
96+
validate?(input: string): boolean|string;
97+
/**
98+
* Receive the user input and return the filtered value to be used inside the program.
99+
* The value returned will be added to the Answers hash.
100+
*/
101+
filter?(input: string): string;
102+
/**
103+
* Receive the current user answers hash and should return true or false depending on whether or
104+
* not this question should be asked. The value can also be a simple boolean.
105+
*/
106+
when?: boolean|((answers: Answers) => boolean);
107+
paginated?: boolean;
108+
}
109+
110+
/**
111+
* A key/value hash containing the client answers in each prompt.
112+
*/
113+
interface Answers {
114+
[key: string]: string|boolean;
115+
}
116+
117+
namespace ui {
118+
/**
119+
* Base interface class other can inherits from
120+
*/
121+
interface Prompt extends BaseUI<Prompts> {
122+
new(promptModule: Prompts): Prompt;
123+
/**
124+
* Once all prompt are over
125+
*/
126+
onCompletion(): void;
127+
processQuestion(question: Question): any;
128+
fetchAnswer(question: Question): any;
129+
setDefaultType(question: Question): any;
130+
filterIfRunnable(question: Question): any;
131+
}
132+
133+
/**
134+
* Sticky bottom bar user interface
135+
*/
136+
interface BottomBar extends BaseUI<BottomBarOption> {
137+
new(opt?: BottomBarOption): BottomBar;
138+
/**
139+
* Render the prompt to screen
140+
* @return self
141+
*/
142+
render(): BottomBar;
143+
/**
144+
* Update the bottom bar content and rerender
145+
* @param bottomBar Bottom bar content
146+
* @return self
147+
*/
148+
updateBottomBar(bottomBar: string): BottomBar;
149+
/**
150+
* Rerender the prompt
151+
* @return self
152+
*/
153+
writeLog(data: any): BottomBar;
154+
/**
155+
* Make sure line end on a line feed
156+
* @param str Input string
157+
* @return The input string with a final line feed
158+
*/
159+
enforceLF(str: string): string;
160+
/**
161+
* Helper for writing message in Prompt
162+
* @param message The message to be output
163+
*/
164+
write(message: string): void;
165+
log: through.ThroughStream;
166+
}
167+
168+
interface BottomBarOption {
169+
bottomBar?: string;
170+
}
171+
/**
172+
* Base interface class other can inherits from
173+
*/
174+
interface BaseUI<TOpt> {
175+
new(opt: TOpt): void;
176+
/**
177+
* Handle the ^C exit
178+
* @return {null}
179+
*/
180+
onForceClose(): void;
181+
/**
182+
* Close the interface and cleanup listeners
183+
*/
184+
close(): void;
185+
/**
186+
* Handle and propagate keypress events
187+
*/
188+
onKeypress(s: string, key: Key): void;
189+
}
190+
191+
interface Key {
192+
sequence: string;
193+
name: string;
194+
meta: boolean;
195+
shift: boolean;
196+
ctrl: boolean;
197+
}
198+
}
199+
200+
namespace objects {
201+
/**
202+
* Choice object
203+
* Normalize input as choice object
204+
* @constructor
205+
* @param {String|Object} val Choice value. If an object is passed, it should contains
206+
* at least one of `value` or `name` property
207+
*/
208+
interface Choice {
209+
new(str: string): Choice;
210+
new(separator: Separator): Choice;
211+
new(option: ChoiceOption): Choice;
212+
}
213+
214+
interface ChoiceOption {
215+
name?: string;
216+
value?: string;
217+
type?: string;
218+
extra?: any;
219+
key?: string;
220+
checked?: boolean;
221+
disabled?: string|((answers: Answers) => any);
222+
}
223+
224+
/**
225+
* Choices collection
226+
* Collection of multiple `choice` object
227+
* @constructor
228+
* @param choices All `choice` to keep in the collection
229+
*/
230+
interface Choices {
231+
new(choices: (string|Separator|ChoiceOption)[], answers?: Answers): Choices;
232+
choices: Choice[];
233+
realChoices: Choice[];
234+
length: number;
235+
realLength: number;
236+
/**
237+
* Get a valid choice from the collection
238+
* @param selector The selected choice index
239+
* @return Return the matched choice or undefined
240+
*/
241+
getChoice(selector: number): Choice;
242+
/**
243+
* Get a raw element from the collection
244+
* @param selector The selected index value
245+
* @return Return the matched choice or undefined
246+
*/
247+
get(selector: number): Choice;
248+
/**
249+
* Match the valid choices against a where clause
250+
* @param whereClause Lodash `where` clause
251+
* @return Matching choices or empty array
252+
*/
253+
where<U extends {}>(whereClause: U): Choice[];
254+
/**
255+
* Pluck a particular key from the choices
256+
* @param propertyName Property name to select
257+
* @return Selected properties
258+
*/
259+
pluck(propertyName: string): any[];
260+
forEach<T>(application: (choice: Choice) => T): T[];
261+
}
262+
263+
interface SeparatorStatic {
264+
/**
265+
* @param line Separation line content (facultative)
266+
*/
267+
new(line?: string): Separator;
268+
/**
269+
* Helper function returning false if object is a separator
270+
* @param obj object to test against
271+
* @return `false` if object is a separator
272+
*/
273+
exclude(obj: any): boolean;
274+
}
275+
276+
/**
277+
* Separator object
278+
* Used to space/separate choices group
279+
* @constructor
280+
* @param {String} line Separation line content (facultative)
281+
*/
282+
interface Separator {
283+
type: string;
284+
line: string;
285+
/**
286+
* Stringify separator
287+
* @return {String} the separator display string
288+
*/
289+
toString(): string;
290+
}
291+
}
292+
}
293+
294+
var inquirer: inquirer.Inquirer;
295+
296+
export = inquirer;
297+
}
298+

‎apps/rush-lib/typings/jju/jju.d.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Type definitions for jju 1.3.0
2+
// Project: https://www.npmjs.com/package/jju
3+
// Definitions by: pgonzal
4+
5+
interface IJjuOptions {
6+
reserved_keys? : 'ignore' | 'throw' | 'replace';
7+
mode?: 'json';
8+
reviver?: (key: any, value: any) => any;
9+
}
10+
11+
declare module 'jju' {
12+
export function parse(text: string, options?: IJjuOptions): any;
13+
}

0 commit comments

Comments
 (0)