Skip to content

Latest commit

 

History

History
93 lines (67 loc) · 1.91 KB

force-types-on-object-props.md

File metadata and controls

93 lines (67 loc) · 1.91 KB
pageClass sidebarDepth title description
rule-details
0
vue/force-types-on-object-props
enforce user to add type declaration to object props

vue/force-types-on-object-props

enforce user to add type declaration to object props

  • This rule has not been released yet.
  • ⚙️ This rule is included in all of "plugin:vue/base", "plugin:vue/essential", "plugin:vue/vue3-essential", "plugin:vue/strongly-recommended", "plugin:vue/vue3-strongly-recommended", "plugin:vue/recommended" and "plugin:vue/vue3-recommended".

📖 Rule Details

Prevent missing type declaration of not primitive objects in a TypeScript projects.

Bad:

export default {
  props: {
    prop: {
      type: Object,
    },
  },
}
export default {
  props: {
    prop: {
      type: Array
    }
  }
}

Good:

export default {
  props: {
    prop: {
      type: Object as Props<Anything>,
    }
  }
}
export default {
  props: {
    prop: {
      type: String, // or any other primitive type
    }
  }
}

Options

Nothing.

🔇 When Not To Use It

When you're not using TypeScript in the project****.

📚 Further Reading

Nothing

🔍 Implementation