Skip to content

Commit 7d5ef35

Browse files
committed
refactor(scripts): add missing type annotations to 3 more functions
- fix/commonjs-exports.mts: processDirectory(dir: string, verbose: boolean): Promise<number> - validate/external-types.mts: getDtsFilesRecursive(dir: string, files: string[]): string[] - build-externals/esbuild-config.mts: createStubPlugin(stubMap: Record<string, string>)
1 parent f6710eb commit 7d5ef35

3 files changed

Lines changed: 7 additions & 10 deletions

File tree

scripts/build-externals/esbuild-config.mts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,9 @@ function createForceNodeModulesPlugin() {
143143

144144
/**
145145
* Create esbuild plugin to stub modules using files from stubs/ directory.
146-
*
147-
* @param {Record<string, string>} stubMap - Map of regex patterns to stub filenames
148-
* @returns {import('esbuild').Plugin}
146+
* stubMap keys are regex patterns; values are stub filenames.
149147
*/
150-
function createStubPlugin(stubMap = STUB_MAP) {
148+
function createStubPlugin(stubMap: Record<string, string> = STUB_MAP) {
151149
// Pre-compile regex patterns and load stub contents
152150
const stubs = Object.entries(stubMap).map(([pattern, filename]) => ({
153151
filter: new RegExp(pattern),

scripts/fix/commonjs-exports.mts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ const distDir = path.resolve(__dirname, '..', '..', 'dist')
2222
/**
2323
* Process files in a directory and fix CommonJS exports.
2424
* Handles files with `export default` by transforming __toCommonJS patterns.
25-
*
26-
* @param {string} dir - Directory to process
27-
* @param {boolean} verbose - Show individual file fixes
28-
* @returns {Promise<number>} Number of files fixed
2925
*/
30-
async function processDirectory(dir, verbose = false) {
26+
async function processDirectory(
27+
dir: string,
28+
verbose: boolean = false,
29+
): Promise<number> {
3130
let fixedCount = 0
3231

3332
try {

scripts/validate/external-types.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const logger = getDefaultLogger()
3131
/**
3232
* Get all .d.ts files recursively in a directory.
3333
*/
34-
function getDtsFilesRecursive(dir, files = []) {
34+
function getDtsFilesRecursive(dir: string, files: string[] = []): string[] {
3535
try {
3636
const entries = readdirSync(dir, { withFileTypes: true })
3737

0 commit comments

Comments
 (0)