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(markRaw): keep the original type when unwrapping markRaw #3791

Merged
merged 7 commits into from
May 6, 2022

Conversation

pikax
Copy link
Member

@pikax pikax commented May 18, 2021

related: #2981

When using markRaw on a reactive object the type will be unwrapped and it will lose it's type

describe('should support markRaw', () => {
  class Test<T> {
    item = {} as Ref<T>
  }
  const test = new Test<number>()
  const plain = {
    ref: ref(1)
  }

  const r = reactive({
    class: {
      raw: markRaw(test),
      reactive: test
    },
    plain: {
      raw: markRaw(plain),
      reactive: plain
    }
  })

  expectType<Test<number>>(r.class.raw)
  // @ts-expect-error it should unwrap
  expectType<Test<number>>(r.class.reactive)

  expectType<Ref<number>>(r.plain.raw.ref)
  // @ts-expect-error it should unwrap
  expectType<Ref<number>>(r.plain.reactive.ref)
})

@HcySunYang
Copy link
Member

Has conflicts 😁

…arkraw

# Conflicts:
#	packages/reactivity/src/reactive.ts
#	packages/reactivity/src/ref.ts
#	test-dts/reactivity.test-d.ts
@netlify
Copy link

netlify bot commented May 6, 2022

Deploy Preview for vuejs-coverage ready!

Name Link
🔨 Latest commit 40ae222
🔍 Latest deploy log https://app.netlify.com/sites/vuejs-coverage/deploys/6274e403f78db500089f4eae
😎 Deploy Preview https://deploy-preview-3791--vuejs-coverage.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 6, 2022

Deploy Preview for vue-sfc-playground ready!

Name Link
🔨 Latest commit 40ae222
🔍 Latest deploy log https://app.netlify.com/sites/vue-sfc-playground/deploys/6274e40365bef40008d71de8
😎 Deploy Preview https://deploy-preview-3791--vue-sfc-playground.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@netlify
Copy link

netlify bot commented May 6, 2022

Deploy Preview for vue-next-template-explorer ready!

Name Link
🔨 Latest commit 40ae222
🔍 Latest deploy log https://app.netlify.com/sites/vue-next-template-explorer/deploys/6274e40309054e0009ea1ed5
😎 Deploy Preview https://deploy-preview-3791--vue-next-template-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@yyx990803 yyx990803 merged commit 32e53bf into vuejs:main May 6, 2022
@pikax pikax deleted the types/maintain_type_from_markraw branch May 6, 2022 13:00
iwusong pushed a commit to iwusong/core that referenced this pull request May 13, 2022
@SinBirb
Copy link

SinBirb commented Aug 3, 2022

Can this also be merged into @vue/composition-api, so we can use it with Vue 2.6 + Pinia?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: types
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants