Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/cli/binding/index.d.cts
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,15 @@ export interface TypeScriptOptions {
rewriteImportExtensions?: 'rewrite' | 'remove' | boolean;
}

/**
* The selected tsconfig and its original source, sent to an asynchronous loader.
* `None` selects discovery explicitly, without consulting the receiving thread's env.
*/
export interface FrozenTsconfig {
path?: string;
source?: string;
}

export interface LoadContext {
/** Export conditions of the relevant `package.json` */
conditions?: Array<string>;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/define-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ export function computeAutoInlineList(
existingInline: (string | RegExp)[] | true | undefined,
projectRoot: string,
_createRequire: (from: string) => { resolve: (id: string) => string } = createRequire,
installedPackages = new Map<string, boolean>(),
installedPackages: Map<string, boolean> = new Map<string, boolean>(),
): (string | RegExp)[] | null {
// User opted into "inline everything" — don't touch.
if (existingInline === true) {
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/oxlint-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'node:fs';
import path from 'node:path';

import { definePlugin, defineRule } from '@oxlint/plugins';
import type { Context, ESTree } from '@oxlint/plugins';
import type { Context, ESTree, Plugin, Rule } from '@oxlint/plugins';

import cliPackage from '../package.json' with { type: 'json' };
import {
Expand Down Expand Up @@ -362,7 +362,7 @@ function reportLegacyOxlintPluginApiImport(
reportSpecifier(context, literal, VITE_PLUS_LINT_PLUGINS);
}

export const preferVitePlusImportsRule = defineRule({
export const preferVitePlusImportsRule: Rule = defineRule({
meta: {
type: 'problem',
docs: {
Expand Down Expand Up @@ -435,7 +435,7 @@ export const preferVitePlusImportsRule = defineRule({
},
});

const plugin = definePlugin({
const plugin: Plugin = definePlugin({
meta: {
name: VITE_PLUS_OXLINT_PLUGIN_NAME,
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function resolveToolVersions(localPackagePath: string): Promise<Record<str
/**
* Print version information
*/
export async function printVersion(cwd: string) {
export async function printVersion(cwd: string): Promise<void> {
const globalVersion = getGlobalVersion();
const cliVersion = getCliVersion();
const localMetadata = getLocalMetadata(cwd);
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ export default defineConfig([
format: 'esm',
fixedExtension: false,
shims: true,
dts: true,
dts: {
// TypeScript 7 no longer ships the classic tsc API and its tsgo API
// requires 7.1+, so rolldown-plugin-dts cannot use either here. Generate
// declarations with Oxc instead.
generator: 'oxc',
},
clean: true,
// NAPI binding uses a relative path that tsdown can't auto-detect from package.json
deps: { neverBundle: [/\.\.\/binding\/index\.(js|cjs)/] },
Expand Down
6 changes: 1 addition & 5 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@
"peerDependencies": {
"@arethetypeswrong/core": "^0.18.1",
"@types/node": "^20.19.0 || >=22.12.0",
"@typescript/native-preview": "*",
"@vitejs/devtools": "^0.7.1 || ^0.8.0",
"@volar/typescript": "~2.4.0",
"@vue/language-core": "~3.2.0 || ~3.3.0",
Expand All @@ -168,9 +167,6 @@
"yaml": "^2.4.2"
},
"peerDependenciesMeta": {
"@typescript/native-preview": {
"optional": true
},
"@volar/typescript": {
"optional": true
},
Expand Down Expand Up @@ -241,6 +237,6 @@
"bundledVersions": {
"vite": "8.3.5",
"rolldown": "1.2.15",
"tsdown": "0.23.1"
"tsdown": "0.23.2"
}
}
2 changes: 1 addition & 1 deletion packages/prompts/src/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function getPaddingForLine(

const defaultFormatBorder = color.gray;

export const box = (message = '', title = '', opts?: BoxOptions) => {
export const box = (message = '', title = '', opts?: BoxOptions): void => {
const output: Writable = opts?.output ?? process.stdout;
const columns = getColumns(output);
const borderWidth = 1;
Expand Down
80 changes: 40 additions & 40 deletions packages/prompts/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const wrapTextWithPrefix = (
output: Writable | undefined,
text: string,
prefix: string,
startPrefix = prefix,
startPrefix: string = prefix,
): string => {
const width = Math.max(
1,
Expand Down Expand Up @@ -58,8 +58,8 @@ export const optionText = (
.join('\n');
};

export const SELECT_INSTRUCTIONS = ['↑/↓ navigate', 'Enter confirm'];
export const MULTISELECT_INSTRUCTIONS = ['↑/↓ navigate', 'Space select', 'Enter confirm'];
export const SELECT_INSTRUCTIONS: string[] = ['↑/↓ navigate', 'Enter confirm'];
export const MULTISELECT_INSTRUCTIONS: string[] = ['↑/↓ navigate', 'Space select', 'Enter confirm'];
export const formatInstructionFooter = (
instructions: string[],
hasGuide: boolean,
Expand All @@ -71,47 +71,47 @@ export const formatInstructionFooter = (
hasGuide ? `${color.blue(S_BAR)} ` : ' ',
).split('\n');

export const unicode = isUnicodeSupported();
export const unicode: boolean = isUnicodeSupported();
export const isCI = (): boolean => process.env.CI === 'true';
export const isTTY = (output: Writable): boolean => {
return (output as Writable & { isTTY?: boolean }).isTTY === true;
};
export const unicodeOr = (c: string, fallback: string) => (unicode ? c : fallback);
export const S_POINTER_ACTIVE = unicodeOr('›', '>');
export const unicodeOr = (c: string, fallback: string): string => (unicode ? c : fallback);
export const S_POINTER_ACTIVE: string = unicodeOr('›', '>');
export const S_POINTER_INACTIVE = ' ';
export const S_STEP_ACTIVE = S_POINTER_ACTIVE;
export const S_STEP_CANCEL = unicodeOr('■', 'x');
export const S_STEP_ERROR = unicodeOr('▲', 'x');
export const S_STEP_SUBMIT = unicodeOr('◇', 'o');

export const S_BAR_START = unicodeOr('┌', 'T');
export const S_BAR = unicodeOr('│', '|');
export const S_BAR_END = unicodeOr('└', '—');
export const S_BAR_START_RIGHT = unicodeOr('┐', 'T');
export const S_BAR_END_RIGHT = unicodeOr('┘', '—');

export const S_RADIO_ACTIVE = S_POINTER_ACTIVE;
export const S_RADIO_INACTIVE = S_POINTER_INACTIVE;
export const S_CHECKBOX_ACTIVE = unicodeOr('◻', '[•]');
export const S_CHECKBOX_SELECTED = unicodeOr('◼', '[+]');
export const S_CHECKBOX_INACTIVE = unicodeOr('◻', '[ ]');
export const S_PASSWORD_MASK = unicodeOr('▪', '•');

export const S_BAR_H = unicodeOr('─', '-');
export const S_CORNER_TOP_RIGHT = unicodeOr('╮', '+');
export const S_CONNECT_LEFT = unicodeOr('├', '+');
export const S_CORNER_BOTTOM_RIGHT = unicodeOr('╯', '+');
export const S_CORNER_BOTTOM_LEFT = unicodeOr('╰', '+');
export const S_CORNER_TOP_LEFT = unicodeOr('╭', '+');

export const S_INFO = unicodeOr('●', '•');
export const S_SUCCESS = unicodeOr('◆', '*');
export const S_WARN = unicodeOr('▲', '!');
export const S_ERROR = unicodeOr('■', 'x');

export const completeColor = (value: string) => color.gray(value);

export const symbol = (state: State) => {
export const S_STEP_ACTIVE: string = S_POINTER_ACTIVE;
export const S_STEP_CANCEL: string = unicodeOr('■', 'x');
export const S_STEP_ERROR: string = unicodeOr('▲', 'x');
export const S_STEP_SUBMIT: string = unicodeOr('◇', 'o');

export const S_BAR_START: string = unicodeOr('┌', 'T');
export const S_BAR: string = unicodeOr('│', '|');
export const S_BAR_END: string = unicodeOr('└', '—');
export const S_BAR_START_RIGHT: string = unicodeOr('┐', 'T');
export const S_BAR_END_RIGHT: string = unicodeOr('┘', '—');

export const S_RADIO_ACTIVE: string = S_POINTER_ACTIVE;
export const S_RADIO_INACTIVE: string = S_POINTER_INACTIVE;
export const S_CHECKBOX_ACTIVE: string = unicodeOr('◻', '[•]');
export const S_CHECKBOX_SELECTED: string = unicodeOr('◼', '[+]');
export const S_CHECKBOX_INACTIVE: string = unicodeOr('◻', '[ ]');
export const S_PASSWORD_MASK: string = unicodeOr('▪', '•');

export const S_BAR_H: string = unicodeOr('─', '-');
export const S_CORNER_TOP_RIGHT: string = unicodeOr('╮', '+');
export const S_CONNECT_LEFT: string = unicodeOr('├', '+');
export const S_CORNER_BOTTOM_RIGHT: string = unicodeOr('╯', '+');
export const S_CORNER_BOTTOM_LEFT: string = unicodeOr('╰', '+');
export const S_CORNER_TOP_LEFT: string = unicodeOr('╭', '+');

export const S_INFO: string = unicodeOr('●', '•');
export const S_SUCCESS: string = unicodeOr('◆', '*');
export const S_WARN: string = unicodeOr('▲', '!');
export const S_ERROR: string = unicodeOr('■', 'x');

export const completeColor = (value: string): string => color.gray(value);

export const symbol = (state: State): string => {
switch (state) {
case 'initial':
case 'active':
Expand All @@ -129,7 +129,7 @@ export const symbol = (state: State) => {
}
};

export const symbolBar = (state: State) => {
export const symbolBar = (state: State): string => {
switch (state) {
case 'initial':
case 'active':
Expand Down
14 changes: 7 additions & 7 deletions packages/prompts/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const log = {
spacing = 0,
withGuide,
}: LogMessageOptions = {},
) => {
): void => {
const parts: string[] = [];
const hasGuide = getGuide({ withGuide });
const spacingString = !hasGuide ? '' : secondarySymbol;
Expand Down Expand Up @@ -59,23 +59,23 @@ export const log = {
}
output.write(`${parts.join('\n')}\n`);
},
info: (message: string, opts?: LogMessageOptions) => {
info: (message: string, opts?: LogMessageOptions): void => {
log.message(message, { ...opts, symbol: color.blue(S_INFO) });
},
success: (message: string, opts?: LogMessageOptions) => {
success: (message: string, opts?: LogMessageOptions): void => {
log.message(message, { ...opts, symbol: completeColor(S_SUCCESS) });
},
step: (message: string, opts?: LogMessageOptions) => {
step: (message: string, opts?: LogMessageOptions): void => {
log.message(message, { ...opts, symbol: completeColor(S_STEP_SUBMIT) });
},
warn: (message: string, opts?: LogMessageOptions) => {
warn: (message: string, opts?: LogMessageOptions): void => {
log.message(message, { ...opts, symbol: color.yellow(S_WARN) });
},
/** alias for `log.warn()`. */
warning: (message: string, opts?: LogMessageOptions) => {
warning: (message: string, opts?: LogMessageOptions): void => {
log.warn(message, opts);
},
error: (message: string, opts?: LogMessageOptions) => {
error: (message: string, opts?: LogMessageOptions): void => {
log.message(message, { ...opts, symbol: color.red(S_ERROR) });
},
};
6 changes: 3 additions & 3 deletions packages/prompts/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import color from 'picocolors';

import { type CommonOptions, getGuide, S_BAR, S_BAR_START, S_BAR_END } from './common.js';

export const cancel = (message = '', opts?: CommonOptions) => {
export const cancel = (message = '', opts?: CommonOptions): void => {
const output: Writable = opts?.output ?? process.stdout;
const prefix = getGuide(opts) ? `${color.gray(S_BAR_END)} ` : '';
output.write(`${prefix}${color.red(message)}\n\n`);
};

export const intro = (title = '', opts?: CommonOptions) => {
export const intro = (title = '', opts?: CommonOptions): void => {
const output: Writable = opts?.output ?? process.stdout;
const prefix = getGuide(opts) ? `${color.gray(S_BAR_START)} ` : '';
output.write(`${prefix}${title}\n\n`);
};

export const outro = (message = '', opts?: CommonOptions) => {
export const outro = (message = '', opts?: CommonOptions): void => {
const output: Writable = opts?.output ?? process.stdout;
const prefix = getGuide(opts) ? `${color.gray(S_BAR)}\n${color.gray(S_BAR_END)} ` : '';
output.write(`${prefix}${message}\n\n`);
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface NoteOptions extends CommonOptions {
}

/** A compact, enclosed note. Guide bars never replace its side borders. */
export const note = (message = '', title = '', opts?: NoteOptions) => {
export const note = (message = '', title = '', opts?: NoteOptions): void => {
const content = opts?.format ? message.split('\n').map(opts.format).join('\n') : message;
box(`\n${content}\n`, title, { ...opts, width: 'auto', rounded: true, formatBorder: color.gray });
};
14 changes: 7 additions & 7 deletions packages/prompts/src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const stream = {
message: async (
iterable: Iterable<string> | AsyncIterable<string>,
{ symbol = '' }: LogMessageOptions = {},
) => {
): Promise<void> => {
process.stdout.write(symbol ? `${symbol} ` : '');
const initialWidth = symbol ? 2 : 0;
let lineWidth = initialWidth;
Expand All @@ -36,23 +36,23 @@ export const stream = {
}
process.stdout.write('\n');
},
info: (iterable: Iterable<string> | AsyncIterable<string>) => {
info: (iterable: Iterable<string> | AsyncIterable<string>): Promise<void> => {
return stream.message(iterable, { symbol: color.blue(S_INFO) });
},
success: (iterable: Iterable<string> | AsyncIterable<string>) => {
success: (iterable: Iterable<string> | AsyncIterable<string>): Promise<void> => {
return stream.message(iterable, { symbol: completeColor(S_SUCCESS) });
},
step: (iterable: Iterable<string> | AsyncIterable<string>) => {
step: (iterable: Iterable<string> | AsyncIterable<string>): Promise<void> => {
return stream.message(iterable, { symbol: completeColor(S_STEP_SUBMIT) });
},
warn: (iterable: Iterable<string> | AsyncIterable<string>) => {
warn: (iterable: Iterable<string> | AsyncIterable<string>): Promise<void> => {
return stream.message(iterable, { symbol: color.yellow(S_WARN) });
},
/** alias for `log.warn()`. */
warning: (iterable: Iterable<string> | AsyncIterable<string>) => {
warning: (iterable: Iterable<string> | AsyncIterable<string>): Promise<void> => {
return stream.warn(iterable);
},
error: (iterable: Iterable<string> | AsyncIterable<string>) => {
error: (iterable: Iterable<string> | AsyncIterable<string>): Promise<void> => {
return stream.message(iterable, { symbol: color.red(S_ERROR) });
},
};
15 changes: 14 additions & 1 deletion packages/prompts/src/task-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ export interface TaskLogCompletionOptions {
showLog?: boolean;
}

export interface TaskLogGroup {
message(msg: string, mopts?: TaskLogMessageOptions): void;
error(message: string): void;
success(message: string): void;
}

export interface TaskLog {
message(msg: string, mopts?: TaskLogMessageOptions): void;
group(name: string): TaskLogGroup;
error(message: string, opts?: TaskLogCompletionOptions): void;
success(message: string, opts?: TaskLogCompletionOptions): void;
}

interface BufferEntry {
header?: string;
value: string;
Expand All @@ -49,7 +62,7 @@ const stripDestructiveANSI = (input: string): string => {
/**
* Renders a log which clears on success and remains on failure
*/
export const taskLog = (opts: TaskLogOptions) => {
export const taskLog = (opts: TaskLogOptions): TaskLog => {
const output: Writable = opts.output ?? process.stdout;
const columns = getColumns(output);
const secondarySymbol = color.gray(S_BAR);
Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type Task = {
/**
* Define a group of tasks to be executed
*/
export const tasks = async (tasks: Task[], opts?: CommonOptions) => {
export const tasks = async (tasks: Task[], opts?: CommonOptions): Promise<void> => {
for (const task of tasks) {
if (task.enabled === false) {
continue;
Expand Down
6 changes: 6 additions & 0 deletions packages/prompts/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ export default defineConfig({
deps: {
onlyBundle: false,
},
dts: {
// TypeScript 7 no longer ships the classic tsc API and its tsgo API
// requires 7.1+, so rolldown-plugin-dts cannot use either here. Generate
// declarations with Oxc instead.
generator: 'oxc',
},
});
2 changes: 1 addition & 1 deletion packages/tools/.upstream-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"oxc-node": {
"repo": "https://github.com/oxc-project/oxc-node.git",
"branch": "main",
"hash": "4759cedbda87f67ca646d3277166884cfcd62f81"
"hash": "6d5376df15df5446a91d01d53f3d7965d8b9708e"
}
}
Loading
Loading