You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After I download the template, I execute the ni command to install the relevant dependencies of the template After installation, add the following code to <script> of App.vue
<scriptsetuplang="ts">// Mock ref variables returned from hooks utility functionsconst refDataA =ref(1)const refDataB =ref(2)setInterval(() => { refDataA.value++; refDataB.value*=2 }, 1000)// use in businessconst $refDataA =$(refDataA)const $refDataB =$(refDataB)// Simulate the `use` tool function like hooksfunction useAdd(...params:Ref<number>[]) {returncomputed(() =>params.reduce((acc, param) => { returnacc+param.value }, 0))}// Need to `use xxx as unknown as number` assertion// Otherwise it will be treated as JQuery<Ref<number>> typeconst afterComputed =useAdd($$($refDataAasunknownasnumber), $$($refDataBasunknownasnumber))// continuous outputwatch(afterComputed, () =>console.log(afterComputed.value))</script>
When using $() to convert Ref to reactive variables, the type of $() is overwritten by the type of jquery in cypress
I was looking at tsconfig.ts and found that the type of cypress package was excluded and only included in tsconfig.ts inside the /cypress folder, but this doesn't seem to work, in vuevscode in the file still recognizes the type of cypress package, I don't know what's going on here.
I tried uninstalling the cypress package to test if the conflict was really caused by the cypress package, which turned out to be correct.
While the solution works, I need to use the cypress package in my project to test my project, so I can't live without it.
I try to use xxx as unknown as number to assert the transformed variable before using it, it works, but if I need to assert every time I use it, it will increase the burden on my coding mind, I am eager Solve the conflict problem once and for all from a global perspective.
+1, another workaround is adding import { $ } from 'vue/macros' everywhere you need it, that corrects the typing but kinda defeats the whole auto-import feature.
Describe the bug
After I download the template, I execute the
ni
command to install the relevant dependencies of the template After installation, add the following code to<script>
ofApp.vue
When using
$()
to convertRef
to reactive variables, the type of$()
is overwritten by the type ofjquery
incypress
I was looking at
tsconfig.ts
and found that the type ofcypress
package was excluded and only included intsconfig.ts
inside the/cypress
folder, but this doesn't seem to work, invue
vscode
in the file still recognizes the type ofcypress
package, I don't know what's going on here.I tried uninstalling the
cypress
package to test if the conflict was really caused by thecypress
package, which turned out to be correct.While the solution works, I need to use the
cypress
package in my project to test my project, so I can't live without it.I try to use
xxx as unknown as number
to assert the transformed variable before using it, it works, but if I need to assert every time I use it, it will increase the burden on my coding mind, I am eager Solve the conflict problem once and for all from a global perspective.What should I do please?
Reproduction
https://github.com/jiangmaniu/vitesse-type-conflict-repo
System Info
Used Package Manager
pnpm
Validations
The text was updated successfully, but these errors were encountered: