Skip to content

Latest commit

 

History

History
55 lines (38 loc) · 1.35 KB

require-typed-object-prop.md

File metadata and controls

55 lines (38 loc) · 1.35 KB
pageClass sidebarDepth title description since
rule-details
0
vue/require-typed-object-prop
enforce adding type declarations to object props
v9.16.0

vue/require-typed-object-prop

enforce adding type declarations to object props

  • 💡 Some problems reported by this rule are manually fixable by editor suggestions.

📖 Rule Details

Prevent missing type declarations for non-primitive object props in TypeScript projects.

<script lang="ts">
export default {
  props: {
    // ✗ BAD
    bad1: Object,
    bad2: { type: Array },

    // ✓ GOOD
    good1: Object as PropType<Anything>,
    good2: { type: Array as PropType<Anything[]> },
    good3: [String, Boolean], // or any other primitive type
  }
}
</script>

🔧 Options

Nothing.

🔇 When Not To Use It

When you're not using TypeScript in the project.

🚀 Version

This rule was introduced in eslint-plugin-vue v9.16.0

🔍 Implementation