Last active
April 16, 2020 13:30
-
-
Save decadef20/295f4b081f7dfb92010e16b1b7e92f13 to your computer and use it in GitHub Desktop.
This file contains 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
// how to add ts interface by babel-types | |
const interfaces = path.insertAfter( | |
t.tSInterfaceDeclaration( | |
t.identifier('State'), | |
null, | |
null, | |
t.tsInterfaceBody( | |
[ t.tsPropertySignature(t.stringLiteral('test'), t.tsTypeAnnotation(t.TSLiteralType(t.stringLiteral('string')))) ] | |
) | |
) | |
) | |
// how to add ts type by babel-types | |
const types = t.typeAlias( | |
t.identifier("State"), | |
t.typeParameterDeclaration( | |
[] | |
// [t.TypeParameter(t.typeAnnotation(t.stringLiteralTypeAnnotation('string')), t.stringLiteralTypeAnnotation('string') , t.variance('plus'))] | |
), | |
t.objectTypeAnnotation( | |
[ | |
t.ObjectTypeProperty(t.identifier('test'), t.stringLiteralTypeAnnotation('string')) , | |
t.ObjectTypeProperty(t.identifier('aaa'), t.stringLiteralTypeAnnotation('string')) | |
] | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment