[go: up one dir, main page]

Skip to content

mistlog/type-query

Repository files navigation

TypeQuery · Build Status Coverage Status

TypeQuery is a lib of typetype, used to create complex typescript type using js, in jQuery style(jQuery means fashion here, :)).

Usage

> npm i @mistlog/type-query

API

example: typetype-template/src/type-query-basic.ts

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";
};

Examples

License

This project is MIT licensed.

About

jQuery style type manipulation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published