@litert/typeguard 1.0.1 → 1.3.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +16 -0
- package/lib/BuiltInTypeCompiler.d.ts +4 -4
- package/lib/BuiltInTypeCompiler.d.ts.map +1 -1
- package/lib/BuiltInTypeCompiler.js +167 -166
- package/lib/BuiltInTypeCompiler.js.map +1 -1
- package/lib/BuiltInTypes.d.ts +1 -1
- package/lib/BuiltInTypes.js +37 -36
- package/lib/BuiltInTypes.js.map +1 -1
- package/lib/Common.d.ts +27 -10
- package/lib/Common.d.ts.map +1 -1
- package/lib/Common.js +1 -1
- package/lib/Compiler.d.ts +2 -2
- package/lib/Compiler.d.ts.map +1 -1
- package/lib/Compiler.js +159 -102
- package/lib/Compiler.js.map +1 -1
- package/lib/Context.d.ts +6 -5
- package/lib/Context.d.ts.map +1 -1
- package/lib/Context.js +11 -7
- package/lib/Context.js.map +1 -1
- package/lib/FilterCompiler.d.ts +5 -5
- package/lib/FilterCompiler.d.ts.map +1 -1
- package/lib/FilterCompiler.js +25 -24
- package/lib/FilterCompiler.js.map +1 -1
- package/lib/InlineCompiler.d.ts +12 -5
- package/lib/InlineCompiler.d.ts.map +1 -1
- package/lib/InlineCompiler.js +18 -6
- package/lib/InlineCompiler.js.map +1 -1
- package/lib/Internal.d.ts +6 -4
- package/lib/Internal.d.ts.map +1 -1
- package/lib/Internal.js +12 -10
- package/lib/Internal.js.map +1 -1
- package/lib/Modifiers.d.ts +1 -1
- package/lib/Modifiers.js +2 -1
- package/lib/Modifiers.js.map +1 -1
- package/lib/index.d.ts +5 -5
- package/lib/index.js +19 -7
- package/lib/index.js.map +1 -1
- package/lib/langs/JavaScript.d.ts +2 -2
- package/lib/langs/JavaScript.d.ts.map +1 -1
- package/lib/langs/JavaScript.js +55 -29
- package/lib/langs/JavaScript.js.map +1 -1
- package/package.json +17 -13
- package/src/examples/quick-start.ts +172 -0
- package/src/lib/BuiltInTypeCompiler.ts +171 -171
- package/src/lib/BuiltInTypes.ts +36 -36
- package/src/lib/Common.ts +49 -10
- package/src/lib/Compiler.ts +354 -247
- package/src/lib/Context.ts +11 -13
- package/src/lib/FilterCompiler.ts +84 -84
- package/src/lib/InlineCompiler.ts +41 -15
- package/src/lib/Internal.ts +17 -13
- package/src/lib/Modifiers.ts +2 -2
- package/src/lib/index.ts +5 -5
- package/src/lib/langs/JavaScript.ts +84 -31
- package/src/test/00-all.ts +10 -10
- package/src/test/01-elemental-types.ts +1111 -1110
- package/src/test/02-array-and-list.ts +75 -75
- package/src/test/03-tuple.ts +87 -87
- package/src/test/04-from-string.ts +849 -848
- package/src/test/05-string-asserts.ts +422 -422
- package/src/test/06-structure.ts +107 -107
- package/src/test/07-modifiers.ts +151 -42
- package/src/test/08-map-and-dict.ts +46 -46
- package/src/test/09-exceptions.ts +30 -9
- package/src/test/abstracts.ts +83 -45
- package/dist/typeguard.amd.d.ts +0 -588
- package/dist/typeguard.amd.d.ts.map +0 -1
- package/dist/typeguard.amd.js +0 -2069
- package/dist/typeguard.amd.js.map +0 -1
- package/dist/typeguard.system.d.ts +0 -588
- package/dist/typeguard.system.d.ts.map +0 -1
- package/dist/typeguard.system.js +0 -2185
- package/dist/typeguard.system.js.map +0 -1
- package/src/samples/quick-start.ts +0 -52
- package/tsconfig-amd.json +0 -72
- package/tsconfig-systemjs.json +0 -72
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2022 Angus Fenying <fenying@litert.org>
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import * as C from
|
|
18
|
-
import * as I from
|
|
19
|
-
import * as B from
|
|
17
|
+
import * as C from './Common';
|
|
18
|
+
import * as I from './Internal';
|
|
19
|
+
import * as B from './BuiltInTypes';
|
|
20
20
|
|
|
21
21
|
interface ITypeInfo {
|
|
22
22
|
|
|
@@ -31,214 +31,214 @@ interface ITypeInfo {
|
|
|
31
31
|
|
|
32
32
|
const BUILT_IN_TYPES: Record<string, ITypeInfo> = {
|
|
33
33
|
[B.STRING]: {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
'kind': 'string',
|
|
35
|
+
'string': true,
|
|
36
|
+
'constructed': false,
|
|
37
|
+
'elemental': true
|
|
38
38
|
},
|
|
39
39
|
[B.ASCII_STRING]: {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
'kind': 'string',
|
|
41
|
+
'string': true,
|
|
42
|
+
'constructed': false,
|
|
43
|
+
'elemental': true
|
|
44
44
|
},
|
|
45
45
|
[B.HEX_STRING]: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
'kind': 'string',
|
|
47
|
+
'string': true,
|
|
48
|
+
'constructed': false,
|
|
49
|
+
'elemental': true
|
|
50
50
|
},
|
|
51
51
|
[B.LATIN_STRING]: {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
'kind': 'string',
|
|
53
|
+
'string': true,
|
|
54
|
+
'constructed': false,
|
|
55
|
+
'elemental': true
|
|
56
56
|
},
|
|
57
57
|
[B.NUMERIC]: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
'kind': 'number',
|
|
59
|
+
'string': true,
|
|
60
|
+
'constructed': false,
|
|
61
|
+
'elemental': true
|
|
62
62
|
},
|
|
63
63
|
[B.SAFE_INT]: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
'kind': 'number',
|
|
65
|
+
'string': false,
|
|
66
|
+
'constructed': false,
|
|
67
|
+
'elemental': true
|
|
68
68
|
},
|
|
69
69
|
[B.INT]: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
'kind': 'number',
|
|
71
|
+
'string': false,
|
|
72
|
+
'constructed': false,
|
|
73
|
+
'elemental': true
|
|
74
74
|
},
|
|
75
75
|
[B.INT8]: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
'kind': 'number',
|
|
77
|
+
'string': false,
|
|
78
|
+
'constructed': false,
|
|
79
|
+
'elemental': true
|
|
80
80
|
},
|
|
81
81
|
[B.INT16]: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
'kind': 'number',
|
|
83
|
+
'string': false,
|
|
84
|
+
'constructed': false,
|
|
85
|
+
'elemental': true
|
|
86
86
|
},
|
|
87
87
|
[B.INT32]: {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
'kind': 'number',
|
|
89
|
+
'string': false,
|
|
90
|
+
'constructed': false,
|
|
91
|
+
'elemental': true
|
|
92
92
|
},
|
|
93
93
|
[B.INT64]: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
'kind': 'number',
|
|
95
|
+
'string': false,
|
|
96
|
+
'constructed': false,
|
|
97
|
+
'elemental': true
|
|
98
98
|
},
|
|
99
99
|
[B.SAFE_UINT]: {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
'kind': 'number',
|
|
101
|
+
'string': false,
|
|
102
|
+
'constructed': false,
|
|
103
|
+
'elemental': true
|
|
104
104
|
},
|
|
105
105
|
[B.UINT]: {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
106
|
+
'kind': 'number',
|
|
107
|
+
'string': false,
|
|
108
|
+
'constructed': false,
|
|
109
|
+
'elemental': true
|
|
110
110
|
},
|
|
111
111
|
[B.UINT8]: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
'kind': 'number',
|
|
113
|
+
'string': false,
|
|
114
|
+
'constructed': false,
|
|
115
|
+
'elemental': true
|
|
116
116
|
},
|
|
117
117
|
[B.UINT16]: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
'kind': 'number',
|
|
119
|
+
'string': false,
|
|
120
|
+
'constructed': false,
|
|
121
|
+
'elemental': true
|
|
122
122
|
},
|
|
123
123
|
[B.UINT32]: {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
'kind': 'number',
|
|
125
|
+
'string': false,
|
|
126
|
+
'constructed': false,
|
|
127
|
+
'elemental': true
|
|
128
128
|
},
|
|
129
129
|
[B.UINT64]: {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
'kind': 'number',
|
|
131
|
+
'string': false,
|
|
132
|
+
'constructed': false,
|
|
133
|
+
'elemental': true
|
|
134
134
|
},
|
|
135
135
|
[B.BOOLEAN]: {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
'kind': 'boolean',
|
|
137
|
+
'string': false,
|
|
138
|
+
'constructed': false,
|
|
139
|
+
'elemental': true
|
|
140
140
|
},
|
|
141
141
|
[B.ARRAY]: {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
'kind': 'array',
|
|
143
|
+
'string': false,
|
|
144
|
+
'constructed': true,
|
|
145
|
+
'elemental': false
|
|
146
146
|
},
|
|
147
147
|
[B.ANY]: {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
148
|
+
'kind': 'unknown',
|
|
149
|
+
'string': false,
|
|
150
|
+
'constructed': false,
|
|
151
|
+
'elemental': false
|
|
152
152
|
},
|
|
153
153
|
[B.STRUCT]: {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
154
|
+
'kind': 'struct',
|
|
155
|
+
'string': false,
|
|
156
|
+
'constructed': true,
|
|
157
|
+
'elemental': false
|
|
158
158
|
},
|
|
159
159
|
[B.NULL]: {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
160
|
+
'kind': 'null',
|
|
161
|
+
'string': false,
|
|
162
|
+
'constructed': false,
|
|
163
|
+
'elemental': false
|
|
164
164
|
},
|
|
165
165
|
[B.UNDEFINED]: {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
'kind': 'void',
|
|
167
|
+
'string': false,
|
|
168
|
+
'constructed': false,
|
|
169
|
+
'elemental': false
|
|
170
170
|
},
|
|
171
171
|
[B.VOID]: {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
'kind': 'void',
|
|
173
|
+
'string': false,
|
|
174
|
+
'constructed': false,
|
|
175
|
+
'elemental': false
|
|
176
176
|
},
|
|
177
177
|
[B.FALSE]: {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
'kind': 'boolean',
|
|
179
|
+
'string': false,
|
|
180
|
+
'constructed': false,
|
|
181
|
+
'elemental': true
|
|
182
182
|
},
|
|
183
183
|
[B.TRUE]: {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
'kind': 'boolean',
|
|
185
|
+
'string': false,
|
|
186
|
+
'constructed': false,
|
|
187
|
+
'elemental': true
|
|
188
188
|
},
|
|
189
189
|
[B.FALSE_VALUE]: {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
'kind': 'unknown',
|
|
191
|
+
'string': false,
|
|
192
|
+
'constructed': false,
|
|
193
|
+
'elemental': false
|
|
194
194
|
},
|
|
195
195
|
[B.TRUE_VALUE]: {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
196
|
+
'kind': 'unknown',
|
|
197
|
+
'string': false,
|
|
198
|
+
'constructed': false,
|
|
199
|
+
'elemental': false
|
|
200
200
|
},
|
|
201
201
|
[B.OPTIONAL]: {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
'kind': 'void',
|
|
203
|
+
'string': false,
|
|
204
|
+
'constructed': false,
|
|
205
|
+
'elemental': false
|
|
206
206
|
},
|
|
207
207
|
[B.REQUIRED]: {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
208
|
+
'kind': 'unknown',
|
|
209
|
+
'string': false,
|
|
210
|
+
'constructed': false,
|
|
211
|
+
'elemental': false
|
|
212
212
|
},
|
|
213
213
|
[B.DECIMAL]: {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
'kind': 'number',
|
|
215
|
+
'string': true,
|
|
216
|
+
'constructed': false,
|
|
217
|
+
'elemental': true
|
|
218
218
|
},
|
|
219
219
|
[B.NUMBER]: {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
220
|
+
'kind': 'number',
|
|
221
|
+
'string': false,
|
|
222
|
+
'constructed': false,
|
|
223
|
+
'elemental': true
|
|
224
224
|
},
|
|
225
225
|
[B.FLOAT]: {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
'kind': 'number',
|
|
227
|
+
'string': false,
|
|
228
|
+
'constructed': false,
|
|
229
|
+
'elemental': true
|
|
230
230
|
},
|
|
231
231
|
[B.UDECIMAL]: {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
'kind': 'number',
|
|
233
|
+
'string': true,
|
|
234
|
+
'constructed': false,
|
|
235
|
+
'elemental': true
|
|
236
236
|
},
|
|
237
237
|
[B.UFLOAT]: {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
238
|
+
'kind': 'number',
|
|
239
|
+
'string': false,
|
|
240
|
+
'constructed': false,
|
|
241
|
+
'elemental': true
|
|
242
242
|
}
|
|
243
243
|
};
|
|
244
244
|
|
|
@@ -246,7 +246,7 @@ export class BuiltInTypeCompiler
|
|
|
246
246
|
implements I.IBuiltInTypeCompiler {
|
|
247
247
|
|
|
248
248
|
public constructor(
|
|
249
|
-
private _lang: C.ILanguageBuilder
|
|
249
|
+
private readonly _lang: C.ILanguageBuilder
|
|
250
250
|
) {}
|
|
251
251
|
|
|
252
252
|
public isStringType(type: string): boolean {
|
|
@@ -273,10 +273,10 @@ implements I.IBuiltInTypeCompiler {
|
|
|
273
273
|
|
|
274
274
|
const fromString = !!(ctx.flags[I.EFlags.FROM_STRING] &&
|
|
275
275
|
this.isBuiltInType(type) && (
|
|
276
|
-
|
|
277
|
-
BUILT_IN_TYPES[type].kind ===
|
|
278
|
-
BUILT_IN_TYPES[type].kind ===
|
|
279
|
-
|
|
276
|
+
BUILT_IN_TYPES[type].kind === 'number' ||
|
|
277
|
+
BUILT_IN_TYPES[type].kind === 'boolean' ||
|
|
278
|
+
BUILT_IN_TYPES[type].kind === 'null'
|
|
279
|
+
));
|
|
280
280
|
|
|
281
281
|
switch (type) {
|
|
282
282
|
|
|
@@ -288,7 +288,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
288
288
|
this._lang.isNull(ctx.vName, true),
|
|
289
289
|
this._lang.eq(
|
|
290
290
|
ctx.vName,
|
|
291
|
-
this._lang.literal(
|
|
291
|
+
this._lang.literal('null')
|
|
292
292
|
)
|
|
293
293
|
]);
|
|
294
294
|
}
|
|
@@ -312,7 +312,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
312
312
|
return this._isString(
|
|
313
313
|
ctx,
|
|
314
314
|
args,
|
|
315
|
-
|
|
315
|
+
'[\\u0000-\\u007F]'
|
|
316
316
|
);
|
|
317
317
|
}
|
|
318
318
|
case B.LATIN_STRING: {
|
|
@@ -320,12 +320,12 @@ implements I.IBuiltInTypeCompiler {
|
|
|
320
320
|
return this._isString(
|
|
321
321
|
ctx,
|
|
322
322
|
args,
|
|
323
|
-
|
|
323
|
+
'[\\u0000-\\u024F\\u2C60-\\u2C7F]'
|
|
324
324
|
);
|
|
325
325
|
}
|
|
326
326
|
case B.HEX_STRING: {
|
|
327
327
|
|
|
328
|
-
return this._isString(ctx, args,
|
|
328
|
+
return this._isString(ctx, args, '[0-9A-Fa-f]');
|
|
329
329
|
}
|
|
330
330
|
case B.UFLOAT: {
|
|
331
331
|
|
|
@@ -469,7 +469,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
469
469
|
if (ctx.flags[I.EFlags.REQUIRED]) {
|
|
470
470
|
|
|
471
471
|
throw new Error(
|
|
472
|
-
|
|
472
|
+
'Conflicted: Can not use "optional" with "required" type.'
|
|
473
473
|
);
|
|
474
474
|
}
|
|
475
475
|
|
|
@@ -487,7 +487,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
487
487
|
if (ctx.flags[I.EFlags.OPTIONAL]) {
|
|
488
488
|
|
|
489
489
|
throw new Error(
|
|
490
|
-
|
|
490
|
+
'Conflicted: Can not use "required" with "optional" type.'
|
|
491
491
|
);
|
|
492
492
|
}
|
|
493
493
|
|
|
@@ -530,10 +530,10 @@ implements I.IBuiltInTypeCompiler {
|
|
|
530
530
|
|
|
531
531
|
if (params[0] <= 0) {
|
|
532
532
|
|
|
533
|
-
throw new RangeError(
|
|
533
|
+
throw new RangeError('Arg 0 can not be zero for decimal.');
|
|
534
534
|
}
|
|
535
535
|
|
|
536
|
-
const sign = unsigned ?
|
|
536
|
+
const sign = unsigned ? '' : '[-+]?';
|
|
537
537
|
switch (params.length) {
|
|
538
538
|
|
|
539
539
|
default:
|
|
@@ -557,7 +557,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
557
557
|
`^${sign}([1-9]\\d*|0)(\\.\\d+)?$`
|
|
558
558
|
),
|
|
559
559
|
this._lang.ifElseOp(
|
|
560
|
-
this._lang.instr(ctx.vName, this._lang.literal(
|
|
560
|
+
this._lang.instr(ctx.vName, this._lang.literal('.')),
|
|
561
561
|
this._lang.lte(
|
|
562
562
|
this._lang.stringLength(ctx.vName),
|
|
563
563
|
params[0] + 1
|
|
@@ -574,7 +574,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
574
574
|
|
|
575
575
|
if (params[0] < params[1]) {
|
|
576
576
|
|
|
577
|
-
throw new RangeError(
|
|
577
|
+
throw new RangeError('Arg 0 should not be larger than arg 1 for decimal.');
|
|
578
578
|
}
|
|
579
579
|
|
|
580
580
|
if (params[1] === 0) {
|
|
@@ -654,7 +654,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
654
654
|
if (params[0] > params[1]) {
|
|
655
655
|
|
|
656
656
|
throw new RangeError(
|
|
657
|
-
|
|
657
|
+
'Arg 0 should not be larger than arg 1 for array.'
|
|
658
658
|
);
|
|
659
659
|
}
|
|
660
660
|
|
|
@@ -691,7 +691,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
691
691
|
this._lang.isString(ctx.vName, true),
|
|
692
692
|
this._lang.matchRegExp(
|
|
693
693
|
ctx.vName,
|
|
694
|
-
|
|
694
|
+
'^[-+]?\\d+(\\.\\d+)?$'
|
|
695
695
|
)
|
|
696
696
|
]));
|
|
697
697
|
}
|
|
@@ -720,7 +720,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
720
720
|
|
|
721
721
|
if (params[0] > params[1]) {
|
|
722
722
|
|
|
723
|
-
throw new RangeError(
|
|
723
|
+
throw new RangeError('Arg 0 should not be larger than arg 1 for number.');
|
|
724
724
|
}
|
|
725
725
|
|
|
726
726
|
result.push(this._lang.lte(
|
|
@@ -732,7 +732,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
732
732
|
if (result.length === 1) {
|
|
733
733
|
|
|
734
734
|
throw new SyntaxError(
|
|
735
|
-
|
|
735
|
+
'Invalid syntax of integer.'
|
|
736
736
|
);
|
|
737
737
|
}
|
|
738
738
|
|
|
@@ -747,7 +747,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
747
747
|
this._lang.isString(ctx.vName, true),
|
|
748
748
|
this._lang.matchRegExp(
|
|
749
749
|
ctx.vName,
|
|
750
|
-
|
|
750
|
+
'^[-+]?\\d+(\\.\\d+)?$'
|
|
751
751
|
)
|
|
752
752
|
])
|
|
753
753
|
]),
|
|
@@ -783,7 +783,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
783
783
|
|
|
784
784
|
private _checkValidInteger(v: number | string, msg: string): boolean {
|
|
785
785
|
|
|
786
|
-
if (typeof v ===
|
|
786
|
+
if (typeof v === 'string') {
|
|
787
787
|
|
|
788
788
|
v = parseFloat(v);
|
|
789
789
|
}
|
|
@@ -836,7 +836,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
836
836
|
this._lang.isString(ctx.vName, true),
|
|
837
837
|
this._lang.matchRegExp(
|
|
838
838
|
ctx.vName,
|
|
839
|
-
|
|
839
|
+
'^[-+]?\\d+$'
|
|
840
840
|
)
|
|
841
841
|
]));
|
|
842
842
|
}
|
|
@@ -872,7 +872,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
872
872
|
if (params[0] > params[1]) {
|
|
873
873
|
|
|
874
874
|
throw new RangeError(
|
|
875
|
-
|
|
875
|
+
'Arg 0 should not be larger than arg 1 for number.'
|
|
876
876
|
);
|
|
877
877
|
}
|
|
878
878
|
|
|
@@ -885,7 +885,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
885
885
|
if (result.length === 1) {
|
|
886
886
|
|
|
887
887
|
throw new SyntaxError(
|
|
888
|
-
|
|
888
|
+
'Invalid syntax of integer.'
|
|
889
889
|
);
|
|
890
890
|
}
|
|
891
891
|
|
|
@@ -900,7 +900,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
900
900
|
this._lang.isString(ctx.vName, true),
|
|
901
901
|
this._lang.matchRegExp(
|
|
902
902
|
ctx.vName,
|
|
903
|
-
|
|
903
|
+
'^[-+]?\\d+$'
|
|
904
904
|
)
|
|
905
905
|
])
|
|
906
906
|
]),
|
|
@@ -980,7 +980,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
980
980
|
if (params[0] > params[1]) {
|
|
981
981
|
|
|
982
982
|
throw new RangeError(
|
|
983
|
-
|
|
983
|
+
'Arg 0 should not be larger than arg 1 for string.'
|
|
984
984
|
);
|
|
985
985
|
}
|
|
986
986
|
|
|
@@ -1007,7 +1007,7 @@ implements I.IBuiltInTypeCompiler {
|
|
|
1007
1007
|
if (params[0] > params[1]) {
|
|
1008
1008
|
|
|
1009
1009
|
throw new RangeError(
|
|
1010
|
-
|
|
1010
|
+
'Arg 0 should not be larger than arg 1 for string.'
|
|
1011
1011
|
);
|
|
1012
1012
|
}
|
|
1013
1013
|
|