arktype 2.0.0-dev.6 → 2.0.0-dev.8

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.
Files changed (98) hide show
  1. package/__tests__/array.test.ts +23 -25
  2. package/__tests__/config.test.ts +8 -8
  3. package/__tests__/cyclic.test.ts +3 -3
  4. package/__tests__/examples.test.ts +3 -3
  5. package/__tests__/instanceof.test.ts +7 -7
  6. package/__tests__/intersection.test.ts +2 -2
  7. package/__tests__/keyTraversal.test.ts +15 -15
  8. package/__tests__/keywords.test.ts +50 -37
  9. package/__tests__/literal.test.ts +2 -2
  10. package/__tests__/match.bench.ts +6 -6
  11. package/__tests__/narrow.test.ts +17 -23
  12. package/__tests__/objectLiteral.test.ts +4 -4
  13. package/__tests__/operator.bench.ts +4 -4
  14. package/__tests__/{morph.test.ts → pipe.test.ts} +136 -75
  15. package/__tests__/scope.test.ts +5 -15
  16. package/__tests__/traverse.test.ts +36 -35
  17. package/__tests__/type.test.ts +8 -10
  18. package/ark.ts +14 -11
  19. package/generic.ts +8 -6
  20. package/main.ts +3 -3
  21. package/match.ts +59 -70
  22. package/out/ark.d.ts +4 -3
  23. package/out/ark.d.ts.map +1 -1
  24. package/out/ark.js +4 -4
  25. package/out/ark.js.map +1 -1
  26. package/out/generic.d.ts.map +1 -1
  27. package/out/generic.js +8 -6
  28. package/out/generic.js.map +1 -1
  29. package/out/main.d.ts +3 -3
  30. package/out/main.d.ts.map +1 -1
  31. package/out/main.js +3 -2
  32. package/out/main.js.map +1 -1
  33. package/out/match.d.ts.map +1 -1
  34. package/out/match.js +50 -56
  35. package/out/match.js.map +1 -1
  36. package/out/parser/generic.d.ts +3 -3
  37. package/out/parser/generic.d.ts.map +1 -1
  38. package/out/parser/generic.js +4 -5
  39. package/out/parser/generic.js.map +1 -1
  40. package/out/parser/objectLiteral.d.ts.map +1 -1
  41. package/out/parser/objectLiteral.js +2 -3
  42. package/out/parser/objectLiteral.js.map +1 -1
  43. package/out/parser/semantic/validate.d.ts +2 -2
  44. package/out/parser/semantic/validate.d.ts.map +1 -1
  45. package/out/parser/semantic/validate.js.map +1 -1
  46. package/out/parser/string/reduce/dynamic.d.ts.map +1 -1
  47. package/out/parser/string/reduce/dynamic.js +4 -8
  48. package/out/parser/string/reduce/dynamic.js.map +1 -1
  49. package/out/parser/string/shift/operand/date.js +2 -4
  50. package/out/parser/string/shift/operand/date.js.map +1 -1
  51. package/out/parser/string/shift/operand/enclosed.js +6 -8
  52. package/out/parser/string/shift/operand/enclosed.js.map +1 -1
  53. package/out/parser/string/shift/operand/genericArgs.d.ts +4 -4
  54. package/out/parser/string/shift/operand/genericArgs.js +4 -5
  55. package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
  56. package/out/parser/string/shift/operand/unenclosed.d.ts +4 -4
  57. package/out/parser/string/shift/operand/unenclosed.d.ts.map +1 -1
  58. package/out/parser/string/shift/operand/unenclosed.js +5 -10
  59. package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
  60. package/out/parser/string/shift/operator/bounds.d.ts.map +1 -1
  61. package/out/parser/string/shift/operator/bounds.js +4 -8
  62. package/out/parser/string/shift/operator/bounds.js.map +1 -1
  63. package/out/parser/string/shift/operator/divisor.d.ts.map +1 -1
  64. package/out/parser/string/shift/operator/divisor.js +1 -2
  65. package/out/parser/string/shift/operator/divisor.js.map +1 -1
  66. package/out/parser/string/shift/scanner.d.ts.map +1 -1
  67. package/out/parser/string/shift/scanner.js +2 -4
  68. package/out/parser/string/shift/scanner.js.map +1 -1
  69. package/out/parser/string/string.d.ts.map +1 -1
  70. package/out/parser/string/string.js +1 -2
  71. package/out/parser/string/string.js.map +1 -1
  72. package/out/parser/tuple.d.ts.map +1 -1
  73. package/out/parser/tuple.js +12 -15
  74. package/out/parser/tuple.js.map +1 -1
  75. package/out/scope.d.ts +9 -9
  76. package/out/scope.d.ts.map +1 -1
  77. package/out/scope.js +11 -33
  78. package/out/scope.js.map +1 -1
  79. package/out/type.d.ts +38 -18
  80. package/out/type.d.ts.map +1 -1
  81. package/out/type.js +32 -1
  82. package/out/type.js.map +1 -1
  83. package/package.json +3 -3
  84. package/parser/generic.ts +11 -12
  85. package/parser/objectLiteral.ts +2 -4
  86. package/parser/semantic/validate.ts +2 -3
  87. package/parser/string/reduce/dynamic.ts +7 -10
  88. package/parser/string/shift/operand/date.ts +3 -6
  89. package/parser/string/shift/operand/enclosed.ts +8 -8
  90. package/parser/string/shift/operand/genericArgs.ts +8 -8
  91. package/parser/string/shift/operand/unenclosed.ts +14 -23
  92. package/parser/string/shift/operator/bounds.ts +7 -9
  93. package/parser/string/shift/operator/divisor.ts +2 -3
  94. package/parser/string/shift/scanner.ts +2 -4
  95. package/parser/string/string.ts +2 -3
  96. package/parser/tuple.ts +15 -16
  97. package/scope.ts +24 -48
  98. package/type.ts +150 -35
