rust-code-analysis 0.0.25

Tool to compute and export code metrics
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
// Code generated; DO NOT EDIT.

use num_derive::FromPrimitive;

#[derive(Clone, Debug, PartialEq, Eq, FromPrimitive)]
pub enum Typescript {
    End = 0,
    Identifier = 1,
    HashBangLine = 2,
    Export = 3,
    STAR = 4,
    Default = 5,
    Type = 6,
    EQ = 7,
    As = 8,
    Namespace = 9,
    LBRACE = 10,
    COMMA = 11,
    RBRACE = 12,
    Typeof = 13,
    Import2 = 14,
    From = 15,
    Var = 16,
    Let = 17,
    Const = 18,
    BANG = 19,
    Else = 20,
    If = 21,
    Switch = 22,
    For = 23,
    LPAREN = 24,
    RPAREN = 25,
    Await = 26,
    In = 27,
    Of = 28,
    While = 29,
    Do = 30,
    Try = 31,
    With = 32,
    Break = 33,
    Continue = 34,
    Debugger = 35,
    Return = 36,
    Throw = 37,
    SEMI = 38,
    COLON = 39,
    Case = 40,
    Catch = 41,
    Finally = 42,
    Yield = 43,
    LBRACK = 44,
    RBRACK = 45,
    LT = 46,
    GT = 47,
    SLASH = 48,
    DOT = 49,
    Class2 = 50,
    Async = 51,
    Function2 = 52,
    EQGT = 53,
    QMARKDOT = 54,
    New = 55,
    PLUSEQ = 56,
    DASHEQ = 57,
    STAREQ = 58,
    SLASHEQ = 59,
    PERCENTEQ = 60,
    CARETEQ = 61,
    AMPEQ = 62,
    PIPEEQ = 63,
    GTGTEQ = 64,
    GTGTGTEQ = 65,
    LTLTEQ = 66,
    STARSTAREQ = 67,
    AMPAMPEQ = 68,
    PIPEPIPEEQ = 69,
    QMARKQMARKEQ = 70,
    DOTDOTDOT = 71,
    AMPAMP = 72,
    PIPEPIPE = 73,
    GTGT = 74,
    GTGTGT = 75,
    LTLT = 76,
    AMP = 77,
    CARET = 78,
    PIPE = 79,
    PLUS = 80,
    DASH = 81,
    PERCENT = 82,
    STARSTAR = 83,
    LTEQ = 84,
    EQEQ = 85,
    EQEQEQ = 86,
    BANGEQ = 87,
    BANGEQEQ = 88,
    GTEQ = 89,
    QMARKQMARK = 90,
    Instanceof = 91,
    TILDE = 92,
    Void = 93,
    Delete = 94,
    PLUSPLUS = 95,
    DASHDASH = 96,
    DQUOTE = 97,
    SQUOTE = 98,
    StringFragment = 99,
    StringFragment2 = 100,
    EscapeSequence = 101,
    Comment = 102,
    BQUOTE = 103,
    DOLLARLBRACE = 104,
    SLASH2 = 105,
    RegexPattern = 106,
    RegexFlags = 107,
    Number = 108,
    PrivatePropertyIdentifier = 109,
    Target = 110,
    This = 111,
    Super = 112,
    True = 113,
    False = 114,
    Null = 115,
    Undefined = 116,
    AT = 117,
    Static = 118,
    Readonly = 119,
    Get = 120,
    Set = 121,
    QMARK = 122,
    Declare = 123,
    Public = 124,
    Private = 125,
    Protected = 126,
    Override = 127,
    Module2 = 128,
    Any = 129,
    Number2 = 130,
    Boolean = 131,
    String2 = 132,
    Symbol = 133,
    Abstract = 134,
    Require = 135,
    Extends = 136,
    Implements = 137,
    Global = 138,
    Interface = 139,
    Enum = 140,
    DASHQMARKCOLON = 141,
    QMARKCOLON = 142,
    Asserts2 = 143,
    Infer = 144,
    Is = 145,
    Keyof = 146,
    Unknown = 147,
    Never = 148,
    Object2 = 149,
    LBRACEPIPE = 150,
    PIPERBRACE = 151,
    AutomaticSemicolon = 152,
    TemplateChars = 153,
    QMARK2 = 154,
    FunctionSignatureAutomaticSemicolon = 155,
    Program = 156,
    ExportStatement = 157,
    ExportClause = 158,
    ExportSpecifier = 159,
    Declaration = 160,
    Import = 161,
    ImportStatement = 162,
    ImportClause = 163,
    FromClause = 164,
    NamespaceImport = 165,
    NamedImports = 166,
    ExpressionStatement = 167,
    VariableDeclaration = 168,
    LexicalDeclaration = 169,
    VariableDeclarator = 170,
    StatementBlock = 171,
    ElseClause = 172,
    IfStatement = 173,
    SwitchStatement = 174,
    ForStatement = 175,
    ForInStatement = 176,
    ForHeader = 177,
    WhileStatement = 178,
    DoStatement = 179,
    TryStatement = 180,
    WithStatement = 181,
    BreakStatement = 182,
    ContinueStatement = 183,
    DebuggerStatement = 184,
    ReturnStatement = 185,
    ThrowStatement = 186,
    EmptyStatement = 187,
    LabeledStatement = 188,
    SwitchBody = 189,
    SwitchCase = 190,
    SwitchDefault = 191,
    CatchClause = 192,
    FinallyClause = 193,
    ParenthesizedExpression = 194,
    Expression = 195,
    PrimaryExpression = 196,
    YieldExpression = 197,
    Object = 198,
    ObjectPattern = 199,
    AssignmentPattern = 200,
    ObjectAssignmentPattern = 201,
    Array = 202,
    ArrayPattern = 203,
    NestedIdentifier = 204,
    Class = 205,
    ClassDeclaration = 206,
    ClassHeritage = 207,
    Function = 208,
    FunctionDeclaration = 209,
    GeneratorFunction = 210,
    GeneratorFunctionDeclaration = 211,
    ArrowFunction = 212,
    CallSignature2 = 213,
    FormalParameter = 214,
    CallExpression = 215,
    NewExpression = 216,
    AwaitExpression = 217,
    MemberExpression = 218,
    SubscriptExpression = 219,
    AssignmentExpression = 220,
    AugmentedAssignmentLhs = 221,
    AugmentedAssignmentExpression = 222,
    Initializer = 223,
    DestructuringPattern = 224,
    SpreadElement = 225,
    TernaryExpression = 226,
    BinaryExpression = 227,
    UnaryExpression = 228,
    UpdateExpression = 229,
    SequenceExpression = 230,
    String = 231,
    TemplateString = 232,
    TemplateSubstitution = 233,
    Regex = 234,
    MetaProperty = 235,
    Arguments = 236,
    Decorator = 237,
    MemberExpression2 = 238,
    CallExpression2 = 239,
    ClassBody = 240,
    FormalParameters = 241,
    Pattern = 242,
    RestPattern = 243,
    MethodDefinition = 244,
    Pair = 245,
    PairPattern = 246,
    PropertyName = 247,
    ComputedPropertyName = 248,
    PublicFieldDefinition = 249,
    NonNullExpression = 250,
    MethodSignature = 251,
    AbstractMethodSignature = 252,
    FunctionSignature = 253,
    TypeAssertion = 254,
    AsExpression = 255,
    ImportRequireClause = 256,
    ExtendsClause = 257,
    ImplementsClause = 258,
    AmbientDeclaration = 259,
    AbstractClassDeclaration = 260,
    Module = 261,
    InternalModule = 262,
    Module3 = 263,
    ImportAlias = 264,
    NestedTypeIdentifier = 265,
    InterfaceDeclaration = 266,
    ExtendsTypeClause = 267,
    EnumDeclaration = 268,
    EnumBody = 269,
    EnumAssignment = 270,
    TypeAliasDeclaration = 271,
    AccessibilityModifier = 272,
    OverrideModifier = 273,
    RequiredParameter = 274,
    OptionalParameter = 275,
    ParameterName = 276,
    OmittingTypeAnnotation = 277,
    OptingTypeAnnotation = 278,
    TypeAnnotation = 279,
    Asserts = 280,
    Type2 = 281,
    RequiredParameter2 = 282,
    OptionalParameter2 = 283,
    OptionalType = 284,
    RestType = 285,
    TupleTypeMember = 286,
    ConstructorType = 287,
    PrimaryType = 288,
    TemplateType = 289,
    TemplateLiteralType = 290,
    InferType = 291,
    ConditionalType = 292,
    GenericType = 293,
    TypePredicate = 294,
    TypePredicateAnnotation = 295,
    MemberExpression3 = 296,
    SubscriptExpression2 = 297,
    CallExpression3 = 298,
    TypeQuery = 299,
    IndexTypeQuery = 300,
    LookupType = 301,
    MappedTypeClause = 302,
    LiteralType = 303,
    UnaryExpression2 = 304,
    ExistentialType = 305,
    FlowMaybeType = 306,
    ParenthesizedType = 307,
    PredefinedType = 308,
    TypeArguments = 309,
    ObjectType = 310,
    CallSignature = 311,
    PropertySignature = 312,
    TypeParameters = 313,
    TypeParameter = 314,
    DefaultType = 315,
    Constraint = 316,
    ConstructSignature = 317,
    IndexSignature = 318,
    ArrayType = 319,
    TupleType = 320,
    ReadonlyType = 321,
    UnionType = 322,
    IntersectionType = 323,
    FunctionType = 324,
    ProgramRepeat1 = 325,
    ExportStatementRepeat1 = 326,
    ExportClauseRepeat1 = 327,
    NamedImportsRepeat1 = 328,
    VariableDeclarationRepeat1 = 329,
    SwitchBodyRepeat1 = 330,
    ObjectRepeat1 = 331,
    ObjectPatternRepeat1 = 332,
    ArrayRepeat1 = 333,
    ArrayPatternRepeat1 = 334,
    StringRepeat1 = 335,
    StringRepeat2 = 336,
    TemplateStringRepeat1 = 337,
    ClassBodyRepeat1 = 338,
    FormalParametersRepeat1 = 339,
    ExtendsClauseRepeat1 = 340,
    ImplementsClauseRepeat1 = 341,
    ExtendsTypeClauseRepeat1 = 342,
    EnumBodyRepeat1 = 343,
    TemplateLiteralTypeRepeat1 = 344,
    ObjectTypeRepeat1 = 345,
    TypeParametersRepeat1 = 346,
    TupleTypeRepeat1 = 347,
    ImportSpecifier = 348,
    NamespaceExport = 349,
    PropertyIdentifier = 350,
    ShorthandPropertyIdentifier = 351,
    ShorthandPropertyIdentifierPattern = 352,
    StatementIdentifier = 353,
    ThisType = 354,
    TypeIdentifier = 355,
    Error = 356,
}

