Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { TaskEither } from "fp-ts/lib/TaskEither";
- import * as ts from "typescript";
- type SyntaxKindToValueType = {
- [ts.SyntaxKind.StringLiteral]: string;
- [ts.SyntaxKind.NumericLiteral]: number;
- };
- type NumericStringToNumer<N extends string> = ({
- "8": 8
- "9": 9;
- } & { [K: string]: never })[N];
- type NumerToNumericString<N extends number> = ({
- 8: "8",
- 9:"9"
- } & { [K: number]: never })[N];
- type SupportedNodes = { kind: keyof SyntaxKindToValueType };
- type IExecutionContext = {};
- declare function compileNode<K extends NumericStringToNumer<keyof SyntaxKindToValueType>>(
- node: { kind: K } & ts.Node
- ): (x: IExecutionContext) => TaskEither<never, SyntaxKindToValueType[NumerToNumericString<K>]>;
- const shouldBeString = compileNode((1 as any) as ts.StringLiteral);
- const shouldBeNumber = compileNode((1 as any) as ts.NumericLiteral);
Add Comment
Please, Sign In to add comment