-
Notifications
You must be signed in to change notification settings - Fork 1
/
types-as-schema.math.ts
34 lines (32 loc) · 1.09 KB
/
types-as-schema.math.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Configuration } from 'types-as-schema'
const config: Configuration = {
files: [
'./node_modules/typescript/lib/lib.es5.d.ts',
'./node_modules/typescript/lib/lib.es2015.core.d.ts',
],
plugins: [
(typeDeclarations) => {
const result: { name: string, comment?: string, parameters?: { name: string, comment?: string, optional?: boolean }[] }[] = []
for (const math of typeDeclarations.filter(t => t.name === 'Math')) {
if (math.kind === 'object') {
for (const member of math.members) {
result.push({
name: member.name,
comment: member.jsDocs?.find(d => d.name === '')?.comment,
parameters: member.parameters?.map(p => ({
name: p.name,
comment: p.comments?.[0],
optional: p.optional,
}))
})
}
}
}
return [{
path: './dev/expression/math.ts',
content: `export const math = ` + JSON.stringify([{ name: 'Math', members: result }], null, 2) + '',
}]
},
],
}
export default config