Skip to content

Type error if no <script> #412

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

Closed
shadow-light opened this issue Aug 24, 2021 · 1 comment
Closed

Type error if no <script> #412

shadow-light opened this issue Aug 24, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@shadow-light
Copy link

The <script> section of vue templates is optional and apps build fine without it, but vue-tsc causes a type error to be thrown:

Example component:

<template lang='pug'>

app-svg(name='logo' responsive)

</template>

(noting there's no <script> section)

app/src/components/other/AppSidebar.vue:43:2 - error TS2769: No overload matches this call.
  Overload 1 of 2, '(options: ComponentOptions<Vue, DefaultData<Vue>, DefaultMethods<Vue>, DefaultComputed, PropsDefinition<DefaultProps>, DefaultProps> & ThisType<...>): <VC extends VueClass<...>>(target: VC) => VC', gave the following error.
    Type 'DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, PublicProps, Readonly<...> & ({ ...; } | { ...; }), {}>' is not assignable to type 'Component<any, any, any, any> | AsyncComponent<any, any, any, any>'.
      Type 'ComponentPublicInstanceConstructor<{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}> & Omit<({} & (Readonly<{} & {} & {}> & ({ [x: string & `on${string}`]: never; } | { ...; }))) & (VNodeProps & ... 3 more ... & ({ ...; } | { ...; })), never>; ... 10 more ...; $watch(source: string | Function, cb: Funct...' is missing the following properties from type 'VueConstructor<Vue>': extend, nextTick, set, delete, and 10 more.
  Overload 2 of 2, '(target: VueClass<Vue>): VueClass<Vue>', gave the following error.
    Argument of type '{ components: { AppLogo: DefineComponent<{}, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, EmitsOptions, string, PublicProps, Readonly<...> & ({ ...; } | { ...; }), {}>; }; }' is not assignable to parameter of type 'VueClass<Vue>'.
      Object literal may only specify known properties, but 'components' does not exist in type 'VueClass<Vue>'. Did you mean to write 'component'?

43 @Component({
    ~~~~~~~~~~~
44     components: {AppLogo},
   ~~~~~~~~~~~~~~~~~~~~~~~~~~
45 })
   ~~

Simply adding in <script></script> resolves the issue. So this obviously isn't a big deal, but just thought I'd mention, especially as it took me a very long time to debug :)

@johnsoncodehk johnsoncodehk added the bug Something isn't working label Aug 24, 2021
@shadow-light
Copy link
Author

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants