-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Description
π Search Terms
"cli", "tsc"
π Version & Regression Information
- This changed between versions 5.9.2
β― Playground Link
No response
π» Code
I want to use child_process get tsc CLI output for further analyse.
npm i typescript -g
tsc --version
Version 5.9.2
cd /tmp
mkdir a
cd a
tsc --init
cat <<\EOT> index.ts
const a:number = ""
console.info(a)
EOT
tsc --noEmit
index.ts:1:7 - error TS2322: Type 'string' is not assignable to type 'number'.
1 const a:number = ""
~
Found 1 error in index.ts:1
// use child_process spawn get tsc CLI output
cat <<\EOT> get_output.mjs
import child_process from 'child_process';
const { spawn } = child_process;
async function test() {
const ls = spawn('tsc', ['--noEmit'], {});
ls.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});
ls.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});
ls.on('close', (code) => {
console.log(`child process exited with code ${code}`);
});
}
test();
EOT
node get_output.mjs
stdout: index.ts(1,7): error TS2322: Type 'string' is not assignable to type 'number'.
child process exited with code 2
π Actual behavior
stdout missing information below
1 const a:number = ""
~
Found 1 error in index.ts:1
π Expected behavior
stdout should same as tsc CLI output
Additional information about the issue
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels