Skip to content

Commit 5ae8bec

Browse files
committed
fix(core): unref setup returned dotValue correctly
1 parent 8d62bd7 commit 5ae8bec

File tree

8 files changed

+118
-30
lines changed

8 files changed

+118
-30
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<view>
3+
{{ mapResetInfo.source }}
4+
{{ mapResetInfo1.trackAttrs.uid }}
5+
</view>
6+
</template>
7+
8+
<script lang="ts" setup>
9+
import { computed } from '@mpxjs/core'
10+
import useMapDrag from './useMapDrag'
11+
12+
const { mapResetInfo } = useMapDrag()
13+
14+
const mapResetInfo1 = computed(() => {
15+
return {
16+
source: 'estimate',
17+
statusType: 'success',
18+
trackAttrs: {
19+
uid: 1,
20+
},
21+
}
22+
})
23+
24+
defineExpose({
25+
mapResetInfo,
26+
mapResetInfo1
27+
})
28+
</script>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template>
2+
<view>
3+
{{ mapResetInfo.source }}
4+
{{ mapResetInfo1.statusType}}
5+
</view>
6+
</template>
7+
8+
<script lang="ts">
9+
import { createPage, computed } from '@mpxjs/core'
10+
import useMapDrag from './useMapDrag'
11+
12+
createPage({
13+
setup(){
14+
const { mapResetInfo } = useMapDrag()
15+
16+
const mapResetInfo1 = computed(() => {
17+
return {
18+
source: 'estimate',
19+
statusType: 'success',
20+
trackAttrs: {
21+
uid: 1,
22+
},
23+
}
24+
})
25+
26+
return {
27+
mapResetInfo,
28+
mapResetInfo1
29+
}
30+
},
31+
computed: {
32+
}
33+
})
34+
</script>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { computed } from '@mpxjs/core'
2+
3+
export default function useMapDrag() {
4+
const mapResetInfo = computed(() => {
5+
return {
6+
source: 'estimate',
7+
statusType: 'success',
8+
trackAttrs: {
9+
uid: 1,
10+
},
11+
}
12+
})
13+
14+
return {
15+
mapResetInfo,
16+
}
17+
}

inspect-extension/components/composition/dotValue.mpx

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
<view>
3+
{{ msg.a }} - {{ count.b.value.a }} - {{ computedMsg.count }}
4+
</view>
5+
</template>
6+
7+
<script setup lang="ts">
8+
import { ref, computed } from '@mpxjs/core'
9+
10+
const msg = ref({ a: 'default message' })
11+
const count = { b: ref({ a: 123 }) }
12+
const computedMsg = computed(() => {
13+
return {
14+
msg: msg.value.a,
15+
count: count.b.value.a
16+
}
17+
})
18+
19+
defineExpose({
20+
msg,
21+
count,
22+
computedMsg
23+
})
24+
</script>

inspect-extension/components/options/basic01.mpx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<view class="title"> title: {{ title }} </view>
2+
<view class="title">
3+
title: {{ title }}
4+
titleRef: {{ titleRef }}
5+
</view>
36
<view wx:class="list" bindtap="onClick">
47
<view> parentText: {{ parentText }} </view>
58
<view> msg: {{ msg }} </view>
@@ -9,7 +12,7 @@
912
</template>
1013

1114
<script lang="ts">
12-
import { createComponent } from '@mpxjs/core'
15+
import { createComponent, ref } from '@mpxjs/core'
1316

1417
createComponent({
1518
properties:{
@@ -26,10 +29,12 @@ createComponent({
2629
b: 2
2730
}
2831
},
29-
setup() {
30-
console.log('setup')
32+
setup(props, context) {
33+
console.log('setup', props.parentText)
34+
context.triggerEvent('requestSuccess', {})
3135
return {
32-
title: 'Mpx component'
36+
title: 'Mpx component',
37+
titleRef: ref('Mpx component'),
3338
}
3439
},
3540
computed: {
@@ -42,7 +47,7 @@ createComponent({
4247
},
4348
methods: {
4449
onClick() {
45-
console.log('click', this.count, this.content)
50+
console.log('click', this.titleRef, this.content)
4651
this.count++
4752
}
4853
},

packages/language-core/src/codegen/globalTypes/defineComponentTypes.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const globalTypes = `
1010
O extends AnyObject = {},
1111
>(
1212
opt: ThisTypedComponentOpt<D, P, C, M, Mi, S, O>,
13+
config?: { customCtor: any }
1314
): ComponentIns<D, P, C, M, Mi, S, O>
1415
// #endregion
1516
@@ -23,6 +24,7 @@ const globalTypes = `
2324
O extends AnyObject = {},
2425
>(
2526
opt: ThisTypedPageOpt<D, P, C, M, Mi, O>,
27+
config?: { customCtor: any }
2628
): ComponentIns<D, P, C, M, Mi, O>
2729
// #endregion
2830
`
@@ -162,19 +164,14 @@ export type ComponentIns<
162164
UnboxMixinsField<Mi, 'data'> &
163165
M &
164166
UnboxMixinsField<Mi, 'methods'> & {
165-
[K in keyof S]: S[K] extends Ref<infer V> ? V : S[K]
167+
[K in keyof S]: S[K] extends import('@mpxjs/core').Ref<infer V> ? V : S[K]
166168
} & GetPropsType<P & UnboxMixinsField<Mi, 'properties'>> &
167169
GetComputedType<C & UnboxMixinsField<Mi, 'computed'>> &
168170
WxComponentIns<D, P, M> &
169171
MpxComponentIns &
170172
MpxComProps<O>
171173
type GetDataType<T> = T extends () => any ? ReturnType<T> : T
172174
type MpxComProps<O> = { $rawOptions: O }
173-
export interface Ref<T = any> {
174-
value: T
175-
[RefSymbol]: true
176-
}
177-
declare const RefSymbol: unique symbol
178175
export interface MpxComponentIns {
179176
[k: string]: any
180177
}

packages/language-core/src/codegen/globalTypes/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export function generateGlobalTypes({
156156
function __VLS_tryAsConstant<const T>(t: T): T;
157157
158158
type UnwrapRefs<T> = {
159-
[K in keyof T]: T[K] extends { value: any }
159+
[K in keyof T]: T[K] extends import('${lib}').Ref
160160
? import('${lib}').UnwrapRef<T[K]>
161161
: T[K]
162162
}

0 commit comments

Comments
 (0)