typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

Error with deriving implicit type from initializer

Open jkieboom opened this issue 7 months ago • 0 comments

In the following example, I get the error "implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer" with the native preview, whereas in regular typescript this type checks:

class ReactiveMap<K, V> {
  private readonly _map;

  constructor(entries?: readonly (readonly [K, V])[] | null) {
    this._map = new Map(entries);
  }

  clear(): void {
    this._map.clear();
  }
}

with regular ts, type is correctly inferred:

Image

I also tried with a local build from fix-921 branch for (#921) since the error looks the same, but it still produces the error also with that branch build.

jkieboom avatar May 26 '25 20:05 jkieboom