Added test for string types in tuples.

This commit is contained in:
Daniel Rosenwasser
2015-10-01 16:58:03 -07:00
parent 8891fba149
commit 82545ce854

View File

@@ -0,0 +1,20 @@
// @declaration: true
// Should all be strings.
let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"];
type RexOrRaptor = "t-rex" | "raptor"
let [im, a, dinosaur]: ["I'm", "a", Dinosaur] = ['I\'m', 'a', 't-rex'];
rawr(dinosaur);
function rawr(dino: RexOrRaptor) {
if (dino === "t-rex") {
return "ROAAAAR!";
}
if (dino === "raptor") {
return "yip yip!";
}
throw "Unexpected " + dino;
}