diff --git a/.yarnrc.yml b/.yarnrc.yml index 8a4e27b2611..21eb9091d6a 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -239,7 +239,7 @@ catalogs: react-native-windows: ^0.81.0 react-test-renderer: 19.1.4 -dynamicPackageExtensions: ./scripts/dynamic.extensions.mjs +dynamicPackageExtensions: ./scripts/dynamic.extensions.mts enableGlobalCache: false diff --git a/package.json b/package.json index 4f83e0cf82a..eec4e8ddfd9 100644 --- a/package.json +++ b/package.json @@ -16,17 +16,17 @@ ], "scripts": { "build": "lage build-all", - "clean-all": "node ./scripts/src/preinstall/clean-all.js", + "clean-all": "node ./scripts/src/preinstall/clean-all.ts", "docs": "yarn workspace fluent-rn-website start", "bundle:repo": "lage bundle", "clean": "lage clean", "change": "node .github/scripts/change.mts", "changeset:version": "node .github/scripts/changeset-version-with-postbump.mts", "change:check": "node .github/scripts/change.mts --check", - "check-publishing": "node ./scripts/src/cli.mjs check-publishing", + "check-publishing": "node ./scripts/src/cli.ts check-publishing", "lint-fix": "cross-env FURN_FIX_MODE=true lage lint", "lint-package-fix": "cross-env FURN_FIX_MODE=true lage lint-package", - "preinstall": "node ./scripts/src/preinstall/use-yarn-please.js", + "preinstall": "node ./scripts/src/preinstall/use-yarn-please.ts", "format": "oxfmt", "format:check": "oxfmt --check", "lint-lockfile": "lint-lockfile", diff --git a/scripts/dynamic.extensions.mjs b/scripts/dynamic.extensions.mts similarity index 62% rename from scripts/dynamic.extensions.mjs rename to scripts/dynamic.extensions.mts index f1635d5cbaa..c6c50ee7109 100644 --- a/scripts/dynamic.extensions.mjs +++ b/scripts/dynamic.extensions.mts @@ -1,23 +1,19 @@ -// @ts-check - import fs from 'node:fs'; import path from 'node:path'; -import { getToolVersion, hasJestConfig } from './src/preinstall/tool-versions.js'; +import { getToolVersion, hasJestConfig } from './src/preinstall/tool-versions.ts'; +import type { PackageManifest } from './src/utils/projectRoot.ts'; -/** - * @typedef {() => boolean} ConditionalCheck - */ +type ConditionalCheck = () => boolean; /** * Conditionally add a dependency to the given dependencies object if it is not already present - * @param {string[]} depsToAdd - * @param {import('./src/utils/projectRoot.ts').PackageManifest} manifest - * @param {ConditionalCheck | boolean | undefined} condition - * @returns {Record} */ -function conditionallyAdd(depsToAdd, manifest, condition) { - /** @type {Record} */ - const newDeps = {}; +function conditionallyAdd( + depsToAdd: string[], + manifest: PackageManifest, + condition: ConditionalCheck | boolean | undefined, +): Record { + const newDeps: Record = {}; if (!condition || (typeof condition === 'function' ? condition() : condition)) { for (const dep of depsToAdd) { if (!manifest.dependencies?.[dep] && !manifest.devDependencies?.[dep]) { @@ -36,29 +32,23 @@ function conditionallyAdd(depsToAdd, manifest, condition) { } /** - * @param {import('./src/utils/projectRoot.ts').PackageManifest} manifest - The package manifest. - * @returns {boolean} true if oxfmt should be added based on the manifest's prettier scripts + * Returns true if oxfmt should be added based on the manifest's prettier scripts. */ -function addOxfmt(manifest) { +function addOxfmt(manifest: PackageManifest): boolean { return Boolean(manifest && manifest.scripts && (manifest.scripts.format || manifest.scripts['format:fix'])); } /** * Check if Jest is already in the manifest or if a Jest script is defined. - * @param {string} cwd - The current working directory. - * @param {import('./src/utils/projectRoot.ts').PackageManifest} manifest - The package manifest. - * @returns {boolean} - True if Jest should be added, false otherwise. */ -function addJest(cwd, manifest) { +function addJest(cwd: string, manifest: PackageManifest): boolean { return Boolean(manifest.scripts?.test && hasJestConfig(cwd)); } /** * Get the dynamic dependencies for the given package given the package root directory and its manifest. - * @param {{cwd: string, manifest: import('./src/utils/projectRoot.ts').PackageManifest}} param0 - * @returns { { dependencies: Record } } */ -export default function ({ cwd, manifest }) { +export default function ({ cwd, manifest }: { cwd: string; manifest: PackageManifest }): { dependencies: Record } { const enableLinting = Boolean(manifest.scripts && manifest.scripts.lint); return { diff --git a/scripts/package.json b/scripts/package.json index 5f939174fce..aecaac3c6d8 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -9,14 +9,14 @@ "directory": "scripts" }, "bin": { - "fluentui-scripts": "./src/cli.mjs" + "fluentui-scripts": "./src/cli.ts" }, "type": "module", - "main": "./src/index.js", + "main": "./src/index.ts", "exports": { ".": { - "require": "./src/index.js", - "default": "./src/index.js" + "require": "./src/index.ts", + "default": "./src/index.ts" }, "./babel-config": "./configs/jest/babel.config.cjs", "./jest-config": "./configs/jest/jest.config.cjs", @@ -29,10 +29,10 @@ "build": "tsgo", "build-core": "tsgo", "bundlesize": "bundlesize --debug", - "depcheck": "node ./src/cli.mjs depcheck", - "format": "node ./src/cli.mjs format", - "lint": "node ./src/cli.mjs lint", - "lint-package": "node ./src/cli.mjs lint-package" + "depcheck": "node ./src/cli.ts depcheck", + "format": "node ./src/cli.ts format", + "lint": "node ./src/cli.ts lint", + "lint-package": "node ./src/cli.ts lint-package" }, "dependencies": { "@babel/core": "catalog:", diff --git a/scripts/src/cli.mjs b/scripts/src/cli.ts old mode 100755 new mode 100644 similarity index 79% rename from scripts/src/cli.mjs rename to scripts/src/cli.ts index 8220c1e8462..788a380a2ae --- a/scripts/src/cli.mjs +++ b/scripts/src/cli.ts @@ -1,14 +1,13 @@ #!/usr/bin/env node -// @ts-check import { Builtins, Cli } from 'clipanion'; import { BuildCommand } from './tasks/build.ts'; -import { CleanCommand } from './tasks/clean.js'; -import { FormatCommand } from './tasks/format.js'; -import { LintCommand } from './tasks/lint.js'; +import { CleanCommand } from './tasks/clean.ts'; +import { FormatCommand } from './tasks/format.ts'; +import { LintCommand } from './tasks/lint.ts'; import { LintPackageCommand } from './tasks/lintPackage.ts'; -import { JestCommand } from './tasks/jest.js'; -import { CheckPublishingCommand } from './tasks/checkPublishingTask.js'; +import { JestCommand } from './tasks/jest.ts'; +import { CheckPublishingCommand } from './tasks/checkPublishingTask.ts'; import { DepcheckCommand } from './tasks/depcheck.ts'; const cli = new Cli({ diff --git a/scripts/src/index.js b/scripts/src/index.ts similarity index 78% rename from scripts/src/index.js rename to scripts/src/index.ts index a4d81b66e68..5c342fe8014 100644 --- a/scripts/src/index.js +++ b/scripts/src/index.ts @@ -1,2 +1 @@ -// @ts-check export { isPnpmMode } from './utils/ispnpm.ts'; diff --git a/scripts/src/preinstall/clean-all.js b/scripts/src/preinstall/clean-all.ts similarity index 82% rename from scripts/src/preinstall/clean-all.js rename to scripts/src/preinstall/clean-all.ts index 90fe5dba7bd..1d3fd0e9cc9 100644 --- a/scripts/src/preinstall/clean-all.js +++ b/scripts/src/preinstall/clean-all.ts @@ -1,16 +1,10 @@ -// @ts-check - -const child_process = require('child_process'); -const fs = require('fs'); -const path = require('path'); -const os = require('os'); +import child_process from 'node:child_process'; +import fs from 'node:fs'; +import path from 'node:path'; +import os from 'node:os'; // This script MUST NOT have any deps aside from Node built-ins, because it deletes all node_modules! -/** - * @param {string} question - The question to prompt the user with - * @returns {Promise} - * */ -function prompt(question) { +function prompt(question: string): Promise { return new Promise((resolve) => { process.stdin.resume(); process.stdout.write(question); @@ -22,10 +16,7 @@ function prompt(question) { }); } -/** - * @param {string} itemPath - The path to the item to check - */ -function deleteIfSymlink(itemPath) { +function deleteIfSymlink(itemPath: string): void { itemPath = path.resolve(itemPath); try { // Compare realpath since fs.statSync(itemPath).isSymbolicLink() doesn't work on Windows @@ -40,10 +31,8 @@ function deleteIfSymlink(itemPath) { /** * Deletes symlinks in the specified node_modules directory. - * @param {string} nodeModulesPath - The path to the node_modules directory - * @returns {void} */ -function deleteNodeModulesSymlinks(nodeModulesPath) { +function deleteNodeModulesSymlinks(nodeModulesPath: string): void { if (!fs.existsSync(nodeModulesPath)) { return; } @@ -62,10 +51,8 @@ function deleteNodeModulesSymlinks(nodeModulesPath) { /** * Deletes symlinks in the specified parent folder. - * @param {string} parentFolder - The path to the parent folder - * @returns {void} */ -function deleteSymlinks(parentFolder) { +function deleteSymlinks(parentFolder: string): void { const parentPath = path.join(process.cwd(), parentFolder); if (!fs.existsSync(parentPath)) { return; diff --git a/scripts/src/preinstall/tool-versions.js b/scripts/src/preinstall/tool-versions.ts similarity index 80% rename from scripts/src/preinstall/tool-versions.js rename to scripts/src/preinstall/tool-versions.ts index f3cdedec8d3..c86fbd11cd0 100644 --- a/scripts/src/preinstall/tool-versions.js +++ b/scripts/src/preinstall/tool-versions.ts @@ -2,12 +2,12 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; +import type { PackageManifest } from '../utils/projectRoot.ts'; + /** * Get the package.json manifest for a given folder. - * @param {string} folder - * @returns {import('../utils/projectRoot.ts').PackageManifest} */ -function getPackageManifest(folder) { +function getPackageManifest(folder: string): PackageManifest { const manifestPath = path.join(folder, 'package.json'); return JSON.parse(fs.readFileSync(manifestPath, 'utf-8')); } @@ -17,8 +17,7 @@ const scriptFolder = path.join(path.dirname(fileURLToPath(import.meta.url)), '.. const scriptManifest = getPackageManifest(scriptFolder); const rootManifest = getPackageManifest(path.dirname(scriptFolder)); -/** @type {Record} */ -const devToolVersions = { +const devToolVersions: Record = { '@eslint/js': '^9.0.0', '@microsoft/eslint-plugin-sdl': '^1.1.0', '@react-native-community/cli': '^13.6.4', @@ -58,27 +57,21 @@ const devToolVersions = { ...rootManifest.devDependencies, }; -/** @type {Record} */ -const workspaceToolVersions = { +const workspaceToolVersions: Record = { '@fluentui-react-native/scripts': 'workspace:*', }; -/** - * - * @param {string} packageName - * @returns {string | null} - */ -export function getToolVersion(packageName) { +export function getToolVersion(packageName: string): string | null { return devToolVersions[packageName] ?? workspaceToolVersions[packageName] ?? null; } const CONFIG_EXTENSIONS = ['.js', '.cjs', '.mjs', '.ts', '.cts', '.mts']; /** - * @param {string} cwd - The current working directory. - * @returns {boolean} - True if a Jest config file exists in the cwd, false otherwise. + * @param cwd the current working directory. + * @returns true if a Jest config file exists in the cwd, false otherwise. */ -export function hasJestConfig(cwd) { +export function hasJestConfig(cwd: string): boolean { for (const ext of CONFIG_EXTENSIONS) { if (fs.existsSync(path.join(cwd, `jest.config${ext}`))) { return true; diff --git a/scripts/src/preinstall/use-yarn-please.js b/scripts/src/preinstall/use-yarn-please.ts similarity index 100% rename from scripts/src/preinstall/use-yarn-please.js rename to scripts/src/preinstall/use-yarn-please.ts diff --git a/scripts/src/tasks/build.ts b/scripts/src/tasks/build.ts index 7579032b75c..b3dcc73ce73 100644 --- a/scripts/src/tasks/build.ts +++ b/scripts/src/tasks/build.ts @@ -1,7 +1,5 @@ -// @ts-check - import { Command } from 'clipanion'; -import { runYarn } from '../utils/runScript.js'; +import { runYarn } from '../utils/runScript.ts'; import { getProjectRoot } from '../utils/projectRoot.ts'; import { getResolvedConfig } from '../utils/buildConfig.ts'; diff --git a/scripts/src/tasks/checkPublishingTask.js b/scripts/src/tasks/checkPublishingTask.ts similarity index 78% rename from scripts/src/tasks/checkPublishingTask.js rename to scripts/src/tasks/checkPublishingTask.ts index 21be1cba732..54fe94c7a4c 100644 --- a/scripts/src/tasks/checkPublishingTask.js +++ b/scripts/src/tasks/checkPublishingTask.ts @@ -1,28 +1,21 @@ -// @ts-check - import { Command } from 'clipanion'; import { getPackageInfos, findGitRoot } from 'workspace-tools'; -import { checkDependencies } from '../utils/checkDependencies.js'; +import { checkDependencies } from '../utils/checkDependencies.ts'; -/** - * @typedef {'dependencies' | 'devDependencies' | 'peerDependencies'} DependencyType - * @typedef {{ dependencyTypes?: DependencyType[] }} CheckPublishingOptions - */ +type DependencyType = 'dependencies' | 'devDependencies' | 'peerDependencies'; export class CheckPublishingCommand extends Command { - /** @override */ - static paths = [['check-publishing']]; + static override paths = [['check-publishing']]; - /** @override */ - static usage = Command.Usage({ + static override usage = Command.Usage({ description: 'Check the matrix of packages for publishing errors', details: 'This command checks for published packages that have a dependency on a private package.', examples: [['Check for publishing errors', '$0 check-publishing']], }); async execute() { - const dependencyTypes = ['dependencies']; + const dependencyTypes: DependencyType[] = ['dependencies']; const packageInfos = getPackageInfos(findGitRoot(process.cwd())); console.info('Starting scan for publishing errors'); try { diff --git a/scripts/src/tasks/clean.js b/scripts/src/tasks/clean.ts similarity index 77% rename from scripts/src/tasks/clean.js rename to scripts/src/tasks/clean.ts index 0e3a8789c2a..8bbe1f947fe 100644 --- a/scripts/src/tasks/clean.js +++ b/scripts/src/tasks/clean.ts @@ -1,15 +1,11 @@ -// @ts-check - import { Command } from 'clipanion'; import fs from 'node:fs'; import path from 'node:path'; export class CleanCommand extends Command { - /** @override */ - static paths = [['clean']]; + static override paths = [['clean']]; - /** @override */ - static usage = Command.Usage({ + static override usage = Command.Usage({ description: 'Cleans the current package', details: 'This command removes all build artifacts from the current package.', examples: [['Clean the current package', '$0 clean']], @@ -22,9 +18,8 @@ export class CleanCommand extends Command { /** * Cleans the specified folder by removing certain directories and files. - * @param {string} [cwd=process.cwd()] - The target directory to clean. */ -export function cleanFolder(cwd = process.cwd()) { +export function cleanFolder(cwd: string = process.cwd()): number { const options = { force: true, maxRetries: 3, recursive: true }; [ 'lib', diff --git a/scripts/src/tasks/depcheck.ts b/scripts/src/tasks/depcheck.ts index 2a4f08a71dd..eaeda5f150a 100644 --- a/scripts/src/tasks/depcheck.ts +++ b/scripts/src/tasks/depcheck.ts @@ -1,12 +1,10 @@ -// @ts-check - import { Command, Option } from 'clipanion'; import depcheck from 'depcheck'; import type { ProjectRoot } from '../utils/projectRoot.ts'; import { getProjectRoot } from '../utils/projectRoot.ts'; -import getInjectedDeps from '../../dynamic.extensions.mjs'; +import getInjectedDeps from '../../dynamic.extensions.mts'; import { getReporter } from '../utils/getReporter.ts'; -import { getToolVersion } from '../preinstall/tool-versions.js'; +import { getToolVersion } from '../preinstall/tool-versions.ts'; import micromatch from 'micromatch'; import { isFixMode } from '../utils/env.ts'; diff --git a/scripts/src/tasks/format.js b/scripts/src/tasks/format.ts similarity index 77% rename from scripts/src/tasks/format.js rename to scripts/src/tasks/format.ts index 341377edd51..8878eeaec20 100644 --- a/scripts/src/tasks/format.js +++ b/scripts/src/tasks/format.ts @@ -1,15 +1,11 @@ -// @ts-check - import { Command, Option } from 'clipanion'; -import { runScript } from '../utils/runScript.js'; +import { runScript } from '../utils/runScript.ts'; import { isFixMode } from '../utils/env.ts'; export class FormatCommand extends Command { - /** @override */ - static paths = [['format']]; + static override paths = [['format']]; - /** @override */ - static usage = Command.Usage({ + static override usage = Command.Usage({ description: 'Formats the current package', details: 'This command formats the current package using oxfmt.', examples: [['Format the current package', '$0 format']], diff --git a/scripts/src/tasks/jest.js b/scripts/src/tasks/jest.ts similarity index 73% rename from scripts/src/tasks/jest.js rename to scripts/src/tasks/jest.ts index 97c8d33c43c..bbffcfbd255 100644 --- a/scripts/src/tasks/jest.js +++ b/scripts/src/tasks/jest.ts @@ -1,14 +1,11 @@ -// @ts-check import { Command, Option } from 'clipanion'; -import { runScript } from '../utils/runScript.js'; -import { hasJestConfig } from '../preinstall/tool-versions.js'; +import { runScript } from '../utils/runScript.ts'; +import { hasJestConfig } from '../preinstall/tool-versions.ts'; export class JestCommand extends Command { - /** @override */ - static paths = [['jest']]; + static override paths = [['jest']]; - /** @override */ - static usage = Command.Usage({ + static override usage = Command.Usage({ description: 'Tests the current package using jest', details: 'This command tests the current package.', examples: [['Test the current package', '$0 jest']], diff --git a/scripts/src/tasks/lint.js b/scripts/src/tasks/lint.ts similarity index 91% rename from scripts/src/tasks/lint.js rename to scripts/src/tasks/lint.ts index ed41dc97596..fdcf9716a93 100644 --- a/scripts/src/tasks/lint.js +++ b/scripts/src/tasks/lint.ts @@ -1,5 +1,3 @@ -// @ts-check - import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; @@ -7,11 +5,9 @@ import { Command, Option } from 'clipanion'; import { isFixMode } from '../utils/env.ts'; export class LintCommand extends Command { - /** @override */ - static paths = [['lint']]; + static override paths = [['lint']]; - /** @override */ - static usage = Command.Usage({ + static override usage = Command.Usage({ description: 'Lints the current package', details: 'This command lints the current package using oxlint.', examples: [['Lint the current package', '$0 lint']], diff --git a/scripts/src/tasks/lintPackage.ts b/scripts/src/tasks/lintPackage.ts index 36880e06c07..2221277e82e 100644 --- a/scripts/src/tasks/lintPackage.ts +++ b/scripts/src/tasks/lintPackage.ts @@ -478,7 +478,7 @@ export class LintPackageCommand extends Command { } private getFluentScriptsText(command: string) { - return this.isScripts ? `node ./src/cli.mjs ${command}` : `fluentui-scripts ${command}`; + return this.isScripts ? `node ./src/cli.ts ${command}` : `fluentui-scripts ${command}`; } } diff --git a/scripts/src/tasks/runAlignDeps.ts b/scripts/src/tasks/runAlignDeps.ts index 624f29d816d..ab476e01c85 100644 --- a/scripts/src/tasks/runAlignDeps.ts +++ b/scripts/src/tasks/runAlignDeps.ts @@ -1,6 +1,6 @@ import { scriptsDir } from '../utils/ispnpm.ts'; import { spawn } from 'node:child_process'; -import { yarnVerb } from '../utils/runScript.js'; +import { yarnVerb } from '../utils/runScript.ts'; import path from 'node:path'; export async function runAlignDeps(targetDir: string, fixMode: boolean): Promise { diff --git a/scripts/src/utils/checkDependencies.js b/scripts/src/utils/checkDependencies.ts similarity index 82% rename from scripts/src/utils/checkDependencies.js rename to scripts/src/utils/checkDependencies.ts index e9593f70163..afd57daee1e 100644 --- a/scripts/src/utils/checkDependencies.js +++ b/scripts/src/utils/checkDependencies.ts @@ -1,5 +1,3 @@ -// @ts-check - /** * Quick and dirty script to ensure we have got our nested peerDependencies correct * @@ -11,7 +9,17 @@ import { readFileSync, writeFileSync } from 'node:fs'; import { findGitRoot, getPackageInfos } from 'workspace-tools'; -export function checkDependencies() { +type PackageJson = { + 'rnx-kit'?: { kitType?: string }; + peerDependencies?: Record; + peerDependenciesMeta?: Record; +}; + +type PackageInfoWithJson = ReturnType[string] & { + pkgJson: PackageJson; +}; + +export function checkDependencies(): void { let requireRescan = true; let everWrote = false; @@ -21,7 +29,7 @@ export function checkDependencies() { while (requireRescan) { requireRescan = false; - const infos = getPackageInfos(findGitRoot(process.cwd())); + const infos = getPackageInfos(findGitRoot(process.cwd())) as Record; // getPackageInfos unfortunately doesn't provide peerDependenciesMeta, so we need to parse the whole package.json for (const pkgName in infos) { @@ -34,10 +42,8 @@ export function checkDependencies() { const deps = { ...infos[pkgName].dependencies, ...infos[pkgName].peerDependencies }; - /** @type {{ name: string, version: string }[]} */ - const missingPeerDeps = []; - /** @type {string[]} */ - const missingPeerDepsMeta = []; + const missingPeerDeps: { name: string; version: string }[] = []; + const missingPeerDepsMeta: string[] = []; for (const dep in deps) { if (infos[dep]) { @@ -69,7 +75,7 @@ export function checkDependencies() { infos[pkgName].pkgJson.peerDependencies = {}; } for (const missingDep of missingPeerDeps) { - infos[pkgName].pkgJson.peerDependencies[missingDep.name] = missingDep.version; + infos[pkgName].pkgJson.peerDependencies![missingDep.name] = missingDep.version; } requireWriteFile = true; } @@ -80,7 +86,7 @@ export function checkDependencies() { } for (const missingMeta of missingPeerDepsMeta) { - infos[pkgName].pkgJson.peerDependenciesMeta[missingMeta] = { + infos[pkgName].pkgJson.peerDependenciesMeta![missingMeta] = { optional: true, }; } diff --git a/scripts/src/utils/resolvePaths.js b/scripts/src/utils/resolvePaths.ts similarity index 72% rename from scripts/src/utils/resolvePaths.js rename to scripts/src/utils/resolvePaths.ts index a6f9f18a842..41c9fd7566c 100644 --- a/scripts/src/utils/resolvePaths.js +++ b/scripts/src/utils/resolvePaths.ts @@ -4,11 +4,9 @@ import path from 'node:path'; /** * Find all node_modules directories up to the project root - * @returns {string[]} - An array of paths to node_modules directories found in the project root. */ -export function nodeModulesToRoot() { - /** @type {string[]} */ - const results = []; +export function nodeModulesToRoot(): string[] { + const results: string[] = []; findUp.sync((directory) => { const nodeModulesPath = path.join(directory, 'node_modules'); if (fs.existsSync(nodeModulesPath)) { diff --git a/scripts/src/utils/runScript.js b/scripts/src/utils/runScript.ts similarity index 71% rename from scripts/src/utils/runScript.js rename to scripts/src/utils/runScript.ts index 49e5dae321e..50d60fdb907 100644 --- a/scripts/src/utils/runScript.js +++ b/scripts/src/utils/runScript.ts @@ -1,33 +1,23 @@ -// @ts-check - import { spawn } from 'node:child_process'; import { getProjectRoot } from './projectRoot.ts'; import os from 'node:os'; export const yarnVerb = os.platform() === 'win32' ? 'yarn.cmd' : 'yarn'; -/** @type {Record} */ -const cmdToModule = { +const cmdToModule: Record = { tsc: 'typescript', }; /** * Get the path to a bin entrypoint for a js package. - * @param {string} command - * @returns {string | undefined} */ -function getBinPath(command) { +function getBinPath(command: string): string | undefined { const wdRoot = getProjectRoot(process.cwd()); const cmdModule = cmdToModule[command] ?? command; return wdRoot.openModule(cmdModule).getBinPath(command); } -/** - * @param {string} command - * @param {...string} args - * @returns {Promise} - */ -export async function runScript(command, ...args) { +export async function runScript(command: string, ...args: string[]): Promise { const binPath = getBinPath(command); const verb = binPath ? process.execPath : yarnVerb; const spawnArgs = binPath ? [binPath, ...args] : ['exec', command, ...args]; @@ -43,12 +33,7 @@ export async function runScript(command, ...args) { }); } -/** - * @param {string} command - * @param {...string} args - * @returns {Promise} - */ -export async function runYarn(command, ...args) { +export async function runYarn(command: string, ...args: string[]): Promise { const verb = yarnVerb; const spawnArgs = [command, ...args]; return new Promise((resolve) => { diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index b9983f0655d..07998cf34bf 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "@rnx-kit/tsconfig/tsconfig.node.json", "compilerOptions": { - "allowJs": true, - "checkJs": true, "noEmit": true, "allowSyntheticDefaultImports": true, "target": "es2022" diff --git a/yarn.lock b/yarn.lock index d58e8f824e7..404af1a744e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4878,7 +4878,7 @@ __metadata: workspace-tools: "npm:^0.26.3" zx: "npm:^8.2.4" bin: - fluentui-scripts: ./src/cli.mjs + fluentui-scripts: ./src/cli.ts languageName: unknown linkType: soft