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

types(reactivity): fix the return type error when the toRaw parameter type is readonly #9124

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Alfred-Skyblue
Copy link
Member

@Alfred-Skyblue Alfred-Skyblue commented Sep 4, 2023

type Foo = { a: number; b: string; c: { d: number } }
  const foo: Foo = {
    a: 1,
    b: 'b',
    c: { d: 2 },
  }

  const r = readonly(foo)
  const rawObj = toRaw(r) // ❌ { readonly a: number, readonly b: string, readonly c: {...} }

rawObj is expected to be of type Foo, but the actual result is { readonly a: number, readonly b: string, readonly c: {...} }.

@Alfred-Skyblue Alfred-Skyblue marked this pull request as ready for review September 4, 2023 03:48
@github-actions
Copy link

github-actions bot commented Sep 4, 2023

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 101 kB 38.1 kB 34.2 kB
vue.global.prod.js 160 kB 58 kB 51.5 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 49.1 kB 18.9 kB 17.3 kB
createApp 55.7 kB 21.4 kB 19.6 kB
createSSRApp 59.7 kB 23.1 kB 21 kB
defineCustomElement 60.4 kB 23 kB 20.9 kB
overall 69.4 kB 26.5 kB 24.1 kB

Copy link

codspeed-hq bot commented Dec 20, 2023

CodSpeed Performance Report

Merging #9124 will not alter performance

Comparing Alfred-Skyblue:fix-toRaw-readolny-type (bd25703) with main (9fa8241)

Summary

✅ 53 untouched benchmarks

@edison1105
Copy link
Member

The test cases can still pass without these changes

Copy link

pkg-pr-new bot commented Oct 10, 2024

Open in Stackblitz

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@9124

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@9124

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@9124

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@9124

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@9124

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@9124

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@9124

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@9124

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@9124

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@9124

vue

pnpm add https://pkg.pr.new/vue@9124

commit: 221b27d

Copy link

netlify bot commented Oct 10, 2024

Deploy Preview for vue-sfc-playground failed.

Name Link
🔨 Latest commit a92509d
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/670791c1f8053d00096fa0fa

@Alfred-Skyblue
Copy link
Member Author

It seems that TypeScript currently allows this, see: microsoft/TypeScript#13347

However, microsoft/TypeScript#58296 is addressing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

3 participants