What you're trying to do is not only extremely complicated in better-suited languages but I doubt it's even possible in Typescript...
A better solution is to plan the whole thing differently (better) and go with inheritance.
your Paul class probably inherits from the Person interface just the same as your Sue class so you instantiate with the parent interface
let me rephrase that... you could instantiate with a
let test: Person
switch(name) {
case 'Paul':
test = new Paul()
}
which would serve your purpose.. My guess is you're trying to do that cause you wanna later do something like
let people: any[] = //...
for(let person of people) {
}
but you should instead do
let people: Person[] = //...
for(let person of people) {
}
and any class that implements the Person interface would be able to fit your people array
But again, if you really need a shit ton of classes all with different names, then it begs the question, do you really need separate classes?
UPDATE:
I saw your comment about
WALL, 'Adrien' HOUSE, 'Pierre'
In that case you'd use a switch
let houses: House[] = []
let walls: Wall[] = []
...
switch(key) {
case 'WALL':
walls.push(new Wall(value))
case 'HOUSE':
houses.push(new House(value))
...
}
windowis the global object in browser side JavaScript. It's not clear what you're trying to do at the moment as in, why would you try to use a string to create a class?