Skip to content

Commit 4473aff

Browse files
committed
Add flags argument and switch to amd modules by default.
See microsoft/TypeScript#1544 for more information on why --out was unacceptable with modules.
1 parent f85bf7b commit 4473aff

File tree

5 files changed

+49
-1
lines changed

5 files changed

+49
-1
lines changed

examples/walkthrough/flags/BUILD

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load("//typescript:def.bzl", "ts_binary", "ts_library")
2+
3+
ts_library(
4+
name = "lib",
5+
srcs = [
6+
"animal.ts",
7+
"main.ts",
8+
]
9+
)
10+
11+
ts_binary(
12+
name = "flags",
13+
flags = [
14+
"--noImplicitAny",
15+
],
16+
deps = [
17+
":lib",
18+
]
19+
)

examples/walkthrough/flags/animal.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Sample inheritance in typescript.
2+
export default class {
3+
constructor(public name: string) { }
4+
5+
sound(sound: string) {
6+
return this.name + " goes " + sound;
7+
}
8+
}

examples/walkthrough/flags/main.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Sample inheritance in typescript.
2+
import Animal from './animal'
3+
4+
module Rescue {
5+
export class Dog extends Animal {
6+
constructor(name: string) {
7+
super(name);
8+
}
9+
10+
sound() {
11+
return "My dog " + super.sound("bark!");
12+
}
13+
}
14+
}
15+
16+
let c = new Rescue.Dog("Colby");
17+
c.sound();

typescript/def.bzl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ def ts_binary_impl(ctx):
2020
inputs=files,
2121
outputs=[output],
2222
executable=ctx.executable.tsc_,
23+
env={
24+
"FLAGS": ' '.join(ctx.attr.flags),
25+
},
2326
arguments=["%s" % (output.path)] + \
2427
["%s" % x.path for x in files])
2528

@@ -40,6 +43,7 @@ ts_binary = rule(
4043
executable=True),
4144
"deps": attr.label_list(allow_files=True),
4245
"srcs": attr.label_list(allow_files=ts_filetype),
46+
"flags": attr.string_list(),
4347
},
4448
outputs = {
4549
"out": "%{name}.js"

typescript/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ for var in "$@"; do
2121
args+=("$(pwd)/${var}")
2222
done
2323

24-
$NAR exec "--out ${args[*]}"
24+
$NAR exec "--module amd ${FLAGS} --outFile ${args[*]}"
2525
touch .tsc_unlock

0 commit comments

Comments
 (0)