impl From<Typescript> for &'static str {
    #[inline(always)]
    fn from(tok: Typescript) -> Self {
        match tok {
            Typescript::End => "end",
            Typescript::Identifier => "identifier",
            Typescript::HashBangLine => "hash_bang_line",
            Typescript::Export => "export",
            Typescript::STAR => "*",
            Typescript::Default => "default",
            Typescript::Type => "type",
            Typescript::EQ => "=",
            Typescript::As => "as",
            Typescript::Namespace => "namespace",
            Typescript::LBRACE => "{",
            Typescript::COMMA => ",",
            Typescript::RBRACE => "}",
            Typescript::Typeof => "typeof",
            Typescript::Import2 => "import",
            Typescript::From => "from",
            Typescript::Var => "var",
            Typescript::Let => "let",
            Typescript::Const => "const",
            Typescript::BANG => "!",
            Typescript::Else => "else",
            Typescript::If => "if",
            Typescript::Switch => "switch",
            Typescript::For => "for",
            Typescript::LPAREN => "(",
            Typescript::RPAREN => ")",
            Typescript::Await => "await",
            Typescript::In => "in",
            Typescript::Of => "of",
            Typescript::While => "while",
            Typescript::Do => "do",
            Typescript::Try => "try",
            Typescript::With => "with",
            Typescript::Break => "break",
            Typescript::Continue => "continue",
            Typescript::Debugger => "debugger",
            Typescript::Return => "return",
            Typescript::Throw => "throw",
            Typescript::SEMI => ";",
            Typescript::COLON => ":",
            Typescript::Case => "case",
            Typescript::Catch => "catch",
            Typescript::Finally => "finally",
            Typescript::Yield => "yield",
            Typescript::LBRACK => "[",
            Typescript::RBRACK => "]",
            Typescript::LT => "<",
            Typescript::GT => ">",
            Typescript::SLASH => "/",
            Typescript::DOT => ".",
            Typescript::Class2 => "class",
            Typescript::Async => "async",
            Typescript::Function2 => "function",
            Typescript::EQGT => "=>",
            Typescript::QMARKDOT => "?.",
            Typescript::New => "new",
            Typescript::PLUSEQ => "+=",
            Typescript::DASHEQ => "-=",
            Typescript::STAREQ => "*=",
            Typescript::SLASHEQ => "/=",
            Typescript::PERCENTEQ => "%=",
            Typescript::CARETEQ => "^=",
            Typescript::AMPEQ => "&=",
            Typescript::PIPEEQ => "|=",
            Typescript::GTGTEQ => ">>=",
            Typescript::GTGTGTEQ => ">>>=",
            Typescript::LTLTEQ => "<<=",
            Typescript::STARSTAREQ => "**=",
            Typescript::AMPAMPEQ => "&&=",
            Typescript::PIPEPIPEEQ => "||=",
            Typescript::QMARKQMARKEQ => "??=",
            Typescript::DOTDOTDOT => "...",
            Typescript::AMPAMP => "&&",
            Typescript::PIPEPIPE => "||",
            Typescript::GTGT => ">>",
            Typescript::GTGTGT => ">>>",
            Typescript::LTLT => "<<",
            Typescript::AMP => "&",
            Typescript::CARET => "^",
            Typescript::PIPE => "|",
            Typescript::PLUS => "+",
            Typescript::DASH => "-",
            Typescript::PERCENT => "%",
            Typescript::STARSTAR => "**",
            Typescript::LTEQ => "<=",
            Typescript::EQEQ => "==",
            Typescript::EQEQEQ => "===",
            Typescript::BANGEQ => "!=",
            Typescript::BANGEQEQ => "!==",
            Typescript::GTEQ => ">=",
            Typescript::QMARKQMARK => "??",
            Typescript::Instanceof => "instanceof",
            Typescript::TILDE => "~",
            Typescript::Void => "void",
            Typescript::Delete => "delete",
            Typescript::PLUSPLUS => "++",
            Typescript::DASHDASH => "--",
            Typescript::DQUOTE => "\"",
            Typescript::SQUOTE => "'",
            Typescript::StringFragment => "string_fragment",
            Typescript::StringFragment2 => "string_fragment",
            Typescript::EscapeSequence => "escape_sequence",
            Typescript::Comment => "comment",
            Typescript::BQUOTE => "`",
            Typescript::DOLLARLBRACE => "${",
            Typescript::SLASH2 => "/",
            Typescript::RegexPattern => "regex_pattern",
            Typescript::RegexFlags => "regex_flags",
            Typescript::Number => "number",
            Typescript::PrivatePropertyIdentifier => "private_property_identifier",
            Typescript::Target => "target",
            Typescript::This => "this",
            Typescript::Super => "super",
            Typescript::True => "true",
            Typescript::False => "false",
            Typescript::Null => "null",
            Typescript::Undefined => "undefined",
            Typescript::AT => "@",
            Typescript::Static => "static",
            Typescript::Readonly => "readonly",
            Typescript::Get => "get",
            Typescript::Set => "set",
            Typescript::QMARK => "?",
            Typescript::Declare => "declare",
            Typescript::Public => "public",
            Typescript::Private => "private",
            Typescript::Protected => "protected",
            Typescript::Override => "override",
            Typescript::Module2 => "module",
            Typescript::Any => "any",
            Typescript::Number2 => "number",
            Typescript::Boolean => "boolean",
            Typescript::String2 => "string",
            Typescript::Symbol => "symbol",
            Typescript::Abstract => "abstract",
            Typescript::Require => "require",
            Typescript::Extends => "extends",
            Typescript::Implements => "implements",
            Typescript::Global => "global",
            Typescript::Interface => "interface",
            Typescript::Enum => "enum",
            Typescript::DASHQMARKCOLON => "-?:",
            Typescript::QMARKCOLON => "?:",
            Typescript::Asserts2 => "asserts",
            Typescript::Infer => "infer",
            Typescript::Is => "is",
            Typescript::Keyof => "keyof",
            Typescript::Unknown => "unknown",
            Typescript::Never => "never",
            Typescript::Object2 => "object",
            Typescript::LBRACEPIPE => "{|",
            Typescript::PIPERBRACE => "|}",
            Typescript::AutomaticSemicolon => "_automatic_semicolon",
            Typescript::TemplateChars => "_template_chars",
            Typescript::QMARK2 => "?",
            Typescript::FunctionSignatureAutomaticSemicolon => {
                "_function_signature_automatic_semicolon"
            }
            Typescript::Program => "program",
            Typescript::ExportStatement => "export_statement",
            Typescript::ExportClause => "export_clause",
            Typescript::ExportSpecifier => "export_specifier",
            Typescript::Declaration => "declaration",
            Typescript::Import => "import",
            Typescript::ImportStatement => "import_statement",
            Typescript::ImportClause => "import_clause",
            Typescript::FromClause => "_from_clause",
            Typescript::NamespaceImport => "namespace_import",
            Typescript::NamedImports => "named_imports",
            Typescript::ExpressionStatement => "expression_statement",
            Typescript::VariableDeclaration => "variable_declaration",
            Typescript::LexicalDeclaration => "lexical_declaration",
            Typescript::VariableDeclarator => "variable_declarator",
            Typescript::StatementBlock => "statement_block",
            Typescript::ElseClause => "else_clause",
            Typescript::IfStatement => "if_statement",
            Typescript::SwitchStatement => "switch_statement",
            Typescript::ForStatement => "for_statement",
            Typescript::ForInStatement => "for_in_statement",
            Typescript::ForHeader => "_for_header",
            Typescript::WhileStatement => "while_statement",
            Typescript::DoStatement => "do_statement",
            Typescript::TryStatement => "try_statement",
            Typescript::WithStatement => "with_statement",
            Typescript::BreakStatement => "break_statement",
            Typescript::ContinueStatement => "continue_statement",
            Typescript::DebuggerStatement => "debugger_statement",
            Typescript::ReturnStatement => "return_statement",
            Typescript::ThrowStatement => "throw_statement",
            Typescript::EmptyStatement => "empty_statement",
            Typescript::LabeledStatement => "labeled_statement",
            Typescript::SwitchBody => "switch_body",
            Typescript::SwitchCase => "switch_case",
            Typescript::SwitchDefault => "switch_default",
            Typescript::CatchClause => "catch_clause",
            Typescript::FinallyClause => "finally_clause",
            Typescript::ParenthesizedExpression => "parenthesized_expression",
            Typescript::Expression => "expression",
            Typescript::PrimaryExpression => "primary_expression",
            Typescript::YieldExpression => "yield_expression",
            Typescript::Object => "object",
            Typescript::ObjectPattern => "object_pattern",
            Typescript::AssignmentPattern => "assignment_pattern",
            Typescript::ObjectAssignmentPattern => "object_assignment_pattern",
            Typescript::Array => "array",
            Typescript::ArrayPattern => "array_pattern",
            Typescript::NestedIdentifier => "nested_identifier",
            Typescript::Class => "class",
            Typescript::ClassDeclaration => "class_declaration",
            Typescript::ClassHeritage => "class_heritage",
            Typescript::Function => "function",
            Typescript::FunctionDeclaration => "function_declaration",
            Typescript::GeneratorFunction => "generator_function",
            Typescript::GeneratorFunctionDeclaration => "generator_function_declaration",
            Typescript::ArrowFunction => "arrow_function",
            Typescript::CallSignature2 => "_call_signature",
            Typescript::FormalParameter => "_formal_parameter",
            Typescript::CallExpression => "call_expression",
            Typescript::NewExpression => "new_expression",
            Typescript::AwaitExpression => "await_expression",
            Typescript::MemberExpression => "member_expression",
            Typescript::SubscriptExpression => "subscript_expression",
            Typescript::AssignmentExpression => "assignment_expression",
            Typescript::AugmentedAssignmentLhs => "_augmented_assignment_lhs",
            Typescript::AugmentedAssignmentExpression => "augmented_assignment_expression",
            Typescript::Initializer => "_initializer",
            Typescript::DestructuringPattern => "_destructuring_pattern",
            Typescript::SpreadElement => "spread_element",
            Typescript::TernaryExpression => "ternary_expression",
            Typescript::BinaryExpression => "binary_expression",
            Typescript::UnaryExpression => "unary_expression",
            Typescript::UpdateExpression => "update_expression",
            Typescript::SequenceExpression => "sequence_expression",
            Typescript::String => "string",
            Typescript::TemplateString => "template_string",
            Typescript::TemplateSubstitution => "template_substitution",
            Typescript::Regex => "regex",
            Typescript::MetaProperty => "meta_property",
            Typescript::Arguments => "arguments",
            Typescript::Decorator => "decorator",
            Typescript::MemberExpression2 => "member_expression",
            Typescript::CallExpression2 => "call_expression",
            Typescript::ClassBody => "class_body",
            Typescript::FormalParameters => "formal_parameters",
            Typescript::Pattern => "pattern",
            Typescript::RestPattern => "rest_pattern",
            Typescript::MethodDefinition => "method_definition",
            Typescript::Pair => "pair",
            Typescript::PairPattern => "pair_pattern",
            Typescript::PropertyName => "_property_name",
            Typescript::ComputedPropertyName => "computed_property_name",
            Typescript::PublicFieldDefinition => "public_field_definition",
            Typescript::NonNullExpression => "non_null_expression",
            Typescript::MethodSignature => "method_signature",
            Typescript::AbstractMethodSignature => "abstract_method_signature",
            Typescript::FunctionSignature => "function_signature",
            Typescript::TypeAssertion => "type_assertion",
            Typescript::AsExpression => "as_expression",
            Typescript::ImportRequireClause => "import_require_clause",
            Typescript::ExtendsClause => "extends_clause",
            Typescript::ImplementsClause => "implements_clause",
            Typescript::AmbientDeclaration => "ambient_declaration",
            Typescript::AbstractClassDeclaration => "abstract_class_declaration",
            Typescript::Module => "module",
            Typescript::InternalModule => "internal_module",
            Typescript::Module3 => "_module",
            Typescript::ImportAlias => "import_alias",
            Typescript::NestedTypeIdentifier => "nested_type_identifier",
            Typescript::InterfaceDeclaration => "interface_declaration",
            Typescript::ExtendsTypeClause => "extends_type_clause",
            Typescript::EnumDeclaration => "enum_declaration",
            Typescript::EnumBody => "enum_body",
            Typescript::EnumAssignment => "enum_assignment",
            Typescript::TypeAliasDeclaration => "type_alias_declaration",
            Typescript::AccessibilityModifier => "accessibility_modifier",
            Typescript::OverrideModifier => "override_modifier",
            Typescript::RequiredParameter => "required_parameter",
            Typescript::OptionalParameter => "optional_parameter",
            Typescript::ParameterName => "_parameter_name",
            Typescript::OmittingTypeAnnotation => "omitting_type_annotation",
            Typescript::OptingTypeAnnotation => "opting_type_annotation",
            Typescript::TypeAnnotation => "type_annotation",
            Typescript::Asserts => "asserts",
            Typescript::Type2 => "_type",
            Typescript::RequiredParameter2 => "required_parameter",
            Typescript::OptionalParameter2 => "optional_parameter",
            Typescript::OptionalType => "optional_type",
            Typescript::RestType => "rest_type",
            Typescript::TupleTypeMember => "_tuple_type_member",
            Typescript::ConstructorType => "constructor_type",
            Typescript::PrimaryType => "_primary_type",
            Typescript::TemplateType => "template_type",
            Typescript::TemplateLiteralType => "template_literal_type",
            Typescript::InferType => "infer_type",
            Typescript::ConditionalType => "conditional_type",
            Typescript::GenericType => "generic_type",
            Typescript::TypePredicate => "type_predicate",
            Typescript::TypePredicateAnnotation => "type_predicate_annotation",
            Typescript::MemberExpression3 => "member_expression",
            Typescript::SubscriptExpression2 => "subscript_expression",
            Typescript::CallExpression3 => "call_expression",
            Typescript::TypeQuery => "type_query",
            Typescript::IndexTypeQuery => "index_type_query",
            Typescript::LookupType => "lookup_type",
            Typescript::MappedTypeClause => "mapped_type_clause",
            Typescript::LiteralType => "literal_type",
            Typescript::UnaryExpression2 => "unary_expression",
            Typescript::ExistentialType => "existential_type",
            Typescript::FlowMaybeType => "flow_maybe_type",
            Typescript::ParenthesizedType => "parenthesized_type",
            Typescript::PredefinedType => "predefined_type",
            Typescript::TypeArguments => "type_arguments",
            Typescript::ObjectType => "object_type",
            Typescript::CallSignature => "call_signature",
            Typescript::PropertySignature => "property_signature",
            Typescript::TypeParameters => "type_parameters",
            Typescript::TypeParameter => "type_parameter",
            Typescript::DefaultType => "default_type",
            Typescript::Constraint => "constraint",
            Typescript::ConstructSignature => "construct_signature",
            Typescript::IndexSignature => "index_signature",
            Typescript::ArrayType => "array_type",
            Typescript::TupleType => "tuple_type",
            Typescript::ReadonlyType => "readonly_type",
            Typescript::UnionType => "union_type",
            Typescript::IntersectionType => "intersection_type",
            Typescript::FunctionType => "function_type",
            Typescript::ProgramRepeat1 => "program_repeat1",
            Typescript::ExportStatementRepeat1 => "export_statement_repeat1",
            Typescript::ExportClauseRepeat1 => "export_clause_repeat1",
            Typescript::NamedImportsRepeat1 => "named_imports_repeat1",
            Typescript::VariableDeclarationRepeat1 => "variable_declaration_repeat1",
            Typescript::SwitchBodyRepeat1 => "switch_body_repeat1",
            Typescript::ObjectRepeat1 => "object_repeat1",
            Typescript::ObjectPatternRepeat1 => "object_pattern_repeat1",
            Typescript::ArrayRepeat1 => "array_repeat1",
            Typescript::ArrayPatternRepeat1 => "array_pattern_repeat1",
            Typescript::StringRepeat1 => "string_repeat1",
            Typescript::StringRepeat2 => "string_repeat2",
            Typescript::TemplateStringRepeat1 => "template_string_repeat1",
            Typescript::ClassBodyRepeat1 => "class_body_repeat1",
            Typescript::FormalParametersRepeat1 => "formal_parameters_repeat1",
            Typescript::ExtendsClauseRepeat1 => "extends_clause_repeat1",
            Typescript::ImplementsClauseRepeat1 => "implements_clause_repeat1",
            Typescript::ExtendsTypeClauseRepeat1 => "extends_type_clause_repeat1",
            Typescript::EnumBodyRepeat1 => "enum_body_repeat1",
            Typescript::TemplateLiteralTypeRepeat1 => "template_literal_type_repeat1",
            Typescript::ObjectTypeRepeat1 => "object_type_repeat1",
            Typescript::TypeParametersRepeat1 => "type_parameters_repeat1",
            Typescript::TupleTypeRepeat1 => "tuple_type_repeat1",
            Typescript::ImportSpecifier => "import_specifier",
            Typescript::NamespaceExport => "namespace_export",
            Typescript::PropertyIdentifier => "property_identifier",
            Typescript::ShorthandPropertyIdentifier => "shorthand_property_identifier",
            Typescript::ShorthandPropertyIdentifierPattern => {
                "shorthand_property_identifier_pattern"
            }
            Typescript::StatementIdentifier => "statement_identifier",
            Typescript::ThisType => "this_type",
            Typescript::TypeIdentifier => "type_identifier",
            Typescript::Error => "ERROR",
        }
    }
}

impl From<u16> for Typescript {
    #[inline(always)]
    fn from(x: u16) -> Self {
        num::FromPrimitive::from_u16(x).unwrap_or(Self::Error)
    }
}

// Typescript == u16
impl PartialEq<u16> for Typescript {
    #[inline(always)]
    fn eq(&self, x: &u16) -> bool {
        *self == Typescript::from(*x)
    }
}

// u16 == Typescript
impl PartialEq<Typescript> for u16 {
    #[inline(always)]
    fn eq(&self, x: &Typescript) -> bool {
        *x == *self
    }
}