(path, options, print, args)
| 47 | import { printUnionType } from "./union-type.js"; |
| 48 | |
| 49 | function printTypescript(path, options, print, args) { |
| 50 | const { node } = path; |
| 51 | |
| 52 | // TypeScript nodes always starts with `TS` |
| 53 | if (!node.type.startsWith("TS")) { |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | if (isTsKeywordType(node)) { |
| 58 | // TS keyword types stars with `TS`, ends with `Keyword` |
| 59 | return node.type.slice(2, -7).toLowerCase(); |
| 60 | } |
| 61 | |
| 62 | switch (node.type) { |
| 63 | case "TSThisType": |
| 64 | return "this"; |
| 65 | case "TSTypeAssertion": |
| 66 | return printTypeAssertion(path, options, print); |
| 67 | |
| 68 | case "TSDeclareFunction": |
| 69 | return printFunction(path, options, print); |
| 70 | case "TSExportAssignment": |
| 71 | return ["export = ", print("expression"), printSemicolon(options)]; |
| 72 | case "TSModuleBlock": |
| 73 | return printBlock(path, options, print); |
| 74 | case "TSInterfaceBody": |
| 75 | case "TSTypeLiteral": |
| 76 | return printClassBody(path, options, print); |
| 77 | case "TSTypeAliasDeclaration": |
| 78 | return printTypeAlias(path, options, print); |
| 79 | case "TSQualifiedName": |
| 80 | return [print("left"), ".", print("right")]; |
| 81 | case "TSAbstractMethodDefinition": |
| 82 | case "TSDeclareMethod": |
| 83 | return printClassMethod(path, options, print); |
| 84 | case "TSAbstractAccessorProperty": |
| 85 | case "TSAbstractPropertyDefinition": |
| 86 | return printClassProperty(path, options, print); |
| 87 | case "TSInterfaceHeritage": |
| 88 | case "TSClassImplements": |
| 89 | case "TSInstantiationExpression": |
| 90 | return [print("expression"), print("typeArguments")]; |
| 91 | case "TSTemplateLiteralType": |
| 92 | return printTemplateLiteral(path, options, print); |
| 93 | case "TSNamedTupleMember": |
| 94 | return printNamedTupleMember(path, options, print); |
| 95 | case "TSRestType": |
| 96 | return printRestType(path, options, print); |
| 97 | case "TSOptionalType": |
| 98 | return [print("typeAnnotation"), "?"]; |
| 99 | case "TSInterfaceDeclaration": |
| 100 | return printClass(path, options, print); |
| 101 | case "TSTypeParameterDeclaration": |
| 102 | case "TSTypeParameterInstantiation": |
| 103 | return printTypeParameters(path, options, print, "params"); |
| 104 | case "TSTypeParameter": |
| 105 | return printTypeParameter(path, options, print); |
| 106 | case "TSAsExpression": |
nothing calls this directly
no test coverage detected
searching dependent graphs…