Skip to content

Commit

Permalink
chore: reproduce issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Jan 27, 2024
1 parent afef302 commit 6462f01
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 3 deletions.
10 changes: 9 additions & 1 deletion examples/resolve_json_module/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@

load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains")
load("@aspect_rules_js//js:defs.bzl", "js_test")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config", "ts_project")

ts_config(
name = "tsconfig",
src = "tsconfig.json",
visibility = ["//:__subpackages__"],
)

ts_project(
name = "ts",
srcs = [
"data.json",
"index.ts",
],
declaration = True,
resolve_json_module = True,
visibility = ["//examples/resolve_json_module:__subpackages__"],
)

assert_contains(
Expand Down
15 changes: 15 additions & 0 deletions examples/resolve_json_module/bar/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")

ts_project(
name = "bar",
srcs = [
"bar.ts",
],
args = ["--listFiles"],
declaration = True,
resolve_json_module = True,
tsconfig = "//examples/resolve_json_module:tsconfig",
deps = [
"//examples/resolve_json_module:ts",
],
)
3 changes: 3 additions & 0 deletions examples/resolve_json_module/bar/bar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import type { Data } from '../index'

const data: Data = [{ a: 'b' }]
1 change: 1 addition & 0 deletions examples/resolve_json_module/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import data from './data.json'
export const a: string = 'hello' + JSON.stringify(data)
export type Data = typeof data
3 changes: 2 additions & 1 deletion examples/resolve_json_module/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"esModuleInterop": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"declaration": true
}
}
2 changes: 1 addition & 1 deletion ts/private/ts_validate_options.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def _validate_options_impl(ctx):
for d in ctx.attr.deps:
if not d[JsInfo].declarations:
fail("""\
ts_project '{1}' dependency '{0}' does does not contain any declarations (.d.ts or other type-check files).
ts_project '{1}' dependency '{0}' does not contain any declarations (.d.ts or other type-check files).
Generally, targets which produce no declarations aren't useful as dependencies to the TypeScript type-checker.
This likely means you forgot to set 'declaration = true' in the compilerOptions for that target.
Expand Down

0 comments on commit 6462f01

Please sign in to comment.