Answer the question
In order to leave comments, you need to log in
Typescript and ternary statement in export?
The situation is this: I check for the presence of a native Set , and if it exists, then the module returns it, if not, then the polyfill. Looks like this:
let Set = (<any>window).Set;
if (!Set || Set.toString().indexOf('[native code]') == -1) {
Set = class Set<T> {
// ...
};
}
export = Set;
import Set = require('./Set');
let s: Set<Node> = new Set<Node>();
class Set<T> {
// ...
};
let NativeSet = (<any>window).Set;
export = NativeSet && NativeSet.toString().indexOf('[native code]') != -1 ? NativeSet : Set;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question