Skip to content

VueComponent.extend type is not strict enough. This type ensures extended methods exist and their types match.

License

Notifications You must be signed in to change notification settings

lukaw3d/typed-vue-extend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to use

const Component = Vue.extend({
  methods: {
    a() {
      return 'a';
    },
    async b() {
      return 'b';
    },
  },
});


import type { TypedVueExtendOverride } from 'typed-vue-extend';
Component.extend({
  methods: {
    // Type checked that method exists and return type matches.
    async b() {
      return 'bb';
    },
  },
} as TypedVueExtendOverride<typeof Component>);

See ./test.ts

Note: editors commonly use shims-vue.d.ts for Component.vue imports. In those cases editor will not show errors detected by TypedVueExtendOverride - only compilation will.

About

VueComponent.extend type is not strict enough. This type ensures extended methods exist and their types match.

Topics

Resources

License

Stars

Watchers

Forks