-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
196 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
docs/*.md | ||
examples/pnpm-lock.yaml | ||
**/expected.js | ||
**/expected.cjs | ||
**/expected.* | ||
**/expected_tsc |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files") | ||
load("@aspect_rules_swc//swc:defs.bzl", "swc") | ||
load("@bazel_skylib//rules:build_test.bzl", "build_test") | ||
|
||
# No root/out | ||
swc( | ||
name = "emit_dts", | ||
srcs = [ | ||
"src/a.ts", | ||
"src/b.ts", | ||
], | ||
emit_isolated_dts = True, | ||
) | ||
|
||
build_test( | ||
name = "emit_dts-test", | ||
targets = [ | ||
"src/a.js", | ||
"src/a.d.ts", | ||
"src/b.js", | ||
"src/b.d.ts", | ||
], | ||
) | ||
|
||
# With out_dir | ||
swc( | ||
name = "emit_dts_outdir", | ||
srcs = [ | ||
"src/a.ts", | ||
"src/b.ts", | ||
], | ||
emit_isolated_dts = True, | ||
out_dir = "out", | ||
) | ||
|
||
build_test( | ||
name = "emit_dts_outdir-test", | ||
targets = [ | ||
"out/src/a.js", | ||
"out/src/a.d.ts", | ||
"out/src/b.js", | ||
"out/src/b.d.ts", | ||
], | ||
) | ||
|
||
# With root_dir | ||
swc( | ||
name = "emit_dts_rootdir", | ||
srcs = [ | ||
"src/a.ts", | ||
"src/b.ts", | ||
], | ||
emit_isolated_dts = True, | ||
root_dir = "src", | ||
) | ||
|
||
build_test( | ||
name = "emit_dts_rootdir-test", | ||
targets = [ | ||
"a.js", | ||
"a.d.ts", | ||
"b.js", | ||
"b.d.ts", | ||
], | ||
) | ||
|
||
# With out_dir and root_dir | ||
swc( | ||
name = "emit_dts_outdir_rootdir", | ||
srcs = [ | ||
"src/a.ts", | ||
"src/b.ts", | ||
], | ||
emit_isolated_dts = True, | ||
out_dir = "out_root", | ||
root_dir = "src", | ||
) | ||
|
||
build_test( | ||
name = "emit_dts_outdir_rootdir-test", | ||
targets = [ | ||
"out_root/a.js", | ||
"out_root/a.d.ts", | ||
"out_root/b.js", | ||
"out_root/b.d.ts", | ||
], | ||
) | ||
|
||
# Assert the output files are correct, have not changed etc. | ||
write_source_files( | ||
name = "outputs_test", | ||
files = { | ||
"expected.a.d.ts": "src/a.d.ts", | ||
"expected.b.d.ts": "src/b.d.ts", | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* A basic interface */ export interface Foo { | ||
// teh name! | ||
name: string; | ||
} | ||
// Implicit type | ||
export declare const A: number; | ||
// Explicit type | ||
export declare const AF: Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Imported and used as types | ||
import { A, Foo } from "./a"; | ||
// Use of imported types | ||
export declare const B: typeof A; | ||
/** Another use of imported types */ export declare const BF: Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* A basic interface */ | ||
export interface Foo { | ||
// teh name! | ||
name: string; | ||
} | ||
|
||
// Implicit type | ||
export const A = 1; | ||
|
||
// Explicit type | ||
export const AF: Foo = { | ||
name: "bar", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Imported and used as types | ||
import { A, Foo } from "./a"; | ||
|
||
// Use of imported types | ||
export const B: typeof A = 1; | ||
|
||
/** Another use of imported types */ | ||
export const BF: Foo = { | ||
name: "baz", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters