dgeni-packages icon indicating copy to clipboard operation
dgeni-packages copied to clipboard

Unresolved TypeScript symbols

Open dpogue opened this issue 7 years ago • 0 comments

This is admittedly a particularly bizzarre example of TypeScript syntax, but it's our current workaround for some TypeScript limitations with subclassing ES6 built-ins.

// Our hacky helper function:
function safeSubclass<T>(klasstype : T) : T {
  // Bunch of stuff to use Reflect.construct, but essentially:
  return klasstype;
}

// Our subclass:
class MyPromise<T> extends safeSubclass(Promise)<T> { /* ... */ }

When running through dgeni, this results in an unresolved TypeScript symbol:

warn:    Unresolved TypeScript symbol(s): subclass(Promise)<T> - doc "src/helpers/MyPromise" (class)  - from file "src/helpers/promise.ts"

The syntax for the generic type on the promise is super weird, but is correct (and does work exactly as intended).

dpogue avatar Apr 18 '18 03:04 dpogue