question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] TS2322: Type 'string | { "image/*": string[]; }' is not assignable to type 'Accept'

See original GitHub issue

Describe 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:

  1. Go to ‘…’
  2. Click on ‘…’
  3. Select file ‘…’
  4. 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:open
  • Created a year ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

2reactions
ru88scommented, Oct 6, 2022

“react-dropzone”: “^14.2.2”, same bug.

I think there is something wrong here.

export interface Accept {
  [key: string]: string[];
}
1reaction
Muhindo-Galiencommented, Dec 18, 2022

use the code bellow instead accept: { ‘image/png’: [‘.png’], ‘image/jpg’: [‘.jpg’], ‘image/jpeg’: [‘.jpeg’], ‘text/html’: [‘.html’, ‘.htm’], },

@khteh

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found