Skip to content

Commit 153a559

Browse files
committed
Improve typings
1 parent 4e5a93d commit 153a559

File tree

1 file changed

+87
-16
lines changed

1 file changed

+87
-16
lines changed

lib/parser/Parser.d.ts

+87-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
declare module '@vuedoc/parser/parser/Parser.js' {
22
import EventEmitter from 'node:events';
33

4+
45
export type Options = {
56
/**
67
* Source to parse
@@ -53,36 +54,106 @@ declare module '@vuedoc/parser/parser/Parser.js' {
5354
walk(): Parser;
5455
}
5556

56-
export interface NameEntry {
57-
kind: 'name';
58-
value: string;
57+
export type ParsingEntry = ComputedEntry
58+
| DataEntry
59+
| DescriptionEntry
60+
| EventEntry
61+
| InheritAttrsEntry
62+
| KeywordsEntry
63+
| MethodEntry
64+
| ModelEntry
65+
| NameEntry
66+
| PropEntry
67+
| SlotEntry;
68+
69+
export type Keyword = {
70+
name: string;
71+
description?: string;
72+
};
73+
74+
export interface AbstractEntry<Kind extends string> {
75+
kind: Kind;
76+
description?: string;
77+
category?: string;
78+
version?: string;
79+
visibility: Visibility;
80+
keywords: Keyword[];
81+
}
82+
83+
export interface ComputedEntry extends AbstractEntry<'computed'> {
84+
type: string;
85+
name: string;
86+
dependencies: string[];
87+
}
88+
89+
export interface DataEntry extends AbstractEntry<'data'> {
90+
type: string;
91+
name: string;
92+
initialValue: string;
5993
}
6094

61-
export interface DescriptionEntry {
62-
kind: 'description'
95+
export interface DescriptionEntry extends AbstractEntry<'description'> {
6396
value: string;
6497
}
98+
99+
export interface EventEntry extends AbstractEntry<'event'> {
100+
name: string;
101+
arguments: Array<{
102+
name: string;
103+
type: string;
104+
description: string;
105+
rest: boolean;
106+
}>;
107+
}
65108

66-
export interface InheritAttrsEntry {
67-
kind: 'inheritAttrs'
109+
export interface InheritAttrsEntry extends AbstractEntry<'inheritAttrs'> {
68110
value: boolean;
69111
}
70112

71-
export interface KeywordsEntry {
72-
kind: 'keywords';
113+
export interface KeywordsEntry extends AbstractEntry<'keywords'> {
73114
value: Keyword[];
74115
}
116+
117+
export interface MethodEntry extends AbstractEntry<'method'> {
118+
name: string;
119+
syntax: string[];
120+
params: Array<{
121+
name: string;
122+
type: string;
123+
description: string;
124+
defaultValue: string;
125+
rest: boolean;
126+
}>;
127+
returns: {
128+
type: string;
129+
description?: string;
130+
};
131+
}
75132

76-
export interface ModelEntry {
77-
kind: 'model';
133+
export interface ModelEntry extends AbstractEntry<'model'> {
78134
prop: string;
79135
event: string;
80-
description?: string;
81-
keywords: Keyword[];
82136
}
83-
84-
export type Keyword = {
137+
138+
export interface NameEntry extends AbstractEntry<'name'> {
139+
value: string;
140+
}
141+
142+
export interface PropEntry extends AbstractEntry<'prop'> {
143+
type: string;
144+
name: string;
145+
default: string;
146+
required: boolean;
147+
describeModel: boolean;
148+
}
149+
150+
export interface SlotEntry extends AbstractEntry<'slot'> {
85151
name: string;
86152
description?: string;
87-
};
153+
props: Array<{
154+
name: string;
155+
type: string;
156+
description?: string;
157+
}>;
158+
}
88159
}

0 commit comments

Comments
 (0)