Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createImageBitmap() imageOrientation option type incorrect in 5.0.0-beta #53053

Closed
frank-weindel opened this issue Mar 1, 2023 · 3 comments
Closed
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@frank-weindel
Copy link

frank-weindel commented Mar 1, 2023

lib Update Request

Configuration Check

My compilation target is ES2022 and my lib is the default.

Missing / Incorrect Definition

In 5.0.0-beta the DOM provided createImageBitmap (MDN linked) function is not allowing the string "none" to be set on the imageOrientation option property.

It should be allowing the strings "flipY" | "none" according to MDN (and does work in previous TS versions) but in 5.0.0-beta the only strings allowed are: "flipY" | "from-image".

"from-image" seems to be coming from a related but separate CSS property called image-orientation.

node_modules/typescript/lib/lib.dom.d.ts:

// ...
interface ImageBitmapOptions {
    colorSpaceConversion?: ColorSpaceConversion;
    imageOrientation?: ImageOrientation;
    premultiplyAlpha?: PremultiplyAlpha;
    resizeHeight?: number;
    resizeQuality?: ResizeQuality;
    resizeWidth?: number;
}
// ...
declare function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>;
declare function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>;
// ...
type ImageOrientation = "flipY" | "from-image";
// ...

Sample Code

Sample:

createImageBitmap({} as ImageBitmap, {
    imageOrientation: 'none'
 // ^^^^^^^^^^^^^^^^ Type '"none"' is not assignable to type 'ImageOrientation | undefined'.(2322)
});

Playground Link

Documentation Link

https://developer.mozilla.org/en-US/docs/Web/API/createImageBitmap

@frank-weindel
Copy link
Author

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Mar 2, 2023
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 2, 2023
@Josh-Cena
Copy link
Contributor

Josh-Cena commented Jun 1, 2023

For posterity, there is a change to the createImageBitmap API that MDN is not catching up with (and even seems to be unfinished within the standard group). See mdn/content#23564, mdn/content#24857. microsoft/TypeScript-DOM-lib-generator#1507 also has some more information.

@jakebailey
Copy link
Member

This was fixed in #53652.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

4 participants