Created
May 18, 2018 17:05
-
-
Save wwahammy/da70bcb62d44e3b7293c14397e0af317 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function a() : string |number | |
{ | |
return "" | |
} | |
function b(){ | |
let foo = a() | |
if( typeof foo === "number") | |
{ | |
console.log(foo.toFixed()) | |
} | |
if (typeof foo === "string") | |
{ | |
console.log(foo.toLowerCase()) | |
} | |
} |
class Character {
constructor(public name: string, public x: number, public y: number) { }
}
class Butts {
static doThing(isCoordinate: boolean): { x: number, y: number } | Character {
if (isCoordinate) return { x: 1, y: 1 };
return new Character('test', 1, 1);
}
}
const res = Butts.doThing(true);
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In fact, this also compiles fine