Subscribe on changes!

defineProps does not support a type that uses Omit

avatar
Jun 22nd 2022

Vue version

^3.2.33 => 3.2.36

Link to minimal reproduction

https://sfc.vuejs.org/#eyJBcHAudnVlIjoiPHNjcmlwdCBsYW5nPVwidHNcIiBzZXR1cD5cbmltcG9ydCB7IHJlZiB9IGZyb20gJ3Z1ZSdcblxuaW50ZXJmYWNlIEZvbyB7XG4gIGJhcjogc3RyaW5nXG4gIGJhejogc3RyaW5nXG59XG5cbnR5cGUgV2l0aG91dEJhciA9IE9taXQ8Rm9vLCBcImJhclwiPlxuXG4vLyBXb3Jrc1xuLy8gY29uc3QgcHJvcHMgPSBkZWZpbmVQcm9wczxGb28+KCk7XG5cbi8vIERvZXMgbm90IHdvcmtcbmNvbnN0IHByb3BzID0gZGVmaW5lUHJvcHM8V2l0aG91dEJhcj4oKTtcbjwvc2NyaXB0PlxuXG48dGVtcGxhdGU+XG48L3RlbXBsYXRlPiIsImltcG9ydC1tYXAuanNvbiI6IntcbiAgXCJpbXBvcnRzXCI6IHtcbiAgICBcInZ1ZVwiOiBcImh0dHBzOi8vc2ZjLnZ1ZWpzLm9yZy92dWUucnVudGltZS5lc20tYnJvd3Nlci5qc1wiXG4gIH1cbn0ifQ==

Steps to reproduce

  1. Create an interface
  2. Update the interface with Omit
  3. Pass the Omitted type to defineProps

What is expected?

It would pick up the omitted type inside the defineProps.

What is actually happening?

A compiler error stating:

[@vue/compiler-sfc] type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type```

### System Info

```shell
System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Max
    Memory: 130.52 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 17.9.0 - ~/.nvm/versions/node/v17.9.0/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.11.0
  Browsers:
    Chrome: 102.0.5005.115
    Firefox: 101.0.1
    Safari: 15.5
  npmPackages:
    vue: ^3.2.33 => 3.2.36

Any additional comments?

No response

avatar
Jun 22nd 2022

I'd say thats another aspect of the currently documented restrictions:

As of now, the type declaration argument must be one of the following to ensure correct static analysis:

  • A type literal
  • A reference to an interface or a type literal in the same file

https://vuejs.org/api/sfc-script-setup.html#typescript-only-features

Insofar it's not a bug.

avatar
Jun 22nd 2022

Aaah check. Have missed that. Think we can close this one then? Otherwise it's a useless issue.