The problem in my case was that I had installed tsc package instead of the correct typescript. From https://www.npmjs.com/package/tsc:
Use
typescriptto get access to thetscCLI command.
The fix is:
npm uninstall tsc
npm install -D typescript
Commands like npx tsc --version will still run because typescript provides the tsc executable.