Answer the question
In order to leave comments, you need to log in
Typescript, block cast type to variable, how?
Hello, I'm picking typescript and one question doesn't even google: let's say this code:
on(types: string|string[]|Object, fn: Function, context?: Object): Emitter {
// types can be a view of types/handlers
if (typeof types == 'object') {
for (let type in <Object>types) {
// we don't process space-separated events here for performance;
// it's a hot path since Layer uses the on(obj) syntax
this._on(type, types[type], fn);
}
}
// ...
}
let t = <Object>types;
Answer the question
In order to leave comments, you need to log in
So you can’t do anything here, because types can be of 3 types and each time you have to cast.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question