angular / dgeni-packages

A collection of dgeni packages for generating documentation from source code.
MIT License
142 stars 106 forks source link

Unresolved TypeScript symbols #265

Open dpogue opened 6 years ago

dpogue commented 6 years ago

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).