t3-oss / create-t3-app

The best way to start a full-stack, typesafe Next.js app
https://create.t3.gg
MIT License
25.42k stars 1.16k forks source link

bug: Fresh nextauth.ts with 2 errors (lint? ts?) next-auth has no exported member 'type' and ',' expected.ts #993

Closed am1ru1 closed 1 year ago

am1ru1 commented 1 year ago

Provide environment information

Binaries: Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.0/bin/yarn npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm

Describe the bug

Getting from VS, from fresh create-t3 (with Jest):

Module '"next-auth"' has no exported member 'type'. Did you mean to use 'import type from "next-auth"' instead?ts(2614) and ',' expected.ts(1005)

image

To reproduce

Fresh project and under file: \src\pages\api\auth[...nextauth].ts

Additional information

No response

juliusmarminge commented 1 year ago

Works on my end.

Can you confirm which version you're at? NextAuth.js has sometimes change their types in the past although I've never seen this particular typerror before...

CleanShot 2022-12-20 at 09 26 05@2x
am1ru1 commented 1 year ago

@juliusmarminge I have decided to remove NextAuth. But noticed NextPage, NextApiRequest, NextApiResponse seems to be having similar issue. Not sure how else to debug

2 Issues: Module '"next"' has no exported member 'type'. Did you mean to use 'import type from "next"' instead?

image image

',' expected.ts(1005)

image

Versions:

  "dependencies": {
    "@prisma/client": "^4.5.0",
    "@tanstack/react-query": "^4.16.0",
    "@trpc/client": "^10.0.0",
    "@trpc/next": "^10.0.0",
    "@trpc/react-query": "^10.0.0",
    "@trpc/server": "^10.0.0",
    "next": "13.0.2",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "superjson": "1.9.1",
    "zod": "^3.18.0"
  },

    "devDependencies": {
    "@playwright/test": "^1.29.0",
    "@types/node": "^18.0.0",
    "@types/react": "^18.0.14",
    "@types/react-dom": "^18.0.5",
    "@typescript-eslint/eslint-plugin": "^5.33.0",
    "@typescript-eslint/parser": "^5.33.0",
    "autoprefixer": "^10.4.7",
    "eslint": "^8.26.0",
    "eslint-config-next": "13.0.2",
    "jest": "^29.3.1",
    "postcss": "^8.4.14",
    "prettier": "^2.7.1",
    "prettier-plugin-tailwindcss": "^0.1.13",
    "prisma": "^4.5.0",
    "tailwindcss": "^3.2.0",
    "typescript": "^4.8.4"
  },

Eslintrc.json

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "project": "./tsconfig.json"
  },
  "plugins": ["@typescript-eslint"],
  "extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"],
  "rules": {
    "@typescript-eslint/consistent-type-imports": "warn"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es2017",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "noUncheckedIndexedAccess": true
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.cjs", "**/*.mjs", "xplaywright.config.xt"],
  "exclude": ["node_modules"]
}

prettier.config.cjs

/** @type {import("prettier").Config} */
module.exports = {
  plugins: [require.resolve("prettier-plugin-tailwindcss")],
};
juliusmarminge commented 1 year ago

pnpm i and restart language server is the best advice i can think of

am1ru1 commented 1 year ago

thanks @juliusmarminge . Have restart TS and ESlint servers, and removed node_modules and .next, and then yarn install. Issue still persist. Could be my personal vscode/yarn/node/npm setup issue. Hopefully others might have suggestion

am1ru1 commented 1 year ago

closing this issue.