From cefd1e4251f3603c4c90ca4dcfaca9d8552001e9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 25 Sep 2019 09:34:24 -0700 Subject: [PATCH] Add regression test --- .../controlFlow/neverReturningFunctions1.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/tests/cases/conformance/controlFlow/neverReturningFunctions1.ts b/tests/cases/conformance/controlFlow/neverReturningFunctions1.ts index 63e7ecf786f..72dd0a13b5a 100644 --- a/tests/cases/conformance/controlFlow/neverReturningFunctions1.ts +++ b/tests/cases/conformance/controlFlow/neverReturningFunctions1.ts @@ -156,3 +156,72 @@ function f42(x: number) { } x; // Unreachable } + +// Repro from #33582 + +export interface Component { + attrName?: string; + data: T; + dependencies?: string[]; + el: any; + id: string; + multiple?: boolean; + name: string; + schema: unknown; + system: any; + + init(data?: T): void; + pause(): void; + play(): void; + remove(): void; + tick?(time: number, timeDelta: number): void; + update(oldData: T): void; + updateSchema?(): void; + + extendSchema(update: unknown): void; + flushToDOM(): void; +} + +export interface ComponentConstructor { + new (el: unknown, attrValue: string, id: string): T & Component; + prototype: T & { + name: string; + system: unknown; + play(): void; + pause(): void; + }; +} + +declare function registerComponent( + name: string, + component: ComponentDefinition +): ComponentConstructor; + +export type ComponentDefinition = T & Partial & ThisType; + +const Component = registerComponent('test-component', { + schema: { + myProperty: { + default: [], + parse() { + return [true]; + } + }, + string: { type: 'string' }, + num: 0 + }, + init() { + this.data.num = 0; + this.el.setAttribute('custom-attribute', 'custom-value'); + }, + update() {}, + tick() {}, + remove() {}, + pause() {}, + play() {}, + + multiply(f: number) { + // Reference to system because both were registered with the same name. + return f * this.data.num * this.system!.data.counter; + } +});