A
arktypeβ€’7mo ago
dion

Need help understanding this error

[0] ParseError: Alias 'type200' has a shallow resolution cycle: type200->type200 [0] at throwError (file:///workspaces/node_modules/.pnpm/@ark+util@0.45.7/node_modules/@ark/util/out/errors.js:5:11) [0] at throwParseError (file:///workspaces/node_modules/.pnpm/@ark+util@0.45.7/node_modules/@ark/util/out/errors.js:10:43) [0] at AliasNode._resolve (file:///workspaces/node_modules/.pnpm/@ark+schema@0.45.7/node_modules/@ark/schema/out/roots/alias.js:59:24) [0] at get resolution (file:///workspaces/node_modules/.pnpm/@ark+schema@0.45.7/node_modules/@ark/schema/out/roots/alias.js:46:29) [0] at file:///workspaces/node_modules/.pnpm/@ark+schema@0.45.7/node_modules/@ark/schema/out/scope.js:407:59 [0] at Array.forEach (<anonymous>) [0] at bootstrapAliasReferences (file:///workspaces/node_modules/.pnpm/@ark+schema@0.45.7/node_modules/@ark/schema/out/scope.js:406:10) [0] at InternalScope.finalize (file:///workspaces/node_modules/.pnpm/@ark+schema@0.45.7/node_modules/@ark/schema/out/scope.js:383:9) [0] at InternalScope.schema (file:///workspaces/node_modules/.pnpm/@ark+schema@0.45.7/node_modules/@ark/schema/out/scope.js:185:37) [0] at AliasNode.array (file:///workspaces/node_modules/.pnpm/@ark+schema@0.45.7/node_modules/@ark/schema/out/roots/root.js:163:23) I'm not sure where this is coming from,. or which definition this is happening on. ANy idea what this might be?
6 Replies
πŸŒΊπŸ‡«πŸ‡· Shigu :3 🌺
It would be helpful to also provide the code which is causing this. If you can't find it using the stack trace, try setting Error.stackTraceLimit to Infinity before running the code.
dion
dionOPβ€’7mo ago
Ah didnt know i could do that. Here's the full schema:
export const ApprovalConfigStepNodeValidator = type({
id: 'string.uuid',
name: 'string',
teams_that_can_approve: 'string.uuid[]',
description: 'string?',
conditions: ConditionValidator,
nextSteps: 'this[]'
});
export type TApprovalConfigStepNode = typeof ApprovalConfigStepNodeValidator.infer;

export const ConditionValidator = type
.or(AtomicConditionSchema, CompositeConditionSchema)
.array()
.or('boolean');

const ConditionOperatorSchema = type.or(
"'eq'",
"'neq'",
"'gt'",
"'gte'",
"'lt'",
"'lte'",
"'like'",
"'nlike'",
"'ilike'",
"'nilike'",
"'in'",
"'nin'",
"'isnull'",
"'notnull'",
"'cs'",
"'cd'",
"'ov'",
"'fts'",
"'plfts'",
"'phfts'",
"'wfts'",
"'is'",
"'isnot'",
"'similar'",
"'nsimilar'",
"'between'",
"'nbetween'"
);
export const { AtomicConditionSchema, CompositeConditionSchema } = scope({
AtomicConditionSchema: {
field: 'string',
operator: ConditionOperatorSchema,
qualifiers: "('some' | 'every')?",
aggregation: "('count' | 'sum' | 'avg' | 'min' | 'max')?",
value: 'unknown'
},
CompositeConditionSchema: {
operator: "'or' | 'and'",
value: '(CompositeConditionSchema | AtomicConditionSchema)[]'
}
}).export();
export const ApprovalConfigStepNodeValidator = type({
id: 'string.uuid',
name: 'string',
teams_that_can_approve: 'string.uuid[]',
description: 'string?',
conditions: ConditionValidator,
nextSteps: 'this[]'
});
export type TApprovalConfigStepNode = typeof ApprovalConfigStepNodeValidator.infer;

export const ConditionValidator = type
.or(AtomicConditionSchema, CompositeConditionSchema)
.array()
.or('boolean');

const ConditionOperatorSchema = type.or(
"'eq'",
"'neq'",
"'gt'",
"'gte'",
"'lt'",
"'lte'",
"'like'",
"'nlike'",
"'ilike'",
"'nilike'",
"'in'",
"'nin'",
"'isnull'",
"'notnull'",
"'cs'",
"'cd'",
"'ov'",
"'fts'",
"'plfts'",
"'phfts'",
"'wfts'",
"'is'",
"'isnot'",
"'similar'",
"'nsimilar'",
"'between'",
"'nbetween'"
);
export const { AtomicConditionSchema, CompositeConditionSchema } = scope({
AtomicConditionSchema: {
field: 'string',
operator: ConditionOperatorSchema,
qualifiers: "('some' | 'every')?",
aggregation: "('count' | 'sum' | 'avg' | 'min' | 'max')?",
value: 'unknown'
},
CompositeConditionSchema: {
operator: "'or' | 'and'",
value: '(CompositeConditionSchema | AtomicConditionSchema)[]'
}
}).export();
There are not type errors in the above definition. Not sure if im defining the recursive structures correctly tho
dion
dionOPβ€’7mo ago
I have attatched the link to the playground here (It's too long)
dion
dionOPβ€’7mo ago
Think the exact cause is because of this:
this[]
this[]
Anyone know why this happens? Or is it a bug? Changing it to:
export const ApprovalConfigStepNodeValidator = type({
id: 'string.uuid',
name: 'string',
teams_that_can_approve: 'string.uuid[]',
description: 'string?',
conditions: ConditionValidator,
nextSteps: type('this').array().optional()
});
export const ApprovalConfigStepNodeValidator = type({
id: 'string.uuid',
name: 'string',
teams_that_can_approve: 'string.uuid[]',
description: 'string?',
conditions: ConditionValidator,
nextSteps: type('this').array().optional()
});
Resolves this issue. However, it's giving me back:
Type instantiation is excessively deep and possibly infinite.ts(2589)
Type instantiation is excessively deep and possibly infinite.ts(2589)
Error
ssalbdivad
ssalbdivadβ€’7mo ago
Looks like there is an issue with this[] I created an issue to track it: https://github.com/arktypeio/arktype/issues/1406
dion
dionOPβ€’7mo ago
nice thanks!

Did you find this page helpful?