Skip to content

Type-only defineProps does not recognize Promise #5941

Closed
@lseeker

Description

Link to minimal reproduction

https://sfc.vuejs.org/#__DEV__eyJBcHAudnVlIjoiPHNjcmlwdCBzZXR1cD5cbmltcG9ydCB7IHJlZiB9IGZyb20gJ3Z1ZSdcbmltcG9ydCBDb21wIGZyb20gJy4vQ29tcC52dWUnXG4gIFxuY29uc3QgbXNnID0gcmVmKCdIZWxsbyBXb3JsZCEnKVxuY29uc3QgZGF0YSA9IFByb21pc2UucmVzb2x2ZShbJ2EnXSlcbjwvc2NyaXB0PlxuXG48dGVtcGxhdGU+XG4gIDxoMT57eyBtc2cgfX08L2gxPlxuICA8aW5wdXQgdi1tb2RlbD1cIm1zZ1wiPlxuICA8Q29tcCA6ZGF0YT1cImRhdGFcIi8+XG48L3RlbXBsYXRlPlxuIiwiaW1wb3J0LW1hcC5qc29uIjoie1xuICBcImltcG9ydHNcIjoge1xuICAgIFwidnVlXCI6IFwiaHR0cHM6Ly9zZmMudnVlanMub3JnL3Z1ZS5ydW50aW1lLmVzbS1icm93c2VyLmpzXCJcbiAgfVxufSIsIkNvbXAudnVlIjoiPHNjcmlwdCBzZXR1cCBsYW5nPVwidHNcIj5cbmltcG9ydCB7IHJlZiB9IGZyb20gJ3Z1ZSdcblxuY29uc3QgcHJvcHMgPSBkZWZpbmVQcm9wczx7XG4gIGRhdGE6IFByb21pc2U8dW5rbm93bltdPnx1bmtub3duW11cbn0+KCk7XG4gIFxuY29uc3QgbG9hZGVkID0gcmVmKFtdKVxuUHJvbWlzZS5yZXNvbHZlKHByb3BzLmRhdGEpLnRoZW4oKGFycikgPT4geyBsb2FkZWQudmFsdWUgPSBhcnIgfSlcbjwvc2NyaXB0PlxuPHRlbXBsYXRlPlxuICA8ZGl2PlxuICAgIHt7IGxvYWRlZCB9fVxuICA8L2Rpdj5cbjwvdGVtcGxhdGU+XG4ifQ==

Steps to reproduce

On component, defineProps with Promise :

<script lang="ts" setup>
defineProps<{
  data: unknown[]|Promise<unknown[]>
}>();
</script>

Use this component to bind data property with Promise, type check warning is emitted.

What is expected?

no warning

What is actually happening?

[Vue warn]: Invalid prop: type check failed for prop "data". Expected Null | Array, got Promise

System Info

No response

Any additional comments?

Problem exists on compiler-sfc/src/compileScript.ts inferRuntimeType() function.
Adding 'Promise' on TSTypeReference typename.name switch statement, this bug will fixed.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions