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

Update example usage docs to add allowDownload #570

Open
aslanalyiev opened this issue Jul 21, 2023 · 2 comments
Open

Update example usage docs to add allowDownload #570

aslanalyiev opened this issue Jul 21, 2023 · 2 comments

Comments

@aslanalyiev
Copy link

aslanalyiev commented Jul 21, 2023

image

Expected Behavior

image

Current Behavior

No overload matches this call.
  Overload 1 of 2, '(options: OptionsObject<GrowlerTypesValues.INFO> & { message?: SnackbarMessage; }): SnackbarKey', gave the following error.
    Argument of type '{ variant: GrowlerTypesValues.INFO; message: string; actionText: string; }' is not assignable to parameter of type 'OptionsObject<GrowlerTypesValues.INFO> & { message?: SnackbarMessage; }'.
      Object literal may only specify known properties, and 'actionText' does not exist in type 'OptionsObject<GrowlerTypesValues.INFO> & { message?: SnackbarMessage; }'.
  Overload 2 of 2, '(message: SnackbarMessage, options?: OptionsObject<"default" | "error" | "success" | "warning" | "info"> | undefined): SnackbarKey', gave the following error.
    Argument of type '{ variant: GrowlerTypesValues; message: string; actionText: string; }' is not assignable to parameter of type 'SnackbarMessage'.
      Object literal may only specify known properties, and 'variant' does not exist in type 'ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal'.

Steps to Reproduce

  1. Copy-past best practice from off doc - https://notistack.com/features/customization#best-practices
  2. Turn on TS.
  3. Get Error

Your Environment

{
  "compilerOptions": {
    "baseUrl": "src",
    "target": "ES2021",
    "downlevelIteration": true,
    "lib": ["dom", "dom.iterable", "esnext", "webworker"],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "types": ["node", "vitest/globals"],
    "noFallthroughCasesInSwitch": true,
    "forceConsistentCasingInFileNames": true,
    "sourceMap": true,
    "useDefineForClassFields": true,
  },
  "include": ["src", "./types", "./setupTests.ts"],
  "exclude": ["dist"]
}
Tech Version
Notistack v3.0.1
React v.18.2.0
Browser doesn't matter
TS 5.0.4
etc.
@iamhosseindhv
Copy link
Owner

Hi @aslanalyiev - Have your followed this section of the docs? https://notistack.com/features/customization#custom-variant-(typescript)

Link above explains how to define your custom component's props (which a believe actionText is one of).

Also please provide a codesandbox minimal reproduction so I can help further.

@jeffreypeoples
Copy link

jeffreypeoples commented Jul 27, 2023

I ran into the same confusion.
The official example on codesandbox:
https://codesandbox.io/s/github/iamhosseindhv/notistack/tree/master/examples/custom-snackbar-example-2
it is missing the allowDownload property in its declare module.
It actually reproduces the problem aslan was referring to.

@iamhosseindhv iamhosseindhv changed the title Very poor typescript Update example usage docs to add allowDownload Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants