Skip to content

Commit

Permalink
Set declarationDir equal to outDir
Browse files Browse the repository at this point in the history
Explicitly set/override the users declarationDir setting to
suppress *.d.ts files from being emitted in a non-predicatable
fashion.

Fixes bazel-contrib#32
Closes bazel-contrib#33

PiperOrigin-RevId: 168608369
  • Loading branch information
pcj authored and alexeagle committed Sep 13, 2017
1 parent 85f865b commit 34ffe8a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion third_party/github.com/bazelbuild/rules_typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ Then build it:
`bazel build //path/to/package:target`

The resulting `.d.ts` file paths will be printed. Additionally, the `.js`
outputs from TypeScript will be written to disk, next to the `.d.ts` files.
outputs from TypeScript will be written to disk, next to the `.d.ts` files <sup>1</sup>.

> <sup>1</sup> The
> [declarationDir](https://www.typescriptlang.org/docs/handbook/compiler-options.html)
> compiler option will be silently overwritten if present.
## Notes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def compile_ts(ctx,
# Do not produce declarations in ES6 mode, tsickle cannot produce correct
# .d.ts (or even errors) from the altered Closure-style JS emit.
tsconfig_es6["compilerOptions"]["declaration"] = False
tsconfig_es6["compilerOptions"].pop("declarationDir")
outputs = transpiled_closure_js + tsickle_externs
if perf_trace:
perf_trace_file = ctx.new_file(ctx.label.name + ".es6.trace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ def create_tsconfig(ctx, files, srcs,

"noEmitOnError": False,
"declaration": True,

# We don't support this compiler option (See github #32), so
# always emit declaration files in the same location as outDir.
"declarationDir": "/".join([workspace_path, outdir_path]),
"stripInternal": True,

# Embed source maps and sources in .js outputs
Expand Down

0 comments on commit 34ffe8a

Please sign in to comment.