TypeQuery is a lib of typetype, used to create complex typescript type using js, in jQuery style(jQuery means fashion here, :)).
- introducation: Type Query: jQuery Style Type Manipulation
- quick start: typetype template
> npm i @mistlog/type-query
import { transcribe } from "@mistlog/type-query";
const filePath = "tuple-to-object.type";
const input = `
type tuple = ["tesla", "model 3", "model X", "model Y"]
type result = \`\`\` "use js"
return $.use("tuple")
.tupleToObject()
.omit(key => !key.startsWith("model"))
.type();
\`\`\`
`;
const output = transcribe(filePath, input);
console.log(output.code);
output:
type tuple = ["tesla", "model 3", "model X", "model Y"];
type result = {
"model 3": "model 3";
"model X": "model X";
"model Y": "model Y";
};
- all examples: type query test assets
This project is MIT licensed.