Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Outside value Support #10

Open
Kingwl opened this issue Jan 24, 2019 · 1 comment
Open

Outside value Support #10

Kingwl opened this issue Jan 24, 2019 · 1 comment
Labels
enhancement New feature or request rfc

Comments

@Kingwl
Copy link
Member

Kingwl commented Jan 24, 2019

Syntax node(list) factory

type Factory<T extends Node> = Record<T["kind"], (node: T) => T>  
type ListFactory<T extends Node> = Record<T["kind"], (node: T) =>T[]> 

Signal node factory

const a = 1;
{
   [ts.SyntaxKind.Identifier]: (id: ts.Identifier) => {
        // match id is 'a'
       // ...
        return ts.createIdentifier(id.text.toUpperCase())
    }
}

to

ts.createVariableStatement(
    undefined,
    ts.createVariableDeclarationList(
        [
        ts.createVariableDeclaration(
            ts.createIdentifier('A'),
            undefined,
            ts.createNumericLiteral('1')
        )
        ],
        ts.NodeFlags.Const
    )
)

Multi node factory

interface Foo {
    a: never
}
{
    [ts.SyntaxKind.PropertySignature]: (p: ts.PropertySignature) => {
        // match p is 'a: never'
        // ...
        return [
            ts.createPropertySignature(
                undefined,
                ts.createIdentifier('a'),
                undefined,
                ts.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword),
                undefined
            ),
            ts.createPropertySignature(
                undefined,
                ts.createIdentifier('b'),
                undefined,
                ts.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
                undefined
            )
        ]
    }
}

to

interface Foo {
    a: number
    b: string
}
@Kingwl Kingwl added enhancement New feature or request rfc labels Jan 24, 2019
@Kingwl
Copy link
Member Author

Kingwl commented Jan 25, 2019

consider tsquery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rfc
Projects
None yet
Development

No branches or pull requests

1 participant