Skip to content

Setting components in Component decorator causes Typescript 2.4 error #123

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
qdot opened this issue Jul 12, 2017 · 7 comments
Closed

Setting components in Component decorator causes Typescript 2.4 error #123

qdot opened this issue Jul 12, 2017 · 7 comments

Comments

@qdot
Copy link

qdot commented Jul 12, 2017

The following code worked in Typescript 2.3

@Component({
  components: {
    Slideout,
    PanelComponent,
    VideoComponent
  }
})
export default class App extends Vue {
  @Prop()
  client: client;

  open() {
    console.log("Opened!");
  }
}

Using Typescript 2.4, I get the following error:

ERROR in ./~/ts-loader!./src/App.ts
(10,3): error TS2345: Argument of type '{ components: { 'Slideout': any; 'PanelComponent': "string" | "number" | "boolean" | "sym...' is not assignable to parameter of type 'VueClass'.
Object literal may only specify known properties, and 'components' does not exist in type 'VueClass'.

@vjcagay
Copy link

vjcagay commented Jul 12, 2017

I also get this kind of error when using the vuedraggable plugin, but not when using my own components. I think this might have something to do with the author's packages rather than with Vue Class Component.

@nickmessing
Copy link
Member

Side components should add .d.ts for it to work AFAIK

@ktsn
Copy link
Member

ktsn commented Jul 12, 2017

Could you provide a minimal reproducible project by github repo?

@qdot
Copy link
Author

qdot commented Jul 13, 2017

@ktsn ktsn removed the need repro label Jul 16, 2017
@ktsn
Copy link
Member

ktsn commented Jul 16, 2017

@qdot Thank you for the reproduction. This seems to be fixed if you update vuefiles.d.ts like following (remove typeof):

declare module "*.vue" {
  import Vue from 'vue';
  export default Vue;
}

I remember it had worked with typeof but now it exports the string literal type that the typeof keyword returns instead of the constructor type of Vue.

I already make a PR to fix the example in this repo via #126

@qdot
Copy link
Author

qdot commented Jul 16, 2017

This made it work for me, thanks so much for the help and the library! :)

qdot added a commit to qdot/syncydink that referenced this issue Jul 17, 2017
Needed to remove a typeof to make typescript 2.4 work with vue
decorators. See

vuejs/vue-class-component#123 (comment)
qdot added a commit to qdot/syncydink that referenced this issue Jul 17, 2017
Needed to remove a typeof to make typescript 2.4 work with vue
decorators. See

vuejs/vue-class-component#123 (comment)
@TokugawaTakeshi
Copy link

@nickmessing

Side components should add .d.ts for it to work AFAIK

Would you please to show some example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants