Skip to content

Commit d1d5906

Browse files
committed
chore(ts): annotate return types for isolatedDeclarations
1 parent f6509b4 commit d1d5906

File tree

11 files changed

+44
-29
lines changed

11 files changed

+44
-29
lines changed

packages/core/build.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { defineBuildConfig } from 'unbuild';
1+
import { type BuildConfig, defineBuildConfig } from 'unbuild';
22

33
// @see https://github.com/unjs/unbuild
4-
export default defineBuildConfig({
4+
const config: BuildConfig[] = defineBuildConfig({
55
preset: '../../build.preset',
66
entries: ['src/index'],
77
});
8+
9+
export default config;

packages/core/src/prompts/confirm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface ConfirmOptions extends PromptOptions<ConfirmPrompt> {
77
initialValue?: boolean;
88
}
99
export default class ConfirmPrompt extends Prompt {
10-
get cursor() {
10+
get cursor(): 0 | 1 {
1111
return this.value ? 0 : 1;
1212
}
1313

packages/core/src/prompts/group-multiselect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class GroupMultiSelectPrompt<T extends { value: any }> extends Pr
1515
return this.options.filter((o) => o.group === group);
1616
}
1717

18-
isGroupSelected(group: string) {
18+
isGroupSelected(group: string): boolean {
1919
const items = this.getGroupItems(group);
2020
return items.every((i) => this.value.includes(i.value));
2121
}

packages/core/src/prompts/password.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ interface PasswordOptions extends PromptOptions<PasswordPrompt> {
77
export default class PasswordPrompt extends Prompt {
88
valueWithCursor = '';
99
private _mask = '•';
10-
get cursor() {
10+
get cursor(): number {
1111
return this._cursor;
1212
}
13-
get masked() {
13+
get masked(): string {
1414
return this.value.replaceAll(/./g, this._mask);
1515
}
1616
constructor({ mask, ...opts }: PasswordOptions) {

packages/core/src/prompts/text.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface TextOptions extends PromptOptions<TextPrompt> {
88

99
export default class TextPrompt extends Prompt {
1010
valueWithCursor = '';
11-
get cursor() {
11+
get cursor(): number {
1212
return this._cursor;
1313
}
1414
constructor(opts: TextOptions) {

packages/core/src/utils/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ export * from './settings';
1010

1111
const isWindows = globalThis.process.platform.startsWith('win');
1212

13-
export const CANCEL_SYMBOL = Symbol('clack:cancel');
13+
export const CANCEL_SYMBOL: symbol = Symbol('clack:cancel');
1414

1515
export function isCancel(value: unknown): value is symbol {
1616
return value === CANCEL_SYMBOL;
1717
}
1818

19-
export function setRawMode(input: Readable, value: boolean) {
19+
export function setRawMode(input: Readable, value: boolean): void {
2020
const i = input as typeof stdin;
2121

2222
if (i.isTTY) i.setRawMode(value);
@@ -27,6 +27,11 @@ export function block({
2727
output = stdout,
2828
overwrite = true,
2929
hideCursor = true,
30+
}: {
31+
input?: NodeJS.ReadStream;
32+
output?: NodeJS.WriteStream;
33+
overwrite?: boolean;
34+
hideCursor?: boolean;
3035
} = {}) {
3136
const rl = readline.createInterface({
3237
input,
@@ -57,7 +62,7 @@ export function block({
5762
if (hideCursor) output.write(cursor.hide);
5863
input.once('keypress', clear);
5964

60-
return () => {
65+
return (): void => {
6166
input.off('keypress', clear);
6267
if (hideCursor) output.write(cursor.show);
6368

packages/core/src/utils/settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export interface ClackSettings {
3232
aliases: Record<string, Action>;
3333
}
3434

35-
export function updateSettings(updates: ClackSettings) {
35+
export function updateSettings(updates: ClackSettings): void {
3636
for (const _key in updates) {
3737
const key = _key as keyof ClackSettings;
3838
if (!Object.hasOwn(updates, key)) continue;
@@ -58,7 +58,7 @@ export function updateSettings(updates: ClackSettings) {
5858
* @param action - The action to match
5959
* @returns boolean
6060
*/
61-
export function isActionKey(key: string | Array<string | undefined>, action: Action) {
61+
export function isActionKey(key: string | Array<string | undefined>, action: Action): boolean {
6262
if (typeof key === 'string') {
6363
return settings.aliases.get(key) === action;
6464
}

packages/core/src/utils/string.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function diffLines(a: string, b: string) {
1+
export function diffLines(a: string, b: string): number[] | undefined {
22
if (a === b) return;
33

44
const aLines = a.split('\n');

packages/core/test/mock-readable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Readable } from 'node:stream';
33
export class MockReadable extends Readable {
44
protected _buffer: unknown[] | null = [];
55

6-
_read() {
6+
_read(): void {
77
if (this._buffer === null) {
88
this.push(null);
99
return;

packages/prompts/build.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { defineBuildConfig } from 'unbuild';
1+
import { type BuildConfig, defineBuildConfig } from 'unbuild';
22

3-
export default defineBuildConfig({
3+
const config: BuildConfig[] = defineBuildConfig({
44
preset: '../../build.preset',
55
entries: ['src/index'],
66
});
7+
8+
export default config;

0 commit comments

Comments
 (0)