mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Added test for string types in tuples.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user