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

Type-only defineProps does not recognize Promise #5941

Closed
lseeker opened this issue May 18, 2022 · 0 comments
Closed

Type-only defineProps does not recognize Promise #5941

lseeker opened this issue May 18, 2022 · 0 comments
Labels
feat: compiler feat: script-setup Related to experimental implementation of RFC #227

Comments

@lseeker
Copy link
Contributor

lseeker commented May 18, 2022

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.

@edison1105 edison1105 added feat: compiler feat: script-setup Related to experimental implementation of RFC #227 labels May 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: compiler feat: script-setup Related to experimental implementation of RFC #227
Projects
None yet
Development

No branches or pull requests

2 participants