Skip to content

Commit

Permalink
Merge pull request #3 from rudyxu1102/fix/remove_util
Browse files Browse the repository at this point in the history
feat: remove `ExtractPropsAndEvents` util
  • Loading branch information
rudyxu1102 authored Sep 28, 2023
2 parents 67285e6 + e65e97b commit f1f39e8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-ts-utils",
"version": "0.2.1",
"version": "0.2.2",
"description": "Typescript utils for Vue2 and Vue3",
"main": "src/index.ts",
"typings": "./lib/src/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/componentOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, ComponentCustomOptions, ComponentInjectOptions, ComponentObj
import { DebuggerHook, ErrorCapturedHook } from "./apiLifecycle"
import { ComponentInternalInstance, ComponentInternalOptions, Data, SetupContext } from "./component";
import { EmitsToProps } from "./componentEmits"
import { CreateComponentPublicInstance } from './componentPublicInstance';
import { ComponentPublicInstanceConstructor, CreateComponentPublicInstance } from './componentPublicInstance';
import { LooseRequired, UnionToIntersection, Prettify } from '@vue/shared'
import { CompatConfig } from "./compatConfig";
import { SlotsType } from "./componentSlots";
Expand All @@ -12,7 +12,9 @@ type MergedHook<T = () => void> = T | T[]

declare const AttrSymbol: unique symbol
export type AttrsType<T extends Record<string, any> = Record<string, any>> = {
[AttrSymbol]?: T
[AttrSymbol]?: T extends ComponentPublicInstanceConstructor
? InstanceType<T>['$props']
: T
}
export type ExtractPropsAndEvents<T extends abstract new (...args: any) => any> = InstanceType<T>['$props'];
export type UnwrapAttrsType<
Expand Down
4 changes: 2 additions & 2 deletions test-dts/defineComponent.test-d.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ describe('define attrs', () => {
props: {
bar: Number
},
attrs: Object as AttrsType<ExtractPropsAndEvents<typeof Child>>,
attrs: Object as AttrsType<typeof Child>,
created() {
expectType<unknown>(this.$attrs.class)
expectType<unknown>(this.$attrs.style)
Expand Down Expand Up @@ -1481,7 +1481,7 @@ import {
ComponentCustomProps,
ExtractPropTypes
} from './index'
import { AttrsType, ExtractPropsAndEvents } from 'src/componentOptions'
import { AttrsType } from 'src/componentOptions'

// code generated by tsc / vue-tsc, make sure this continues to work
// so we don't accidentally change the args order of DefineComponent
Expand Down

0 comments on commit f1f39e8

Please sign in to comment.