diff --git a/examples/declaration_only/BUILD.bazel b/examples/declaration_only/BUILD.bazel deleted file mode 100644 index 37093f12..00000000 --- a/examples/declaration_only/BUILD.bazel +++ /dev/null @@ -1,15 +0,0 @@ -load("@aspect_rules_ts//ts:defs.bzl", "ts_project") -load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") - -ts_project( - name = "declaration_only", - declaration = True, - emit_declaration_only = True, -) - -write_source_files( - name = "write_dts", - files = { - "a.d.ts_": ":declaration_only", - }, -) \ No newline at end of file diff --git a/examples/declaration_only/a.d.ts_ b/examples/declaration_only/a.d.ts_ deleted file mode 100644 index 106d610a..00000000 --- a/examples/declaration_only/a.d.ts_ +++ /dev/null @@ -1 +0,0 @@ -export declare const a: string; diff --git a/examples/declaration_only/a.ts b/examples/declaration_only/a.ts deleted file mode 100644 index cbc6bb2c..00000000 --- a/examples/declaration_only/a.ts +++ /dev/null @@ -1 +0,0 @@ -export const a: string = ''; \ No newline at end of file diff --git a/examples/emit_declaration_only/BUILD.bazel b/examples/emit_declaration_only/BUILD.bazel new file mode 100644 index 00000000..dee5f508 --- /dev/null +++ b/examples/emit_declaration_only/BUILD.bazel @@ -0,0 +1,22 @@ +"""Show usage of https://www.typescriptlang.org/tsconfig/#emitDeclarationOnly + +This can be useful to type-check code as part of a `bazel build` even though `tsc` doesn't +transpile to JavaScript, such as when TypeScript can be natively understood by the runtime. + +Note, to use an alternative transpiler, see the `transpiler` attribute instead. +""" + +load("@aspect_bazel_lib//lib:testing.bzl", "assert_contains") +load("@aspect_rules_ts//ts:defs.bzl", "ts_project") + +ts_project( + name = "declaration_only", + declaration = True, + emit_declaration_only = True, +) + +assert_contains( + name = "test", + actual = "a.d.ts", + expected = "export declare const a", +) diff --git a/examples/emit_declaration_only/a.ts b/examples/emit_declaration_only/a.ts new file mode 100644 index 00000000..b1b17974 --- /dev/null +++ b/examples/emit_declaration_only/a.ts @@ -0,0 +1 @@ +export const a: string = '' diff --git a/examples/declaration_only/tsconfig.json b/examples/emit_declaration_only/tsconfig.json similarity index 62% rename from examples/declaration_only/tsconfig.json rename to examples/emit_declaration_only/tsconfig.json index 9c806350..c2ff7cec 100644 --- a/examples/declaration_only/tsconfig.json +++ b/examples/emit_declaration_only/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { "declaration": true, - "emitDeclarationOnly": true, + "emitDeclarationOnly": true } -} \ No newline at end of file +}