Skip to content

Commit

Permalink
Add flags argument and switch to amd modules by default.
Browse files Browse the repository at this point in the history
See microsoft/TypeScript#1544 for more
information on why --out was unacceptable with modules.
  • Loading branch information
achew22 committed May 8, 2016
1 parent f85bf7b commit 4473aff
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
19 changes: 19 additions & 0 deletions examples/walkthrough/flags/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
load("//typescript:def.bzl", "ts_binary", "ts_library")

ts_library(
name = "lib",
srcs = [
"animal.ts",
"main.ts",
]
)

ts_binary(
name = "flags",
flags = [
"--noImplicitAny",
],
deps = [
":lib",
]
)
8 changes: 8 additions & 0 deletions examples/walkthrough/flags/animal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Sample inheritance in typescript.
export default class {
constructor(public name: string) { }

sound(sound: string) {
return this.name + " goes " + sound;
}
}
17 changes: 17 additions & 0 deletions examples/walkthrough/flags/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Sample inheritance in typescript.
import Animal from './animal'

module Rescue {
export class Dog extends Animal {
constructor(name: string) {
super(name);
}

sound() {
return "My dog " + super.sound("bark!");
}
}
}

let c = new Rescue.Dog("Colby");
c.sound();
4 changes: 4 additions & 0 deletions typescript/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def ts_binary_impl(ctx):
inputs=files,
outputs=[output],
executable=ctx.executable.tsc_,
env={
"FLAGS": ' '.join(ctx.attr.flags),
},
arguments=["%s" % (output.path)] + \
["%s" % x.path for x in files])

Expand All @@ -40,6 +43,7 @@ ts_binary = rule(
executable=True),
"deps": attr.label_list(allow_files=True),
"srcs": attr.label_list(allow_files=ts_filetype),
"flags": attr.string_list(),
},
outputs = {
"out": "%{name}.js"
Expand Down
2 changes: 1 addition & 1 deletion typescript/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ for var in "$@"; do
args+=("$(pwd)/${var}")
done

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

0 comments on commit 4473aff

Please sign in to comment.