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

when set tsconfig - vueCompilerOptions.target = 3 and compilerOptions.strict = false , use Partial in defineProps, $props lose type #4839

Closed
Kanade-Lu opened this issue Sep 11, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@Kanade-Lu
Copy link

Kanade-Lu commented Sep 11, 2024

Vue - Official extension or vue-tsc version

2.0.21

VSCode version

1.92.2 (Universal)

Vue version

3.5.4

TypeScript version

5.4.0

System Info

System:
    OS: macOS 13.4.1
    CPU: (8) arm64 Apple M1
    Memory: 159.14 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 7.33.7 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 128.0.6613.121
    Safari: 16.5.1

package.json dependencies

"dependencies": {
    "vue": "^3.5.4"
  },
  "devDependencies": {
    "@tsconfig/node20": "^20.1.4",
    "@types/node": "^20.14.5",
    "@vitejs/plugin-vue": "^5.0.5",
    "@vue/tsconfig": "^0.5.1",
    "npm-run-all2": "^6.2.0",
    "typescript": "~5.4.0",
    "vite": "^5.3.1",
    "vue-tsc": "^2.1.6"
  }

Steps to reproduce

pnpm create vue@latest
use typescript
set tsconfig - vueCompilerOptions.target = 3 and compilerOptions.strict = false

<script setup lang="ts">
import { ref, toRefs } from 'vue'

interface IGroupDetail {
    created_at: string;
}
const props = defineProps<{
    groupDetail: Partial<IGroupDetail>
}>()

// const { groupDetail } = toRefs(props) // Comment this code,groupDetail in template will unknown 

</script>

<template>
  <div>  {{ groupDetail.created_at }}</div>
   <div>  {{ props.groupDetail.created_at }}</div>
</template>
{
  "include": [
    "vite.config.*",
    "vitest.config.*",
    "cypress.config.*",
    "nightwatch.conf.*",
    "playwright.config.*",
    "env.d.ts",
    "src/**/*",
    "src/**/*.vue"
  ],
  "vueCompilerOptions": {
    "target": 3
  },
  "compilerOptions": {
    "strict": false,
  }
}

What is expected?

groupDetail should be IGroupDetail not unknown

What is actually happening?

groupDetail type get unknown

Link to minimal reproduction

https://github.com/Kanade-Lu/vue-bue-report

Any additional comments?

set vueCompilerOptions.target = auto or strict = true will get right type

@KazariEX
Copy link
Collaborator

Duplicate of #4704

@KazariEX KazariEX marked this as a duplicate of #4704 Sep 11, 2024
@KazariEX KazariEX closed this as not planned Won't fix, can't repro, duplicate, stale Sep 11, 2024
@KazariEX KazariEX added duplicate This issue or pull request already exists and removed pending triage labels Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants