Skip to content

Typescript may be can not infer the props type #6924

Closed
@xingyesh

Description

@xingyesh

Version

vue 2.5.2
typescript 2.5.3

Reproduction link

https://jsfiddle.net/chrisvfritz/50wL7mdz/typescript

Steps to reproduce

Typescript may be can not infer the props type. eg:

//App.vue
<template>
    <div>
        <vheader :test="test" :type="type"></vheader>
    </div>
</template>
<script lang="ts">
import header from './header.vue';
export default {
    components: {
        vheader: header
    },
    computed: {
    },
    methods: {
        test(left: number, right: number): number {
            return left   right;
        }
    }
}
</script>
//header.vue
<script lang="ts">
import Vue from 'vue'
export default {
    props: {
        test: Function
    },
    data() {
        this.test('aa','aa');
        return {}
    }
}
</script>

this.test('aa', 'aa') can invoke correct.
Now Vue can not get the parent's(props) function type?

What is expected?

types error.

What is actually happening?

can run success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions