Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit d8f8b82

Browse files
committed
Add delays extractor to the options extractor
1 parent cbade56 commit d8f8b82

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/xstate-compiled/src/extractor.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ const string = (literals?: string[]): TypeExtractor => ({
182182
return [true, undefined];
183183
},
184184
});
185+
const number = (): TypeExtractor => ({
186+
extract(type: Type | undefined) {
187+
if (!type?.isNumber()) {
188+
return [true, undefined];
189+
}
190+
// provide a dummy value since for numbers we don't need to extract literals right now
191+
return [false, 10, true];
192+
},
193+
});
185194

186195
const func = (): TypeExtractor => ({
187196
extract(type: Type | undefined) {
@@ -285,6 +294,11 @@ const Options = optional(
285294
[indexer]: match([func(), Action()]),
286295
}),
287296
),
297+
delays: optional(
298+
object({
299+
[indexer]: match([func(), number()]),
300+
}),
301+
),
288302
guards: optional(
289303
object({
290304
[indexer]: func(),
@@ -307,6 +321,7 @@ export const extractSchema = (type: Type) => {
307321
};
308322

309323
export const extractOptions = (type: Type) => {
324+
debugger;
310325
const [error, options] = Options.extract(type);
311326
if (error) {
312327
throw new Error('Could not extract options');

0 commit comments

Comments
 (0)