tsdjs / tsd

Check TypeScript type definitions
MIT License
2.4k stars 67 forks source link

Add `ts2719` to known errors #220

Closed mcollina closed 1 month ago

mcollina commented 1 month ago

I had found something like:

interface T { }
declare const a: T;
expectError(class Foo<T> {
  x: T;
  constructor(a: T) {
    this.x = a;
  }
  fn() {
    this.x = a;
  }
})

Would generate:

  index.test-d.ts:11:4
  ✖   5:0  Found an error that tsd does not currently support (ts2719), consider creating an issue on GitHub.                                                                       
  ✖  11:4  Type T is not assignable to type T. Two different types with this name exist, but they are unrelated.
  T could be instantiated with an arbitrary type which could be unrelated to T.

  2 errors

Originally found at https://github.com/fastify/fastify/actions/runs/10696978690/job/29653469150?pr=5660#step:5:12 as

 test/types/instance.test-d.ts:374:2
  ✖  373:0  Found an error that tsd does not currently support (ts2719), consider creating an issue on GitHub.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  ✖  374:2  Type (this: import("/home/runner/work/fastify/fastify/types/instance").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, { new (req: import("http").IncomingMessage): import("http").ServerResponse<import("http").IncomingMessage>; prototype: import("http").ServerResponse<any>; ... 29 more ...; Ev... is not assignable to type (this: import("/home/runner/work/fastify/fastify/types/instance").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, { new (req: import("http").IncomingMessage): import("http").ServerResponse<import("http").IncomingMessage>; prototype: import("http").ServerResponse<any>; ... 29 more ...; Ev.... Two different types with this name exist, but they are unrelated.
  Type boolean is not assignable to type string.  
  ✖  421:0  Found an error that tsd does not currently support (ts2719), consider creating an issue on GitHub.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  ✖  422:2  Type (this: import("/home/runner/work/fastify/fastify/types/instance").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, { new (req: import("http").IncomingMessage): import("http").ServerResponse<import("http").IncomingMessage>; prototype: import("http").ServerResponse<any>; ... 29 more ...; Ev... is not assignable to type (this: import("/home/runner/work/fastify/fastify/types/instance").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, { new (req: import("http").IncomingMessage): import("http").ServerResponse<import("http").IncomingMessage>; prototype: import("http").ServerResponse<any>; ... 29 more ...; Ev.... Two different types with this name exist, but they are unrelated.
  Type string is not assignable to type boolean.  

This adds it to the diagnostics codes.

sindresorhus commented 1 month ago

https://github.com/tsdjs/tsd/releases/tag/v0.31.2