Skip to content

Commit bb0a9c8

Browse files
amandeavorkylehgc
authored andcommitted
fix(tsc): preserve informational output
1 parent cf55499 commit bb0a9c8

1 file changed

Lines changed: 48 additions & 1 deletion

File tree

‎src/cmds/js/tsc_cmd.rs‎

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@ fn clean_line(line: &str) -> Cow<'_, str> {
7676
}
7777
}
7878

79+
const INFORMATIONAL_FLAGS: &[&str] = &[
80+
"--showConfig",
81+
"--listFiles",
82+
"--listFilesOnly",
83+
"--init",
84+
"--help",
85+
"-h",
86+
"--version",
87+
"-v",
88+
];
89+
90+
fn is_informational_invocation(args: &[String]) -> bool {
91+
args.iter()
92+
.any(|arg| INFORMATIONAL_FLAGS.contains(&arg.as_str()))
93+
}
94+
7995
/// `runner` is the package runner the user named (`bunx tsc`, `npx tsc`), or
8096
/// None for a bare `rtk tsc` where nothing was specified and detection applies.
8197
pub fn run(runner: Option<&str>, args: &[String], verbose: u8) -> Result<i32> {
@@ -98,10 +114,21 @@ pub fn run(runner: Option<&str>, args: &[String], verbose: u8) -> Result<i32> {
98114
eprintln!("Running: {} {}", via, args.join(" "));
99115
}
100116

117+
let args_display = args.join(" ");
118+
if is_informational_invocation(args) {
119+
return runner::run(
120+
cmd,
121+
"tsc",
122+
&args_display,
123+
runner::RunMode::Passthrough,
124+
runner::RunOptions::default(),
125+
);
126+
}
127+
101128
runner::run_streamed(
102129
cmd,
103130
"tsc",
104-
&args.join(" "),
131+
&args_display,
105132
Box::new(BlockStreamFilter::new(TscHandler::new())),
106133
runner::RunOptions::with_tee("tsc"),
107134
)
@@ -491,6 +518,26 @@ src/app.tsx(20,5): error TS2345: Argument of type 'number' is not assignable to
491518
assert!(result.contains("No errors found"));
492519
}
493520

521+
#[test]
522+
fn informational_flags_bypass_diagnostic_filtering() {
523+
for flag in INFORMATIONAL_FLAGS {
524+
assert!(
525+
is_informational_invocation(&[flag.to_string()]),
526+
"{flag} should preserve native tsc output"
527+
);
528+
}
529+
}
530+
531+
#[test]
532+
fn typecheck_invocations_stay_filtered() {
533+
assert!(!is_informational_invocation(&[]));
534+
assert!(!is_informational_invocation(&["--noEmit".to_string()]));
535+
assert!(!is_informational_invocation(&[
536+
"-p".to_string(),
537+
"tsconfig.json".to_string()
538+
]));
539+
}
540+
494541
// --- Streaming handler tests ---
495542

496543
use crate::core::stream::tests::run_block_filter;

0 commit comments

Comments
 (0)