-
Notifications
You must be signed in to change notification settings - Fork 915
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
Scoped style leads to error: TS7006: Parameter 'n' implicitly has an 'any' type #1915
Comments
"vue-loader": "16.5" works for me. "vue-loader": "16.6" failes:
|
I have the same problem it occurs only if my components have the "scoped" attribute. |
Removing |
Removing strict is very bad for the codebase. Have you guys heard any news on this? |
I got 4 components having the same problem. Those failed to build with Webpack, but succeed in watch mode. |
Same problem here. I also get some other build time ts errors, resolving by changing strict to false. |
Issue still exists. |
I found this thread finally! Was trying to wrap my head around this issue in the span of the last couple of weeks.
This is far from ideal, but I catch most this kind of error during development, mostly in intelliSense. |
@entioentio where is this variable |
Sorry, true that. That's my local variable in webpack.l config |
I get this errror even when the template is not accessing component data. It worked fine when the template was |
I thought I was going insane since I couldn't see anything. |
I could find a work-around that uses Babel, but maybe not the essential solution. https://www.npmjs.com/package/babel-preset-typescript-vue3 npm i -D @babel/core @babel/preset-env @babel/preset-typescript babel-loader babel-preset-typescript-vue3 and {
test: /\.ts$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'babel-preset-typescript-vue3',
'@babel/preset-typescript',
],
},
}, |
This was happening to me. For me it wasn't due to the scoped style but rather from using typescript for my script. I removed the Edit: Spoke too soon. The above initially worked for me until I added a |
I hit this error as well. I'm using v17 with Symfony Webpack Encore. |
I solved it this way instead of removing
|
Greet me in the club. The problem mysteriously does not appear in the watch mode (I'm using the Laravel Mix) so I came up with the idea to set the Replace // @todo Delete once https://github.com/vuejs/vue-loader/issues/1915 is resolved.
// @todo Don't forget to remove the issue mention from the README.md.
const tsOptions = Mix.isWatching()
? undefined
: {
compilerOptions: {
noImplicitAny: false,
},
};
mix
.ts('js/app.ts', 'js', tsOptions)
.vue(); The Webpack rule would have looked this way: {
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
...(Mix.isWatching() ? {} : { compilerOptions: { noImplicitAny: false } })
},
} |
I'm still having this issue on version 17.1.1. Can someone please take a look at this? 🙏 @yyx990803 @sodatea |
Same here. All of these symptoms. <script lang="ts" setup>
//something
</script>
<template>
<div>
</div>
</template>
<style scoped>
</style> Without |
I stumbled upon this issue. The problem still exists. Only solution I could find is to remove the scoped attribute from the style tag. |
Same issue for me. Example with a bad type for v-key in a vue component :
This error is not detected in dev mode. |
Just ran into this issue in the latest version too, turns out our organization has run into this pretty frequently lately 😞 I opted to add a targeted setting to set {
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/],
compilerOptions: {
noImplicitAny: false, // Necessary until the following issue is fixed: https://github.com/vuejs/vue-loader/issues/1915
},
},
},
}, What was really weird was if I ran it using Feels like maybe some kind of a race condition? |
I am having the same issue. Initially, I downgraded to It seems that it may be an issue in Vue's SFC compiler: @xesxen made a pull request that seems like it would fix the cause of this here, I am not 100% sure without some input from them. Regardless, it would be amazing to see this issue addressed, especially since it is causing big issues for many people as evident in this thread, and seeing as people have made active attempts to fix it (i.e. the aforementioned PR) that have seem to been lost in the sea of issues and PRs. Would it be possible to please have someone take a look at this after so long? @yyx990803 @sodatea 🙏🏻 |
Also very interested to see the resolution to this issue. |
To elaborate on this and show an example of the error I get instead of this one when downgrading to
Initially, I tried to resolve this by making a fork of 16.5 and passing the I ended up getting it to work on occasion, but I was having a lot of really weird issues with imported types, and I could never get it working properly. Eventually I decided to give up on the fork idea and just tried to get it working with the newest version, but I experienced an issue with using intersections of imported types as props (see vuejs/core#8482). It's incredibly frustrating that I've spent weeks on this and nothing works as expected. It always boils down to some arbitrary error that appears to come from A warning for anyone coming here from Google in 2024:If you are looking to use modern TypeScript within your Vue components or frontend code in general, and want to use vue-loader to integrate it within your webpack build, I strongly recommend you don't do so, either until these issues are fixed, or until In my personal experience using many non-Vite bundlers, Vue+TS does not work as you'd expect in a lot of circumstances, unless you are using Vite alongside it. I am considering migrating away from Vue in my project for these reasons, as it seems the advent of Vite has led legacy modules that people still rely on (like Really hoping this changes, but unfortunately it seems that this is the way things are going for now. |
Any news about this issue ? I'm not using script setup just because of that ... |
@Threebow Thank you very much for the elaborate answer! The issue still persists in May 2024. Any updates on this? |
Removing scoped from style in Vue3 <script setup lang="ts"> fixed the issue. But I don’t understand the root cause though 🙂 |
@gde-pass @dvogiatzi I am actively watching this, and it doesn't seem so. My use case has extended to Zod type inference, and it has led me to hit further blockers, so I am very interested in a solution to this. The PR that I think might fix this issue has had no activity for three months either, so I will probably look into creating a PR myself if I find the time. The only problem is I wouldn't want my PR to end up in the graveyard.
@varun-maersk On the surface, it is indeed absolutely bizarre that enforcing a scoped style will trigger arbitrary type errors in the TS section of the code. It would seem that they are different cogs in the system, and as such, shouldn't affect each other. However, the way it really works (to my understanding, at least) is that So, what is happening here (again, to the best of my understanding, I could be completely wrong here), is that the presence of a scoped style is outputting some non-strict-mode-compliant TypeScript code, somewhere within the generated P.S.I've also experienced different behavior depending on whether code is added while Webpack is "warmed up" in watch mode, v.s. freshly booted in watch mode. So, the code will error when you add it to project that's actively being watched, however, if you do not change the code whatsoever and restart the watch process, it will then work and the error will disappear. |
@Threebow seems to be merged! |
Version
16.8.3, 17.0.0, maybe older
Reproduction link
github.com
Steps to reproduce
What is expected?
No errors
What is actually happening?
Error: TS7006: Parameter 'n' implicitly has an 'any' type
To get this error style must be scoped and template must access some component data
The text was updated successfully, but these errors were encountered: