Skip to content

Commit 31744ec

Browse files
committed
Build | Infer Path
1 parent 288074e commit 31744ec

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/build/common/infer.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ function InferIdent(parser: Runtime.IIdent) {
4747
function InferInteger(parser: Runtime.IInteger) {
4848
return `string`
4949
}
50+
function InferNumber(parser: Runtime.INumber) {
51+
return `string`
52+
}
5053
function InferOptional(parser: Runtime.IParser) {
5154
return `([${Infer(parser)}] | [])`
5255
}
53-
function InferUnion(parsers: Runtime.IParser[]): string {
54-
return [...new Set(parsers.map((parser) => Infer(parser)))].join(' | ')
55-
}
5656
function InferString(parser: Runtime.IString) {
5757
return `string`
5858
}
@@ -62,12 +62,18 @@ function InferRef(parser: Runtime.IRef) {
6262
function InferRest(parser: Runtime.IRest) {
6363
return `string`
6464
}
65-
function InferNumber(parser: Runtime.INumber) {
66-
return `string`
67-
}
6865
function InferTuple(parsers: Runtime.IParser[]): string {
6966
return `[${parsers.map(() => 'unknown').join(', ')}]`
7067
}
68+
function InferUnion(parsers: Runtime.IParser[]): string {
69+
return [...new Set(parsers.map((parser) => Infer(parser)))].join(' | ')
70+
}
71+
function InferUnsignedInteger(parser: Runtime.IUnsignedInteger) {
72+
return `number`
73+
}
74+
function InferUnsignedNumber(parser: Runtime.IUnsignedNumber) {
75+
return `number`
76+
}
7177
function InferUntil_1(parser: Runtime.IUntil_1) {
7278
return `string`
7379
}
@@ -79,15 +85,17 @@ export function Infer(parser: Runtime.IParser): string {
7985
Runtime.IsArray(parser) ? InferArray(parser.parser) :
8086
Runtime.IsBigInt(parser) ? InferBigInt(parser) :
8187
Runtime.IsConst(parser) ? InferConst(parser) :
82-
Runtime.IsInteger(parser) ? InferInteger(parser) :
8388
Runtime.IsIdent(parser) ? InferIdent(parser) :
89+
Runtime.IsInteger(parser) ? InferInteger(parser) :
8490
Runtime.IsNumber(parser) ? InferNumber(parser) :
8591
Runtime.IsOptional(parser) ? InferOptional(parser.parser) :
8692
Runtime.IsRef(parser) ? InferRef(parser) :
8793
Runtime.IsRest(parser) ? InferRest(parser) :
8894
Runtime.IsString(parser) ? InferString(parser) :
8995
Runtime.IsTuple(parser) ? InferTuple(parser.parsers) :
9096
Runtime.IsUnion(parser) ? InferUnion(parser.parsers) :
97+
Runtime.IsUnsignedInteger(parser) ? InferUnsignedInteger(parser) :
98+
Runtime.IsUnsignedNumber(parser) ? InferUnsignedNumber(parser) :
9199
Runtime.IsUntil_1(parser) ? InferUntil_1(parser) :
92100
Runtime.IsUntil(parser) ? InferUntil(parser) :
93101
Unreachable(parser)

0 commit comments

Comments
 (0)