gpuweb / types

TypeScript type definitions for WebGPU https://gpuweb.github.io/types/
https://www.npmjs.com/package/@webgpu/types
BSD 3-Clause "New" or "Revised" License
181 stars 38 forks source link

"new GPUInternalError(...)" should return type GPUInternalError #108

Closed mattsoulanille closed 1 year ago

mattsoulanille commented 1 year ago

GPUInternalError's new function / constructor is defined without a return type, so it defaults to any. Should this return type be the GPUInternalError interface instead?

interface GPUInternalError
  extends GPUError {
  /**
   * Nominal type branding.
   * https://github.com/microsoft/TypeScript/pull/33038
   * @internal
   */
  readonly __brand: "GPUInternalError";
}

declare var GPUInternalError: {
  prototype: GPUInternalError;
  new (
    message: string
  );
};

Proposed change:

...
declare var GPUInternalError: {
  prototype: GPUInternalError;
  new (
    message: string
  ): GPUInternalError; // <--- This right here.
};

I'd send a PR, but if I understand correctly, this file is generated.

kainino0x commented 1 year ago

Thanks for the report!

There's an upstream bug here: https://github.com/darionco/bikeshed-to-ts/issues/11

But we can also maintain this as a manual diff in the types. They're partially generated, but not fully. I think we already have this manual edit for several other constructors. I can go ahead and add it.

kainino0x commented 1 year ago

published 0.1.23