Skip to content
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

Cross file template type checking - check that components are passed all declared props #2135

Closed
octref opened this issue Aug 8, 2020 · 4 comments

Comments

@octref
Copy link
Member

octref commented Aug 8, 2020

Needed for #1596.

Assume Child.vue,

<script>
export default {
  props: ['foo', 'bar']
}
</script>

and Parent.vue,

<script>
import Child from './Child.vue'

export default {
  components: {
    Child
  },
  props: ['foo', 'bar']
}
</script>

In Parent.vue, these diagnostics should be shown:

<template>
  <!--Missing `foo` and `bar` -->
  <child></child>

  <!--Missing `bar` -->
  <child :foo="foo"></child>

  <!--Missing `bar` -->
  <!--`baz` is not defined in `Child.vue` -->
  <child :foo="foo" :baz="bar"></child>
</template>
@yoyo930021
Copy link
Member

yoyo930021 commented Aug 8, 2020

Sometimes we don't need to have prop
When

export default {
  props: {
    active: {
      type: Boolean,
      default: true
    }
  }
}

This commit cannot detect it.

@octref
Copy link
Member Author

octref commented Aug 8, 2020

@yoyo930021 Good catch!


Update: Are you sure? This seems to work fine for me:

Showing diagnostics:

image

Showing no diagnostics:

image

@yoyo930021
Copy link
Member

yoyo930021 commented Aug 8, 2020

@yoyo930021 Good catch!

Update: Are you sure? This seems to work fine for me:

Showing diagnostics:

image

Showing no diagnostics:

image

When I use default in prop,
I want to allow misses this prop in template.
Like ensure compatibility

@octref
Copy link
Member Author

octref commented Aug 8, 2020

I'll fix it in #2141.

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

No branches or pull requests

2 participants