Skip to content

Commit

Permalink
refactor(types): revert data(vm)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxy060608 committed Aug 7, 2024
1 parent 3b2481f commit 70bb336
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
11 changes: 5 additions & 6 deletions packages/dts-test/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,11 @@ describe('with mixins', () => {
},
},

data(/*vm*/) {
// fixed by uts
// expectType<number>(vm.a)
// expectType<number>(vm.b)
// expectType<number>(vm.c)
// expectType<number>(vm.d)
data(vm) {
expectType<number>(vm.a)
expectType<number>(vm.b)
expectType<number>(vm.c)
expectType<number>(vm.d)

// should also expose declared props on `this`
expectType<number>(this.a)
Expand Down
21 changes: 10 additions & 11 deletions packages/runtime-core/src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,15 @@ interface LegacyOptions<
Mixin,
Extends
>,
// fixed by xxxxxx
// vm: CreateComponentPublicInstance<
// Props,
// {},
// {},
// {},
// MethodOptions,
// Mixin,
// Extends
// >,
vm: CreateComponentPublicInstance<
Props,
{},
{},
{},
MethodOptions,
Mixin,
Extends
>,
) => D
computed?: C
methods?: M
Expand Down Expand Up @@ -715,7 +714,7 @@ export function applyOptions(instance: ComponentInternalInstance) {
`Plain object usage is no longer supported.`,
)
}
const data = dataOptions.call(publicThis /*, publicThis*/) // fixed by xxxxxx
const data = dataOptions.call(publicThis, publicThis)
if (__DEV__ && isPromise(data)) {
warn(
`data() returned a Promise - note data() cannot be async; If you ` +
Expand Down

0 comments on commit 70bb336

Please sign in to comment.