Skip to content

Commit bd21291

Browse files
committed
feat(tsconfig) support allowJs in compilerOptions (#658)
Related to rolldown/rolldown#5867 The extension checks for `include` and `exclude` paths need to take `allowJs` into account.
1 parent 547bce7 commit bd21291

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

fixtures/tsconfig/cases/extends-compiler-options/base-tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"baseUrl": "./src",
4+
"allowJs": true,
45
"emitDecoratorMetadata": true,
56
"useDefineForClassFields": true,
67
"rewriteRelativeImportExtensions": true

src/tests/tsconfig_extends.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn test_extend_tsconfig_compiler_options() {
2424

2525
// Should inherit compilerOptions from parent
2626
assert_eq!(compiler_options.base_url, Some(f.join("src")));
27+
assert_eq!(compiler_options.allow_js, Some(true));
2728
assert_eq!(compiler_options.emit_decorator_metadata, Some(true));
2829
assert_eq!(compiler_options.use_define_for_class_fields, Some(true));
2930
assert_eq!(compiler_options.rewrite_relative_import_extensions, Some(true));

src/tsconfig.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ impl TsConfig {
257257
compiler_options.set_module(module.to_string());
258258
}
259259
}
260+
261+
if compiler_options.allow_js().is_none() {
262+
if let Some(allow_js) = tsconfig.compiler_options().allow_js() {
263+
compiler_options.set_allow_js(*allow_js);
264+
}
265+
}
260266
}
261267
/// "Build" the root tsconfig, resolve:
262268
///
@@ -449,6 +455,9 @@ pub struct CompilerOptions {
449455

450456
/// <https://www.typescriptlang.org/tsconfig/#module>
451457
pub module: Option<String>,
458+
459+
/// <https://www.typescriptlang.org/tsconfig/#allowJs>
460+
pub allow_js: Option<bool>,
452461
}
453462

454463
impl CompilerOptions {
@@ -620,6 +629,16 @@ impl CompilerOptions {
620629
fn set_module(&mut self, module: String) {
621630
self.module = Some(module);
622631
}
632+
633+
/// Whether to allow js.
634+
fn allow_js(&self) -> Option<&bool> {
635+
self.allow_js.as_ref()
636+
}
637+
638+
/// Sets whether to allow js.
639+
fn set_allow_js(&mut self, allow_js: bool) {
640+
self.allow_js = Some(allow_js);
641+
}
623642
}
624643

625644
/// Value for the "extends" field.

0 commit comments

Comments
 (0)