Created
March 10, 2018 09:35
-
-
Save mattiamanzati/767bc0214ba1061510f44948e35f4efd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment