Re-implemented workaround for bug in Typescript compiler