How to use the stringLiteralTypeAnnotation function from @babel/types
Find comprehensive JavaScript @babel/types.stringLiteralTypeAnnotation code examples handpicked from public code repositorys.
160 161 162 163 164 165 166 167 168 169
// this doesn't exist in Flow at the time. types.push( Array.from(typenameAliases).map(typenameAlias => { const otherProp = readOnlyObjectTypeProperty( typenameAlias, t.stringLiteralTypeAnnotation('%other'), ); otherProp.leadingComments = lineComments( "This will never be '%other', but we need some", 'value in case none of the concrete values match.',
0
5
2
+ 7 other calls in file
144 145 146 147 148 149 150 151 152 153
prop.variance = t.variance('plus'); return prop; } function stringLiteralTypeAnnotation(value: string): $FlowFixMe { return t.stringLiteralTypeAnnotation(value); } /** * Create a union type if needed.
0
1
3
+ 3 other calls in file
149 150 151 152 153 154 155 156 157 158
// would set the type to diff(string, set of listed concrete types), but // this doesn't exist in Flow at the time. types.push(Array.from(typenameAliases).map(function (typenameAlias) { var otherProp = readOnlyObjectTypeProperty(typenameAlias, t.stringLiteralTypeAnnotation('%other')); otherProp.leadingComments = lineComments("This will never be '%other', but we need some", 'value in case none of the concrete values match.'); return otherProp; })); })();
0
0
2
+ 3 other calls in file
673 674 675 676 677 678 679 680 681 682
state.runtimeImports.add('Local3DPayload'); types.push( t.genericTypeAnnotation( t.identifier('Local3DPayload'), t.typeParameterInstantiation([ t.stringLiteralTypeAnnotation(moduleImport.documentName), exactObjectTypeAnnotation( selections .filter(sel => sel.schemaName !== 'js') .map(selection =>
0
0
1
+ 4 other calls in file
93 94 95 96 97 98 99 100 101
prop.variance = t.variance('plus'); return prop; } function stringLiteralTypeAnnotation(value: string) { const annotation = t.stringLiteralTypeAnnotation(); annotation.value = value; return annotation; }
0
0
3
+ 9 other calls in file
@babel/types.identifier is the most popular function in @babel/types (20936 examples)