How to create the Typescript type from a generic?
https://arktype.io/docs/generics
const document = type({
id: "string",
coll: type.instanceOf(Module),
ts: TimeStub as type.cast<TimeStub>,
"ttl?": TimeStub as type.cast<TimeStub>,
});
const namedDocument = type("<t>",["t", "&",{
coll: type.instanceOf(Module),
name: "string",
ts: TimeStub as type.cast<TimeStub>,
"data?": "object",
}]);
const test = namedDocument(document) // This works as expected
type Document = typeof document;
type NamedDocument = typeof namedDocument;
const test: NamedDocument<Function> // This throws the error Type 'NamedDocument' is not generic.ts(2315)const document = type({
id: "string",
coll: type.instanceOf(Module),
ts: TimeStub as type.cast<TimeStub>,
"ttl?": TimeStub as type.cast<TimeStub>,
});
const namedDocument = type("<t>",["t", "&",{
coll: type.instanceOf(Module),
name: "string",
ts: TimeStub as type.cast<TimeStub>,
"data?": "object",
}]);
const test = namedDocument(document) // This works as expected
type Document = typeof document;
type NamedDocument = typeof namedDocument;
const test: NamedDocument<Function> // This throws the error Type 'NamedDocument' is not generic.ts(2315)