I have two classes, ./class1.ts
and ./class2.ts
, with the following structure:
export class Class1{ ... }
and
export class Class2{ ... }
In my file ./run.ts
, there is a function that accepts a class input
function doSomething(klass: ClassType){
let foo = new klass()
}
Within ./typings.d.ts
, I have defined:
type ClassType = Class1 | Class2
An error pops up in typings.d.ts
stating that Class1
and Class2
cannot be located.
Adding
/// <reference path="./class1.ts" />
Eliminates the errors but doesn't fix the issue.
Introducing
import {Class1} from './class1.ts'
Resolves the problem within ./typings.d.ts
but renders all typings unusable in the project.
How can I utilize exported classes as types in my project?