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

HTMLImageElement#crossOrigin should use literal union type from allowable values #39829

Open
thw0rted opened this issue Jul 30, 2020 · 2 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript
Milestone

Comments

@thw0rted
Copy link

TypeScript Version: Nightly 2020-07-29

Search Terms: htmlimageelement crossorigin

Code

const i = new Image(10, 10);
// @ts-expect-error
i.crossOrigin = "abc"; // Must be "anonymous" or "use-credentials"

Expected behavior:

Type should be defined with string literals, per this MDN page

Actual behavior:

Property is typed as string | null.


Playground Link

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Aug 20, 2020
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Aug 20, 2020
@RemyMachado
Copy link

RemyMachado commented Aug 11, 2022

TS2322: Type 'string | undefined' is not assignable to type '"" | "anonymous" | "use-credentials" | undefined'.

Currently redefining type for the crossOrigin property on my react App, to avoid this error.

interface Props extends HTMLProps<HTMLImageElement> {
  crossOrigin?: '' | 'anonymous' | 'use-credentials' | undefined
}

@DvzH
Copy link

DvzH commented Dec 18, 2023

Actually this is creating an issue with all the UI libraries such as Material UI, bootstrap etc. It's throws an error saying that the crossOrigin is a required prop even though it was defined as optional in all these above UI lib's. So because of that it requires user to pass crossOrigin as a prop on Input field, Radio and CheckBox etc

ref: creativetimofficial/material-tailwind#427

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
Projects
None yet
Development

No branches or pull requests

4 participants