-
-
Notifications
You must be signed in to change notification settings - Fork 224
TypeScript error: Cannot redeclare block-scoped variable 'self' #443
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
Comments
@hornta check also the You should also add a |
Separate from what? In that file both tsc and the build script are together in it's same script. The build works if I only run This is my package.json {
"name": "web",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "tsc --noEmit && TIMING=1 eslint \"src/**/*.ts*\""
},
"dependencies": {
"@clerk/clerk-js": "^4.22.0",
"@clerk/clerk-react": "^4.6.4",
"@tabler/icons": "^1.118.0",
"@tailwindcss/forms": "^0.5.3",
"@tanstack/react-query": "^4.20.4",
"@tanstack/react-router": "0.0.1-beta.38",
"@trpc/client": "^10.8.1",
"@trpc/react-query": "^10.8.1",
"@trpc/server": "^10.8.1",
"@types/serviceworker": "^0.0.59",
"autoprefixer": "^10.4.13",
"bson": "^4.7.0",
"clsx": "^1.2.1",
"postcss": "^8.4.20",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"superjson": "^1.12.1",
"tailwindcss": "^3.2.4",
"vite-plugin-pwa": "^0.14.1",
"web-push": "^3.5.0"
},
"devDependencies": {
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^3.0.1",
"typescript": "^4.9.4",
"vite": "^4.0.4"
}
}
It is separate. I got two tsconfig.json, one in the project root folder and one in the service-worker directory. My root tsconfig.json. In here I've tried to exclude the {
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"noUncheckedIndexedAccess": true
},
"include": ["./src"],
"exclude": ["service-worker"],
"references": [{ "path": "./tsconfig.node.json" }]
} |
Hmm.. turns out all I had to do was to add a I don't know why it works :-) |
The above comment caused a weird build error:
I had to write |
I'm getting a TypeScript error in my service worker file and I can't figure how to solve it.
This is the error I'm getting:
And this is my service worker file:
I saw another project put the
sw.ts
in its own directory insrc/service-worker
and then put atsconfig.json
at its side. I tried to do it but it doesn't look like it's working.This is the tsconfig.json
src/service-worker/tsconfig.json
Do you see something obvious wrong or should I provide more information?
The text was updated successfully, but these errors were encountered: