'String extends Function?

I ran into a typing problem after upgrading a library. This is the distilled form of the bug:

class Bar {
  id: string = '';
}

declare type ExcludeFunctions<T, K extends keyof T> = T[K] extends Function ? never : (K extends symbol ? never : K);


declare type Baz<T> = {
  [K in keyof T as ExcludeFunctions<T, K>]?: T[K];
};


class Base<T extends Bar> {

  public async foo(input: Baz<T>) {
   //Property 'id' does not exist on type 'Baz<T>'.
    input.id = 'x';
  }
}

Why doesn't Baz have property 'id'? It looks like "string extends Function" evaluates to true, because when I remove this condition the error disappears. But string clearly doesn't extend Function. What is going on here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source