[BUG] TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'
See original GitHub issueDescribe the bug A clear and concise description of what the bug is. “react-dropzone”: “^14.2.2”
const { getRootProps, getInputProps, isDragActive } = useDropzone({
accept: {
"image/*": [".jpeg", ".png", ".jpg"],
},
Error:
MediaField.tsx:266:5 - error TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'.
Type 'string' is not assignable to type 'Accept'.
266 accept: {
~~~~~~
node_modules/react-dropzone/typings/react-dropzone.d.ts:31:3
31 accept?: Accept;
~~~~~~
The expected type comes from property 'accept' which is declared here on type 'DropzoneOptions'
What do I miss? To Reproduce
Steps to reproduce the behavior:
- Go to ‘…’
- Click on ‘…’
- Select file ‘…’
- See error
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: [Ubuntu 22.04]
- Browser [chrome]
- Version [e.g. 22]
Smartphone (please complete the following information):
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
Additional context Add any other context about the problem here.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:8
Top Results From Across the Web
react-dropzone error TS2322: Type 'string | { "image/*"
MediaField.tsx:266:5 - error TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'. Type 'string' is not ...
Read more >Type 'string' is not assignable to type in TypeScript
The "Type 'string' is not assignable to type" TypeScript error occurs when we try to assign a value of type string to something...
Read more >ts2322: type 'string' is not assignable to type 'never'.
This is clearly impossible. In order to resolve this problem, change() should be a generic function, which would allow you to constrain the...
Read more >Useful Patterns by Use Case - React TypeScript Cheatsheets
string ; } export function Button(props: ButtonProps) { ... items={["a", "b"]} // Error: Type 'string' is not assignable to type 'number'.
Read more >Typescript `never` type - Explain Programming
The error which got me to learn more about never : Here Typescript says. Argument of type 'string[]' is not assignable to parameter...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
“react-dropzone”: “^14.2.2”, same bug.
I think there is something wrong here.
use the code bellow instead accept: { ‘image/png’: [‘.png’], ‘image/jpg’: [‘.jpg’], ‘image/jpeg’: [‘.jpeg’], ‘text/html’: [‘.html’, ‘.htm’], },
@khteh