diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index d76807931..6ba40ef38 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -513,6 +513,13 @@ func (ts *typeScriptLang) addProjectRule(cfg *JsGazelleConfig, tsconfigRel strin existing.DelAttr("allow_js") } + // Reflect the tsconfig composite in the ts_project rule + if tsconfig.Composite != nil { + sourceRule.SetAttr("composite", *tsconfig.Composite) + } else if existing != nil { + existing.DelAttr("composite") + } + // Reflect the tsconfig declaration in the ts_project rule if tsconfig.Declaration != nil { sourceRule.SetAttr("declaration", *tsconfig.Declaration) @@ -534,6 +541,13 @@ func (ts *typeScriptLang) addProjectRule(cfg *JsGazelleConfig, tsconfigRel strin existing.DelAttr("source_map") } + // Reflect the tsconfig incremental in the ts_project rule + if tsconfig.Incremental != nil { + sourceRule.SetAttr("incremental", *tsconfig.Incremental) + } else if existing != nil { + existing.DelAttr(("incremental")) + } + // Reflect the tsconfig resolve_json_module in the ts_project rule if tsconfig.ResolveJsonModule != nil { sourceRule.SetAttr("resolve_json_module", *tsconfig.ResolveJsonModule) @@ -565,8 +579,10 @@ func (ts *typeScriptLang) addProjectRule(cfg *JsGazelleConfig, tsconfigRel strin // Clear tsconfig related attributes if no tsconfig is found existing.DelAttr("tsconfig") existing.DelAttr("allow_js") + existing.DelAttr("composite") existing.DelAttr("declaration") existing.DelAttr("declaration_map") + existing.DelAttr("incremental") existing.DelAttr("out_dir") existing.DelAttr("preserve_jsx") existing.DelAttr("resolve_json_module") diff --git a/gazelle/js/tests/tsconfig_composite/BUILD.in b/gazelle/js/tests/tsconfig_composite/BUILD.in new file mode 100644 index 000000000..5b0ea19fe --- /dev/null +++ b/gazelle/js/tests/tsconfig_composite/BUILD.in @@ -0,0 +1 @@ +# gazelle:js_tsconfig enabled \ No newline at end of file diff --git a/gazelle/js/tests/tsconfig_composite/BUILD.out b/gazelle/js/tests/tsconfig_composite/BUILD.out new file mode 100644 index 000000000..13d9b344f --- /dev/null +++ b/gazelle/js/tests/tsconfig_composite/BUILD.out @@ -0,0 +1,15 @@ +load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project") + +# gazelle:js_tsconfig enabled + +ts_project( + name = "tsconfig_composite", + srcs = ["main.ts"], + composite = True, + tsconfig = ":tsconfig", +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", +) diff --git a/gazelle/js/tests/tsconfig_composite/WORKSPACE b/gazelle/js/tests/tsconfig_composite/WORKSPACE new file mode 100644 index 000000000..66f28f7cd --- /dev/null +++ b/gazelle/js/tests/tsconfig_composite/WORKSPACE @@ -0,0 +1,2 @@ +# This is a Bazel workspace for the Gazelle test data. +workspace(name = "tsconfig_composite") diff --git a/gazelle/js/tests/tsconfig_composite/main.ts b/gazelle/js/tests/tsconfig_composite/main.ts new file mode 100644 index 000000000..7b68cbff7 --- /dev/null +++ b/gazelle/js/tests/tsconfig_composite/main.ts @@ -0,0 +1 @@ +console.log('No Imports!'); diff --git a/gazelle/js/tests/tsconfig_composite/tsconfig.json b/gazelle/js/tests/tsconfig_composite/tsconfig.json new file mode 100644 index 000000000..664df5f60 --- /dev/null +++ b/gazelle/js/tests/tsconfig_composite/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "composite": true + } +} diff --git a/gazelle/js/tests/tsconfig_incremental/BUILD.in b/gazelle/js/tests/tsconfig_incremental/BUILD.in new file mode 100644 index 000000000..5b0ea19fe --- /dev/null +++ b/gazelle/js/tests/tsconfig_incremental/BUILD.in @@ -0,0 +1 @@ +# gazelle:js_tsconfig enabled \ No newline at end of file diff --git a/gazelle/js/tests/tsconfig_incremental/BUILD.out b/gazelle/js/tests/tsconfig_incremental/BUILD.out new file mode 100644 index 000000000..fbce55e09 --- /dev/null +++ b/gazelle/js/tests/tsconfig_incremental/BUILD.out @@ -0,0 +1,15 @@ +load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project") + +# gazelle:js_tsconfig enabled + +ts_project( + name = "tsconfig_incremental", + srcs = ["main.ts"], + incremental = True, + tsconfig = ":tsconfig", +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", +) diff --git a/gazelle/js/tests/tsconfig_incremental/WORKSPACE b/gazelle/js/tests/tsconfig_incremental/WORKSPACE new file mode 100644 index 000000000..d1fabaa02 --- /dev/null +++ b/gazelle/js/tests/tsconfig_incremental/WORKSPACE @@ -0,0 +1,2 @@ +# This is a Bazel workspace for the Gazelle test data. +workspace(name = "tsconfig_incremental") diff --git a/gazelle/js/tests/tsconfig_incremental/main.ts b/gazelle/js/tests/tsconfig_incremental/main.ts new file mode 100644 index 000000000..7b68cbff7 --- /dev/null +++ b/gazelle/js/tests/tsconfig_incremental/main.ts @@ -0,0 +1 @@ +console.log('No Imports!'); diff --git a/gazelle/js/tests/tsconfig_incremental/tsconfig.json b/gazelle/js/tests/tsconfig_incremental/tsconfig.json new file mode 100644 index 000000000..78f0d4589 --- /dev/null +++ b/gazelle/js/tests/tsconfig_incremental/tsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "incremental": true + } +} diff --git a/gazelle/js/typescript/tsconfig.go b/gazelle/js/typescript/tsconfig.go index e07bf68af..708629417 100644 --- a/gazelle/js/typescript/tsconfig.go +++ b/gazelle/js/typescript/tsconfig.go @@ -29,8 +29,10 @@ import ( type tsCompilerOptionsJSON struct { AllowJs *bool `json:"allowJs"` + Composite *bool `json:"composite"` Declaration *bool `json:"declaration"` DeclarationMap *bool `json:"declarationMap"` + Incremental *bool `json:"incremental"` SourceMap *bool `json:"sourceMap"` ResolveJsonModule *bool `json:"resolveJsonModule"` OutDir *string `json:"outDir"` @@ -81,8 +83,10 @@ type TsConfig struct { AllowJs *bool ResolveJsonModule *bool + Composite *bool Declaration *bool DeclarationMap *bool + Incremental *bool SourceMap *bool OutDir string RootDir string @@ -217,6 +221,13 @@ func parseTsConfigJSON(parsed map[string]*TsConfig, resolver TsConfigResolver, r allowJs = baseConfig.AllowJs } + var composite *bool + if c.CompilerOptions.Composite != nil { + composite = c.CompilerOptions.Composite + } else if baseConfig != nil { + composite = baseConfig.Composite + } + var declaration *bool if c.CompilerOptions.Declaration != nil { declaration = c.CompilerOptions.Declaration @@ -231,6 +242,13 @@ func parseTsConfigJSON(parsed map[string]*TsConfig, resolver TsConfigResolver, r declarationMap = baseConfig.DeclarationMap } + var incremental *bool + if c.CompilerOptions.Incremental != nil { + incremental = c.CompilerOptions.Incremental + } else if baseConfig != nil { + incremental = baseConfig.Incremental + } + var sourceMap *bool if c.CompilerOptions.SourceMap != nil { sourceMap = c.CompilerOptions.SourceMap @@ -310,8 +328,10 @@ func parseTsConfigJSON(parsed map[string]*TsConfig, resolver TsConfigResolver, r ConfigDir: configDir, ConfigName: configName, AllowJs: allowJs, + Composite: composite, Declaration: declaration, DeclarationMap: declarationMap, + Incremental: incremental, SourceMap: sourceMap, ResolveJsonModule: resolveJsonModule, OutDir: OutDir,