From f3dcaae0f02d597a6f0918488fde203d08570686 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 3 Sep 2016 01:09:28 -0700 Subject: [PATCH] Added a test for branched returns at the end of a constructor. --- ...edClassConstructorWithExplicitReturns01.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/cases/compiler/derivedClassConstructorWithExplicitReturns01.ts diff --git a/tests/cases/compiler/derivedClassConstructorWithExplicitReturns01.ts b/tests/cases/compiler/derivedClassConstructorWithExplicitReturns01.ts new file mode 100644 index 0000000000..2475eac0bb --- /dev/null +++ b/tests/cases/compiler/derivedClassConstructorWithExplicitReturns01.ts @@ -0,0 +1,36 @@ +// @target: es5 +// @sourcemap: true + +class C { + cProp = 10; + + foo() { return "this never gets used."; } + + constructor(value: number) { + return { + cProp: value, + foo() { + return "well this looks kinda C-ish."; + } + } + } +} + +class D extends C { + dProp = () => this; + + constructor(a = 100) { + super(a); + + if (Math.random() < 0.5) { + "You win!" + return { + cProp: 1, + dProp: () => this, + foo() { return "You win!!!!!" } + }; + } + else + return null; + } +} \ No newline at end of file