package/parser/tuple.ts CHANGED
@@ -53,34 +53,33 @@ export const parseTupleLiteral = (def: array, ctx: ParseContext): RawSchema => {
53
53
 
54
54
  i++
55
55
  if (def[i] === "?") {
56
- if (spread) {
57
- return throwParseError(spreadOptionalMessage)
58
- }
56
+ if (spread) return throwParseError(spreadOptionalMessage)
57
+
59
58
  optional = true
60
59
  i++
61
60
  }
62
61
  if (spread) {
63
- if (!element.extends(jsObjects.Array)) {
62
+ if (!element.extends(jsObjects.Array))
64
63
  return throwParseError(writeNonArraySpreadMessage(element.expression))
65
- }
64
+
66
65
  // a spread must be distributed over branches e.g.:
67
66
  // def: [string, ...(number[] | [true, false])]
68
67
  // nodes: [string, ...number[]] | [string, true, false]
69
- sequences = sequences.flatMap((base) =>
68
+ sequences = sequences.flatMap(base =>
70
69
  // since appendElement mutates base, we have to shallow-ish clone it for each branch
71
- element.branches.map((branch) =>
70
+ element.branches.map(branch =>
72
71
  appendSpreadBranch(makeRootAndArrayPropertiesMutable(base), branch)
73
72
  )
74
73
  )
75
74
  } else {
76
- sequences = sequences.map((base) =>
75
+ sequences = sequences.map(base =>
77
76
  appendElement(base, optional ? "optional" : "required", element)
78
77
  )
79
78
  }
80
79
  }
81
80
  return ctx.$.raw.schema(
82
81
  sequences.map(
83
- (sequence) =>
82
+ sequence =>
84
83
  ({
85
84
  proto: Array,
86
85
  sequence
@@ -143,10 +142,10 @@ const appendSpreadBranch = (
143
142
  // the only array with no sequence reference is unknown[]
144
143
  return appendElement(base, "variadic", tsKeywords.unknown)
145
144
  }
146
- spread.prefix.forEach((node) => appendElement(base, "required", node))
147
- spread.optional.forEach((node) => appendElement(base, "optional", node))
145
+ spread.prefix.forEach(node => appendElement(base, "required", node))
146
+ spread.optional.forEach(node => appendElement(base, "optional", node))
148
147
  spread.variadic && appendElement(base, "variadic", spread.variadic)
149
- spread.postfix.forEach((node) => appendElement(base, "required", node))
148
+ spread.postfix.forEach(node => appendElement(base, "required", node))
150
149
  return base
151
150
  }
152
151
 
@@ -414,9 +413,9 @@ export type inferKeyOfExpression<operandDef, $, args> = show<
414
413
  >
415
414
 
416
415
  const parseBranchTuple: PostfixParser<"|" | "&"> = (def, ctx) => {
417
- if (def[2] === undefined) {
416
+ if (def[2] === undefined)
418
417
  return throwParseError(writeMissingRightOperandMessage(def[1], ""))
419
- }
418
+
420
419
  const l = ctx.$.parse(def[0], ctx)
421
420
  const r = ctx.$.parse(def[2], ctx)
422
421
  return def[1] === "&" ? l.and(r) : l.or(r)
@@ -459,7 +458,7 @@ export const parseMorphTuple: PostfixParser<"=>"> = (def, ctx) => {
459
458
  )
460
459
  }
461
460
  // TODO: nested morphs?
462
- return ctx.$.parse(def[0], ctx).morph(def[2] as Morph)
461
+ return ctx.$.parse(def[0], ctx).pipe(def[2] as Morph)
463
462
  }
464
463
 
465
464
  export const writeMalformedFunctionalExpressionMessage = (
@@ -518,7 +517,7 @@ const prefixParsers: {
518
517
  }
519
518
  const branches = def
520
519
  .slice(1)
521
- .map((ctor) =>
520
+ .map(ctor =>
522
521
  typeof ctor === "function" ?
523
522
  ctx.$.node("proto", { proto: ctor as Constructor })
524
523
  : throwParseError(
package/scope.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  type ArkConfig,
3
3
  type GenericProps,
4
+ type NodeParseContext,
4
5
  type NodeParseOptions,
5
6
  type PreparsedNodeResolution,
6
7
  type RawSchema,
@@ -18,6 +19,7 @@ import {
18
19
  type Dict,
19
20
  domainOf,
20
21
  hasDomain,
22
+ type isAnyOrNever,
21
23
  isThunk,
22
24
  type nominal,
23
25
  type show,
@@ -40,11 +42,12 @@ import {
40
42
  } from "./parser/generic.js"
41
43
  import { DynamicState } from "./parser/string/reduce/dynamic.js"
42
44
  import { fullStringParse } from "./parser/string/string.js"
43
- import type {
44
- DeclarationParser,
45
- DefinitionParser,
46
- Type,
47
- TypeParser
45
+ import {
46
+ type DeclarationParser,
47
+ type DefinitionParser,
48
+ RawTypeParser,
49
+ type Type,
50
+ type TypeParser
48
51
  } from "./type.js"
49
52
 
50
53
  export type ScopeParser = <const def>(
@@ -126,12 +129,9 @@ export type resolve<reference extends keyof $ | keyof args, $, args> =
126
129
  args[reference]
127
130
  : $[reference & keyof $]
128
131
  ) extends infer resolution ?
129
- resolution extends Def<infer def> ?
130
- def extends null ?
131
- // handle resolution of any and never
132
- resolution
133
- : inferDefinition<def, $, args>
134
- : resolution
132
+ isAnyOrNever<resolution> extends true ? resolution
133
+ : resolution extends Def<infer def> ? inferDefinition<def, $, args>
134
+ : resolution
135
135
  : never
136
136
 
137
137
  export type moduleKeyOf<$> = {
@@ -148,7 +148,7 @@ export type tryInferSubmoduleReference<$, token> =
148
148
  : never
149
149
  : never
150
150
 
151
- export interface ParseContext extends NodeParseOptions {
151
+ export interface ParseContext extends NodeParseContext {
152
152
  $: RawScope
153
153
  }
154
154
 
@@ -191,65 +191,41 @@ export class RawScope<
191
191
  super(aliases, config)
192
192
  }
193
193
 
194
- type(...args: unknown[]): RawSchema | Generic {
195
- if (args.length === 1) {
196
- // treat as a simple definition
197
- return this.parseRoot(args[0])
198
- }
199
- if (
200
- args.length === 2 &&
201
- typeof args[0] === "string" &&
202
- args[0][0] === "<" &&
203
- args[0].at(-1) === ">"
204
- ) {
205
- // if there are exactly two args, the first of which looks like <${string}>,
206
- // treat as a generic
207
- const params = parseGenericParams(args[0].slice(1, -1))
208
- const def = args[1]
209
- // TODO: validateUninstantiatedGeneric, remove this cast
210
- return new Generic(params, def, this as never) as never
211
- }
212
- // otherwise, treat as a tuple expression. technically, this also allows
213
- // non-expression tuple definitions to be parsed, but it's not a supported
214
- // part of the API as specified by the associated types
215
- return this.parseRoot(args)
216
- }
194
+ type = new RawTypeParser(this as never)
217
195
 
218
196
  match: MatchParser<$> = createMatchParser(this as never) as never
219
197
 
220
- declare(): { type: RawScope["type"] } {
221
- return { type: this.type.bind(this) }
222
- }
198
+ declare = (() => ({
199
+ type: this.type
200
+ })).bind(this)
223
201
 
224
- define(def: unknown): unknown {
225
- return def
226
- }
202
+ define = ((def: unknown) => def).bind(this)
227
203
 
228
204
  override preparseRoot(def: unknown): unknown {
229
- if (isThunk(def) && !hasArkKind(def, "generic")) {
230
- return def()
231
- }
205
+ if (isThunk(def) && !hasArkKind(def, "generic")) return def()
206
+
232
207
  return def
233
208
  }
234
209
 
235
210
  override parseRoot(def: unknown, opts?: NodeParseOptions): RawSchema {
211
+ // args: { this: {} as RawSchema },
236
212
  return this.parse(def, {
237
- args: { this: {} as RawSchema },
238
213
  $: this as never,
214
+ raw: def,
239
215
  ...opts
240
216
  }).bindScope(this)
241
217
  }
242
218
 
243
219
  parse(def: unknown, ctx: ParseContext): RawSchema {
244
220
  if (typeof def === "string") {
245
- if (ctx.args && Object.keys(ctx.args).every((k) => !def.includes(k))) {
221
+ if (ctx.args && Object.keys(ctx.args).every(k => !def.includes(k))) {
246
222
  // we can only rely on the cache if there are no contextual
247
223
  // resolutions like "this" or generic args
248
224
  return this.parseString(def, ctx)
249
225
  }
250
- if (!this.parseCache[def]) {
226
+ if (!this.parseCache[def])
251
227
  this.parseCache[def] = this.parseString(def, ctx)
252
- }
228
+
253
229
  return this.parseCache[def]
254
230
  }
255
231
  return hasDomain(def, "object") ?
package/type.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import {
2
+ ArkErrors,
2
3
  type BaseMeta,
4
+ type BaseRoot,
5
+ type Disjoint,
3
6
  type Morph,
4
7
  type NodeDef,
5
8
  type Out,
@@ -10,31 +13,40 @@ import {
10
13
  type ambient,
11
14
  type constrain,
12
15
  type constraintKindOf,
13
- type distillConstrainableIn,
14
16
  type distillConstrainableOut,
15
17
  type distillIn,
16
18
  type distillOut,
17
19
  type includesMorphs,
18
20
  type inferIntersection,
19
21
  type inferMorphOut,
20
- type inferNarrow
22
+ type inferNarrow,
23
+ type inferPipes,
24
+ type internalImplementationOf
21
25
  } from "@arktype/schema"
22
- import type { Constructor, array, conform } from "@arktype/util"
23
- import type { Generic, validateParameterString } from "./generic.js"
26
+ import {
27
+ Callable,
28
+ type Constructor,
29
+ type array,
30
+ type conform
31
+ } from "@arktype/util"
32
+ import { Generic, type validateParameterString } from "./generic.js"
24
33
  import type {
25
34
  inferDefinition,
26
35
  validateDeclared,
27
36
  validateDefinition
28
37
  } from "./parser/definition.js"
29
- import type { parseGenericParams } from "./parser/generic.js"
38
+ import { parseGenericParams } from "./parser/generic.js"
30
39
  import type {
31
40
  IndexOneOperator,
32
41
  IndexZeroOperator,
33
42
  TupleInfixOperator
34
43
  } from "./parser/tuple.js"
35
- import type { Scope, bindThis } from "./scope.js"
44
+ import type { RawScope, Scope, bindThis } from "./scope.js"
45
+ export interface TypeParserAttachments {
46
+ errors: typeof ArkErrors
47
+ }
36
48
 
37
- export type TypeParser<$> = {
49
+ export interface TypeParser<$> extends TypeParserAttachments {
38
50
  // Parse and check the definition, returning either the original input for a
39
51
  // valid definition or a string representing an error message.
40
52
  <const def>(def: validateTypeRoot<def, $>): Type<inferTypeRoot<def, $>, $>
@@ -68,6 +80,44 @@ export type TypeParser<$> = {
68
80
  ): Generic<parseGenericParams<params>, def, $>
69
81
  }
70
82
 
83
+ const typeParserAttachments = Object.freeze({
84
+ errors: ArkErrors
85
+ } satisfies TypeParserAttachments)
86
+
87
+ export class RawTypeParser extends Callable<
88
+ (...args: unknown[]) => RawSchema | Generic,
89
+ TypeParserAttachments
90
+ > {
91
+ constructor($: RawScope) {
92
+ super(
93
+ (...args) => {
94
+ if (args.length === 1) {
95
+ // treat as a simple definition
96
+ return $.parseRoot(args[0])
97
+ }
98
+ if (
99
+ args.length === 2 &&
100
+ typeof args[0] === "string" &&
101
+ args[0][0] === "<" &&
102
+ args[0].at(-1) === ">"
103
+ ) {
104
+ // if there are exactly two args, the first of which looks like <${string}>,
105
+ // treat as a generic
106
+ const params = parseGenericParams(args[0].slice(1, -1))
107
+ const def = args[1]
108
+ // TODO: validateUninstantiatedGeneric, remove this cast
109
+ return new Generic(params, def, $ as never) as never
110
+ }
111
+ // otherwise, treat as a tuple expression. technically, this also allows
112
+ // non-expression tuple definitions to be parsed, but it's not a supported
113
+ // part of the API as specified by the associated types
114
+ return $.parseRoot(args)
115
+ },
116
+ { bind: $, attach: typeParserAttachments }
117
+ )
118
+ }
119
+ }
120
+
71
121
  export type DeclarationParser<$> = <preinferred>() => {
72
122
  // for some reason, making this a const parameter breaks preinferred validation
73
123
  type: <def>(
@@ -75,59 +125,124 @@ export type DeclarationParser<$> = <preinferred>() => {
75
125
  ) => Type<preinferred, $>
76
126
  }
77
127
 
78
- export interface Type<
79
- /** @ts-expect-error allow instantiation assignment to the base type */
80
- out t = unknown,
81
- $ = any
82
- > extends Schema<t, $> {
83
- and: (<def>(
128
+ // this is declared as a class internally so we can ensure all "abstract"
129
+ // methods of BaseRoot are overridden, but we end up exporting it as an interface
130
+ // to ensure it is not accessed as a runtime value
131
+ declare class _Type<t = unknown, $ = any>
132
+ extends BaseRoot<t, $>
133
+ implements internalImplementationOf<Schema>
134
+ {
135
+ $: Scope<$>;
136
+
137
+ get in(): Type<this["tIn"], $>
138
+ get out(): Type<this["tOut"], $>
139
+
140
+ intersect<def>(
84
141
  def: validateTypeRoot<def, $>
85
- ) => Type<inferIntersection<t, inferTypeRoot<def, $>>, $>) &
86
- Schema<t, $>["and"]
142
+ ): Type<inferIntersection<t, inferTypeRoot<def, $>>> | Disjoint
87
143
 
88
- or: (<def>(
144
+ and<def>(
89
145
  def: validateTypeRoot<def, $>
90
- ) => Type<t | inferTypeRoot<def, $>, $>) &
91
- Schema<t, $>["or"]
146
+ ): Type<inferIntersection<t, inferTypeRoot<def, $>>, $>
92
147
 
93
- get in(): Type<distillConstrainableIn<t>, $>
94
- get out(): Type<distillConstrainableOut<t>, $>
148
+ or<def>(def: validateTypeRoot<def, $>): Type<t | inferTypeRoot<def, $>, $>
95
149
 
96
150
  array(): Type<t[], $>
97
151
 
98
- morph: (<morph extends Morph<this["infer"]>, outValidatorDef = never>(
99
- morph: morph,
100
- outValidator?: validateTypeRoot<outValidatorDef, $>
101
- ) => Type<
102
- (
103
- In: distillConstrainableIn<t>
104
- ) => Out<
105
- [outValidatorDef] extends [never] ? inferMorphOut<morph>
106
- : distillConstrainableOut<inferTypeRoot<outValidatorDef, $>>
107
- >,
108
- $
109
- >) &
110
- Schema<t, $>["morph"]
152
+ keyof(): Type<keyof this["inferIn"], $>
153
+
154
+ pipe<a extends Morph<this["infer"]>>(a: a): Type<inferPipes<t, [a]>, $>
155
+ pipe<a extends Morph<this["infer"]>, b extends Morph<inferMorphOut<a>>>(
156
+ a: a,
157
+ b: b
158
+ ): Type<inferPipes<t, [a, b]>, $>
159
+ pipe<
160
+ a extends Morph<this["infer"]>,
161
+ b extends Morph<inferMorphOut<a>>,
162
+ c extends Morph<inferMorphOut<b>>
163
+ >(a: a, b: b, c: c): Type<inferPipes<t, [a, b, c]>, $>
164
+ pipe<
165
+ a extends Morph<this["infer"]>,
166
+ b extends Morph<inferMorphOut<a>>,
167
+ c extends Morph<inferMorphOut<b>>,
168
+ d extends Morph<inferMorphOut<c>>
169
+ >(a: a, b: b, c: c, d: d): Type<inferPipes<t, [a, b, c, d]>, $>
170
+ pipe<
171
+ a extends Morph<this["infer"]>,
172
+ b extends Morph<inferMorphOut<a>>,
173
+ c extends Morph<inferMorphOut<b>>,
174
+ d extends Morph<inferMorphOut<c>>,
175
+ e extends Morph<inferMorphOut<d>>
176
+ >(a: a, b: b, c: c, d: d, e: e): Type<inferPipes<t, [a, b, c, d, e]>, $>
177
+ pipe<
178
+ a extends Morph<this["infer"]>,
179
+ b extends Morph<inferMorphOut<a>>,
180
+ c extends Morph<inferMorphOut<b>>,
181
+ d extends Morph<inferMorphOut<c>>,
182
+ e extends Morph<inferMorphOut<d>>,
183
+ f extends Morph<inferMorphOut<e>>
184
+ >(
185
+ a: a,
186
+ b: b,
187
+ c: c,
188
+ d: d,
189
+ e: e,
190
+ f: f
191
+ ): Type<inferPipes<t, [a, b, c, d, e, f]>, $>
192
+ pipe<
193
+ a extends Morph<this["infer"]>,
194
+ b extends Morph<inferMorphOut<a>>,
195
+ c extends Morph<inferMorphOut<b>>,
196
+ d extends Morph<inferMorphOut<c>>,
197
+ e extends Morph<inferMorphOut<d>>,
198
+ f extends Morph<inferMorphOut<e>>,
199
+ g extends Morph<inferMorphOut<f>>
200
+ >(
201
+ a: a,
202
+ b: b,
203
+ c: c,
204
+ d: d,
205
+ e: e,
206
+ f: f,
207
+ g: g
208
+ ): Type<inferPipes<t, [a, b, c, d, e, f, g]>, $>
111
209
 
112
210
  // TODO: based on below, should maybe narrow morph output if used after
113
211
  narrow<def extends Predicate<distillConstrainableOut<t>>>(
114
212
  def: def
115
213
  ): Type<
116
214
  includesMorphs<t> extends true ?
117
- (In: distillIn<t>) => Out<inferNarrow<this["infer"], def>>
215
+ (In: this["tIn"]) => Out<inferNarrow<this["infer"], def>>
118
216
  : inferNarrow<this["infer"], def>,
119
217
  $
120
218
  >
121
219
 
220
+ equals<def>(
221
+ def: validateTypeRoot<def, $>
222
+ ): this is Type<inferTypeRoot<def>, $>
223
+
224
+ // TODO: i/o
225
+ extract<def>(r: validateTypeRoot<def, $>): Type<t, $>
226
+ exclude<def>(r: validateTypeRoot<def, $>): Type<t, $>
227
+ extends<def>(
228
+ other: validateTypeRoot<def, $>
229
+ ): this is Type<inferTypeRoot<def>, $>
230
+
122
231
  constrain<
123
232
  kind extends PrimitiveConstraintKind,
124
233
  const def extends NodeDef<kind>
125
234
  >(
126
- kind: conform<kind, constraintKindOf<this["in"]["infer"]>>,
235
+ kind: conform<kind, constraintKindOf<this["inferIn"]>>,
127
236
  def: def
128
237
  ): Type<constrain<t, kind, def>, $>
129
238
  }
130
239
 
240
+ export interface Type<
241
+ /** @ts-expect-error allow instantiation assignment to the base type */
242
+ out t = unknown,
243
+ $ = any
244
+ > extends _Type<t, $> {}
245
+
131
246
  export type TypeConstructor<t = unknown, $ = any> = new (
132
247
  def: unknown,
133
248
  $: Scope<$>