nuxt / scripts

Third-Party Scripts Meets Nuxt Developer Experience.
https://scripts.nuxt.com
MIT License
269 stars 31 forks source link

`npx nuxi typecheck` fails in fresh project #64

Closed enkot closed 4 months ago

enkot commented 4 months ago

Repro: https://stackblitz.com/edit/github-yhnmge?file=nuxt.config.ts,.nuxt%2Ftsconfig.json

❯ npx nuxi typecheck
ℹ Compiled plugins/server.mjs in 527.8ms                                                                                                 20:40:45
ℹ Compiled plugins/client.mjs in 559.59ms                                                                                                20:40:45
ℹ Compiled types/plugins.d.ts in 560.98ms  
node_modules/@nuxt/scripts/dist/runtime/components/ScriptGoogleMaps.vue:96:67 - error TS2339: Property 'apiKey' does not exist on type 'ScriptRegistry'.

96 const apiKey = props.apiKey || scriptRuntimeConfig('googleMaps')?.apiKey
                                                                     ~~~~~~

node_modules/@nuxt/scripts/dist/runtime/components/ScriptGoogleMaps.vue:146:23 - error TS7006: Parameter 'instance' implicitly has an 'any' type.

146   $script.then(async (instance) => {
                          ~~~~~~~~

node_modules/@nuxt/scripts/dist/runtime/components/ScriptLemonSqueezyButton.vue:2:15 - error TS2724: '"#imports"' has no exported member named 'ElementScriptTrigger'. Did you mean 'useElementScriptTrigger'?

2 import { type ElementScriptTrigger, onMounted, ref, useElementScriptTrigger, useScriptLemonSqueezy } from '#imports'
                ~~~~~~~~~~~~~~~~~~~~

node_modules/@nuxt/scripts/dist/runtime/components/ScriptVimeoPlayer.vue:137:79 - error TS18046: 'res' is of type 'unknown'.

137   () => $fetch(`https://vimeo.com/api/v2/video/${props.id}.json`).then(res => res[0]),
                                                                                  ~~~

node_modules/@nuxt/scripts/dist/runtime/components/ScriptVimeoPlayer.vue:163:25 - error TS7031: Binding element 'Vimeo' implicitly has an 'any' type.

163   $script.then(async ({ Vimeo }) => {
                            ~~~~~

node_modules/@nuxt/scripts/dist/runtime/components/ScriptVimeoPlayer.vue:175:15 - error TS2769: No overload matches this call.
  The last overload gave the following error.
    Argument of type 'string' is not assignable to parameter of type '"leavepictureinpicture"'.

175         emits(event, e, player)
                  ~~~~~

  node_modules/@vue/runtime-core/dist/runtime-core.d.ts:1256:21
    1256     [K in keyof T]: (evt: K, ...args: T[K]) => void;
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The last overload is declared here.

node_modules/@nuxt/scripts/dist/runtime/components/ScriptYouTubePlayer.vue:58:23 - error TS7006: Parameter 'instance' implicitly has an 'any' type.

58   $script.then(async (instance) => {
                         ~~~~~~~~

Found 7 errors in 4 files.

Errors  Files
     2  node_modules/@nuxt/scripts/dist/runtime/components/ScriptGoogleMaps.vue:96
     1  node_modules/@nuxt/scripts/dist/runtime/components/ScriptLemonSqueezyButton.vue:2
     3  node_modules/@nuxt/scripts/dist/runtime/components/ScriptVimeoPlayer.vue:137
     1  node_modules/@nuxt/scripts/dist/runtime/components/ScriptYouTubePlayer.vue:58

 ERROR  Command failed with exit code 2: /home/projects/kkvirvvmn.github/node_modules/vue-tsc/bin/vue-tsc.js --noEmit                     20:40:47

  at makeError (node_modules/nuxi/dist/chunks/index3.mjs:1292:11)
  at handlePromise (node_modules/nuxi/dist/chunks/index3.mjs:2530:26)
  at async Object.run (node_modules/nuxi/dist/chunks/typecheck.mjs:91:7)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1678:16)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1669:11)
  at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1807:7) 

 ERROR  Command failed with exit code 2: /home/projects/kkvirvvmn.github/node_modules/vue-tsc/bin/vue-tsc.js --noEmit   
huang-julien commented 4 months ago

Hey :wave: Thank you for openning the issue. It should be soon fixed by #65 #66 and #67

harlan-zw commented 4 months ago

Thanks @huang-julien! This is fixed in 0.4.2.

The CI will now verify the types using nuxi typecheck as well to avoid a regression.