diff --git a/gazelle/js/generate.go b/gazelle/js/generate.go index 87852db7..1b1f2620 100644 --- a/gazelle/js/generate.go +++ b/gazelle/js/generate.go @@ -580,6 +580,13 @@ func (ts *typeScriptLang) addProjectRule(cfg *JsGazelleConfig, tsconfigRel strin existing.DelAttr(("incremental")) } + // Reflect the tsconfig tsBuildInfoFile in the ts_project rule + if tsconfig.TsBuildInfoFile != "" { + sourceRule.SetAttr("ts_build_info_file", tsconfig.TsBuildInfoFile) + } else if existing != nil { + existing.DelAttr(("ts_build_info_file")) + } + // Reflect the tsconfig resolve_json_module in the ts_project rule if tsconfig.ResolveJsonModule != nil { sourceRule.SetAttr("resolve_json_module", *tsconfig.ResolveJsonModule) @@ -615,6 +622,7 @@ func (ts *typeScriptLang) addProjectRule(cfg *JsGazelleConfig, tsconfigRel strin existing.DelAttr("declaration") existing.DelAttr("declaration_map") existing.DelAttr("incremental") + existing.DelAttr("ts_build_info_file") existing.DelAttr("out_dir") existing.DelAttr("preserve_jsx") existing.DelAttr("resolve_json_module") diff --git a/gazelle/js/tests/tsconfig_tsbuildinfo/BUILD.in b/gazelle/js/tests/tsconfig_tsbuildinfo/BUILD.in new file mode 100644 index 00000000..5b0ea19f --- /dev/null +++ b/gazelle/js/tests/tsconfig_tsbuildinfo/BUILD.in @@ -0,0 +1 @@ +# gazelle:js_tsconfig enabled \ No newline at end of file diff --git a/gazelle/js/tests/tsconfig_tsbuildinfo/BUILD.out b/gazelle/js/tests/tsconfig_tsbuildinfo/BUILD.out new file mode 100644 index 00000000..88be2cc7 --- /dev/null +++ b/gazelle/js/tests/tsconfig_tsbuildinfo/BUILD.out @@ -0,0 +1,16 @@ +load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project") + +# gazelle:js_tsconfig enabled + +ts_project( + name = "tsconfig_tsbuildinfo", + srcs = ["main.ts"], + incremental = True, + ts_build_info_file = "dist/tsconfig.tsbuildinfo", + tsconfig = ":tsconfig", +) + +ts_config( + name = "tsconfig", + src = "tsconfig.json", +) diff --git a/gazelle/js/tests/tsconfig_tsbuildinfo/WORKSPACE b/gazelle/js/tests/tsconfig_tsbuildinfo/WORKSPACE new file mode 100644 index 00000000..87619221 --- /dev/null +++ b/gazelle/js/tests/tsconfig_tsbuildinfo/WORKSPACE @@ -0,0 +1,2 @@ +# This is a Bazel workspace for the Gazelle test data. +workspace(name = "tsconfig_tsbuildinfo") diff --git a/gazelle/js/tests/tsconfig_tsbuildinfo/main.ts b/gazelle/js/tests/tsconfig_tsbuildinfo/main.ts new file mode 100644 index 00000000..7b68cbff --- /dev/null +++ b/gazelle/js/tests/tsconfig_tsbuildinfo/main.ts @@ -0,0 +1 @@ +console.log('No Imports!'); diff --git a/gazelle/js/tests/tsconfig_tsbuildinfo/tsconfig.json b/gazelle/js/tests/tsconfig_tsbuildinfo/tsconfig.json new file mode 100644 index 00000000..a16aa5ea --- /dev/null +++ b/gazelle/js/tests/tsconfig_tsbuildinfo/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "incremental": true, + "tsBuildInfoFile": "dist/tsconfig.tsbuildinfo" + } +} diff --git a/gazelle/js/typescript/tsconfig.go b/gazelle/js/typescript/tsconfig.go index c618a862..9a96c997 100644 --- a/gazelle/js/typescript/tsconfig.go +++ b/gazelle/js/typescript/tsconfig.go @@ -33,6 +33,7 @@ type tsCompilerOptionsJSON struct { Declaration *bool `json:"declaration"` DeclarationMap *bool `json:"declarationMap"` Incremental *bool `json:"incremental"` + TsBuildInfoFile *string `json:"tsBuildInfoFile"` SourceMap *bool `json:"sourceMap"` ResolveJsonModule *bool `json:"resolveJsonModule"` OutDir *string `json:"outDir"` @@ -87,6 +88,7 @@ type TsConfig struct { Declaration *bool DeclarationMap *bool Incremental *bool + TsBuildInfoFile string SourceMap *bool OutDir string RootDir string @@ -249,6 +251,13 @@ func parseTsConfigJSON(parsed map[string]*TsConfig, resolver TsConfigResolver, r incremental = baseConfig.Incremental } + var tsBuildInfoFile string + if c.CompilerOptions.TsBuildInfoFile != nil { + tsBuildInfoFile = *c.CompilerOptions.TsBuildInfoFile + } else if baseConfig != nil { + tsBuildInfoFile = baseConfig.TsBuildInfoFile + } + var sourceMap *bool if c.CompilerOptions.SourceMap != nil { sourceMap = c.CompilerOptions.SourceMap @@ -332,6 +341,7 @@ func parseTsConfigJSON(parsed map[string]*TsConfig, resolver TsConfigResolver, r Declaration: declaration, DeclarationMap: declarationMap, Incremental: incremental, + TsBuildInfoFile: tsBuildInfoFile, SourceMap: sourceMap, ResolveJsonModule: resolveJsonModule, OutDir: OutDir,