The TypeScript compiler is telling you that it cannot compile anything because you either ran `tsc` without a tsconfig/project or you pointed it at files that are not TypeScript sources.
tsc either reads a tsconfig.json in the current directory or accepts explicit file paths. When neither is supplied, the CLI cannot build anything and prints "tsc command expects a TypeScript file" to remind you that it needs at least one `.ts`, `.tsx`, `.cts`, `.mts`, or `.d.ts` input.
Run the compiler initialization tool to scratch a tsconfig in the folder where you expect to build from:
npx tsc --initIf the project already has a configuration file, make sure you run tsc from the directory that contains that tsconfig or explicitly pass its path with tsc -p path/to/tsconfig.json.
You can compile individual files without a config by giving them on the CLI:
npx tsc src/index.ts src/lib/util.tsUse .ts, .tsx, .cts, or .mts extensions and avoid directories or JavaScript-only files so that the compiler sees valid input.
TypeScript walks up from your current working directory to find a tsconfig.json. If you operate inside a subfolder, change into the parent or tell the compiler exactly where the config lives:
cd packages/widget
npx tsc
# or
npx tsc -p ../tsconfig.base.jsonThis ensures the compiler does not exit before reading compiler options.
If the repository only contains JavaScript and you rely on allowJs, flip on the compiler option or add TypeScript files so the input set is not empty:
{
"compilerOptions": {
"allowJs": true,
"include": ["src/**/*"]
}
}Otherwise, add a .ts entry (even an empty shim) to give tsc something to compile.
Check npm scripts, CI tasks, and IDE pre-launch commands so they change into the right folder or pass the -p flag. A script that calls npx tsc before building the workspace might run in the repo root while the tsconfig lives in packages/app. Adjust the command or script to match the project layout.
When no tsconfig exists and you do not specify source files, TypeScript prints this message instead of verbose diagnostics. The CLI looks in the working directory and each parent for tsconfig.json, and once it finds one it compiles the files specified by the "files", "include", or "extends" clauses. For monorepos or nested packages, keep a tsconfig in each package and always run tsc -p from inside the package, or create a top-level tsconfig.build.json and compile it with npx tsc -p tsconfig.build.json.
Type parameter 'X' is not used in the function signature
How to fix "Type parameter not used in function signature" in TypeScript
Type parameter 'X' is defined but never used
How to fix "Type parameter is defined but never used" in TypeScript
Function expression requires a return type
Function expression requires a return type
Value of type 'string | undefined' is not iterable
How to fix "Value is not iterable" in TypeScript
Type 'undefined' is not assignable to type 'string'
How to fix "Type undefined is not assignable to type string" in TypeScript