Skip to content
New issue

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

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

Already on GitHub? # to your account

[bug]: ESLint no-unused-vars Error for actionTypes in use-toast.ts with Next.js Build #6708

Open
2 tasks done
dlgnswk opened this issue Feb 21, 2025 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@dlgnswk
Copy link

dlgnswk commented Feb 21, 2025

Describe the bug

I’m encountering an ESLint error (@typescript-eslint/no-unused-vars) related to actionTypes in use-toast.ts when using shadcn/ui in a Next.js project.
This error appears when I run npm run lint.

This error can be resolved by making the following changes.

Before (Current Code):

// use-toast.ts
const actionTypes = {
  ADD_TOAST: "ADD_TOAST",
  UPDATE_TOAST: "UPDATE_TOAST",
  DISMISS_TOAST: "DISMISS_TOAST",
  REMOVE_TOAST: "REMOVE_TOAST",
} as const;

type ActionType = typeof actionTypes;

After (Fixed Code):

// use-toast.ts
type ActionType = {
  ADD_TOAST: "ADD_TOAST";
  UPDATE_TOAST: "UPDATE_TOAST";
  DISMISS_TOAST: "DISMISS_TOAST";
  REMOVE_TOAST: "REMOVE_TOAST";
};

Affected component/components

useToast / use-toast.ts

How to reproduce

  1. Create a new Next.js project (e.g., using npx create-next-app@latest)
  2. Install shadcn/ui by running npx shadcn@latest init (or the command recommended in the docs)
  3. Add the toast component via npx shadcn@latest add toast
  4. Run npm run lint
  5. Observe the ESLint error (@typescript-eslint/no-unused-vars) regarding actionTypes
Error: 'actionTypes' is assigned a value but only used as a type.  @typescript-eslint/no-unused-vars

Codesandbox/StackBlitz link

No response

Logs

Npm run lint

> map-editor@0.1.0 lint
> next lint

./src/shared/hooks/use-toast.ts
18:7  Error: 'actionTypes' is assigned a value but only used as a type.  @typescript-eslint/no-unused-vars

System Info

- next.js : 15.1.7
- radix-ui/react-toast : 1.2.6
- eslint/eslintrc : 3
- eslint : 9
- eslint-config-next : 15.1.7
- eslintConfig : {
    "extends": [
      "plugin:storybook/recommended"
    ]
  }

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@dlgnswk dlgnswk added the bug Something isn't working label Feb 21, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant