diff --git a/Jakefile b/Jakefile index 64394c2d60e..109398b8852 100644 --- a/Jakefile +++ b/Jakefile @@ -133,7 +133,7 @@ function concatenateFiles(destinationFile, sourceFiles) { fs.renameSync(temp, destinationFile); } -var useDebugMode = false; +var useDebugMode = true; var generateDeclarations = false; var host = (process.env.host || process.env.TYPESCRIPT_HOST || "node"); var compilerFilename = "tsc.js"; @@ -148,15 +148,16 @@ var compilerFilename = "tsc.js"; function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile) { file(outFile, prereqs, function() { var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory; - var options = "-removeComments --module commonjs -noImplicitAny "; //" -propagateEnumConstants " + var options = "-removeComments --module commonjs -noImplicitAny "; if (generateDeclarations) { options += "--declaration "; } + + if (useDebugMode) { + options += "--preserveConstEnums "; + } var cmd = host + " " + dir + compilerFilename + " " + options + " "; - if (useDebugMode) { - cmd = cmd + " " + path.join(harnessDirectory, "external/es5compat.ts") + " " + path.join(harnessDirectory, "external/json2.ts") + " "; - } cmd = cmd + sources.join(" ") + (!noOutFile ? " -out " + outFile : ""); if (useDebugMode) { cmd = cmd + " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile)); @@ -258,12 +259,11 @@ task("local", ["generate-diagnostics", "lib", tscFile, servicesFile]); // Local target to build the compiler and services -desc("Emit debug mode files with sourcemaps"); -task("debug", function() { - useDebugMode = true; +desc("Sets release mode flag"); +task("release", function() { + useDebugMode = false; }); - // Set the default task to "local" task("default", ["local"]); @@ -312,7 +312,7 @@ task("generate-spec", [specMd]) // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory desc("Makes a new LKG out of the built js files"); -task("LKG", libraryTargets, function() { +task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() { var expectedFiles = [tscFile, servicesFile].concat(libraryTargets); var missingFiles = expectedFiles.filter(function (f) { return !fs.existsSync(f); diff --git a/bin/tsc.js b/bin/tsc.js index 0b8dd882716..53e1047e852 100644 --- a/bin/tsc.js +++ b/bin/tsc.js @@ -134,7 +134,8 @@ var ts; const_declarations_must_be_initialized: { code: 1155, category: 1 /* Error */, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1 /* Error */, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1 /* Error */, key: "'let' declarations can only be declared inside a block." }, - Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead: { code: 1158, category: 1 /* Error */, key: "Aliased type cannot be an object type literal. Use an interface declaration instead." }, + Invalid_template_literal_expected: { code: 1158, category: 1 /* Error */, key: "Invalid template literal; expected '}'" }, + Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: 1 /* Error */, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, @@ -282,6 +283,7 @@ var ts; The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: 1 /* Error */, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: 1 /* Error */, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: 1 /* Error */, key: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: 1 /* Error */, key: "Type alias name cannot be '{0}'" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, @@ -364,6 +366,12 @@ var ts; Exported_type_alias_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4079, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2: { code: 4080, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: 1 /* Error */, key: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: 1 /* Error */, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 4084, category: 1 /* Error */, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: 1 /* Error */, key: "Index expression arguments in 'const' enums must be of type 'string'." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: 1 /* Error */, key: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: 1 /* Error */, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: 1 /* Error */, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: 1 /* Error */, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: 1 /* Error */, key: "Cannot read file '{0}': {1}" }, @@ -378,6 +386,7 @@ var ts; Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: 2 /* Message */, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, Watch_input_files: { code: 6005, category: 2 /* Message */, key: "Watch input files." }, Redirect_output_structure_to_the_directory: { code: 6006, category: 2 /* Message */, key: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: 2 /* Message */, key: "Do not erase const enum declarations in generated code." }, Do_not_emit_comments_to_output: { code: 6009, category: 2 /* Message */, key: "Do not emit comments to output." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: 2 /* Message */, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: 2 /* Message */, key: "Specify module code generation: 'commonjs' or 'amd'" }, @@ -431,112 +440,112 @@ var ts; var ts; (function (ts) { var textToToken = { - "any": 105 /* AnyKeyword */, - "boolean": 106 /* BooleanKeyword */, - "break": 60 /* BreakKeyword */, - "case": 61 /* CaseKeyword */, - "catch": 62 /* CatchKeyword */, - "class": 63 /* ClassKeyword */, - "continue": 65 /* ContinueKeyword */, - "const": 64 /* ConstKeyword */, - "constructor": 107 /* ConstructorKeyword */, - "debugger": 66 /* DebuggerKeyword */, - "declare": 108 /* DeclareKeyword */, - "default": 67 /* DefaultKeyword */, - "delete": 68 /* DeleteKeyword */, - "do": 69 /* DoKeyword */, - "else": 70 /* ElseKeyword */, - "enum": 71 /* EnumKeyword */, - "export": 72 /* ExportKeyword */, - "extends": 73 /* ExtendsKeyword */, - "false": 74 /* FalseKeyword */, - "finally": 75 /* FinallyKeyword */, - "for": 76 /* ForKeyword */, - "function": 77 /* FunctionKeyword */, - "get": 109 /* GetKeyword */, - "if": 78 /* IfKeyword */, - "implements": 96 /* ImplementsKeyword */, - "import": 79 /* ImportKeyword */, - "in": 80 /* InKeyword */, - "instanceof": 81 /* InstanceOfKeyword */, - "interface": 97 /* InterfaceKeyword */, - "let": 98 /* LetKeyword */, - "module": 110 /* ModuleKeyword */, - "new": 82 /* NewKeyword */, - "null": 83 /* NullKeyword */, - "number": 112 /* NumberKeyword */, - "package": 99 /* PackageKeyword */, - "private": 100 /* PrivateKeyword */, - "protected": 101 /* ProtectedKeyword */, - "public": 102 /* PublicKeyword */, - "require": 111 /* RequireKeyword */, - "return": 84 /* ReturnKeyword */, - "set": 113 /* SetKeyword */, - "static": 103 /* StaticKeyword */, - "string": 114 /* StringKeyword */, - "super": 85 /* SuperKeyword */, - "switch": 86 /* SwitchKeyword */, - "this": 87 /* ThisKeyword */, - "throw": 88 /* ThrowKeyword */, - "true": 89 /* TrueKeyword */, - "try": 90 /* TryKeyword */, - "type": 115 /* TypeKeyword */, - "typeof": 91 /* TypeOfKeyword */, - "var": 92 /* VarKeyword */, - "void": 93 /* VoidKeyword */, - "while": 94 /* WhileKeyword */, - "with": 95 /* WithKeyword */, - "yield": 104 /* YieldKeyword */, - "{": 9 /* OpenBraceToken */, - "}": 10 /* CloseBraceToken */, - "(": 11 /* OpenParenToken */, - ")": 12 /* CloseParenToken */, - "[": 13 /* OpenBracketToken */, - "]": 14 /* CloseBracketToken */, - ".": 15 /* DotToken */, - "...": 16 /* DotDotDotToken */, - ";": 17 /* SemicolonToken */, - ",": 18 /* CommaToken */, - "<": 19 /* LessThanToken */, - ">": 20 /* GreaterThanToken */, - "<=": 21 /* LessThanEqualsToken */, - ">=": 22 /* GreaterThanEqualsToken */, - "==": 23 /* EqualsEqualsToken */, - "!=": 24 /* ExclamationEqualsToken */, - "===": 25 /* EqualsEqualsEqualsToken */, - "!==": 26 /* ExclamationEqualsEqualsToken */, - "=>": 27 /* EqualsGreaterThanToken */, - "+": 28 /* PlusToken */, - "-": 29 /* MinusToken */, - "*": 30 /* AsteriskToken */, - "/": 31 /* SlashToken */, - "%": 32 /* PercentToken */, - "++": 33 /* PlusPlusToken */, - "--": 34 /* MinusMinusToken */, - "<<": 35 /* LessThanLessThanToken */, - ">>": 36 /* GreaterThanGreaterThanToken */, - ">>>": 37 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 38 /* AmpersandToken */, - "|": 39 /* BarToken */, - "^": 40 /* CaretToken */, - "!": 41 /* ExclamationToken */, - "~": 42 /* TildeToken */, - "&&": 43 /* AmpersandAmpersandToken */, - "||": 44 /* BarBarToken */, - "?": 45 /* QuestionToken */, - ":": 46 /* ColonToken */, - "=": 47 /* EqualsToken */, - "+=": 48 /* PlusEqualsToken */, - "-=": 49 /* MinusEqualsToken */, - "*=": 50 /* AsteriskEqualsToken */, - "/=": 51 /* SlashEqualsToken */, - "%=": 52 /* PercentEqualsToken */, - "<<=": 53 /* LessThanLessThanEqualsToken */, - ">>=": 54 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 55 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 56 /* AmpersandEqualsToken */, - "|=": 57 /* BarEqualsToken */, - "^=": 58 /* CaretEqualsToken */ + "any": 109 /* AnyKeyword */, + "boolean": 110 /* BooleanKeyword */, + "break": 64 /* BreakKeyword */, + "case": 65 /* CaseKeyword */, + "catch": 66 /* CatchKeyword */, + "class": 67 /* ClassKeyword */, + "continue": 69 /* ContinueKeyword */, + "const": 68 /* ConstKeyword */, + "constructor": 111 /* ConstructorKeyword */, + "debugger": 70 /* DebuggerKeyword */, + "declare": 112 /* DeclareKeyword */, + "default": 71 /* DefaultKeyword */, + "delete": 72 /* DeleteKeyword */, + "do": 73 /* DoKeyword */, + "else": 74 /* ElseKeyword */, + "enum": 75 /* EnumKeyword */, + "export": 76 /* ExportKeyword */, + "extends": 77 /* ExtendsKeyword */, + "false": 78 /* FalseKeyword */, + "finally": 79 /* FinallyKeyword */, + "for": 80 /* ForKeyword */, + "function": 81 /* FunctionKeyword */, + "get": 113 /* GetKeyword */, + "if": 82 /* IfKeyword */, + "implements": 100 /* ImplementsKeyword */, + "import": 83 /* ImportKeyword */, + "in": 84 /* InKeyword */, + "instanceof": 85 /* InstanceOfKeyword */, + "interface": 101 /* InterfaceKeyword */, + "let": 102 /* LetKeyword */, + "module": 114 /* ModuleKeyword */, + "new": 86 /* NewKeyword */, + "null": 87 /* NullKeyword */, + "number": 116 /* NumberKeyword */, + "package": 103 /* PackageKeyword */, + "private": 104 /* PrivateKeyword */, + "protected": 105 /* ProtectedKeyword */, + "public": 106 /* PublicKeyword */, + "require": 115 /* RequireKeyword */, + "return": 88 /* ReturnKeyword */, + "set": 117 /* SetKeyword */, + "static": 107 /* StaticKeyword */, + "string": 118 /* StringKeyword */, + "super": 89 /* SuperKeyword */, + "switch": 90 /* SwitchKeyword */, + "this": 91 /* ThisKeyword */, + "throw": 92 /* ThrowKeyword */, + "true": 93 /* TrueKeyword */, + "try": 94 /* TryKeyword */, + "type": 119 /* TypeKeyword */, + "typeof": 95 /* TypeOfKeyword */, + "var": 96 /* VarKeyword */, + "void": 97 /* VoidKeyword */, + "while": 98 /* WhileKeyword */, + "with": 99 /* WithKeyword */, + "yield": 108 /* YieldKeyword */, + "{": 13 /* OpenBraceToken */, + "}": 14 /* CloseBraceToken */, + "(": 15 /* OpenParenToken */, + ")": 16 /* CloseParenToken */, + "[": 17 /* OpenBracketToken */, + "]": 18 /* CloseBracketToken */, + ".": 19 /* DotToken */, + "...": 20 /* DotDotDotToken */, + ";": 21 /* SemicolonToken */, + ",": 22 /* CommaToken */, + "<": 23 /* LessThanToken */, + ">": 24 /* GreaterThanToken */, + "<=": 25 /* LessThanEqualsToken */, + ">=": 26 /* GreaterThanEqualsToken */, + "==": 27 /* EqualsEqualsToken */, + "!=": 28 /* ExclamationEqualsToken */, + "===": 29 /* EqualsEqualsEqualsToken */, + "!==": 30 /* ExclamationEqualsEqualsToken */, + "=>": 31 /* EqualsGreaterThanToken */, + "+": 32 /* PlusToken */, + "-": 33 /* MinusToken */, + "*": 34 /* AsteriskToken */, + "/": 35 /* SlashToken */, + "%": 36 /* PercentToken */, + "++": 37 /* PlusPlusToken */, + "--": 38 /* MinusMinusToken */, + "<<": 39 /* LessThanLessThanToken */, + ">>": 40 /* GreaterThanGreaterThanToken */, + ">>>": 41 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 42 /* AmpersandToken */, + "|": 43 /* BarToken */, + "^": 44 /* CaretToken */, + "!": 45 /* ExclamationToken */, + "~": 46 /* TildeToken */, + "&&": 47 /* AmpersandAmpersandToken */, + "||": 48 /* BarBarToken */, + "?": 49 /* QuestionToken */, + ":": 50 /* ColonToken */, + "=": 51 /* EqualsToken */, + "+=": 52 /* PlusEqualsToken */, + "-=": 53 /* MinusEqualsToken */, + "*=": 54 /* AsteriskEqualsToken */, + "/=": 55 /* SlashEqualsToken */, + "%=": 56 /* PercentEqualsToken */, + "<<=": 57 /* LessThanLessThanEqualsToken */, + ">>=": 58 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 60 /* AmpersandEqualsToken */, + "|=": 61 /* BarEqualsToken */, + "^=": 62 /* CaretEqualsToken */ }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -838,10 +847,10 @@ var ts; } return +(text.substring(start, pos)); } - function scanHexDigits(count, exact) { + function scanHexDigits(count, mustMatchCount) { var digits = 0; var value = 0; - while (digits < count || !exact) { + while (digits < count || !mustMatchCount) { var ch = text.charCodeAt(pos); if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { value = value * 16 + ch - 48 /* _0 */; @@ -881,61 +890,7 @@ var ts; } if (ch === 92 /* backslash */) { result += text.substring(start, pos); - pos++; - if (pos >= len) { - error(ts.Diagnostics.Unexpected_end_of_text); - break; - } - ch = text.charCodeAt(pos++); - switch (ch) { - case 48 /* _0 */: - result += "\0"; - break; - case 98 /* b */: - result += "\b"; - break; - case 116 /* t */: - result += "\t"; - break; - case 110 /* n */: - result += "\n"; - break; - case 118 /* v */: - result += "\v"; - break; - case 102 /* f */: - result += "\f"; - break; - case 114 /* r */: - result += "\r"; - break; - case 39 /* singleQuote */: - result += "\'"; - break; - case 34 /* doubleQuote */: - result += "\""; - break; - case 120 /* x */: - case 117 /* u */: - var ch = scanHexDigits(ch === 120 /* x */ ? 2 : 4, true); - if (ch >= 0) { - result += String.fromCharCode(ch); - } - else { - error(ts.Diagnostics.Hexadecimal_digit_expected); - } - break; - case 13 /* carriageReturn */: - if (pos < len && text.charCodeAt(pos) === 10 /* lineFeed */) - pos++; - break; - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: - break; - default: - result += String.fromCharCode(ch); - } + result += scanEscapeSequence(); start = pos; continue; } @@ -948,6 +903,102 @@ var ts; } return result; } + function scanTemplateAndSetTokenValue() { + var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + pos++; + var start = pos; + var contents = ""; + var resultingToken; + while (true) { + if (pos >= len) { + contents += text.substring(start, pos); + error(ts.Diagnostics.Unexpected_end_of_text); + resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; + break; + } + var currChar = text.charCodeAt(pos); + if (currChar === 96 /* backtick */) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; + break; + } + if (currChar === 36 /* $ */ && pos + 1 < len && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + contents += text.substring(start, pos); + pos += 2; + resultingToken = startedWithBacktick ? 10 /* TemplateHead */ : 11 /* TemplateMiddle */; + break; + } + if (currChar === 92 /* backslash */) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + if (currChar === 13 /* carriageReturn */) { + contents += text.substring(start, pos); + if (pos + 1 < len && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + pos++; + } + pos++; + contents += "\n"; + start = pos; + continue; + } + pos++; + } + ts.Debug.assert(resultingToken !== undefined); + tokenValue = contents; + return resultingToken; + } + function scanEscapeSequence() { + pos++; + if (pos >= len) { + error(ts.Diagnostics.Unexpected_end_of_text); + return ""; + } + var ch = text.charCodeAt(pos++); + switch (ch) { + case 48 /* _0 */: + return "\0"; + case 98 /* b */: + return "\b"; + case 116 /* t */: + return "\t"; + case 110 /* n */: + return "\n"; + case 118 /* v */: + return "\v"; + case 102 /* f */: + return "\f"; + case 114 /* r */: + return "\r"; + case 39 /* singleQuote */: + return "\'"; + case 34 /* doubleQuote */: + return "\""; + case 120 /* x */: + case 117 /* u */: + var ch = scanHexDigits(ch === 120 /* x */ ? 2 : 4, true); + if (ch >= 0) { + return String.fromCharCode(ch); + } + else { + error(ts.Diagnostics.Hexadecimal_digit_expected); + return ""; + } + case 13 /* carriageReturn */: + if (pos < len && text.charCodeAt(pos) === 10 /* lineFeed */) { + pos++; + } + case 10 /* lineFeed */: + case 8232 /* lineSeparator */: + case 8233 /* paragraphSeparator */: + return ""; + default: + return String.fromCharCode(ch); + } + } function peekUnicodeEscape() { if (pos + 5 < len && text.charCodeAt(pos + 1) === 117 /* u */) { var start = pos; @@ -991,7 +1042,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 59 /* Identifier */; + return token = 63 /* Identifier */; } function scan() { startPos = pos; @@ -1036,64 +1087,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 26 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 30 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 24 /* ExclamationEqualsToken */; + return pos += 2, token = 28 /* ExclamationEqualsToken */; } - return pos++, token = 41 /* ExclamationToken */; + return pos++, token = 45 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); return token = 7 /* StringLiteral */; + case 96 /* backtick */: + return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 52 /* PercentEqualsToken */; + return pos += 2, token = 56 /* PercentEqualsToken */; } - return pos++, token = 32 /* PercentToken */; + return pos++, token = 36 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 43 /* AmpersandAmpersandToken */; + return pos += 2, token = 47 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* AmpersandEqualsToken */; + return pos += 2, token = 60 /* AmpersandEqualsToken */; } - return pos++, token = 38 /* AmpersandToken */; + return pos++, token = 42 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 11 /* OpenParenToken */; + return pos++, token = 15 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 12 /* CloseParenToken */; + return pos++, token = 16 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 50 /* AsteriskEqualsToken */; + return pos += 2, token = 54 /* AsteriskEqualsToken */; } - return pos++, token = 30 /* AsteriskToken */; + return pos++, token = 34 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 33 /* PlusPlusToken */; + return pos += 2, token = 37 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 48 /* PlusEqualsToken */; + return pos += 2, token = 52 /* PlusEqualsToken */; } - return pos++, token = 28 /* PlusToken */; + return pos++, token = 32 /* PlusToken */; case 44 /* comma */: - return pos++, token = 18 /* CommaToken */; + return pos++, token = 22 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 34 /* MinusMinusToken */; + return pos += 2, token = 38 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 49 /* MinusEqualsToken */; + return pos += 2, token = 53 /* MinusEqualsToken */; } - return pos++, token = 29 /* MinusToken */; + return pos++, token = 33 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); return token = 6 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 16 /* DotDotDotToken */; + return pos += 3, token = 20 /* DotDotDotToken */; } - return pos++, token = 15 /* DotToken */; + return pos++, token = 19 /* DotToken */; case 47 /* slash */: if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; @@ -1142,9 +1195,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 51 /* SlashEqualsToken */; + return pos += 2, token = 55 /* SlashEqualsToken */; } - return pos++, token = 31 /* SlashToken */; + return pos++, token = 35 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < len && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -1172,58 +1225,58 @@ var ts; tokenValue = "" + scanNumber(); return token = 6 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 46 /* ColonToken */; + return pos++, token = 50 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 17 /* SemicolonToken */; + return pos++, token = 21 /* SemicolonToken */; case 60 /* lessThan */: if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 53 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 57 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 35 /* LessThanLessThanToken */; + return pos += 2, token = 39 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 21 /* LessThanEqualsToken */; + return pos += 2, token = 25 /* LessThanEqualsToken */; } - return pos++, token = 19 /* LessThanToken */; + return pos++, token = 23 /* LessThanToken */; case 61 /* equals */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 25 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 29 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 23 /* EqualsEqualsToken */; + return pos += 2, token = 27 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 27 /* EqualsGreaterThanToken */; + return pos += 2, token = 31 /* EqualsGreaterThanToken */; } - return pos++, token = 47 /* EqualsToken */; + return pos++, token = 51 /* EqualsToken */; case 62 /* greaterThan */: - return pos++, token = 20 /* GreaterThanToken */; + return pos++, token = 24 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 45 /* QuestionToken */; + return pos++, token = 49 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 13 /* OpenBracketToken */; + return pos++, token = 17 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 14 /* CloseBracketToken */; + return pos++, token = 18 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* CaretEqualsToken */; + return pos += 2, token = 62 /* CaretEqualsToken */; } - return pos++, token = 40 /* CaretToken */; + return pos++, token = 44 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 9 /* OpenBraceToken */; + return pos++, token = 13 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 44 /* BarBarToken */; + return pos += 2, token = 48 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* BarEqualsToken */; + return pos += 2, token = 61 /* BarEqualsToken */; } - return pos++, token = 39 /* BarToken */; + return pos++, token = 43 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 10 /* CloseBraceToken */; + return pos++, token = 14 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 42 /* TildeToken */; + return pos++, token = 46 /* TildeToken */; case 92 /* backslash */: var ch = peekUnicodeEscape(); if (ch >= 0 && isIdentifierStart(ch)) { @@ -1259,27 +1312,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 20 /* GreaterThanToken */) { + if (token === 24 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 55 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 37 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 41 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 54 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 58 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 36 /* GreaterThanGreaterThanToken */; + return pos++, token = 40 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 22 /* GreaterThanEqualsToken */; + return pos++, token = 26 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 31 /* SlashToken */ || token === 51 /* SlashEqualsToken */) { + if (token === 35 /* SlashToken */ || token === 55 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -1318,6 +1371,11 @@ var ts; } return token; } + function reScanTemplateToken() { + ts.Debug.assert(token === 14 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + pos = tokenPos; + return token = scanTemplateAndSetTokenValue(); + } function tryScan(callback) { var savePos = pos; var saveStartPos = startPos; @@ -1357,10 +1415,11 @@ var ts; getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 59 /* Identifier */ || token > ts.SyntaxKind.LastReservedWord; }, - isReservedWord: function () { return token >= ts.SyntaxKind.FirstReservedWord && token <= ts.SyntaxKind.LastReservedWord; }, + isIdentifier: function () { return token === 63 /* Identifier */ || token > 99 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 64 /* FirstReservedWord */ && token <= 99 /* LastReservedWord */; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, scan: scan, setText: setText, setTextPos: setTextPos, @@ -1371,234 +1430,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 6] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 7] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 8] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 9] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 10] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 11] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 12] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 13] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 14] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 15] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 16] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 17] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 18] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 19] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 20] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 21] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 22] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 23] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 24] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 25] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 26] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 27] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 28] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 29] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 30] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 31] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 32] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 33] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 34] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 35] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 36] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 37] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 38] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 39] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 40] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 41] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 42] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 43] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 44] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 45] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 46] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 47] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 48] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 49] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 50] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 51] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 52] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 53] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 54] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 55] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 56] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 57] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 58] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 59] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 60] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 61] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 62] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 63] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 64] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 65] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 66] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 67] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 68] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 69] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 70] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 71] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 72] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 73] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 74] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 75] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 76] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 77] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 78] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 79] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 80] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 81] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 82] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 83] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 84] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 85] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 86] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 87] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 88] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 89] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 90] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 91] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 92] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 93] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 94] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 95] = "WithKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 96] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 97] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 98] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 99] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 100] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 101] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 102] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 103] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 104] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 105] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 106] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 107] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 108] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 109] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 110] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 111] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 112] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 113] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 114] = "StringKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 115] = "TypeKeyword"; - SyntaxKind[SyntaxKind["Missing"] = 116] = "Missing"; - SyntaxKind[SyntaxKind["QualifiedName"] = 117] = "QualifiedName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 118] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 119] = "Parameter"; - SyntaxKind[SyntaxKind["Property"] = 120] = "Property"; - SyntaxKind[SyntaxKind["Method"] = 121] = "Method"; - SyntaxKind[SyntaxKind["Constructor"] = 122] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 123] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 124] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 125] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 126] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 127] = "IndexSignature"; - SyntaxKind[SyntaxKind["TypeReference"] = 128] = "TypeReference"; - SyntaxKind[SyntaxKind["TypeQuery"] = 129] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 130] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 131] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 132] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 133] = "UnionType"; - SyntaxKind[SyntaxKind["ParenType"] = 134] = "ParenType"; - SyntaxKind[SyntaxKind["ArrayLiteral"] = 135] = "ArrayLiteral"; - SyntaxKind[SyntaxKind["ObjectLiteral"] = 136] = "ObjectLiteral"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 137] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["PropertyAccess"] = 138] = "PropertyAccess"; - SyntaxKind[SyntaxKind["IndexedAccess"] = 139] = "IndexedAccess"; - SyntaxKind[SyntaxKind["CallExpression"] = 140] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 141] = "NewExpression"; - SyntaxKind[SyntaxKind["TypeAssertion"] = 142] = "TypeAssertion"; - SyntaxKind[SyntaxKind["ParenExpression"] = 143] = "ParenExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 144] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 145] = "ArrowFunction"; - SyntaxKind[SyntaxKind["PrefixOperator"] = 146] = "PrefixOperator"; - SyntaxKind[SyntaxKind["PostfixOperator"] = 147] = "PostfixOperator"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 148] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 149] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 150] = "OmittedExpression"; - SyntaxKind[SyntaxKind["Block"] = 151] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 152] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 153] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 154] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 155] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 156] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 157] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 158] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 159] = "ForInStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 160] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 161] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 162] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 164] = "SwitchStatement"; - SyntaxKind[SyntaxKind["CaseClause"] = 165] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 166] = "DefaultClause"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 167] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 168] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 169] = "TryStatement"; - SyntaxKind[SyntaxKind["TryBlock"] = 170] = "TryBlock"; - SyntaxKind[SyntaxKind["CatchBlock"] = 171] = "CatchBlock"; - SyntaxKind[SyntaxKind["FinallyBlock"] = 172] = "FinallyBlock"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 173] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 174] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 175] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["FunctionBlock"] = 176] = "FunctionBlock"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 177] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 178] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 179] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 180] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 181] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 182] = "ModuleBlock"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 183] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 184] = "ExportAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 185] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 186] = "SourceFile"; - SyntaxKind[SyntaxKind["Program"] = 187] = "Program"; - SyntaxKind[SyntaxKind["SyntaxList"] = 188] = "SyntaxList"; - SyntaxKind[SyntaxKind["Count"] = 189] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = SyntaxKind.EqualsToken] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = SyntaxKind.CaretEqualsToken] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = SyntaxKind.BreakKeyword] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = SyntaxKind.WithKeyword] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.BreakKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.TypeKeyword] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = SyntaxKind.YieldKeyword] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = SyntaxKind.TypeReference] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = SyntaxKind.ParenType] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.CaretEqualsToken] = "LastPunctuation"; - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.EndOfFileToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.TypeKeyword] = "LastToken"; - SyntaxKind[SyntaxKind["FirstTriviaToken"] = SyntaxKind.SingleLineCommentTrivia] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = SyntaxKind.WhitespaceTrivia] = "LastTriviaToken"; - })(ts.SyntaxKind || (ts.SyntaxKind = {})); - var SyntaxKind = ts.SyntaxKind; - (function (NodeFlags) { - NodeFlags[NodeFlags["Export"] = 0x00000001] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 0x00000002] = "Ambient"; - NodeFlags[NodeFlags["QuestionMark"] = 0x00000004] = "QuestionMark"; - NodeFlags[NodeFlags["Rest"] = 0x00000008] = "Rest"; - NodeFlags[NodeFlags["Public"] = 0x00000010] = "Public"; - NodeFlags[NodeFlags["Private"] = 0x00000020] = "Private"; - NodeFlags[NodeFlags["Protected"] = 0x00000040] = "Protected"; - NodeFlags[NodeFlags["Static"] = 0x00000080] = "Static"; - NodeFlags[NodeFlags["MultiLine"] = 0x00000100] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 0x00000200] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 0x00000400] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 0x00000800] = "Let"; - NodeFlags[NodeFlags["Const"] = 0x00001000] = "Const"; - NodeFlags[NodeFlags["Modifier"] = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Static] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = NodeFlags.Let | NodeFlags.Const] = "BlockScoped"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; (function (EmitReturnStatus) { EmitReturnStatus[EmitReturnStatus["Succeeded"] = 0] = "Succeeded"; EmitReturnStatus[EmitReturnStatus["AllOutputGenerationSkipped"] = 1] = "AllOutputGenerationSkipped"; @@ -1608,284 +1439,12 @@ var ts; EmitReturnStatus[EmitReturnStatus["CompilerOptionsErrors"] = 5] = "CompilerOptionsErrors"; })(ts.EmitReturnStatus || (ts.EmitReturnStatus = {})); var EmitReturnStatus = ts.EmitReturnStatus; - (function (TypeFormatFlags) { - TypeFormatFlags[TypeFormatFlags["None"] = 0x00000000] = "None"; - TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType"; - TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction"; - TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation"; - TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 0x00000008] = "WriteArrowStyleSignature"; - TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0x00000010] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 0x00000020] = "WriteTypeArgumentsOfSignature"; - TypeFormatFlags[TypeFormatFlags["InElementType"] = 0x00000040] = "InElementType"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; - (function (SymbolFormatFlags) { - SymbolFormatFlags[SymbolFormatFlags["None"] = 0x00000000] = "None"; - SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 0x00000001] = "WriteTypeParametersOrArguments"; - SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 0x00000002] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; - (function (SymbolAccessibility) { - SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; - SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; - SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; - })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); - var SymbolAccessibility = ts.SymbolAccessibility; - (function (SymbolFlags) { - SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 0x00000001] = "FunctionScopedVariable"; - SymbolFlags[SymbolFlags["BlockScopedVariable"] = 0x00000002] = "BlockScopedVariable"; - SymbolFlags[SymbolFlags["Property"] = 0x00000004] = "Property"; - SymbolFlags[SymbolFlags["EnumMember"] = 0x00000008] = "EnumMember"; - SymbolFlags[SymbolFlags["Function"] = 0x00000010] = "Function"; - SymbolFlags[SymbolFlags["Class"] = 0x00000020] = "Class"; - SymbolFlags[SymbolFlags["Interface"] = 0x00000040] = "Interface"; - SymbolFlags[SymbolFlags["Enum"] = 0x00000080] = "Enum"; - SymbolFlags[SymbolFlags["ValueModule"] = 0x00000100] = "ValueModule"; - SymbolFlags[SymbolFlags["NamespaceModule"] = 0x00000200] = "NamespaceModule"; - SymbolFlags[SymbolFlags["TypeLiteral"] = 0x00000400] = "TypeLiteral"; - SymbolFlags[SymbolFlags["ObjectLiteral"] = 0x00000800] = "ObjectLiteral"; - SymbolFlags[SymbolFlags["Method"] = 0x00001000] = "Method"; - SymbolFlags[SymbolFlags["Constructor"] = 0x00002000] = "Constructor"; - SymbolFlags[SymbolFlags["GetAccessor"] = 0x00004000] = "GetAccessor"; - SymbolFlags[SymbolFlags["SetAccessor"] = 0x00008000] = "SetAccessor"; - SymbolFlags[SymbolFlags["CallSignature"] = 0x00010000] = "CallSignature"; - SymbolFlags[SymbolFlags["ConstructSignature"] = 0x00020000] = "ConstructSignature"; - SymbolFlags[SymbolFlags["IndexSignature"] = 0x00040000] = "IndexSignature"; - SymbolFlags[SymbolFlags["TypeParameter"] = 0x00080000] = "TypeParameter"; - SymbolFlags[SymbolFlags["TypeAlias"] = 0x00100000] = "TypeAlias"; - SymbolFlags[SymbolFlags["ExportValue"] = 0x00200000] = "ExportValue"; - SymbolFlags[SymbolFlags["ExportType"] = 0x00400000] = "ExportType"; - SymbolFlags[SymbolFlags["ExportNamespace"] = 0x00800000] = "ExportNamespace"; - SymbolFlags[SymbolFlags["Import"] = 0x01000000] = "Import"; - SymbolFlags[SymbolFlags["Instantiated"] = 0x02000000] = "Instantiated"; - SymbolFlags[SymbolFlags["Merged"] = 0x04000000] = "Merged"; - SymbolFlags[SymbolFlags["Transient"] = 0x08000000] = "Transient"; - SymbolFlags[SymbolFlags["Prototype"] = 0x10000000] = "Prototype"; - SymbolFlags[SymbolFlags["UnionProperty"] = 0x20000000] = "UnionProperty"; - SymbolFlags[SymbolFlags["Variable"] = SymbolFlags.FunctionScopedVariable | SymbolFlags.BlockScopedVariable] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = SymbolFlags.Variable | SymbolFlags.Property | SymbolFlags.EnumMember | SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule | SymbolFlags.Method | SymbolFlags.GetAccessor | SymbolFlags.SetAccessor] = "Value"; - SymbolFlags[SymbolFlags["Type"] = SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.Enum | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral | SymbolFlags.TypeParameter | SymbolFlags.TypeAlias] = "Type"; - SymbolFlags[SymbolFlags["Namespace"] = SymbolFlags.ValueModule | SymbolFlags.NamespaceModule] = "Namespace"; - SymbolFlags[SymbolFlags["Module"] = SymbolFlags.ValueModule | SymbolFlags.NamespaceModule] = "Module"; - SymbolFlags[SymbolFlags["Accessor"] = SymbolFlags.GetAccessor | SymbolFlags.SetAccessor] = "Accessor"; - SymbolFlags[SymbolFlags["Signature"] = SymbolFlags.CallSignature | SymbolFlags.ConstructSignature | SymbolFlags.IndexSignature] = "Signature"; - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = SymbolFlags.Value & ~SymbolFlags.FunctionScopedVariable] = "FunctionScopedVariableExcludes"; - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = SymbolFlags.Value] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = SymbolFlags.Value] = "ParameterExcludes"; - SymbolFlags[SymbolFlags["PropertyExcludes"] = SymbolFlags.Value] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = SymbolFlags.Value] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = SymbolFlags.Value & ~(SymbolFlags.Function | SymbolFlags.ValueModule)] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = (SymbolFlags.Value | SymbolFlags.Type) & ~SymbolFlags.ValueModule] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = SymbolFlags.Type & ~SymbolFlags.Interface] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["EnumExcludes"] = (SymbolFlags.Value | SymbolFlags.Type) & ~(SymbolFlags.Enum | SymbolFlags.ValueModule)] = "EnumExcludes"; - SymbolFlags[SymbolFlags["ValueModuleExcludes"] = SymbolFlags.Value & ~(SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)] = "ValueModuleExcludes"; - SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = SymbolFlags.Value & ~SymbolFlags.Method] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = SymbolFlags.Value & ~SymbolFlags.SetAccessor] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = SymbolFlags.Value & ~SymbolFlags.GetAccessor] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = SymbolFlags.Type & ~SymbolFlags.TypeParameter] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = SymbolFlags.Type] = "TypeAliasExcludes"; - SymbolFlags[SymbolFlags["ImportExcludes"] = SymbolFlags.Import] = "ImportExcludes"; - SymbolFlags[SymbolFlags["ModuleMember"] = SymbolFlags.Variable | SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.Enum | SymbolFlags.Module | SymbolFlags.TypeAlias | SymbolFlags.Import] = "ModuleMember"; - SymbolFlags[SymbolFlags["ExportHasLocal"] = SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule] = "ExportHasLocal"; - SymbolFlags[SymbolFlags["HasLocals"] = SymbolFlags.Function | SymbolFlags.Module | SymbolFlags.Method | SymbolFlags.Constructor | SymbolFlags.Accessor | SymbolFlags.Signature] = "HasLocals"; - SymbolFlags[SymbolFlags["HasExports"] = SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.Module] = "HasExports"; - SymbolFlags[SymbolFlags["HasMembers"] = SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral] = "HasMembers"; - SymbolFlags[SymbolFlags["IsContainer"] = SymbolFlags.HasLocals | SymbolFlags.HasExports | SymbolFlags.HasMembers] = "IsContainer"; - SymbolFlags[SymbolFlags["PropertyOrAccessor"] = SymbolFlags.Property | SymbolFlags.Accessor] = "PropertyOrAccessor"; - SymbolFlags[SymbolFlags["Export"] = SymbolFlags.ExportNamespace | SymbolFlags.ExportType | SymbolFlags.ExportValue] = "Export"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; - (function (NodeCheckFlags) { - NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 0x00000001] = "TypeChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 0x00000002] = "LexicalThis"; - NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 0x00000004] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 0x00000008] = "EmitExtends"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 0x00000010] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 0x00000020] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 0x00000040] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 0x00000080] = "EnumValuesComputed"; - })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); - var NodeCheckFlags = ts.NodeCheckFlags; - (function (TypeFlags) { - TypeFlags[TypeFlags["Any"] = 0x00000001] = "Any"; - TypeFlags[TypeFlags["String"] = 0x00000002] = "String"; - TypeFlags[TypeFlags["Number"] = 0x00000004] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 0x00000008] = "Boolean"; - TypeFlags[TypeFlags["Void"] = 0x00000010] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 0x00000020] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 0x00000040] = "Null"; - TypeFlags[TypeFlags["Enum"] = 0x00000080] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 0x00000100] = "StringLiteral"; - TypeFlags[TypeFlags["TypeParameter"] = 0x00000200] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 0x00000400] = "Class"; - TypeFlags[TypeFlags["Interface"] = 0x00000800] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 0x00001000] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 0x00002000] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 0x00004000] = "Union"; - TypeFlags[TypeFlags["Anonymous"] = 0x00008000] = "Anonymous"; - TypeFlags[TypeFlags["FromSignature"] = 0x00010000] = "FromSignature"; - TypeFlags[TypeFlags["Intrinsic"] = TypeFlags.Any | TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Void | TypeFlags.Undefined | TypeFlags.Null] = "Intrinsic"; - TypeFlags[TypeFlags["StringLike"] = TypeFlags.String | TypeFlags.StringLiteral] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = TypeFlags.Number | TypeFlags.Enum] = "NumberLike"; - TypeFlags[TypeFlags["ObjectType"] = TypeFlags.Class | TypeFlags.Interface | TypeFlags.Reference | TypeFlags.Tuple | TypeFlags.Anonymous] = "ObjectType"; - TypeFlags[TypeFlags["Structured"] = TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter] = "Structured"; - })(ts.TypeFlags || (ts.TypeFlags = {})); - var TypeFlags = ts.TypeFlags; - (function (SignatureKind) { - SignatureKind[SignatureKind["Call"] = 0] = "Call"; - SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; - })(ts.SignatureKind || (ts.SignatureKind = {})); - var SignatureKind = ts.SignatureKind; - (function (IndexKind) { - IndexKind[IndexKind["String"] = 0] = "String"; - IndexKind[IndexKind["Number"] = 1] = "Number"; - })(ts.IndexKind || (ts.IndexKind = {})); - var IndexKind = ts.IndexKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; - (function (ModuleKind) { - ModuleKind[ModuleKind["None"] = 0] = "None"; - ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; - ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; - })(ts.ModuleKind || (ts.ModuleKind = {})); - var ModuleKind = ts.ModuleKind; - (function (ScriptTarget) { - ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; - ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; - ScriptTarget[ScriptTarget["ES6"] = 2] = "ES6"; - ScriptTarget[ScriptTarget["Latest"] = ScriptTarget.ES6] = "Latest"; - })(ts.ScriptTarget || (ts.ScriptTarget = {})); - var ScriptTarget = ts.ScriptTarget; - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 0x7F] = "maxAsciiCharacter"; - CharacterCodes[CharacterCodes["lineFeed"] = 0x0A] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 0x0D] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - CharacterCodes[CharacterCodes["mathematicalSpace"] = 0x205F] = "mathematicalSpace"; - CharacterCodes[CharacterCodes["ogham"] = 0x1680] = "ogham"; - CharacterCodes[CharacterCodes["_"] = 0x5F] = "_"; - CharacterCodes[CharacterCodes["$"] = 0x24] = "$"; - CharacterCodes[CharacterCodes["_0"] = 0x30] = "_0"; - CharacterCodes[CharacterCodes["_1"] = 0x31] = "_1"; - CharacterCodes[CharacterCodes["_2"] = 0x32] = "_2"; - CharacterCodes[CharacterCodes["_3"] = 0x33] = "_3"; - CharacterCodes[CharacterCodes["_4"] = 0x34] = "_4"; - CharacterCodes[CharacterCodes["_5"] = 0x35] = "_5"; - CharacterCodes[CharacterCodes["_6"] = 0x36] = "_6"; - CharacterCodes[CharacterCodes["_7"] = 0x37] = "_7"; - CharacterCodes[CharacterCodes["_8"] = 0x38] = "_8"; - CharacterCodes[CharacterCodes["_9"] = 0x39] = "_9"; - CharacterCodes[CharacterCodes["a"] = 0x61] = "a"; - CharacterCodes[CharacterCodes["b"] = 0x62] = "b"; - CharacterCodes[CharacterCodes["c"] = 0x63] = "c"; - CharacterCodes[CharacterCodes["d"] = 0x64] = "d"; - CharacterCodes[CharacterCodes["e"] = 0x65] = "e"; - CharacterCodes[CharacterCodes["f"] = 0x66] = "f"; - CharacterCodes[CharacterCodes["g"] = 0x67] = "g"; - CharacterCodes[CharacterCodes["h"] = 0x68] = "h"; - CharacterCodes[CharacterCodes["i"] = 0x69] = "i"; - CharacterCodes[CharacterCodes["j"] = 0x6A] = "j"; - CharacterCodes[CharacterCodes["k"] = 0x6B] = "k"; - CharacterCodes[CharacterCodes["l"] = 0x6C] = "l"; - CharacterCodes[CharacterCodes["m"] = 0x6D] = "m"; - CharacterCodes[CharacterCodes["n"] = 0x6E] = "n"; - CharacterCodes[CharacterCodes["o"] = 0x6F] = "o"; - CharacterCodes[CharacterCodes["p"] = 0x70] = "p"; - CharacterCodes[CharacterCodes["q"] = 0x71] = "q"; - CharacterCodes[CharacterCodes["r"] = 0x72] = "r"; - CharacterCodes[CharacterCodes["s"] = 0x73] = "s"; - CharacterCodes[CharacterCodes["t"] = 0x74] = "t"; - CharacterCodes[CharacterCodes["u"] = 0x75] = "u"; - CharacterCodes[CharacterCodes["v"] = 0x76] = "v"; - CharacterCodes[CharacterCodes["w"] = 0x77] = "w"; - CharacterCodes[CharacterCodes["x"] = 0x78] = "x"; - CharacterCodes[CharacterCodes["y"] = 0x79] = "y"; - CharacterCodes[CharacterCodes["z"] = 0x7A] = "z"; - CharacterCodes[CharacterCodes["A"] = 0x41] = "A"; - CharacterCodes[CharacterCodes["B"] = 0x42] = "B"; - CharacterCodes[CharacterCodes["C"] = 0x43] = "C"; - CharacterCodes[CharacterCodes["D"] = 0x44] = "D"; - CharacterCodes[CharacterCodes["E"] = 0x45] = "E"; - CharacterCodes[CharacterCodes["F"] = 0x46] = "F"; - CharacterCodes[CharacterCodes["G"] = 0x47] = "G"; - CharacterCodes[CharacterCodes["H"] = 0x48] = "H"; - CharacterCodes[CharacterCodes["I"] = 0x49] = "I"; - CharacterCodes[CharacterCodes["J"] = 0x4A] = "J"; - CharacterCodes[CharacterCodes["K"] = 0x4B] = "K"; - CharacterCodes[CharacterCodes["L"] = 0x4C] = "L"; - CharacterCodes[CharacterCodes["M"] = 0x4D] = "M"; - CharacterCodes[CharacterCodes["N"] = 0x4E] = "N"; - CharacterCodes[CharacterCodes["O"] = 0x4F] = "O"; - CharacterCodes[CharacterCodes["P"] = 0x50] = "P"; - CharacterCodes[CharacterCodes["Q"] = 0x51] = "Q"; - CharacterCodes[CharacterCodes["R"] = 0x52] = "R"; - CharacterCodes[CharacterCodes["S"] = 0x53] = "S"; - CharacterCodes[CharacterCodes["T"] = 0x54] = "T"; - CharacterCodes[CharacterCodes["U"] = 0x55] = "U"; - CharacterCodes[CharacterCodes["V"] = 0x56] = "V"; - CharacterCodes[CharacterCodes["W"] = 0x57] = "W"; - CharacterCodes[CharacterCodes["X"] = 0x58] = "X"; - CharacterCodes[CharacterCodes["Y"] = 0x59] = "Y"; - CharacterCodes[CharacterCodes["Z"] = 0x5a] = "Z"; - CharacterCodes[CharacterCodes["ampersand"] = 0x26] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 0x2A] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 0x40] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 0x5C] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 0x7C] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 0x5E] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 0x7D] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 0x5D] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 0x29] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 0x3A] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 0x2C] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 0x2E] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 0x22] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 0x3D] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 0x21] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 0x3E] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 0x3C] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 0x2D] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 0x7B] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 0x5B] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 0x28] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 0x25] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 0x2B] = "plus"; - CharacterCodes[CharacterCodes["question"] = 0x3F] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 0x3B] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 0x27] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 0x2F] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 0x7E] = "tilde"; - CharacterCodes[CharacterCodes["backspace"] = 0x08] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 0x0C] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 0x09] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 0x0B] = "verticalTab"; - })(ts.CharacterCodes || (ts.CharacterCodes = {})); - var CharacterCodes = ts.CharacterCodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -2161,12 +1720,12 @@ var ts; ts.flattenDiagnosticChain = flattenDiagnosticChain; function compareValues(a, b) { if (a === b) - return 0; + return 0 /* EqualTo */; if (a === undefined) - return -1; + return -1 /* LessThan */; if (b === undefined) - return 1; - return a < b ? -1 : 1; + return 1 /* GreaterThan */; + return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; } ts.compareValues = compareValues; function getDiagnosticFilename(diagnostic) { @@ -2184,7 +1743,7 @@ var ts; var previousDiagnostic = diagnostics[0]; for (var i = 1; i < diagnostics.length; i++) { var currentDiagnostic = diagnostics[i]; - var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0; + var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */; if (!isDupe) { newDiagnostics.push(currentDiagnostic); previousDiagnostic = currentDiagnostic; @@ -2413,13 +1972,6 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; - (function (AssertionLevel) { - AssertionLevel[AssertionLevel["None"] = 0] = "None"; - AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; - AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; - AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(ts.AssertionLevel || (ts.AssertionLevel = {})); - var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { var currentAssertionLevel = 0 /* None */; @@ -2640,7 +2192,7 @@ var sys = (function () { })(); var ts; (function (ts) { - var nodeConstructors = new Array(189 /* Count */); + var nodeConstructors = new Array(196 /* Count */); function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); } @@ -2653,7 +2205,7 @@ var ts; return node; } function getSourceFileOfNode(node) { - while (node && node.kind !== 186 /* SourceFile */) + while (node && node.kind !== 193 /* SourceFile */) node = node.parent; return node; } @@ -2690,81 +2242,13 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function identifierToString(identifier) { - return identifier.kind === 116 /* Missing */ ? "(Missing)" : getTextOfNode(identifier); + return identifier.kind === 120 /* Missing */ ? "(Missing)" : getTextOfNode(identifier); } ts.identifierToString = identifierToString; - function isExpression(node) { - switch (node.kind) { - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: - case 83 /* NullKeyword */: - case 89 /* TrueKeyword */: - case 74 /* FalseKeyword */: - case 8 /* RegularExpressionLiteral */: - case 135 /* ArrayLiteral */: - case 136 /* ObjectLiteral */: - case 138 /* PropertyAccess */: - case 139 /* IndexedAccess */: - case 140 /* CallExpression */: - case 141 /* NewExpression */: - case 142 /* TypeAssertion */: - case 143 /* ParenExpression */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: - case 148 /* BinaryExpression */: - case 149 /* ConditionalExpression */: - case 150 /* OmittedExpression */: - return true; - case 117 /* QualifiedName */: - while (node.parent.kind === 117 /* QualifiedName */) - node = node.parent; - return node.parent.kind === 129 /* TypeQuery */; - case 59 /* Identifier */: - if (node.parent.kind === 129 /* TypeQuery */) { - return true; - } - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - var parent = node.parent; - switch (parent.kind) { - case 174 /* VariableDeclaration */: - case 119 /* Parameter */: - case 120 /* Property */: - case 185 /* EnumMember */: - case 137 /* PropertyAssignment */: - return parent.initializer === node; - case 154 /* ExpressionStatement */: - case 155 /* IfStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 162 /* ReturnStatement */: - case 163 /* WithStatement */: - case 164 /* SwitchStatement */: - case 165 /* CaseClause */: - case 168 /* ThrowStatement */: - case 164 /* SwitchStatement */: - return parent.expression === node; - case 158 /* ForStatement */: - return parent.initializer === node || parent.condition === node || parent.iterator === node; - case 159 /* ForInStatement */: - return parent.variable === node || parent.expression === node; - case 142 /* TypeAssertion */: - return node === parent.operand; - default: - if (isExpression(parent)) { - return true; - } - } - } - return false; - } - ts.isExpression = isExpression; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { node = getErrorSpanForNode(node); var file = getSourceFileOfNode(node); - var start = node.kind === 116 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos); + var start = node.kind === 120 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos); var length = node.end - start; return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); } @@ -2780,12 +2264,12 @@ var ts; function getErrorSpanForNode(node) { var errorSpan; switch (node.kind) { - case 174 /* VariableDeclaration */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 181 /* ModuleDeclaration */: - case 180 /* EnumDeclaration */: - case 185 /* EnumMember */: + case 181 /* VariableDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 188 /* ModuleDeclaration */: + case 187 /* EnumDeclaration */: + case 192 /* EnumMember */: errorSpan = node.name; break; } @@ -2800,12 +2284,16 @@ var ts; return (file.flags & 1024 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return (node.flags & 4096 /* Const */) !== 0; + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; function isPrologueDirective(node) { - return node.kind === 154 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; + return node.kind === 161 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isEvalOrArgumentsIdentifier(node) { - return node.kind === 59 /* Identifier */ && node.text && (node.text === "eval" || node.text === "arguments"); + return node.kind === 63 /* Identifier */ && node.text && (node.text === "eval" || node.text === "arguments"); } function isUseStrictPrologueDirective(node) { ts.Debug.assert(isPrologueDirective(node)); @@ -2813,7 +2301,7 @@ var ts; } function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 119 /* Parameter */ || node.kind === 118 /* TypeParameter */) { + if (node.kind === 123 /* Parameter */ || node.kind === 122 /* TypeParameter */) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -2849,122 +2337,128 @@ var ts; if (!node) return; switch (node.kind) { - case 117 /* QualifiedName */: + case 121 /* QualifiedName */: return child(node.left) || child(node.right); - case 118 /* TypeParameter */: + case 122 /* TypeParameter */: return child(node.name) || child(node.constraint); - case 119 /* Parameter */: + case 123 /* Parameter */: return child(node.name) || child(node.type) || child(node.initializer); - case 120 /* Property */: - case 137 /* PropertyAssignment */: + case 124 /* Property */: + case 141 /* PropertyAssignment */: return child(node.name) || child(node.type) || child(node.initializer); - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: return children(node.typeParameters) || children(node.parameters) || child(node.type); - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 144 /* FunctionExpression */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 149 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: return child(node.name) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); - case 128 /* TypeReference */: + case 132 /* TypeReference */: return child(node.typeName) || children(node.typeArguments); - case 129 /* TypeQuery */: + case 133 /* TypeQuery */: return child(node.exprName); - case 130 /* TypeLiteral */: + case 134 /* TypeLiteral */: return children(node.members); - case 131 /* ArrayType */: + case 135 /* ArrayType */: return child(node.elementType); - case 132 /* TupleType */: + case 136 /* TupleType */: return children(node.elementTypes); - case 133 /* UnionType */: + case 137 /* UnionType */: return children(node.types); - case 134 /* ParenType */: + case 138 /* ParenType */: return child(node.type); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return children(node.elements); - case 136 /* ObjectLiteral */: + case 140 /* ObjectLiteral */: return children(node.properties); - case 138 /* PropertyAccess */: + case 142 /* PropertyAccess */: return child(node.left) || child(node.right); - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return child(node.object) || child(node.index); - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return child(node.func) || children(node.typeArguments) || children(node.arguments); - case 142 /* TypeAssertion */: + case 146 /* TaggedTemplateExpression */: + return child(node.tag) || child(node.template); + case 147 /* TypeAssertion */: return child(node.type) || child(node.operand); - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return child(node.expression); - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: return child(node.operand); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return child(node.left) || child(node.right); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); - case 151 /* Block */: - case 170 /* TryBlock */: - case 172 /* FinallyBlock */: - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: - case 186 /* SourceFile */: + case 158 /* Block */: + case 177 /* TryBlock */: + case 179 /* FinallyBlock */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: + case 193 /* SourceFile */: return children(node.statements); - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return children(node.declarations); - case 154 /* ExpressionStatement */: + case 161 /* ExpressionStatement */: return child(node.expression); - case 155 /* IfStatement */: + case 162 /* IfStatement */: return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); - case 156 /* DoStatement */: + case 163 /* DoStatement */: return child(node.statement) || child(node.expression); - case 157 /* WhileStatement */: + case 164 /* WhileStatement */: return child(node.expression) || child(node.statement); - case 158 /* ForStatement */: + case 165 /* ForStatement */: return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); - case 159 /* ForInStatement */: + case 166 /* ForInStatement */: return child(node.declaration) || child(node.variable) || child(node.expression) || child(node.statement); - case 160 /* ContinueStatement */: - case 161 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 168 /* BreakStatement */: return child(node.label); - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return child(node.expression); - case 163 /* WithStatement */: + case 170 /* WithStatement */: return child(node.expression) || child(node.statement); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return child(node.expression) || children(node.clauses); - case 165 /* CaseClause */: - case 166 /* DefaultClause */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: return child(node.expression) || children(node.statements); - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return child(node.label) || child(node.statement); - case 168 /* ThrowStatement */: + case 175 /* ThrowStatement */: return child(node.expression); - case 169 /* TryStatement */: + case 176 /* TryStatement */: return child(node.tryBlock) || child(node.catchBlock) || child(node.finallyBlock); - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: return child(node.variable) || children(node.statements); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: return child(node.name) || child(node.type) || child(node.initializer); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return child(node.name) || children(node.typeParameters) || child(node.baseType) || children(node.implementedTypes) || children(node.members); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return child(node.name) || children(node.typeParameters) || children(node.baseTypes) || children(node.members); - case 179 /* TypeAliasDeclaration */: + case 186 /* TypeAliasDeclaration */: return child(node.name) || child(node.type); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return child(node.name) || children(node.members); - case 185 /* EnumMember */: + case 192 /* EnumMember */: return child(node.name) || child(node.initializer); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return child(node.name) || child(node.body); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return child(node.name) || child(node.entityName) || child(node.externalModuleName); - case 184 /* ExportAssignment */: + case 191 /* ExportAssignment */: return child(node.exportName); + case 155 /* TemplateExpression */: + return child(node.head) || children(node.templateSpans); + case 156 /* TemplateSpan */: + return child(node.expression) || child(node.literal); } } ts.forEachChild = forEachChild; @@ -2972,24 +2466,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return visitor(node); - case 151 /* Block */: - case 176 /* FunctionBlock */: - case 155 /* IfStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 163 /* WithStatement */: - case 164 /* SwitchStatement */: - case 165 /* CaseClause */: - case 166 /* DefaultClause */: - case 167 /* LabeledStatement */: - case 169 /* TryStatement */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: + case 158 /* Block */: + case 183 /* FunctionBlock */: + case 162 /* IfStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 170 /* WithStatement */: + case 171 /* SwitchStatement */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: + case 174 /* LabeledStatement */: + case 176 /* TryStatement */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: return forEachChild(node, traverse); } } @@ -2998,13 +2492,13 @@ var ts; function isAnyFunction(node) { if (node) { switch (node.kind) { - case 144 /* FunctionExpression */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: - case 121 /* Method */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 122 /* Constructor */: + case 149 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: + case 125 /* Method */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 126 /* Constructor */: return true; } } @@ -3027,20 +2521,20 @@ var ts; return undefined; } switch (node.kind) { - case 145 /* ArrowFunction */: + case 150 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 181 /* ModuleDeclaration */: - case 120 /* Property */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 180 /* EnumDeclaration */: - case 186 /* SourceFile */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 188 /* ModuleDeclaration */: + case 124 /* Property */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 187 /* EnumDeclaration */: + case 193 /* SourceFile */: return node; } } @@ -3053,20 +2547,103 @@ var ts; return undefined; } switch (node.kind) { - case 120 /* Property */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 124 /* Property */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; + function isExpression(node) { + switch (node.kind) { + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: + case 87 /* NullKeyword */: + case 93 /* TrueKeyword */: + case 78 /* FalseKeyword */: + case 8 /* RegularExpressionLiteral */: + case 139 /* ArrayLiteral */: + case 140 /* ObjectLiteral */: + case 142 /* PropertyAccess */: + case 143 /* IndexedAccess */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: + case 146 /* TaggedTemplateExpression */: + case 147 /* TypeAssertion */: + case 148 /* ParenExpression */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: + case 153 /* BinaryExpression */: + case 154 /* ConditionalExpression */: + case 155 /* TemplateExpression */: + case 157 /* OmittedExpression */: + return true; + case 121 /* QualifiedName */: + while (node.parent.kind === 121 /* QualifiedName */) + node = node.parent; + return node.parent.kind === 133 /* TypeQuery */; + case 63 /* Identifier */: + if (node.parent.kind === 133 /* TypeQuery */) { + return true; + } + case 6 /* NumericLiteral */: + case 7 /* StringLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: + var parent = node.parent; + switch (parent.kind) { + case 181 /* VariableDeclaration */: + case 123 /* Parameter */: + case 124 /* Property */: + case 192 /* EnumMember */: + case 141 /* PropertyAssignment */: + return parent.initializer === node; + case 161 /* ExpressionStatement */: + case 162 /* IfStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 169 /* ReturnStatement */: + case 170 /* WithStatement */: + case 171 /* SwitchStatement */: + case 172 /* CaseClause */: + case 175 /* ThrowStatement */: + case 171 /* SwitchStatement */: + return parent.expression === node; + case 165 /* ForStatement */: + return parent.initializer === node || parent.condition === node || parent.iterator === node; + case 166 /* ForInStatement */: + return parent.variable === node || parent.expression === node; + case 147 /* TypeAssertion */: + return node === parent.operand; + default: + if (isExpression(parent)) { + return true; + } + } + } + return false; + } + ts.isExpression = isExpression; function hasRestParameters(s) { return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & 8 /* Rest */) !== 0; } ts.hasRestParameters = hasRestParameters; + function isLiteralKind(kind) { + return 6 /* FirstLiteralToken */ <= kind && kind <= 9 /* LastLiteralToken */; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 7 /* StringLiteral */ || kind === 9 /* NoSubstitutionTemplateLiteral */; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isTemplateLiteralKind(kind) { + return 9 /* FirstTemplateToken */ <= kind && kind <= 12 /* LastTemplateToken */; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; function isInAmbientContext(node) { while (node) { if (node.flags & (2 /* Ambient */ | 1024 /* DeclarationFile */)) @@ -3078,22 +2655,22 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 118 /* TypeParameter */: - case 119 /* Parameter */: - case 174 /* VariableDeclaration */: - case 120 /* Property */: - case 137 /* PropertyAssignment */: - case 185 /* EnumMember */: - case 121 /* Method */: - case 175 /* FunctionDeclaration */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 180 /* EnumDeclaration */: - case 181 /* ModuleDeclaration */: - case 183 /* ImportDeclaration */: + case 122 /* TypeParameter */: + case 123 /* Parameter */: + case 181 /* VariableDeclaration */: + case 124 /* Property */: + case 141 /* PropertyAssignment */: + case 192 /* EnumMember */: + case 125 /* Method */: + case 182 /* FunctionDeclaration */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 187 /* EnumDeclaration */: + case 188 /* ModuleDeclaration */: + case 190 /* ImportDeclaration */: return true; } return false; @@ -3101,24 +2678,24 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 161 /* BreakStatement */: - case 160 /* ContinueStatement */: - case 173 /* DebuggerStatement */: - case 156 /* DoStatement */: - case 154 /* ExpressionStatement */: - case 153 /* EmptyStatement */: - case 159 /* ForInStatement */: - case 158 /* ForStatement */: - case 155 /* IfStatement */: - case 167 /* LabeledStatement */: - case 162 /* ReturnStatement */: - case 164 /* SwitchStatement */: - case 88 /* ThrowKeyword */: - case 169 /* TryStatement */: - case 152 /* VariableStatement */: - case 157 /* WhileStatement */: - case 163 /* WithStatement */: - case 184 /* ExportAssignment */: + case 168 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 180 /* DebuggerStatement */: + case 163 /* DoStatement */: + case 161 /* ExpressionStatement */: + case 160 /* EmptyStatement */: + case 166 /* ForInStatement */: + case 165 /* ForStatement */: + case 162 /* IfStatement */: + case 174 /* LabeledStatement */: + case 169 /* ReturnStatement */: + case 171 /* SwitchStatement */: + case 92 /* ThrowKeyword */: + case 176 /* TryStatement */: + case 159 /* VariableStatement */: + case 164 /* WhileStatement */: + case 170 /* WithStatement */: + case 191 /* ExportAssignment */: return true; default: return false; @@ -3126,14 +2703,14 @@ var ts; } ts.isStatement = isStatement; function isDeclarationOrFunctionExpressionOrCatchVariableName(name) { - if (name.kind !== 59 /* Identifier */ && name.kind !== 7 /* StringLiteral */ && name.kind !== 6 /* NumericLiteral */) { + if (name.kind !== 63 /* Identifier */ && name.kind !== 7 /* StringLiteral */ && name.kind !== 6 /* NumericLiteral */) { return false; } var parent = name.parent; - if (isDeclaration(parent) || parent.kind === 144 /* FunctionExpression */) { + if (isDeclaration(parent) || parent.kind === 149 /* FunctionExpression */) { return parent.name === name; } - if (parent.kind === 171 /* CatchBlock */) { + if (parent.kind === 178 /* CatchBlock */) { return parent.variable === name; } return false; @@ -3141,16 +2718,16 @@ var ts; ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName; function getAncestor(node, kind) { switch (kind) { - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: while (node) { switch (node.kind) { - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return node; - case 180 /* EnumDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 181 /* ModuleDeclaration */: - case 183 /* ImportDeclaration */: + case 187 /* EnumDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 188 /* ModuleDeclaration */: + case 190 /* ImportDeclaration */: return undefined; default: node = node.parent; @@ -3170,107 +2747,44 @@ var ts; return undefined; } ts.getAncestor = getAncestor; - var ParsingContext; - (function (ParsingContext) { - ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["ModuleElements"] = 1] = "ModuleElements"; - ParsingContext[ParsingContext["BlockStatements"] = 2] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 3] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 4] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 5] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 6] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 7] = "EnumMembers"; - ParsingContext[ParsingContext["BaseTypeReferences"] = 8] = "BaseTypeReferences"; - ParsingContext[ParsingContext["VariableDeclarations"] = 9] = "VariableDeclarations"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 10] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 11] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["ArrayLiteralMembers"] = 12] = "ArrayLiteralMembers"; - ParsingContext[ParsingContext["Parameters"] = 13] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 14] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 15] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 16] = "TupleElementTypes"; - ParsingContext[ParsingContext["Count"] = 17] = "Count"; - })(ParsingContext || (ParsingContext = {})); - var Tristate; - (function (Tristate) { - Tristate[Tristate["False"] = 0] = "False"; - Tristate[Tristate["True"] = 1] = "True"; - Tristate[Tristate["Unknown"] = 2] = "Unknown"; - })(Tristate || (Tristate = {})); function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: - return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: - return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: - return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: - return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: - return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: - return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: - return ts.Diagnostics.Enum_member_expected; - case 8 /* BaseTypeReferences */: - return ts.Diagnostics.Type_reference_expected; - case 9 /* VariableDeclarations */: - return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ArgumentExpressions */: - return ts.Diagnostics.Argument_expression_expected; - case 11 /* ObjectLiteralMembers */: - return ts.Diagnostics.Property_assignment_expected; - case 12 /* ArrayLiteralMembers */: - return ts.Diagnostics.Expression_or_comma_expected; - case 13 /* Parameters */: - return ts.Diagnostics.Parameter_declaration_expected; - case 14 /* TypeParameters */: - return ts.Diagnostics.Type_parameter_declaration_expected; - case 15 /* TypeArguments */: - return ts.Diagnostics.Type_argument_expected; - case 16 /* TupleElementTypes */: - return ts.Diagnostics.Type_expected; + case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; + case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 8 /* BaseTypeReferences */: return ts.Diagnostics.Type_reference_expected; + case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; } } ; - var LookAheadMode; - (function (LookAheadMode) { - LookAheadMode[LookAheadMode["NotLookingAhead"] = 0] = "NotLookingAhead"; - LookAheadMode[LookAheadMode["NoErrorYet"] = 1] = "NoErrorYet"; - LookAheadMode[LookAheadMode["Error"] = 2] = "Error"; - })(LookAheadMode || (LookAheadMode = {})); - var ModifierContext; - (function (ModifierContext) { - ModifierContext[ModifierContext["SourceElements"] = 0] = "SourceElements"; - ModifierContext[ModifierContext["ModuleElements"] = 1] = "ModuleElements"; - ModifierContext[ModifierContext["ClassMembers"] = 2] = "ClassMembers"; - ModifierContext[ModifierContext["Parameters"] = 3] = "Parameters"; - })(ModifierContext || (ModifierContext = {})); - var ControlBlockContext; - (function (ControlBlockContext) { - ControlBlockContext[ControlBlockContext["NotNested"] = 0] = "NotNested"; - ControlBlockContext[ControlBlockContext["Nested"] = 1] = "Nested"; - ControlBlockContext[ControlBlockContext["CrossingFunctionBoundary"] = 2] = "CrossingFunctionBoundary"; - })(ControlBlockContext || (ControlBlockContext = {})); function isKeyword(token) { - return ts.SyntaxKind.FirstKeyword <= token && token <= ts.SyntaxKind.LastKeyword; + return 64 /* FirstKeyword */ <= token && token <= 119 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return ts.SyntaxKind.FirstTriviaToken <= token && token <= ts.SyntaxKind.LastTriviaToken; + return 2 /* FirstTriviaToken */ <= token && token <= 5 /* LastTriviaToken */; } ts.isTrivia = isTrivia; function isModifier(token) { switch (token) { - case 102 /* PublicKeyword */: - case 100 /* PrivateKeyword */: - case 101 /* ProtectedKeyword */: - case 103 /* StaticKeyword */: - case 72 /* ExportKeyword */: - case 108 /* DeclareKeyword */: + case 106 /* PublicKeyword */: + case 104 /* PrivateKeyword */: + case 105 /* ProtectedKeyword */: + case 107 /* StaticKeyword */: + case 76 /* ExportKeyword */: + case 112 /* DeclareKeyword */: return true; } return false; @@ -3432,6 +2946,9 @@ var ts; function reScanSlashToken() { return token = scanner.reScanSlashToken(); } + function reScanTemplateToken() { + return token = scanner.reScanTemplateToken(); + } function lookAheadHelper(callback, alwaysResetState) { var saveToken = token; var saveSyntacticErrorsLength = file.syntacticErrors.length; @@ -3461,7 +2978,7 @@ var ts; return scanner.tryScan(function () { return lookAheadHelper(callback, false); }); } function isIdentifier() { - return token === 59 /* Identifier */ || (isInStrictMode ? token > ts.SyntaxKind.LastFutureReservedWord : token > ts.SyntaxKind.LastReservedWord); + return token === 63 /* Identifier */ || (isInStrictMode ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */); } function parseExpected(t) { if (token === t) { @@ -3479,14 +2996,14 @@ var ts; return false; } function canParseSemicolon() { - if (token === 17 /* SemicolonToken */) { + if (token === 21 /* SemicolonToken */) { return true; } - return token === 10 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 14 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 17 /* SemicolonToken */) { + if (token === 21 /* SemicolonToken */) { nextToken(); } } @@ -3508,7 +3025,7 @@ var ts; return node; } function createMissingNode() { - return createNode(116 /* Missing */); + return createNode(120 /* Missing */); } function internIdentifier(text) { return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); @@ -3516,7 +3033,7 @@ var ts; function createIdentifier(isIdentifier) { identifierCount++; if (isIdentifier) { - var node = createNode(59 /* Identifier */); + var node = createNode(63 /* Identifier */); var text = escapeIdentifier(scanner.getTokenValue()); node.text = internIdentifier(text); nextToken(); @@ -3531,10 +3048,10 @@ var ts; return createIdentifier(isIdentifier()); } function parseIdentifierName() { - return createIdentifier(token >= 59 /* Identifier */); + return createIdentifier(token >= 63 /* Identifier */); } function isPropertyName() { - return token >= 59 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; + return token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; } function parsePropertyName() { if (token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { @@ -3545,13 +3062,13 @@ var ts; function parseContextualModifier(t) { return token === t && tryParse(function () { nextToken(); - return token === 13 /* OpenBracketToken */ || isPropertyName(); + return token === 17 /* OpenBracketToken */ || isPropertyName(); }); } function parseAnyContextualModifier() { return isModifier(token) && tryParse(function () { nextToken(); - return token === 13 /* OpenBracketToken */ || isPropertyName(); + return token === 17 /* OpenBracketToken */ || isPropertyName(); }); } function isListElement(kind, inErrorRecovery) { @@ -3563,28 +3080,28 @@ var ts; case 4 /* SwitchClauseStatements */: return isStatement(inErrorRecovery); case 3 /* SwitchClauses */: - return token === 61 /* CaseKeyword */ || token === 67 /* DefaultKeyword */; + return token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; case 5 /* TypeMembers */: - return isTypeMember(); + return isStartOfTypeMember(); case 6 /* ClassMembers */: return lookAhead(isClassMemberStart); case 7 /* EnumMembers */: case 11 /* ObjectLiteralMembers */: return isPropertyName(); case 8 /* BaseTypeReferences */: - return isIdentifier() && ((token !== 73 /* ExtendsKeyword */ && token !== 96 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); })); + return isIdentifier() && ((token !== 77 /* ExtendsKeyword */ && token !== 100 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); })); case 9 /* VariableDeclarations */: case 14 /* TypeParameters */: return isIdentifier(); case 10 /* ArgumentExpressions */: - return token === 18 /* CommaToken */ || isExpression(); + return token === 22 /* CommaToken */ || isStartOfExpression(); case 12 /* ArrayLiteralMembers */: - return token === 18 /* CommaToken */ || isExpression(); + return token === 22 /* CommaToken */ || isStartOfExpression(); case 13 /* Parameters */: - return isParameter(); + return isStartOfParameter(); case 15 /* TypeArguments */: case 16 /* TupleElementTypes */: - return token === 18 /* CommaToken */ || isType(); + return token === 22 /* CommaToken */ || isStartOfType(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } @@ -3600,34 +3117,34 @@ var ts; case 6 /* ClassMembers */: case 7 /* EnumMembers */: case 11 /* ObjectLiteralMembers */: - return token === 10 /* CloseBraceToken */; + return token === 14 /* CloseBraceToken */; case 4 /* SwitchClauseStatements */: - return token === 10 /* CloseBraceToken */ || token === 61 /* CaseKeyword */ || token === 67 /* DefaultKeyword */; + return token === 14 /* CloseBraceToken */ || token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; case 8 /* BaseTypeReferences */: - return token === 9 /* OpenBraceToken */ || token === 73 /* ExtendsKeyword */ || token === 96 /* ImplementsKeyword */; + return token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; case 9 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 14 /* TypeParameters */: - return token === 20 /* GreaterThanToken */ || token === 11 /* OpenParenToken */ || token === 9 /* OpenBraceToken */ || token === 73 /* ExtendsKeyword */ || token === 96 /* ImplementsKeyword */; + return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */ || token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; case 10 /* ArgumentExpressions */: - return token === 12 /* CloseParenToken */ || token === 17 /* SemicolonToken */; + return token === 16 /* CloseParenToken */ || token === 21 /* SemicolonToken */; case 12 /* ArrayLiteralMembers */: case 16 /* TupleElementTypes */: - return token === 14 /* CloseBracketToken */; + return token === 18 /* CloseBracketToken */; case 13 /* Parameters */: - return token === 12 /* CloseParenToken */ || token === 14 /* CloseBracketToken */ || token === 9 /* OpenBraceToken */; + return token === 16 /* CloseParenToken */ || token === 18 /* CloseBracketToken */ || token === 13 /* OpenBraceToken */; case 15 /* TypeArguments */: - return token === 20 /* GreaterThanToken */ || token === 11 /* OpenParenToken */; + return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */; } } function isVariableDeclaratorListTerminator() { if (canParseSemicolon()) { return true; } - if (token === 80 /* InKeyword */) { + if (token === 84 /* InKeyword */) { return true; } - if (token === 27 /* EqualsGreaterThanToken */) { + if (token === 31 /* EqualsGreaterThanToken */) { return true; } return false; @@ -3688,7 +3205,7 @@ var ts; if (isListElement(kind, false)) { result.push(parseElement()); commaStart = scanner.getTokenPos(); - if (parseOptional(18 /* CommaToken */)) { + if (parseOptional(22 /* CommaToken */)) { continue; } commaStart = -1; @@ -3743,8 +3260,8 @@ var ts; } function parseEntityName(allowReservedWords) { var entity = parseIdentifier(); - while (parseOptional(15 /* DotToken */)) { - var node = createNode(117 /* QualifiedName */, entity.pos); + while (parseOptional(19 /* DotToken */)) { + var node = createNode(121 /* QualifiedName */, entity.pos); node.left = entity; node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier(); entity = finishNode(node); @@ -3756,6 +3273,35 @@ var ts; nextToken(); return finishNode(node); } + function parseTemplateExpression() { + var template = createNode(155 /* TemplateExpression */); + template.head = parseLiteralNode(); + ts.Debug.assert(template.head.kind === 10 /* TemplateHead */, "Template head has wrong token kind"); + var templateSpans = []; + templateSpans.pos = getNodePos(); + do { + templateSpans.push(parseTemplateSpan()); + } while (templateSpans[templateSpans.length - 1].literal.kind === 11 /* TemplateMiddle */); + templateSpans.end = getNodeEnd(); + template.templateSpans = templateSpans; + return finishNode(template); + } + function parseTemplateSpan() { + var span = createNode(156 /* TemplateSpan */); + span.expression = parseExpression(false); + var literal; + if (token === 14 /* CloseBraceToken */) { + reScanTemplateToken(); + literal = parseLiteralNode(); + } + else { + error(ts.Diagnostics.Invalid_template_literal_expected); + literal = createMissingNode(); + literal.text = ""; + } + span.literal = literal; + return finishNode(span); + } function parseLiteralNode(internName) { var node = createNode(token); var text = scanner.getTokenValue(); @@ -3774,30 +3320,31 @@ var ts; return node; } function parseStringLiteral() { - if (token === 7 /* StringLiteral */) + if (token === 7 /* StringLiteral */) { return parseLiteralNode(true); + } error(ts.Diagnostics.String_literal_expected); return createMissingNode(); } function parseTypeReference() { - var node = createNode(128 /* TypeReference */); + var node = createNode(132 /* TypeReference */); node.typeName = parseEntityName(false); - if (!scanner.hasPrecedingLineBreak() && token === 19 /* LessThanToken */) { + if (!scanner.hasPrecedingLineBreak() && token === 23 /* LessThanToken */) { node.typeArguments = parseTypeArguments(); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(129 /* TypeQuery */); - parseExpected(91 /* TypeOfKeyword */); + var node = createNode(133 /* TypeQuery */); + parseExpected(95 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(118 /* TypeParameter */); + var node = createNode(122 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(73 /* ExtendsKeyword */)) { - if (isType() || !isExpression()) { + if (parseOptional(77 /* ExtendsKeyword */)) { + if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } else { @@ -3808,9 +3355,9 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 19 /* LessThanToken */) { + if (token === 23 /* LessThanToken */) { var pos = getNodePos(); - var result = parseBracketedList(14 /* TypeParameters */, parseTypeParameter, 19 /* LessThanToken */, 20 /* GreaterThanToken */); + var result = parseBracketedList(14 /* TypeParameters */, parseTypeParameter, 23 /* LessThanToken */, 24 /* GreaterThanToken */); if (!result.length) { var start = getTokenPos(pos); var length = getNodePos() - start; @@ -3820,23 +3367,23 @@ var ts; } } function parseParameterType() { - return parseOptional(46 /* ColonToken */) ? token === 7 /* StringLiteral */ ? parseStringLiteral() : parseType() : undefined; + return parseOptional(50 /* ColonToken */) ? token === 7 /* StringLiteral */ ? parseStringLiteral() : parseType() : undefined; } - function isParameter() { - return token === 16 /* DotDotDotToken */ || isIdentifier() || isModifier(token); + function isStartOfParameter() { + return token === 20 /* DotDotDotToken */ || isIdentifier() || isModifier(token); } function parseParameter(flags) { if (flags === void 0) { flags = 0; } - var node = createNode(119 /* Parameter */); + var node = createNode(123 /* Parameter */); node.flags |= parseAndCheckModifiers(3 /* Parameters */); - if (parseOptional(16 /* DotDotDotToken */)) { + if (parseOptional(20 /* DotDotDotToken */)) { node.flags |= 8 /* Rest */; } node.name = parseIdentifier(); - if (node.name.kind === 116 /* Missing */ && node.flags === 0 && isModifier(token)) { + if (node.name.kind === 120 /* Missing */ && node.flags === 0 && isModifier(token)) { nextToken(); } - if (parseOptional(45 /* QuestionToken */)) { + if (parseOptional(49 /* QuestionToken */)) { node.flags |= 4 /* QuestionMark */; } node.type = parseParameterType(); @@ -3844,11 +3391,11 @@ var ts; return finishNode(node); } function parseSignature(kind, returnToken, returnTokenRequired) { - if (kind === 126 /* ConstructSignature */) { - parseExpected(82 /* NewKeyword */); + if (kind === 130 /* ConstructSignature */) { + parseExpected(86 /* NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameterList(11 /* OpenParenToken */, 12 /* CloseParenToken */); + var parameters = parseParameterList(15 /* OpenParenToken */, 16 /* CloseParenToken */); checkParameterList(parameters); var type; if (returnTokenRequired) { @@ -3915,10 +3462,10 @@ var ts; return finishNode(node); } function parseIndexSignatureMember() { - var node = createNode(127 /* IndexSignature */); + var node = createNode(131 /* IndexSignature */); var errorCountBeforeIndexSignature = file.syntacticErrors.length; var indexerStart = scanner.getTokenPos(); - node.parameters = parseParameterList(13 /* OpenBracketToken */, 14 /* CloseBracketToken */); + node.parameters = parseParameterList(17 /* OpenBracketToken */, 18 /* CloseBracketToken */); var indexerLength = scanner.getStartPos() - indexerStart; node.type = parseTypeAnnotation(); parseSemicolon(); @@ -3943,7 +3490,7 @@ var ts; grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); return; } - else if (parameter.flags & ts.NodeFlags.Modifier) { + else if (parameter.flags & 243 /* Modifier */) { grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); return; } @@ -3959,7 +3506,7 @@ var ts; grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); return; } - else if (parameter.type.kind !== 114 /* StringKeyword */ && parameter.type.kind !== 112 /* NumberKeyword */) { + else if (parameter.type.kind !== 118 /* StringKeyword */ && parameter.type.kind !== 116 /* NumberKeyword */) { grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); return; } @@ -3971,58 +3518,58 @@ var ts; function parsePropertyOrMethod() { var node = createNode(0 /* Unknown */); node.name = parsePropertyName(); - if (parseOptional(45 /* QuestionToken */)) { + if (parseOptional(49 /* QuestionToken */)) { node.flags |= 4 /* QuestionMark */; } - if (token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) { - node.kind = 121 /* Method */; - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { + node.kind = 125 /* Method */; + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; node.type = sig.type; } else { - node.kind = 120 /* Property */; + node.kind = 124 /* Property */; node.type = parseTypeAnnotation(); } parseSemicolon(); return finishNode(node); } - function isTypeMember() { + function isStartOfTypeMember() { switch (token) { - case 11 /* OpenParenToken */: - case 19 /* LessThanToken */: - case 13 /* OpenBracketToken */: + case 15 /* OpenParenToken */: + case 23 /* LessThanToken */: + case 17 /* OpenBracketToken */: return true; default: - return isPropertyName() && lookAhead(function () { return nextToken() === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */ || token === 45 /* QuestionToken */ || token === 46 /* ColonToken */ || canParseSemicolon(); }); + return isPropertyName() && lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); }); } } function parseTypeMember() { switch (token) { - case 11 /* OpenParenToken */: - case 19 /* LessThanToken */: - return parseSignatureMember(125 /* CallSignature */, 46 /* ColonToken */); - case 13 /* OpenBracketToken */: + case 15 /* OpenParenToken */: + case 23 /* LessThanToken */: + return parseSignatureMember(129 /* CallSignature */, 50 /* ColonToken */); + case 17 /* OpenBracketToken */: return parseIndexSignatureMember(); - case 82 /* NewKeyword */: - if (lookAhead(function () { return nextToken() === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */; })) { - return parseSignatureMember(126 /* ConstructSignature */, 46 /* ColonToken */); + case 86 /* NewKeyword */: + if (lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; })) { + return parseSignatureMember(130 /* ConstructSignature */, 50 /* ColonToken */); } case 7 /* StringLiteral */: case 6 /* NumericLiteral */: return parsePropertyOrMethod(); default: - if (token >= 59 /* Identifier */) { + if (token >= 63 /* Identifier */) { return parsePropertyOrMethod(); } } } function parseTypeLiteral() { - var node = createNode(130 /* TypeLiteral */); - if (parseExpected(9 /* OpenBraceToken */)) { + var node = createNode(134 /* TypeLiteral */); + if (parseExpected(13 /* OpenBraceToken */)) { node.members = parseList(5 /* TypeMembers */, false, parseTypeMember); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -4030,26 +3577,26 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(132 /* TupleType */); + var node = createNode(136 /* TupleType */); var startTokenPos = scanner.getTokenPos(); var startErrorCount = file.syntacticErrors.length; - node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 13 /* OpenBracketToken */, 14 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); if (!node.elementTypes.length && file.syntacticErrors.length === startErrorCount) { grammarErrorAtPos(startTokenPos, scanner.getStartPos() - startTokenPos, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); } return finishNode(node); } function parseParenType() { - var node = createNode(134 /* ParenType */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(138 /* ParenType */); + parseExpected(15 /* OpenParenToken */); node.type = parseType(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); return finishNode(node); } function parseFunctionType(signatureKind) { - var node = createNode(130 /* TypeLiteral */); + var node = createNode(134 /* TypeLiteral */); var member = createNode(signatureKind); - var sig = parseSignature(signatureKind, 27 /* EqualsGreaterThanToken */, true); + var sig = parseSignature(signatureKind, 31 /* EqualsGreaterThanToken */, true); member.typeParameters = sig.typeParameters; member.parameters = sig.parameters; member.type = sig.type; @@ -4059,24 +3606,24 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 15 /* DotToken */ ? undefined : node; + return token === 19 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 105 /* AnyKeyword */: - case 114 /* StringKeyword */: - case 112 /* NumberKeyword */: - case 106 /* BooleanKeyword */: - case 93 /* VoidKeyword */: + case 109 /* AnyKeyword */: + case 118 /* StringKeyword */: + case 116 /* NumberKeyword */: + case 110 /* BooleanKeyword */: + case 97 /* VoidKeyword */: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); - case 91 /* TypeOfKeyword */: + case 95 /* TypeOfKeyword */: return parseTypeQuery(); - case 9 /* OpenBraceToken */: + case 13 /* OpenBraceToken */: return parseTypeLiteral(); - case 13 /* OpenBracketToken */: + case 17 /* OpenBracketToken */: return parseTupleType(); - case 11 /* OpenParenToken */: + case 15 /* OpenParenToken */: return parseParenType(); default: if (isIdentifier()) { @@ -4086,23 +3633,23 @@ var ts; error(ts.Diagnostics.Type_expected); return createMissingNode(); } - function isType() { + function isStartOfType() { switch (token) { - case 105 /* AnyKeyword */: - case 114 /* StringKeyword */: - case 112 /* NumberKeyword */: - case 106 /* BooleanKeyword */: - case 93 /* VoidKeyword */: - case 91 /* TypeOfKeyword */: - case 9 /* OpenBraceToken */: - case 13 /* OpenBracketToken */: - case 19 /* LessThanToken */: - case 82 /* NewKeyword */: + case 109 /* AnyKeyword */: + case 118 /* StringKeyword */: + case 116 /* NumberKeyword */: + case 110 /* BooleanKeyword */: + case 97 /* VoidKeyword */: + case 95 /* TypeOfKeyword */: + case 13 /* OpenBraceToken */: + case 17 /* OpenBracketToken */: + case 23 /* LessThanToken */: + case 86 /* NewKeyword */: return true; - case 11 /* OpenParenToken */: + case 15 /* OpenParenToken */: return lookAhead(function () { nextToken(); - return token === 12 /* CloseParenToken */ || isParameter() || isType(); + return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); }); default: return isIdentifier(); @@ -4110,9 +3657,9 @@ var ts; } function parsePrimaryType() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(13 /* OpenBracketToken */)) { - parseExpected(14 /* CloseBracketToken */); - var node = createNode(131 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(17 /* OpenBracketToken */)) { + parseExpected(18 /* CloseBracketToken */); + var node = createNode(135 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -4120,33 +3667,33 @@ var ts; } function parseUnionType() { var type = parsePrimaryType(); - if (token === 39 /* BarToken */) { + if (token === 43 /* BarToken */) { var types = [type]; types.pos = type.pos; - while (parseOptional(39 /* BarToken */)) { + while (parseOptional(43 /* BarToken */)) { types.push(parsePrimaryType()); } types.end = getNodeEnd(); - var node = createNode(133 /* UnionType */, type.pos); + var node = createNode(137 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } return type; } - function isFunctionType() { - return token === 19 /* LessThanToken */ || token === 11 /* OpenParenToken */ && lookAhead(function () { + function isStartOfFunctionType() { + return token === 23 /* LessThanToken */ || token === 15 /* OpenParenToken */ && lookAhead(function () { nextToken(); - if (token === 12 /* CloseParenToken */ || token === 16 /* DotDotDotToken */) { + if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { return true; } if (isIdentifier() || isModifier(token)) { nextToken(); - if (token === 46 /* ColonToken */ || token === 18 /* CommaToken */ || token === 45 /* QuestionToken */ || token === 47 /* EqualsToken */ || isIdentifier() || isModifier(token)) { + if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || isModifier(token)) { return true; } - if (token === 12 /* CloseParenToken */) { + if (token === 16 /* CloseParenToken */) { nextToken(); - if (token === 27 /* EqualsGreaterThanToken */) { + if (token === 31 /* EqualsGreaterThanToken */) { return true; } } @@ -4155,66 +3702,68 @@ var ts; }); } function parseType() { - if (isFunctionType()) { - return parseFunctionType(125 /* CallSignature */); + if (isStartOfFunctionType()) { + return parseFunctionType(129 /* CallSignature */); } - if (token === 82 /* NewKeyword */) { - return parseFunctionType(126 /* ConstructSignature */); + if (token === 86 /* NewKeyword */) { + return parseFunctionType(130 /* ConstructSignature */); } return parseUnionType(); } function parseTypeAnnotation() { - return parseOptional(46 /* ColonToken */) ? parseType() : undefined; + return parseOptional(50 /* ColonToken */) ? parseType() : undefined; } - function isExpression() { + function isStartOfExpression() { switch (token) { - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: - case 83 /* NullKeyword */: - case 89 /* TrueKeyword */: - case 74 /* FalseKeyword */: + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: + case 87 /* NullKeyword */: + case 93 /* TrueKeyword */: + case 78 /* FalseKeyword */: case 6 /* NumericLiteral */: case 7 /* StringLiteral */: - case 11 /* OpenParenToken */: - case 13 /* OpenBracketToken */: - case 9 /* OpenBraceToken */: - case 77 /* FunctionKeyword */: - case 82 /* NewKeyword */: - case 31 /* SlashToken */: - case 51 /* SlashEqualsToken */: - case 28 /* PlusToken */: - case 29 /* MinusToken */: - case 42 /* TildeToken */: - case 41 /* ExclamationToken */: - case 68 /* DeleteKeyword */: - case 91 /* TypeOfKeyword */: - case 93 /* VoidKeyword */: - case 33 /* PlusPlusToken */: - case 34 /* MinusMinusToken */: - case 19 /* LessThanToken */: - case 59 /* Identifier */: + case 9 /* NoSubstitutionTemplateLiteral */: + case 10 /* TemplateHead */: + case 15 /* OpenParenToken */: + case 17 /* OpenBracketToken */: + case 13 /* OpenBraceToken */: + case 81 /* FunctionKeyword */: + case 86 /* NewKeyword */: + case 35 /* SlashToken */: + case 55 /* SlashEqualsToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: + case 46 /* TildeToken */: + case 45 /* ExclamationToken */: + case 72 /* DeleteKeyword */: + case 95 /* TypeOfKeyword */: + case 97 /* VoidKeyword */: + case 37 /* PlusPlusToken */: + case 38 /* MinusMinusToken */: + case 23 /* LessThanToken */: + case 63 /* Identifier */: return true; default: return isIdentifier(); } } - function isExpressionStatement() { - return token !== 9 /* OpenBraceToken */ && token !== 77 /* FunctionKeyword */ && isExpression(); + function isStartOfExpressionStatement() { + return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression(); } function parseExpression(noIn) { var expr = parseAssignmentExpression(noIn); - while (parseOptional(18 /* CommaToken */)) { - expr = makeBinaryExpression(expr, 18 /* CommaToken */, parseAssignmentExpression(noIn)); + while (parseOptional(22 /* CommaToken */)) { + expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression(noIn)); } return expr; } function parseInitializer(inParameter, noIn) { - if (token !== 47 /* EqualsToken */) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 9 /* OpenBraceToken */) || !isExpression()) { + if (token !== 51 /* EqualsToken */) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 13 /* OpenBraceToken */) || !isStartOfExpression()) { return undefined; } } - parseExpected(47 /* EqualsToken */); + parseExpected(51 /* EqualsToken */); return parseAssignmentExpression(noIn); } function parseAssignmentExpression(noIn) { @@ -4223,7 +3772,7 @@ var ts; return arrowExpression; } var expr = parseConditionalExpression(noIn); - if (expr.kind === 59 /* Identifier */ && token === 27 /* EqualsGreaterThanToken */) { + if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } if (isLeftHandSideExpression(expr) && isAssignmentOperator()) { @@ -4239,33 +3788,36 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 138 /* PropertyAccess */: - case 139 /* IndexedAccess */: - case 141 /* NewExpression */: - case 140 /* CallExpression */: - case 135 /* ArrayLiteral */: - case 143 /* ParenExpression */: - case 136 /* ObjectLiteral */: - case 144 /* FunctionExpression */: - case 59 /* Identifier */: - case 116 /* Missing */: + case 142 /* PropertyAccess */: + case 143 /* IndexedAccess */: + case 145 /* NewExpression */: + case 144 /* CallExpression */: + case 146 /* TaggedTemplateExpression */: + case 139 /* ArrayLiteral */: + case 148 /* ParenExpression */: + case 140 /* ObjectLiteral */: + case 149 /* FunctionExpression */: + case 63 /* Identifier */: + case 120 /* Missing */: case 8 /* RegularExpressionLiteral */: case 6 /* NumericLiteral */: case 7 /* StringLiteral */: - case 74 /* FalseKeyword */: - case 83 /* NullKeyword */: - case 87 /* ThisKeyword */: - case 89 /* TrueKeyword */: - case 85 /* SuperKeyword */: + case 9 /* NoSubstitutionTemplateLiteral */: + case 155 /* TemplateExpression */: + case 78 /* FalseKeyword */: + case 87 /* NullKeyword */: + case 91 /* ThisKeyword */: + case 93 /* TrueKeyword */: + case 89 /* SuperKeyword */: return true; } } return false; } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 27 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - parseExpected(27 /* EqualsGreaterThanToken */); - var parameter = createNode(119 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + parseExpected(31 /* EqualsGreaterThanToken */); + var parameter = createNode(123 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); var parameters = []; @@ -4282,17 +3834,17 @@ var ts; } var pos = getNodePos(); if (triState === 1 /* True */) { - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); - if (parseExpected(27 /* EqualsGreaterThanToken */) || token === 9 /* OpenBraceToken */) { + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); + if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { return parseArrowExpressionTail(pos, sig, false); } else { - return makeFunctionExpression(145 /* ArrowFunction */, pos, undefined, sig, createMissingNode()); + return makeFunctionExpression(150 /* ArrowFunction */, pos, undefined, sig, createMissingNode()); } } var sig = tryParseSignatureIfArrowOrBraceFollows(); if (sig) { - parseExpected(27 /* EqualsGreaterThanToken */); + parseExpected(31 /* EqualsGreaterThanToken */); return parseArrowExpressionTail(pos, sig, false); } else { @@ -4300,35 +3852,35 @@ var ts; } } function isParenthesizedArrowFunctionExpression() { - if (token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) { + if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { return lookAhead(function () { var first = token; var second = nextToken(); - if (first === 11 /* OpenParenToken */) { - if (second === 12 /* CloseParenToken */) { + if (first === 15 /* OpenParenToken */) { + if (second === 16 /* CloseParenToken */) { var third = nextToken(); switch (third) { - case 27 /* EqualsGreaterThanToken */: - case 46 /* ColonToken */: - case 9 /* OpenBraceToken */: + case 31 /* EqualsGreaterThanToken */: + case 50 /* ColonToken */: + case 13 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; } } - if (second === 16 /* DotDotDotToken */) { + if (second === 20 /* DotDotDotToken */) { return 1 /* True */; } if (!isIdentifier()) { return 0 /* False */; } - if (nextToken() === 46 /* ColonToken */) { + if (nextToken() === 50 /* ColonToken */) { return 1 /* True */; } return 2 /* Unknown */; } else { - ts.Debug.assert(first === 19 /* LessThanToken */); + ts.Debug.assert(first === 23 /* LessThanToken */); if (!isIdentifier()) { return 0 /* False */; } @@ -4336,15 +3888,15 @@ var ts; } }); } - if (token === 27 /* EqualsGreaterThanToken */) { + if (token === 31 /* EqualsGreaterThanToken */) { return 1 /* True */; } return 0 /* False */; } function tryParseSignatureIfArrowOrBraceFollows() { return tryParse(function () { - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); - if (token === 27 /* EqualsGreaterThanToken */ || token === 9 /* OpenBraceToken */) { + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); + if (token === 31 /* EqualsGreaterThanToken */ || token === 13 /* OpenBraceToken */) { return sig; } return undefined; @@ -4352,27 +3904,27 @@ var ts; } function parseArrowExpressionTail(pos, sig, noIn) { var body; - if (token === 9 /* OpenBraceToken */) { + if (token === 13 /* OpenBraceToken */) { body = parseBody(false); } - else if (isStatement(true) && !isExpressionStatement() && token !== 77 /* FunctionKeyword */) { + else if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { body = parseBody(true); } else { body = parseAssignmentExpression(noIn); } - return makeFunctionExpression(145 /* ArrowFunction */, pos, undefined, sig, body); + return makeFunctionExpression(150 /* ArrowFunction */, pos, undefined, sig, body); } function isAssignmentOperator() { - return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment; + return token >= 51 /* FirstAssignment */ && token <= 62 /* LastAssignment */; } function parseConditionalExpression(noIn) { var expr = parseBinaryExpression(noIn); - while (parseOptional(45 /* QuestionToken */)) { - var node = createNode(149 /* ConditionalExpression */, expr.pos); + while (parseOptional(49 /* QuestionToken */)) { + var node = createNode(154 /* ConditionalExpression */, expr.pos); node.condition = expr; node.whenTrue = parseAssignmentExpression(false); - parseExpected(46 /* ColonToken */); + parseExpected(50 /* ColonToken */); node.whenFalse = parseAssignmentExpression(noIn); expr = finishNode(node); } @@ -4385,7 +3937,7 @@ var ts; while (true) { reScanGreaterToken(); var precedence = getOperatorPrecedence(); - if (precedence && precedence > minPrecedence && (!noIn || token !== 80 /* InKeyword */)) { + if (precedence && precedence > minPrecedence && (!noIn || token !== 84 /* InKeyword */)) { var operator = token; nextToken(); expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence, noIn)); @@ -4396,44 +3948,44 @@ var ts; } function getOperatorPrecedence() { switch (token) { - case 44 /* BarBarToken */: + case 48 /* BarBarToken */: return 1; - case 43 /* AmpersandAmpersandToken */: + case 47 /* AmpersandAmpersandToken */: return 2; - case 39 /* BarToken */: + case 43 /* BarToken */: return 3; - case 40 /* CaretToken */: + case 44 /* CaretToken */: return 4; - case 38 /* AmpersandToken */: + case 42 /* AmpersandToken */: return 5; - case 23 /* EqualsEqualsToken */: - case 24 /* ExclamationEqualsToken */: - case 25 /* EqualsEqualsEqualsToken */: - case 26 /* ExclamationEqualsEqualsToken */: + case 27 /* EqualsEqualsToken */: + case 28 /* ExclamationEqualsToken */: + case 29 /* EqualsEqualsEqualsToken */: + case 30 /* ExclamationEqualsEqualsToken */: return 6; - case 19 /* LessThanToken */: - case 20 /* GreaterThanToken */: - case 21 /* LessThanEqualsToken */: - case 22 /* GreaterThanEqualsToken */: - case 81 /* InstanceOfKeyword */: - case 80 /* InKeyword */: + case 23 /* LessThanToken */: + case 24 /* GreaterThanToken */: + case 25 /* LessThanEqualsToken */: + case 26 /* GreaterThanEqualsToken */: + case 85 /* InstanceOfKeyword */: + case 84 /* InKeyword */: return 7; - case 35 /* LessThanLessThanToken */: - case 36 /* GreaterThanGreaterThanToken */: - case 37 /* GreaterThanGreaterThanGreaterThanToken */: + case 39 /* LessThanLessThanToken */: + case 40 /* GreaterThanGreaterThanToken */: + case 41 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 28 /* PlusToken */: - case 29 /* MinusToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: return 9; - case 30 /* AsteriskToken */: - case 31 /* SlashToken */: - case 32 /* PercentToken */: + case 34 /* AsteriskToken */: + case 35 /* SlashToken */: + case 36 /* PercentToken */: return 10; } return undefined; } function makeBinaryExpression(left, operator, right) { - var node = createNode(148 /* BinaryExpression */, left.pos); + var node = createNode(153 /* BinaryExpression */, left.pos); node.left = left; node.operator = operator; node.right = right; @@ -4442,52 +3994,52 @@ var ts; function parseUnaryExpression() { var pos = getNodePos(); switch (token) { - case 28 /* PlusToken */: - case 29 /* MinusToken */: - case 42 /* TildeToken */: - case 41 /* ExclamationToken */: - case 68 /* DeleteKeyword */: - case 91 /* TypeOfKeyword */: - case 93 /* VoidKeyword */: - case 33 /* PlusPlusToken */: - case 34 /* MinusMinusToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: + case 46 /* TildeToken */: + case 45 /* ExclamationToken */: + case 72 /* DeleteKeyword */: + case 95 /* TypeOfKeyword */: + case 97 /* VoidKeyword */: + case 37 /* PlusPlusToken */: + case 38 /* MinusMinusToken */: var operator = token; nextToken(); var operand = parseUnaryExpression(); if (isInStrictMode) { - if ((operator === 33 /* PlusPlusToken */ || operator === 34 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(operand)) { + if ((operator === 37 /* PlusPlusToken */ || operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(operand)) { reportInvalidUseInStrictMode(operand); } - else if (operator === 68 /* DeleteKeyword */ && operand.kind === 59 /* Identifier */) { + else if (operator === 72 /* DeleteKeyword */ && operand.kind === 63 /* Identifier */) { grammarErrorOnNode(operand, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); } } - return makeUnaryExpression(146 /* PrefixOperator */, pos, operator, operand); - case 19 /* LessThanToken */: + return makeUnaryExpression(151 /* PrefixOperator */, pos, operator, operand); + case 23 /* LessThanToken */: return parseTypeAssertion(); } var primaryExpression = parsePrimaryExpression(); - var illegalUsageOfSuperKeyword = primaryExpression.kind === 85 /* SuperKeyword */ && token !== 11 /* OpenParenToken */ && token !== 15 /* DotToken */; + var illegalUsageOfSuperKeyword = primaryExpression.kind === 89 /* SuperKeyword */ && token !== 15 /* OpenParenToken */ && token !== 19 /* DotToken */; if (illegalUsageOfSuperKeyword) { error(ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); } var expr = parseCallAndAccess(primaryExpression, false); ts.Debug.assert(isLeftHandSideExpression(expr)); - if ((token === 33 /* PlusPlusToken */ || token === 34 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token === 37 /* PlusPlusToken */ || token === 38 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { if (isInStrictMode && isEvalOrArgumentsIdentifier(expr)) { reportInvalidUseInStrictMode(expr); } var operator = token; nextToken(); - expr = makeUnaryExpression(147 /* PostfixOperator */, expr.pos, operator, expr); + expr = makeUnaryExpression(152 /* PostfixOperator */, expr.pos, operator, expr); } return expr; } function parseTypeAssertion() { - var node = createNode(142 /* TypeAssertion */); - parseExpected(19 /* LessThanToken */); + var node = createNode(147 /* TypeAssertion */); + parseExpected(23 /* LessThanToken */); node.type = parseType(); - parseExpected(20 /* GreaterThanToken */); + parseExpected(24 /* GreaterThanToken */); node.operand = parseUnaryExpression(); return finishNode(node); } @@ -4499,11 +4051,11 @@ var ts; } function parseCallAndAccess(expr, inNewExpression) { while (true) { - var dotStart = scanner.getTokenPos(); - if (parseOptional(15 /* DotToken */)) { - var propertyAccess = createNode(138 /* PropertyAccess */, expr.pos); + var dotOrBracketStart = scanner.getTokenPos(); + if (parseOptional(19 /* DotToken */)) { + var propertyAccess = createNode(142 /* PropertyAccess */, expr.pos); if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord() && lookAhead(function () { return scanner.isReservedWord(); })) { - grammarErrorAtPos(dotStart, scanner.getStartPos() - dotStart, ts.Diagnostics.Identifier_expected); + grammarErrorAtPos(dotOrBracketStart, scanner.getStartPos() - dotOrBracketStart, ts.Diagnostics.Identifier_expected); var id = createMissingNode(); } else { @@ -4514,13 +4066,12 @@ var ts; expr = finishNode(propertyAccess); continue; } - var bracketStart = scanner.getTokenPos(); - if (parseOptional(13 /* OpenBracketToken */)) { - var indexedAccess = createNode(139 /* IndexedAccess */, expr.pos); + if (parseOptional(17 /* OpenBracketToken */)) { + var indexedAccess = createNode(143 /* IndexedAccess */, expr.pos); indexedAccess.object = expr; - if (inNewExpression && parseOptional(14 /* CloseBracketToken */)) { + if (inNewExpression && parseOptional(18 /* CloseBracketToken */)) { indexedAccess.index = createMissingNode(); - grammarErrorAtPos(bracketStart, scanner.getStartPos() - bracketStart, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + grammarErrorAtPos(dotOrBracketStart, scanner.getStartPos() - dotOrBracketStart, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); } else { indexedAccess.index = parseExpression(); @@ -4528,79 +4079,92 @@ var ts; var literal = indexedAccess.index; literal.text = internIdentifier(literal.text); } - parseExpected(14 /* CloseBracketToken */); + parseExpected(18 /* CloseBracketToken */); } expr = finishNode(indexedAccess); continue; } - if ((token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) && !inNewExpression) { - var callExpr = createNode(140 /* CallExpression */, expr.pos); + if ((token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) && !inNewExpression) { + var callExpr = createNode(144 /* CallExpression */, expr.pos); callExpr.func = expr; - if (token === 19 /* LessThanToken */) { + if (token === 23 /* LessThanToken */) { if (!(callExpr.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) return expr; } else { - parseExpected(11 /* OpenParenToken */); + parseExpected(15 /* OpenParenToken */); } callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression, false); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); expr = finishNode(callExpr); continue; } + if (token === 9 /* NoSubstitutionTemplateLiteral */ || token === 10 /* TemplateHead */) { + var tagExpression = createNode(146 /* TaggedTemplateExpression */, expr.pos); + tagExpression.tag = expr; + tagExpression.template = token === 9 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + expr = finishNode(tagExpression); + if (languageVersion < 2 /* ES6 */) { + grammarErrorOnNode(expr, ts.Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + continue; + } return expr; } } function parseTypeArgumentsAndOpenParen() { var result = parseTypeArguments(); - parseExpected(11 /* OpenParenToken */); + parseExpected(15 /* OpenParenToken */); return result; } function parseTypeArguments() { var typeArgumentListStart = scanner.getTokenPos(); var errorCountBeforeTypeParameterList = file.syntacticErrors.length; - var result = parseBracketedList(15 /* TypeArguments */, parseSingleTypeArgument, 19 /* LessThanToken */, 20 /* GreaterThanToken */); + var result = parseBracketedList(15 /* TypeArguments */, parseSingleTypeArgument, 23 /* LessThanToken */, 24 /* GreaterThanToken */); if (!result.length && file.syntacticErrors.length === errorCountBeforeTypeParameterList) { grammarErrorAtPos(typeArgumentListStart, scanner.getStartPos() - typeArgumentListStart, ts.Diagnostics.Type_argument_list_cannot_be_empty); } return result; } function parseSingleTypeArgument() { - if (token === 18 /* CommaToken */) { + if (token === 22 /* CommaToken */) { var errorStart = scanner.getTokenPos(); var errorLength = scanner.getTextPos() - errorStart; grammarErrorAtPos(errorStart, errorLength, ts.Diagnostics.Type_expected); - return createNode(116 /* Missing */); + return createNode(120 /* Missing */); } return parseType(); } function parsePrimaryExpression() { switch (token) { - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: - case 83 /* NullKeyword */: - case 89 /* TrueKeyword */: - case 74 /* FalseKeyword */: + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: + case 87 /* NullKeyword */: + case 93 /* TrueKeyword */: + case 78 /* FalseKeyword */: return parseTokenNode(); case 6 /* NumericLiteral */: case 7 /* StringLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 11 /* OpenParenToken */: + case 15 /* OpenParenToken */: return parseParenExpression(); - case 13 /* OpenBracketToken */: + case 17 /* OpenBracketToken */: return parseArrayLiteral(); - case 9 /* OpenBraceToken */: + case 13 /* OpenBraceToken */: return parseObjectLiteral(); - case 77 /* FunctionKeyword */: + case 81 /* FunctionKeyword */: return parseFunctionExpression(); - case 82 /* NewKeyword */: + case 86 /* NewKeyword */: return parseNewExpression(); - case 31 /* SlashToken */: - case 51 /* SlashEqualsToken */: + case 35 /* SlashToken */: + case 55 /* SlashEqualsToken */: if (reScanSlashToken() === 8 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; + case 10 /* TemplateHead */: + return parseTemplateExpression(); default: if (isIdentifier()) { return parseIdentifier(); @@ -4610,20 +4174,20 @@ var ts; return createMissingNode(); } function parseParenExpression() { - var node = createNode(143 /* ParenExpression */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(148 /* ParenExpression */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); return finishNode(node); } function parseAssignmentExpressionOrOmittedExpression(omittedExpressionDiagnostic) { - if (token === 18 /* CommaToken */) { + if (token === 22 /* CommaToken */) { if (omittedExpressionDiagnostic) { var errorStart = scanner.getTokenPos(); var errorLength = scanner.getTextPos() - errorStart; grammarErrorAtPos(errorStart, errorLength, omittedExpressionDiagnostic); } - return createNode(150 /* OmittedExpression */); + return createNode(157 /* OmittedExpression */); } return parseAssignmentExpression(); } @@ -4634,24 +4198,24 @@ var ts; return parseAssignmentExpressionOrOmittedExpression(ts.Diagnostics.Argument_expression_expected); } function parseArrayLiteral() { - var node = createNode(135 /* ArrayLiteral */); - parseExpected(13 /* OpenBracketToken */); + var node = createNode(139 /* ArrayLiteral */); + parseExpected(17 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 256 /* MultiLine */; node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement, true); - parseExpected(14 /* CloseBracketToken */); + parseExpected(18 /* CloseBracketToken */); return finishNode(node); } function parsePropertyAssignment() { - var node = createNode(137 /* PropertyAssignment */); + var node = createNode(141 /* PropertyAssignment */); node.name = parsePropertyName(); - if (token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) { - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); var body = parseBody(false); - node.initializer = makeFunctionExpression(144 /* FunctionExpression */, node.pos, undefined, sig, body); + node.initializer = makeFunctionExpression(149 /* FunctionExpression */, node.pos, undefined, sig, body); } else { - parseExpected(46 /* ColonToken */); + parseExpected(50 /* ColonToken */); node.initializer = parseAssignmentExpression(false); } return finishNode(node); @@ -4659,41 +4223,41 @@ var ts; function parseObjectLiteralMember() { var initialPos = getNodePos(); var initialToken = token; - if (parseContextualModifier(109 /* GetKeyword */) || parseContextualModifier(113 /* SetKeyword */)) { - var kind = initialToken === 109 /* GetKeyword */ ? 123 /* GetAccessor */ : 124 /* SetAccessor */; + if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { + var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; return parseAndCheckMemberAccessorDeclaration(kind, initialPos, 0); } return parsePropertyAssignment(); } function parseObjectLiteral() { - var node = createNode(136 /* ObjectLiteral */); - parseExpected(9 /* OpenBraceToken */); + var node = createNode(140 /* ObjectLiteral */); + parseExpected(13 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 256 /* MultiLine */; } node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember, true); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); var seen = {}; var Property = 1; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; ts.forEach(node.properties, function (p) { - if (p.kind === 150 /* OmittedExpression */) { + if (p.kind === 157 /* OmittedExpression */) { return; } var currentKind; - if (p.kind === 137 /* PropertyAssignment */) { + if (p.kind === 141 /* PropertyAssignment */) { currentKind = Property; } - else if (p.kind === 123 /* GetAccessor */) { + else if (p.kind === 127 /* GetAccessor */) { currentKind = GetAccessor; } - else if (p.kind === 124 /* SetAccessor */) { + else if (p.kind === 128 /* SetAccessor */) { currentKind = SetAccesor; } else { - ts.Debug.fail("Unexpected syntax kind:" + ts.SyntaxKind[p.kind]); + ts.Debug.fail("Unexpected syntax kind:" + p.kind); } if (!ts.hasProperty(seen, p.name.text)) { seen[p.name.text] = currentKind; @@ -4722,14 +4286,14 @@ var ts; } function parseFunctionExpression() { var pos = getNodePos(); - parseExpected(77 /* FunctionKeyword */); + parseExpected(81 /* FunctionKeyword */); var name = isIdentifier() ? parseIdentifier() : undefined; - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); var body = parseBody(false); if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) { reportInvalidUseInStrictMode(name); } - return makeFunctionExpression(144 /* FunctionExpression */, pos, name, sig, body); + return makeFunctionExpression(149 /* FunctionExpression */, pos, name, sig, body); } function makeFunctionExpression(kind, pos, name, sig, body) { var node = createNode(kind, pos); @@ -4741,12 +4305,12 @@ var ts; return finishNode(node); } function parseNewExpression() { - var node = createNode(141 /* NewExpression */); - parseExpected(82 /* NewKeyword */); + var node = createNode(145 /* NewExpression */); + parseExpected(86 /* NewKeyword */); node.func = parseCallAndAccess(parsePrimaryExpression(), true); - if (parseOptional(11 /* OpenParenToken */) || token === 19 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { + if (parseOptional(15 /* OpenParenToken */) || token === 23 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression, false); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); } return finishNode(node); } @@ -4754,10 +4318,10 @@ var ts; return parseStatement(true); } function parseBlock(ignoreMissingOpenBrace, checkForStrictMode) { - var node = createNode(151 /* Block */); - if (parseExpected(9 /* OpenBraceToken */) || ignoreMissingOpenBrace) { + var node = createNode(158 /* Block */); + if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) { node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatementAllowingLetDeclaration); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -4777,7 +4341,7 @@ var ts; } labelledStatementInfo.pushFunctionBoundary(); var block = parseBlock(ignoreMissingOpenBrace, true); - block.kind = 176 /* FunctionBlock */; + block.kind = 183 /* FunctionBlock */; labelledStatementInfo.pop(); inFunctionBody = saveInFunctionBody; inSwitchStatement = saveInSwitchStatement; @@ -4785,40 +4349,40 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(153 /* EmptyStatement */); - parseExpected(17 /* SemicolonToken */); + var node = createNode(160 /* EmptyStatement */); + parseExpected(21 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(155 /* IfStatement */); - parseExpected(78 /* IfKeyword */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(162 /* IfStatement */); + parseExpected(82 /* IfKeyword */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); node.thenStatement = parseStatement(false); - node.elseStatement = parseOptional(70 /* ElseKeyword */) ? parseStatement(false) : undefined; + node.elseStatement = parseOptional(74 /* ElseKeyword */) ? parseStatement(false) : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(156 /* DoStatement */); - parseExpected(69 /* DoKeyword */); + var node = createNode(163 /* DoStatement */); + parseExpected(73 /* DoKeyword */); var saveInIterationStatement = inIterationStatement; inIterationStatement = 1 /* Nested */; node.statement = parseStatement(false); inIterationStatement = saveInIterationStatement; - parseExpected(94 /* WhileKeyword */); - parseExpected(11 /* OpenParenToken */); + parseExpected(98 /* WhileKeyword */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); - parseOptional(17 /* SemicolonToken */); + parseExpected(16 /* CloseParenToken */); + parseOptional(21 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(157 /* WhileStatement */); - parseExpected(94 /* WhileKeyword */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(164 /* WhileStatement */); + parseExpected(98 /* WhileKeyword */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); var saveInIterationStatement = inIterationStatement; inIterationStatement = 1 /* Nested */; node.statement = parseStatement(false); @@ -4827,16 +4391,16 @@ var ts; } function parseForOrForInStatement() { var pos = getNodePos(); - parseExpected(76 /* ForKeyword */); - parseExpected(11 /* OpenParenToken */); - if (token !== 17 /* SemicolonToken */) { - if (parseOptional(92 /* VarKeyword */)) { + parseExpected(80 /* ForKeyword */); + parseExpected(15 /* OpenParenToken */); + if (token !== 21 /* SemicolonToken */) { + if (parseOptional(96 /* VarKeyword */)) { var declarations = parseVariableDeclarationList(0, true); if (!declarations.length) { error(ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } } - else if (parseOptional(98 /* LetKeyword */)) { + else if (parseOptional(102 /* LetKeyword */)) { var declarations = parseVariableDeclarationList(2048 /* Let */, true); if (!declarations.length) { error(ts.Diagnostics.Variable_declaration_list_cannot_be_empty); @@ -4845,7 +4409,7 @@ var ts; grammarErrorAtPos(declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } } - else if (parseOptional(64 /* ConstKeyword */)) { + else if (parseOptional(68 /* ConstKeyword */)) { var declarations = parseVariableDeclarationList(4096 /* Const */, true); if (!declarations.length) { error(ts.Diagnostics.Variable_declaration_list_cannot_be_empty); @@ -4859,8 +4423,8 @@ var ts; } } var forOrForInStatement; - if (parseOptional(80 /* InKeyword */)) { - var forInStatement = createNode(159 /* ForInStatement */, pos); + if (parseOptional(84 /* InKeyword */)) { + var forInStatement = createNode(166 /* ForInStatement */, pos); if (declarations) { if (declarations.length > 1) { error(ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement); @@ -4871,24 +4435,24 @@ var ts; forInStatement.variable = varOrInit; } forInStatement.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); forOrForInStatement = forInStatement; } else { - var forStatement = createNode(158 /* ForStatement */, pos); + var forStatement = createNode(165 /* ForStatement */, pos); if (declarations) forStatement.declarations = declarations; if (varOrInit) forStatement.initializer = varOrInit; - parseExpected(17 /* SemicolonToken */); - if (token !== 17 /* SemicolonToken */ && token !== 12 /* CloseParenToken */) { + parseExpected(21 /* SemicolonToken */); + if (token !== 21 /* SemicolonToken */ && token !== 16 /* CloseParenToken */) { forStatement.condition = parseExpression(); } - parseExpected(17 /* SemicolonToken */); - if (token !== 12 /* CloseParenToken */) { + parseExpected(21 /* SemicolonToken */); + if (token !== 16 /* CloseParenToken */) { forStatement.iterator = parseExpression(); } - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); forOrForInStatement = forStatement; } var saveInIterationStatement = inIterationStatement; @@ -4900,7 +4464,7 @@ var ts; function parseBreakOrContinueStatement(kind) { var node = createNode(kind); var errorCountBeforeStatement = file.syntacticErrors.length; - parseExpected(kind === 161 /* BreakStatement */ ? 60 /* BreakKeyword */ : 65 /* ContinueKeyword */); + parseExpected(kind === 168 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); if (!canParseSemicolon()) node.label = parseIdentifier(); parseSemicolon(); @@ -4916,7 +4480,7 @@ var ts; return node; } function checkBareBreakOrContinueStatement(node) { - if (node.kind === 161 /* BreakStatement */) { + if (node.kind === 168 /* BreakStatement */) { if (inIterationStatement === 1 /* Nested */ || inSwitchStatement === 1 /* Nested */) { return; } @@ -4925,7 +4489,7 @@ var ts; return; } } - else if (node.kind === 160 /* ContinueStatement */) { + else if (node.kind === 167 /* ContinueStatement */) { if (inIterationStatement === 1 /* Nested */) { return; } @@ -4941,7 +4505,7 @@ var ts; grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } function checkBreakOrContinueStatementWithLabel(node) { - var nodeIsNestedInLabel = labelledStatementInfo.nodeIsNestedInLabel(node.label, node.kind === 160 /* ContinueStatement */, false); + var nodeIsNestedInLabel = labelledStatementInfo.nodeIsNestedInLabel(node.label, node.kind === 167 /* ContinueStatement */, false); if (nodeIsNestedInLabel === 1 /* Nested */) { return; } @@ -4949,10 +4513,10 @@ var ts; grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); return; } - if (node.kind === 160 /* ContinueStatement */) { + if (node.kind === 167 /* ContinueStatement */) { grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } - else if (node.kind === 161 /* BreakStatement */) { + else if (node.kind === 168 /* BreakStatement */) { grammarErrorOnNode(node, ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement); } else { @@ -4960,11 +4524,11 @@ var ts; } } function parseReturnStatement() { - var node = createNode(162 /* ReturnStatement */); + var node = createNode(169 /* ReturnStatement */); var errorCountBeforeReturnStatement = file.syntacticErrors.length; var returnTokenStart = scanner.getTokenPos(); var returnTokenLength = scanner.getTextPos() - returnTokenStart; - parseExpected(84 /* ReturnKeyword */); + parseExpected(88 /* ReturnKeyword */); if (!canParseSemicolon()) node.expression = parseExpression(); parseSemicolon(); @@ -4974,13 +4538,13 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(163 /* WithStatement */); + var node = createNode(170 /* WithStatement */); var startPos = scanner.getTokenPos(); - parseExpected(95 /* WithKeyword */); + parseExpected(99 /* WithKeyword */); var endPos = scanner.getStartPos(); - parseExpected(11 /* OpenParenToken */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); node.statement = parseStatement(false); node = finishNode(node); if (isInStrictMode) { @@ -4989,36 +4553,36 @@ var ts; return node; } function parseCaseClause() { - var node = createNode(165 /* CaseClause */); - parseExpected(61 /* CaseKeyword */); + var node = createNode(172 /* CaseClause */); + parseExpected(65 /* CaseKeyword */); node.expression = parseExpression(); - parseExpected(46 /* ColonToken */); + parseExpected(50 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatementAllowingLetDeclaration); return finishNode(node); } function parseDefaultClause() { - var node = createNode(166 /* DefaultClause */); - parseExpected(67 /* DefaultKeyword */); - parseExpected(46 /* ColonToken */); + var node = createNode(173 /* DefaultClause */); + parseExpected(71 /* DefaultKeyword */); + parseExpected(50 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatementAllowingLetDeclaration); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 61 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(164 /* SwitchStatement */); - parseExpected(86 /* SwitchKeyword */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(171 /* SwitchStatement */); + parseExpected(90 /* SwitchKeyword */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); - parseExpected(9 /* OpenBraceToken */); + parseExpected(16 /* CloseParenToken */); + parseExpected(13 /* OpenBraceToken */); var saveInSwitchStatement = inSwitchStatement; inSwitchStatement = 1 /* Nested */; node.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); inSwitchStatement = saveInSwitchStatement; - parseExpected(10 /* CloseBraceToken */); - var defaultClauses = ts.filter(node.clauses, function (clause) { return clause.kind === 166 /* DefaultClause */; }); + parseExpected(14 /* CloseBraceToken */); + var defaultClauses = ts.filter(node.clauses, function (clause) { return clause.kind === 173 /* DefaultClause */; }); for (var i = 1, n = defaultClauses.length; i < n; i++) { var clause = defaultClauses[i]; var start = ts.skipTrivia(file.text, clause.pos); @@ -5028,8 +4592,8 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(168 /* ThrowStatement */); - parseExpected(88 /* ThrowKeyword */); + var node = createNode(175 /* ThrowStatement */); + parseExpected(92 /* ThrowKeyword */); if (scanner.hasPrecedingLineBreak()) { error(ts.Diagnostics.Line_break_not_permitted_here); } @@ -5038,13 +4602,13 @@ var ts; return finishNode(node); } function parseTryStatement() { - var node = createNode(169 /* TryStatement */); - node.tryBlock = parseTokenAndBlock(90 /* TryKeyword */, 170 /* TryBlock */); - if (token === 62 /* CatchKeyword */) { + var node = createNode(176 /* TryStatement */); + node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 177 /* TryBlock */); + if (token === 66 /* CatchKeyword */) { node.catchBlock = parseCatchBlock(); } - if (token === 75 /* FinallyKeyword */) { - node.finallyBlock = parseTokenAndBlock(75 /* FinallyKeyword */, 172 /* FinallyBlock */); + if (token === 79 /* FinallyKeyword */) { + node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 179 /* FinallyBlock */); } if (!(node.catchBlock || node.finallyBlock)) { error(ts.Diagnostics.catch_or_finally_expected); @@ -5061,15 +4625,15 @@ var ts; } function parseCatchBlock() { var pos = getNodePos(); - parseExpected(62 /* CatchKeyword */); - parseExpected(11 /* OpenParenToken */); + parseExpected(66 /* CatchKeyword */); + parseExpected(15 /* OpenParenToken */); var variable = parseIdentifier(); var typeAnnotationColonStart = scanner.getTokenPos(); var typeAnnotationColonLength = scanner.getTextPos() - typeAnnotationColonStart; var typeAnnotation = parseTypeAnnotation(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); var result = parseBlock(false, false); - result.kind = 171 /* CatchBlock */; + result.kind = 178 /* CatchBlock */; result.pos = pos; result.variable = variable; if (typeAnnotation) { @@ -5081,13 +4645,13 @@ var ts; return result; } function parseDebuggerStatement() { - var node = createNode(173 /* DebuggerStatement */); - parseExpected(66 /* DebuggerKeyword */); + var node = createNode(180 /* DebuggerStatement */); + parseExpected(70 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } function isIterationStatementStart() { - return token === 94 /* WhileKeyword */ || token === 69 /* DoKeyword */ || token === 76 /* ForKeyword */; + return token === 98 /* WhileKeyword */ || token === 73 /* DoKeyword */ || token === 80 /* ForKeyword */; } function parseStatementWithLabelSet(allowLetAndConstDeclarations) { labelledStatementInfo.pushCurrentLabelSet(isIterationStatementStart()); @@ -5096,12 +4660,12 @@ var ts; return statement; } function isLabel() { - return isIdentifier() && lookAhead(function () { return nextToken() === 46 /* ColonToken */; }); + return isIdentifier() && lookAhead(function () { return nextToken() === 50 /* ColonToken */; }); } function parseLabeledStatement(allowLetAndConstDeclarations) { - var node = createNode(167 /* LabeledStatement */); + var node = createNode(174 /* LabeledStatement */); node.label = parseIdentifier(); - parseExpected(46 /* ColonToken */); + parseExpected(50 /* ColonToken */); if (labelledStatementInfo.nodeIsNestedInLabel(node.label, false, true)) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); } @@ -5110,91 +4674,93 @@ var ts; return finishNode(node); } function parseExpressionStatement() { - var node = createNode(154 /* ExpressionStatement */); + var node = createNode(161 /* ExpressionStatement */); node.expression = parseExpression(); parseSemicolon(); return finishNode(node); } function isStatement(inErrorRecovery) { switch (token) { - case 17 /* SemicolonToken */: + case 21 /* SemicolonToken */: return !inErrorRecovery; - case 9 /* OpenBraceToken */: - case 92 /* VarKeyword */: - case 98 /* LetKeyword */: - case 64 /* ConstKeyword */: - case 77 /* FunctionKeyword */: - case 78 /* IfKeyword */: - case 69 /* DoKeyword */: - case 94 /* WhileKeyword */: - case 76 /* ForKeyword */: - case 65 /* ContinueKeyword */: - case 60 /* BreakKeyword */: - case 84 /* ReturnKeyword */: - case 95 /* WithKeyword */: - case 86 /* SwitchKeyword */: - case 88 /* ThrowKeyword */: - case 90 /* TryKeyword */: - case 66 /* DebuggerKeyword */: - case 62 /* CatchKeyword */: - case 75 /* FinallyKeyword */: + case 13 /* OpenBraceToken */: + case 96 /* VarKeyword */: + case 102 /* LetKeyword */: + case 81 /* FunctionKeyword */: + case 82 /* IfKeyword */: + case 73 /* DoKeyword */: + case 98 /* WhileKeyword */: + case 80 /* ForKeyword */: + case 69 /* ContinueKeyword */: + case 64 /* BreakKeyword */: + case 88 /* ReturnKeyword */: + case 99 /* WithKeyword */: + case 90 /* SwitchKeyword */: + case 92 /* ThrowKeyword */: + case 94 /* TryKeyword */: + case 70 /* DebuggerKeyword */: + case 66 /* CatchKeyword */: + case 79 /* FinallyKeyword */: return true; - case 97 /* InterfaceKeyword */: - case 63 /* ClassKeyword */: - case 110 /* ModuleKeyword */: - case 71 /* EnumKeyword */: - case 115 /* TypeKeyword */: - if (isDeclaration()) { + case 68 /* ConstKeyword */: + var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); + return !isConstEnum; + case 101 /* InterfaceKeyword */: + case 67 /* ClassKeyword */: + case 114 /* ModuleKeyword */: + case 75 /* EnumKeyword */: + case 119 /* TypeKeyword */: + if (isDeclarationStart()) { return false; } - case 102 /* PublicKeyword */: - case 100 /* PrivateKeyword */: - case 101 /* ProtectedKeyword */: - case 103 /* StaticKeyword */: - if (lookAhead(function () { return nextToken() >= 59 /* Identifier */; })) { + case 106 /* PublicKeyword */: + case 104 /* PrivateKeyword */: + case 105 /* ProtectedKeyword */: + case 107 /* StaticKeyword */: + if (lookAhead(function () { return nextToken() >= 63 /* Identifier */; })) { return false; } default: - return isExpression(); + return isStartOfExpression(); } } function parseStatement(allowLetAndConstDeclarations) { switch (token) { - case 9 /* OpenBraceToken */: + case 13 /* OpenBraceToken */: return parseBlock(false, false); - case 92 /* VarKeyword */: - case 98 /* LetKeyword */: - case 64 /* ConstKeyword */: + case 96 /* VarKeyword */: + case 102 /* LetKeyword */: + case 68 /* ConstKeyword */: return parseVariableStatement(allowLetAndConstDeclarations); - case 77 /* FunctionKeyword */: + case 81 /* FunctionKeyword */: return parseFunctionDeclaration(); - case 17 /* SemicolonToken */: + case 21 /* SemicolonToken */: return parseEmptyStatement(); - case 78 /* IfKeyword */: + case 82 /* IfKeyword */: return parseIfStatement(); - case 69 /* DoKeyword */: + case 73 /* DoKeyword */: return parseDoStatement(); - case 94 /* WhileKeyword */: + case 98 /* WhileKeyword */: return parseWhileStatement(); - case 76 /* ForKeyword */: + case 80 /* ForKeyword */: return parseForOrForInStatement(); - case 65 /* ContinueKeyword */: - return parseBreakOrContinueStatement(160 /* ContinueStatement */); - case 60 /* BreakKeyword */: - return parseBreakOrContinueStatement(161 /* BreakStatement */); - case 84 /* ReturnKeyword */: + case 69 /* ContinueKeyword */: + return parseBreakOrContinueStatement(167 /* ContinueStatement */); + case 64 /* BreakKeyword */: + return parseBreakOrContinueStatement(168 /* BreakStatement */); + case 88 /* ReturnKeyword */: return parseReturnStatement(); - case 95 /* WithKeyword */: + case 99 /* WithKeyword */: return parseWithStatement(); - case 86 /* SwitchKeyword */: + case 90 /* SwitchKeyword */: return parseSwitchStatement(); - case 88 /* ThrowKeyword */: + case 92 /* ThrowKeyword */: return parseThrowStatement(); - case 90 /* TryKeyword */: - case 62 /* CatchKeyword */: - case 75 /* FinallyKeyword */: + case 94 /* TryKeyword */: + case 66 /* CatchKeyword */: + case 79 /* FinallyKeyword */: return parseTryStatement(); - case 66 /* DebuggerKeyword */: + case 70 /* DebuggerKeyword */: return parseDebuggerStatement(); default: if (isLabel()) { @@ -5206,7 +4772,7 @@ var ts; function parseAndCheckFunctionBody(isConstructor) { var initialPosition = scanner.getTokenPos(); var errorCountBeforeBody = file.syntacticErrors.length; - if (token === 9 /* OpenBraceToken */) { + if (token === 13 /* OpenBraceToken */) { var body = parseBody(false); if (body && inAmbientContext && file.syntacticErrors.length === errorCountBeforeBody) { var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; @@ -5221,7 +4787,7 @@ var ts; error(ts.Diagnostics.Block_or_expected); } function parseVariableDeclaration(flags, noIn) { - var node = createNode(174 /* VariableDeclaration */); + var node = createNode(181 /* VariableDeclaration */); node.flags = flags; var errorCountBeforeVariableDeclaration = file.syntacticErrors.length; node.name = parseIdentifier(); @@ -5244,17 +4810,17 @@ var ts; return parseDelimitedList(9 /* VariableDeclarations */, function () { return parseVariableDeclaration(flags, noIn); }, false); } function parseVariableStatement(allowLetAndConstDeclarations, pos, flags) { - var node = createNode(152 /* VariableStatement */, pos); + var node = createNode(159 /* VariableStatement */, pos); if (flags) node.flags = flags; var errorCountBeforeVarStatement = file.syntacticErrors.length; - if (token === 98 /* LetKeyword */) { + if (token === 102 /* LetKeyword */) { node.flags |= 2048 /* Let */; } - else if (token === 64 /* ConstKeyword */) { + else if (token === 68 /* ConstKeyword */) { node.flags |= 4096 /* Const */; } - else if (token !== 92 /* VarKeyword */) { + else if (token !== 96 /* VarKeyword */) { error(ts.Diagnostics.var_let_or_const_expected); } nextToken(); @@ -5283,12 +4849,12 @@ var ts; return node; } function parseFunctionDeclaration(pos, flags) { - var node = createNode(175 /* FunctionDeclaration */, pos); + var node = createNode(182 /* FunctionDeclaration */, pos); if (flags) node.flags = flags; - parseExpected(77 /* FunctionKeyword */); + parseExpected(81 /* FunctionKeyword */); node.name = parseIdentifier(); - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; node.type = sig.type; @@ -5299,10 +4865,10 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, flags) { - var node = createNode(122 /* Constructor */, pos); + var node = createNode(126 /* Constructor */, pos); node.flags = flags; - parseExpected(107 /* ConstructorKeyword */); - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + parseExpected(111 /* ConstructorKeyword */); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; node.type = sig.type; @@ -5319,14 +4885,14 @@ var ts; var errorCountBeforePropertyDeclaration = file.syntacticErrors.length; var name = parsePropertyName(); var questionStart = scanner.getTokenPos(); - if (parseOptional(45 /* QuestionToken */)) { + if (parseOptional(49 /* QuestionToken */)) { errorAtPos(questionStart, scanner.getStartPos() - questionStart, ts.Diagnostics.A_class_member_cannot_be_declared_optional); } - if (token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) { - var method = createNode(121 /* Method */, pos); + if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { + var method = createNode(125 /* Method */, pos); method.flags = flags; method.name = name; - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); method.typeParameters = sig.typeParameters; method.parameters = sig.parameters; method.type = sig.type; @@ -5334,7 +4900,7 @@ var ts; return finishNode(method); } else { - var property = createNode(120 /* Property */, pos); + var property = createNode(124 /* Property */, pos); property.flags = flags; property.name = name; property.type = parseTypeAnnotation(); @@ -5361,10 +4927,10 @@ var ts; else if (accessor.typeParameters) { grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 123 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 127 /* GetAccessor */ && accessor.parameters.length) { grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 124 /* SetAccessor */) { + else if (kind === 128 /* SetAccessor */) { if (accessor.type) { grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -5376,7 +4942,7 @@ var ts; if (parameter.flags & 8 /* Rest */) { grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & ts.NodeFlags.Modifier) { + else if (parameter.flags & 243 /* Modifier */) { grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.flags & 4 /* QuestionMark */) { @@ -5394,7 +4960,7 @@ var ts; var node = createNode(kind, pos); node.flags = flags; node.name = parsePropertyName(); - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; node.type = sig.type; @@ -5417,19 +4983,19 @@ var ts; idToken = token; nextToken(); } - if (token === 13 /* OpenBracketToken */) { + if (token === 17 /* OpenBracketToken */) { return true; } if (idToken !== undefined) { - if (!isKeyword(idToken) || idToken === 113 /* SetKeyword */ || idToken === 109 /* GetKeyword */) { + if (!isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { return true; } switch (token) { - case 11 /* OpenParenToken */: - case 19 /* LessThanToken */: - case 46 /* ColonToken */: - case 47 /* EqualsToken */: - case 45 /* QuestionToken */: + case 15 /* OpenParenToken */: + case 23 /* LessThanToken */: + case 50 /* ColonToken */: + case 51 /* EqualsToken */: + case 49 /* QuestionToken */: return true; default: return canParseSemicolon(); @@ -5454,8 +5020,8 @@ var ts; break; var modifierLength = scanner.getStartPos() - modifierStart; switch (modifierToken) { - case 102 /* PublicKeyword */: - if (flags & ts.NodeFlags.AccessibilityModifier) { + case 106 /* PublicKeyword */: + if (flags & 112 /* AccessibilityModifier */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics.Accessibility_modifier_already_seen); } else if (flags & 128 /* Static */) { @@ -5466,8 +5032,8 @@ var ts; } flags |= 16 /* Public */; break; - case 100 /* PrivateKeyword */: - if (flags & ts.NodeFlags.AccessibilityModifier) { + case 104 /* PrivateKeyword */: + if (flags & 112 /* AccessibilityModifier */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics.Accessibility_modifier_already_seen); } else if (flags & 128 /* Static */) { @@ -5480,7 +5046,7 @@ var ts; lastPrivateModifierLength = modifierLength; flags |= 32 /* Private */; break; - case 101 /* ProtectedKeyword */: + case 105 /* ProtectedKeyword */: if (flags & 16 /* Public */ || flags & 32 /* Private */ || flags & 64 /* Protected */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics.Accessibility_modifier_already_seen); } @@ -5494,7 +5060,7 @@ var ts; lastProtectedModifierLength = modifierLength; flags |= 64 /* Protected */; break; - case 103 /* StaticKeyword */: + case 107 /* StaticKeyword */: if (flags & 128 /* Static */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -5508,7 +5074,7 @@ var ts; lastStaticModifierLength = modifierLength; flags |= 128 /* Static */; break; - case 72 /* ExportKeyword */: + case 76 /* ExportKeyword */: if (flags & 1 /* Export */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -5523,7 +5089,7 @@ var ts; } flags |= 1 /* Export */; break; - case 108 /* DeclareKeyword */: + case 112 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics._0_modifier_already_seen, "declare"); } @@ -5542,26 +5108,26 @@ var ts; break; } } - if (token === 107 /* ConstructorKeyword */ && flags & 128 /* Static */) { + if (token === 111 /* ConstructorKeyword */ && flags & 128 /* Static */) { grammarErrorAtPos(lastStaticModifierStart, lastStaticModifierLength, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - else if (token === 107 /* ConstructorKeyword */ && flags & 32 /* Private */) { + else if (token === 111 /* ConstructorKeyword */ && flags & 32 /* Private */) { grammarErrorAtPos(lastPrivateModifierStart, lastPrivateModifierLength, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (token === 107 /* ConstructorKeyword */ && flags & 64 /* Protected */) { + else if (token === 111 /* ConstructorKeyword */ && flags & 64 /* Protected */) { grammarErrorAtPos(lastProtectedModifierStart, lastProtectedModifierLength, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (token === 79 /* ImportKeyword */) { + else if (token === 83 /* ImportKeyword */) { if (flags & 2 /* Ambient */) { grammarErrorAtPos(lastDeclareModifierStart, lastDeclareModifierLength, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } } - else if (token === 97 /* InterfaceKeyword */) { + else if (token === 101 /* InterfaceKeyword */) { if (flags & 2 /* Ambient */) { grammarErrorAtPos(lastDeclareModifierStart, lastDeclareModifierLength, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } } - else if (token !== 72 /* ExportKeyword */ && !(flags & 2 /* Ambient */) && inAmbientContext && context === 0 /* SourceElements */) { + else if (token !== 76 /* ExportKeyword */ && !(flags & 2 /* Ambient */) && inAmbientContext && context === 0 /* SourceElements */) { var declarationStart = scanner.getTokenPos(); var declarationFirstTokenLength = scanner.getTextPos() - declarationStart; grammarErrorAtPos(declarationStart, declarationFirstTokenLength, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -5571,19 +5137,19 @@ var ts; function parseClassMemberDeclaration() { var pos = getNodePos(); var flags = parseAndCheckModifiers(2 /* ClassMembers */); - if (parseContextualModifier(109 /* GetKeyword */)) { - return parseAndCheckMemberAccessorDeclaration(123 /* GetAccessor */, pos, flags); + if (parseContextualModifier(113 /* GetKeyword */)) { + return parseAndCheckMemberAccessorDeclaration(127 /* GetAccessor */, pos, flags); } - if (parseContextualModifier(113 /* SetKeyword */)) { - return parseAndCheckMemberAccessorDeclaration(124 /* SetAccessor */, pos, flags); + if (parseContextualModifier(117 /* SetKeyword */)) { + return parseAndCheckMemberAccessorDeclaration(128 /* SetAccessor */, pos, flags); } - if (token === 107 /* ConstructorKeyword */) { + if (token === 111 /* ConstructorKeyword */) { return parseConstructorDeclaration(pos, flags); } - if (token >= 59 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { + if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { return parsePropertyMemberDeclaration(pos, flags); } - if (token === 13 /* OpenBracketToken */) { + if (token === 17 /* OpenBracketToken */) { if (flags) { var start = getTokenPos(pos); var length = getNodePos() - start; @@ -5594,23 +5160,23 @@ var ts; ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassDeclaration(pos, flags) { - var node = createNode(177 /* ClassDeclaration */, pos); + var node = createNode(184 /* ClassDeclaration */, pos); node.flags = flags; var errorCountBeforeClassDeclaration = file.syntacticErrors.length; - parseExpected(63 /* ClassKeyword */); + parseExpected(67 /* ClassKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.baseType = parseOptional(73 /* ExtendsKeyword */) ? parseTypeReference() : undefined; + node.baseType = parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined; var implementsKeywordStart = scanner.getTokenPos(); var implementsKeywordLength; - if (parseOptional(96 /* ImplementsKeyword */)) { + if (parseOptional(100 /* ImplementsKeyword */)) { implementsKeywordLength = scanner.getStartPos() - implementsKeywordStart; node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, false); } var errorCountBeforeClassBody = file.syntacticErrors.length; - if (parseExpected(9 /* OpenBraceToken */)) { + if (parseExpected(13 /* OpenBraceToken */)) { node.members = parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -5621,15 +5187,15 @@ var ts; return finishNode(node); } function parseInterfaceDeclaration(pos, flags) { - var node = createNode(178 /* InterfaceDeclaration */, pos); + var node = createNode(185 /* InterfaceDeclaration */, pos); node.flags = flags; var errorCountBeforeInterfaceDeclaration = file.syntacticErrors.length; - parseExpected(97 /* InterfaceKeyword */); + parseExpected(101 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); var extendsKeywordStart = scanner.getTokenPos(); var extendsKeywordLength; - if (parseOptional(73 /* ExtendsKeyword */)) { + if (parseOptional(77 /* ExtendsKeyword */)) { extendsKeywordLength = scanner.getStartPos() - extendsKeywordStart; node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, false); } @@ -5641,30 +5207,24 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(pos, flags) { - var node = createNode(179 /* TypeAliasDeclaration */, pos); + var node = createNode(186 /* TypeAliasDeclaration */, pos); node.flags = flags; - parseExpected(115 /* TypeKeyword */); + parseExpected(119 /* TypeKeyword */); node.name = parseIdentifier(); - parseExpected(47 /* EqualsToken */); + parseExpected(51 /* EqualsToken */); node.type = parseType(); parseSemicolon(); - var n = node.type; - while (n.kind === 134 /* ParenType */) { - n = n.type; - } - if (n.kind === 130 /* TypeLiteral */ && (n.pos !== n.members.pos || n.end !== n.members.end)) { - grammarErrorOnNode(node.type, ts.Diagnostics.Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead); - } return finishNode(node); } function parseAndCheckEnumDeclaration(pos, flags) { + var enumIsConst = flags & 4096 /* Const */; function isIntegerLiteral(expression) { function isInteger(literalExpression) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); } - if (expression.kind === 146 /* PrefixOperator */) { + if (expression.kind === 151 /* PrefixOperator */) { var unaryExpression = expression; - if (unaryExpression.operator === 28 /* PlusToken */ || unaryExpression.operator === 29 /* MinusToken */) { + if (unaryExpression.operator === 32 /* PlusToken */ || unaryExpression.operator === 33 /* MinusToken */) { expression = unaryExpression.operand; } } @@ -5675,30 +5235,35 @@ var ts; } var inConstantEnumMemberSection = true; function parseAndCheckEnumMember() { - var node = createNode(185 /* EnumMember */); + var node = createNode(192 /* EnumMember */); var errorCountBeforeEnumMember = file.syntacticErrors.length; node.name = parsePropertyName(); node.initializer = parseInitializer(false); - if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer) && errorCountBeforeEnumMember === file.syntacticErrors.length) { - grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers); + if (!enumIsConst) { + if (inAmbientContext) { + if (node.initializer && !isIntegerLiteral(node.initializer) && errorCountBeforeEnumMember === file.syntacticErrors.length) { + grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers); + } + } + else if (node.initializer) { + inConstantEnumMemberSection = isIntegerLiteral(node.initializer); + } + else if (!inConstantEnumMemberSection && errorCountBeforeEnumMember === file.syntacticErrors.length) { + grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer); } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection && errorCountBeforeEnumMember === file.syntacticErrors.length) { - grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer); } return finishNode(node); } - var node = createNode(180 /* EnumDeclaration */, pos); + var node = createNode(187 /* EnumDeclaration */, pos); node.flags = flags; - parseExpected(71 /* EnumKeyword */); + if (enumIsConst) { + parseExpected(68 /* ConstKeyword */); + } + parseExpected(75 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(9 /* OpenBraceToken */)) { + if (parseExpected(13 /* OpenBraceToken */)) { node.members = parseDelimitedList(7 /* EnumMembers */, parseAndCheckEnumMember, true); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -5706,10 +5271,10 @@ var ts; return finishNode(node); } function parseModuleBody() { - var node = createNode(182 /* ModuleBlock */); - if (parseExpected(9 /* OpenBraceToken */)) { + var node = createNode(189 /* ModuleBlock */); + if (parseExpected(13 /* OpenBraceToken */)) { node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -5717,19 +5282,19 @@ var ts; return finishNode(node); } function parseInternalModuleTail(pos, flags) { - var node = createNode(181 /* ModuleDeclaration */, pos); + var node = createNode(188 /* ModuleDeclaration */, pos); node.flags = flags; node.name = parseIdentifier(); - if (parseOptional(15 /* DotToken */)) { + if (parseOptional(19 /* DotToken */)) { node.body = parseInternalModuleTail(getNodePos(), 1 /* Export */); } else { node.body = parseModuleBody(); ts.forEach(node.body.statements, function (s) { - if (s.kind === 184 /* ExportAssignment */) { + if (s.kind === 191 /* ExportAssignment */) { grammarErrorOnNode(s, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); } - else if (s.kind === 183 /* ImportDeclaration */ && s.externalModuleName) { + else if (s.kind === 190 /* ImportDeclaration */ && s.externalModuleName) { grammarErrorOnNode(s, ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); } }); @@ -5737,7 +5302,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(pos, flags) { - var node = createNode(181 /* ModuleDeclaration */, pos); + var node = createNode(188 /* ModuleDeclaration */, pos); node.flags = flags; node.name = parseStringLiteral(); if (!inAmbientContext) { @@ -5753,19 +5318,19 @@ var ts; return finishNode(node); } function parseModuleDeclaration(pos, flags) { - parseExpected(110 /* ModuleKeyword */); + parseExpected(114 /* ModuleKeyword */); return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(pos, flags) : parseInternalModuleTail(pos, flags); } function parseImportDeclaration(pos, flags) { - var node = createNode(183 /* ImportDeclaration */, pos); + var node = createNode(190 /* ImportDeclaration */, pos); node.flags = flags; - parseExpected(79 /* ImportKeyword */); + parseExpected(83 /* ImportKeyword */); node.name = parseIdentifier(); - parseExpected(47 /* EqualsToken */); + parseExpected(51 /* EqualsToken */); var entityName = parseEntityName(false); - if (entityName.kind === 59 /* Identifier */ && entityName.text === "require" && parseOptional(11 /* OpenParenToken */)) { + if (entityName.kind === 63 /* Identifier */ && entityName.text === "require" && parseOptional(15 /* OpenParenToken */)) { node.externalModuleName = parseStringLiteral(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); } else { node.entityName = entityName; @@ -5774,36 +5339,36 @@ var ts; return finishNode(node); } function parseExportAssignmentTail(pos) { - var node = createNode(184 /* ExportAssignment */, pos); + var node = createNode(191 /* ExportAssignment */, pos); node.exportName = parseIdentifier(); parseSemicolon(); return finishNode(node); } - function isDeclaration() { + function isDeclarationStart() { switch (token) { - case 92 /* VarKeyword */: - case 98 /* LetKeyword */: - case 64 /* ConstKeyword */: - case 77 /* FunctionKeyword */: + case 96 /* VarKeyword */: + case 102 /* LetKeyword */: + case 68 /* ConstKeyword */: + case 81 /* FunctionKeyword */: return true; - case 63 /* ClassKeyword */: - case 97 /* InterfaceKeyword */: - case 71 /* EnumKeyword */: - case 79 /* ImportKeyword */: - case 115 /* TypeKeyword */: - return lookAhead(function () { return nextToken() >= 59 /* Identifier */; }); - case 110 /* ModuleKeyword */: - return lookAhead(function () { return nextToken() >= 59 /* Identifier */ || token === 7 /* StringLiteral */; }); - case 72 /* ExportKeyword */: - return lookAhead(function () { return nextToken() === 47 /* EqualsToken */ || isDeclaration(); }); - case 108 /* DeclareKeyword */: - case 102 /* PublicKeyword */: - case 100 /* PrivateKeyword */: - case 101 /* ProtectedKeyword */: - case 103 /* StaticKeyword */: + case 67 /* ClassKeyword */: + case 101 /* InterfaceKeyword */: + case 75 /* EnumKeyword */: + case 83 /* ImportKeyword */: + case 119 /* TypeKeyword */: + return lookAhead(function () { return nextToken() >= 63 /* Identifier */; }); + case 114 /* ModuleKeyword */: + return lookAhead(function () { return nextToken() >= 63 /* Identifier */ || token === 7 /* StringLiteral */; }); + case 76 /* ExportKeyword */: + return lookAhead(function () { return nextToken() === 51 /* EqualsToken */ || isDeclarationStart(); }); + case 112 /* DeclareKeyword */: + case 106 /* PublicKeyword */: + case 104 /* PrivateKeyword */: + case 105 /* ProtectedKeyword */: + case 107 /* StaticKeyword */: return lookAhead(function () { nextToken(); - return isDeclaration(); + return isDeclarationStart(); }); } } @@ -5811,10 +5376,10 @@ var ts; var pos = getNodePos(); var errorCountBeforeModifiers = file.syntacticErrors.length; var flags = parseAndCheckModifiers(modifierContext); - if (token === 72 /* ExportKeyword */) { + if (token === 76 /* ExportKeyword */) { var modifiersEnd = scanner.getStartPos(); nextToken(); - if (parseOptional(47 /* EqualsToken */)) { + if (parseOptional(51 /* EqualsToken */)) { var exportAssignmentTail = parseExportAssignmentTail(pos); if (flags !== 0 && errorCountBeforeModifiers === file.syntacticErrors.length) { var modifiersStart = ts.skipTrivia(sourceText, pos); @@ -5829,30 +5394,38 @@ var ts; } var result; switch (token) { - case 92 /* VarKeyword */: - case 98 /* LetKeyword */: - case 64 /* ConstKeyword */: + case 96 /* VarKeyword */: + case 102 /* LetKeyword */: result = parseVariableStatement(true, pos, flags); break; - case 77 /* FunctionKeyword */: + case 68 /* ConstKeyword */: + var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); + if (isConstEnum) { + result = parseAndCheckEnumDeclaration(pos, flags | 4096 /* Const */); + } + else { + result = parseVariableStatement(true, pos, flags); + } + break; + case 81 /* FunctionKeyword */: result = parseFunctionDeclaration(pos, flags); break; - case 63 /* ClassKeyword */: + case 67 /* ClassKeyword */: result = parseClassDeclaration(pos, flags); break; - case 97 /* InterfaceKeyword */: + case 101 /* InterfaceKeyword */: result = parseInterfaceDeclaration(pos, flags); break; - case 115 /* TypeKeyword */: + case 119 /* TypeKeyword */: result = parseTypeAliasDeclaration(pos, flags); break; - case 71 /* EnumKeyword */: + case 75 /* EnumKeyword */: result = parseAndCheckEnumDeclaration(pos, flags); break; - case 110 /* ModuleKeyword */: + case 114 /* ModuleKeyword */: result = parseModuleDeclaration(pos, flags); break; - case 79 /* ImportKeyword */: + case 83 /* ImportKeyword */: result = parseImportDeclaration(pos, flags); break; default: @@ -5862,7 +5435,7 @@ var ts; return result; } function isSourceElement(inErrorRecovery) { - return isDeclaration() || isStatement(inErrorRecovery); + return isDeclarationStart() || isStatement(inErrorRecovery); } function parseSourceElement() { return parseSourceElementOrModuleElement(0 /* SourceElements */); @@ -5871,7 +5444,7 @@ var ts; return parseSourceElementOrModuleElement(1 /* ModuleElements */); } function parseSourceElementOrModuleElement(modifierContext) { - if (isDeclaration()) { + if (isDeclarationStart()) { return parseDeclaration(modifierContext); } var statementStart = scanner.getTokenPos(); @@ -5929,7 +5502,7 @@ var ts; }; } function getExternalModuleIndicator() { - return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 183 /* ImportDeclaration */ && node.externalModuleName || node.kind === 184 /* ExportAssignment */ ? node : undefined; }); + return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 190 /* ImportDeclaration */ && node.externalModuleName || node.kind === 191 /* ExportAssignment */ ? node : undefined; }); } scanner = ts.createScanner(languageVersion, true, sourceText, scanError, onComment); var rootNodeFlags = 0; @@ -5937,7 +5510,7 @@ var ts; rootNodeFlags = 1024 /* DeclarationFile */; inAmbientContext = true; } - file = createRootNode(186 /* SourceFile */, 0, sourceText.length, rootNodeFlags); + file = createRootNode(193 /* SourceFile */, 0, sourceText.length, rootNodeFlags); file.filename = ts.normalizePath(filename); file.text = sourceText; file.getLineAndCharacterFromPosition = getLineAndCharacterlFromSourcePosition; @@ -6070,7 +5643,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 183 /* ImportDeclaration */ && node.externalModuleName) { + if (node.kind === 190 /* ImportDeclaration */ && node.externalModuleName) { var nameLiteral = node.externalModuleName; var moduleName = nameLiteral.text; if (moduleName) { @@ -6088,9 +5661,9 @@ var ts; } } } - else if (node.kind === 181 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { + else if (node.kind === 188 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { forEachChild(node.body, function (node) { - if (node.kind === 183 /* ImportDeclaration */ && node.externalModuleName) { + if (node.kind === 190 /* ImportDeclaration */ && node.externalModuleName) { var nameLiteral = node.externalModuleName; var moduleName = nameLiteral.text; if (moduleName) { @@ -6162,24 +5735,40 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function isInstantiated(node) { - if (node.kind === 178 /* InterfaceDeclaration */) { - return false; + function getModuleInstanceState(node) { + if (node.kind === 185 /* InterfaceDeclaration */) { + return 0 /* NonInstantiated */; } - else if (node.kind === 183 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { - return false; + else if (node.kind === 187 /* EnumDeclaration */ && ts.isConstEnumDeclaration(node)) { + return 2 /* ConstEnumOnly */; } - else if (node.kind === 182 /* ModuleBlock */ && !ts.forEachChild(node, isInstantiated)) { - return false; + else if (node.kind === 190 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { + return 0 /* NonInstantiated */; } - else if (node.kind === 181 /* ModuleDeclaration */ && !isInstantiated(node.body)) { - return false; + else if (node.kind === 189 /* ModuleBlock */) { + var state = 0 /* NonInstantiated */; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0 /* NonInstantiated */: + return false; + case 2 /* ConstEnumOnly */: + state = 2 /* ConstEnumOnly */; + return false; + case 1 /* Instantiated */: + state = 1 /* Instantiated */; + return true; + } + }); + return state; + } + else if (node.kind === 188 /* ModuleDeclaration */) { + return getModuleInstanceState(node.body); } else { - return true; + return 1 /* Instantiated */; } } - ts.isInstantiated = isInstantiated; + ts.getModuleInstanceState = getModuleInstanceState; function bindSourceFile(file) { var parent; var container; @@ -6202,30 +5791,26 @@ var ts; if (!symbol.declarations) symbol.declarations = []; symbol.declarations.push(node); - if (symbolKind & ts.SymbolFlags.HasExports && !symbol.exports) + if (symbolKind & 1952 /* HasExports */ && !symbol.exports) symbol.exports = {}; - if (symbolKind & ts.SymbolFlags.HasMembers && !symbol.members) + if (symbolKind & 6240 /* HasMembers */ && !symbol.members) symbol.members = {}; node.symbol = symbol; - if (symbolKind & ts.SymbolFlags.Value && !symbol.valueDeclaration) + if (symbolKind & 107455 /* Value */ && !symbol.valueDeclaration) symbol.valueDeclaration = node; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 181 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { + if (node.kind === 188 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { return '"' + node.name.text + '"'; } return node.name.text; } switch (node.kind) { - case 122 /* Constructor */: - return "__constructor"; - case 125 /* CallSignature */: - return "__call"; - case 126 /* ConstructSignature */: - return "__new"; - case 127 /* IndexSignature */: - return "__index"; + case 126 /* Constructor */: return "__constructor"; + case 129 /* CallSignature */: return "__call"; + case 130 /* ConstructSignature */: return "__new"; + case 131 /* IndexSignature */: return "__index"; } } function getDisplayName(node) { @@ -6252,8 +5837,8 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if (node.kind === 177 /* ClassDeclaration */ && symbol.exports) { - var prototypeSymbol = createSymbol(4 /* Property */ | 268435456 /* Prototype */, "prototype"); + if (node.kind === 184 /* ClassDeclaration */ && symbol.exports) { + var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { node.name.parent = node; @@ -6275,16 +5860,16 @@ var ts; } function declareModuleMember(node, symbolKind, symbolExcludes) { var exportKind = 0; - if (symbolKind & ts.SymbolFlags.Value) { - exportKind |= 2097152 /* ExportValue */; + if (symbolKind & 107455 /* Value */) { + exportKind |= 4194304 /* ExportValue */; } - if (symbolKind & ts.SymbolFlags.Type) { - exportKind |= 4194304 /* ExportType */; + if (symbolKind & 3152352 /* Type */) { + exportKind |= 8388608 /* ExportType */; } - if (symbolKind & ts.SymbolFlags.Namespace) { - exportKind |= 8388608 /* ExportNamespace */; + if (symbolKind & 1536 /* Namespace */) { + exportKind |= 16777216 /* ExportNamespace */; } - if (node.flags & 1 /* Export */ || (node.kind !== 183 /* ImportDeclaration */ && isAmbientContext(container))) { + if (node.flags & 1 /* Export */ || (node.kind !== 190 /* ImportDeclaration */ && isAmbientContext(container))) { if (exportKind) { var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); @@ -6299,14 +5884,14 @@ var ts; } } function bindChildren(node, symbolKind, isBlockScopeContainer) { - if (symbolKind & ts.SymbolFlags.HasLocals) { + if (symbolKind & 1041936 /* HasLocals */) { node.locals = {}; } var saveParent = parent; var saveContainer = container; var savedBlockScopeContainer = blockScopeContainer; parent = node; - if (symbolKind & ts.SymbolFlags.IsContainer) { + if (symbolKind & 1048560 /* IsContainer */) { container = node; if (lastContainer !== container && !container.nextContainer) { if (lastContainer) { @@ -6325,59 +5910,68 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: if (node.flags & 128 /* Static */) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 130 /* TypeLiteral */: - case 136 /* ObjectLiteral */: - case 178 /* InterfaceDeclaration */: + case 134 /* TypeLiteral */: + case 140 /* ObjectLiteral */: + case 185 /* InterfaceDeclaration */: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } bindChildren(node, symbolKind, isBlockScopeContainer); } function bindConstructorDeclaration(node) { - bindDeclaration(node, 8192 /* Constructor */, 0, true); + bindDeclaration(node, 16384 /* Constructor */, 0, true); ts.forEach(node.parameters, function (p) { if (p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */)) { - bindDeclaration(p, 4 /* Property */, ts.SymbolFlags.PropertyExcludes, false); + bindDeclaration(p, 4 /* Property */, 107455 /* PropertyExcludes */, false); } }); } function bindModuleDeclaration(node) { if (node.name.kind === 7 /* StringLiteral */) { - bindDeclaration(node, 256 /* ValueModule */, ts.SymbolFlags.ValueModuleExcludes, true); - } - else if (isInstantiated(node)) { - bindDeclaration(node, 256 /* ValueModule */, ts.SymbolFlags.ValueModuleExcludes, true); + bindDeclaration(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */, true); } else { - bindDeclaration(node, 512 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */, true); + var state = getModuleInstanceState(node); + if (state === 0 /* NonInstantiated */) { + bindDeclaration(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */, true); + } + else { + bindDeclaration(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */, true); + if (state === 2 /* ConstEnumOnly */) { + node.symbol.constEnumOnlyModule = true; + } + else if (node.symbol.constEnumOnlyModule) { + node.symbol.constEnumOnlyModule = false; + } + } } } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { @@ -6397,113 +5991,118 @@ var ts; } function bindBlockScopedVariableDeclaration(node) { switch (blockScopeContainer.kind) { - case 181 /* ModuleDeclaration */: - declareModuleMember(node, 2 /* BlockScopedVariable */, ts.SymbolFlags.BlockScopedVariableExcludes); + case 188 /* ModuleDeclaration */: + declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (ts.isExternalModule(container)) { - declareModuleMember(node, 2 /* BlockScopedVariable */, ts.SymbolFlags.BlockScopedVariableExcludes); + declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; } default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; } - declareSymbol(blockScopeContainer.locals, undefined, node, 2 /* BlockScopedVariable */, ts.SymbolFlags.BlockScopedVariableExcludes); + declareSymbol(blockScopeContainer.locals, undefined, node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); } bindChildren(node, 2 /* BlockScopedVariable */, false); } function bind(node) { node.parent = parent; switch (node.kind) { - case 118 /* TypeParameter */: - bindDeclaration(node, 524288 /* TypeParameter */, ts.SymbolFlags.TypeParameterExcludes, false); + case 122 /* TypeParameter */: + bindDeclaration(node, 1048576 /* TypeParameter */, 2103776 /* TypeParameterExcludes */, false); break; - case 119 /* Parameter */: - bindDeclaration(node, 1 /* FunctionScopedVariable */, ts.SymbolFlags.ParameterExcludes, false); + case 123 /* Parameter */: + bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); break; - case 174 /* VariableDeclaration */: - if (node.flags & ts.NodeFlags.BlockScoped) { + case 181 /* VariableDeclaration */: + if (node.flags & 6144 /* BlockScoped */) { bindBlockScopedVariableDeclaration(node); } else { - bindDeclaration(node, 1 /* FunctionScopedVariable */, ts.SymbolFlags.FunctionScopedVariableExcludes, false); + bindDeclaration(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */, false); } break; - case 120 /* Property */: - case 137 /* PropertyAssignment */: - bindDeclaration(node, 4 /* Property */, ts.SymbolFlags.PropertyExcludes, false); + case 124 /* Property */: + case 141 /* PropertyAssignment */: + bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); break; - case 185 /* EnumMember */: - bindDeclaration(node, 8 /* EnumMember */, ts.SymbolFlags.EnumMemberExcludes, false); + case 192 /* EnumMember */: + bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); break; - case 125 /* CallSignature */: - bindDeclaration(node, 65536 /* CallSignature */, 0, false); + case 129 /* CallSignature */: + bindDeclaration(node, 131072 /* CallSignature */, 0, false); break; - case 121 /* Method */: - bindDeclaration(node, 4096 /* Method */, ts.SymbolFlags.MethodExcludes, true); + case 125 /* Method */: + bindDeclaration(node, 8192 /* Method */, 99263 /* MethodExcludes */, true); break; - case 126 /* ConstructSignature */: - bindDeclaration(node, 131072 /* ConstructSignature */, 0, true); + case 130 /* ConstructSignature */: + bindDeclaration(node, 262144 /* ConstructSignature */, 0, true); break; - case 127 /* IndexSignature */: - bindDeclaration(node, 262144 /* IndexSignature */, 0, false); + case 131 /* IndexSignature */: + bindDeclaration(node, 524288 /* IndexSignature */, 0, false); break; - case 175 /* FunctionDeclaration */: - bindDeclaration(node, 16 /* Function */, ts.SymbolFlags.FunctionExcludes, true); + case 182 /* FunctionDeclaration */: + bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); break; - case 122 /* Constructor */: + case 126 /* Constructor */: bindConstructorDeclaration(node); break; - case 123 /* GetAccessor */: - bindDeclaration(node, 16384 /* GetAccessor */, ts.SymbolFlags.GetAccessorExcludes, true); + case 127 /* GetAccessor */: + bindDeclaration(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */, true); break; - case 124 /* SetAccessor */: - bindDeclaration(node, 32768 /* SetAccessor */, ts.SymbolFlags.SetAccessorExcludes, true); + case 128 /* SetAccessor */: + bindDeclaration(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */, true); break; - case 130 /* TypeLiteral */: - bindAnonymousDeclaration(node, 1024 /* TypeLiteral */, "__type", false); + case 134 /* TypeLiteral */: + bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); break; - case 136 /* ObjectLiteral */: - bindAnonymousDeclaration(node, 2048 /* ObjectLiteral */, "__object", false); + case 140 /* ObjectLiteral */: + bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); break; - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); break; - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: bindCatchVariableDeclaration(node); break; - case 177 /* ClassDeclaration */: - bindDeclaration(node, 32 /* Class */, ts.SymbolFlags.ClassExcludes, false); + case 184 /* ClassDeclaration */: + bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false); break; - case 178 /* InterfaceDeclaration */: - bindDeclaration(node, 64 /* Interface */, ts.SymbolFlags.InterfaceExcludes, false); + case 185 /* InterfaceDeclaration */: + bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false); break; - case 179 /* TypeAliasDeclaration */: - bindDeclaration(node, 1048576 /* TypeAlias */, ts.SymbolFlags.TypeAliasExcludes, false); + case 186 /* TypeAliasDeclaration */: + bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false); break; - case 180 /* EnumDeclaration */: - bindDeclaration(node, 128 /* Enum */, ts.SymbolFlags.EnumExcludes, false); + case 187 /* EnumDeclaration */: + if (ts.isConstEnumDeclaration(node)) { + bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false); + } + else { + bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false); + } break; - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: bindModuleDeclaration(node); break; - case 183 /* ImportDeclaration */: - bindDeclaration(node, 16777216 /* Import */, ts.SymbolFlags.ImportExcludes, false); + case 190 /* ImportDeclaration */: + bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false); break; - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (ts.isExternalModule(node)) { - bindAnonymousDeclaration(node, 256 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); + bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); break; } - case 151 /* Block */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 164 /* SwitchStatement */: + case 158 /* Block */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 171 /* SwitchStatement */: bindChildren(node, 0, true); break; default: @@ -6566,7 +6165,7 @@ var ts; } function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 122 /* Constructor */ && member.body) { + if (member.kind === 126 /* Constructor */ && member.body) { return member; } }); @@ -6576,14 +6175,14 @@ var ts; var getAccessor; var setAccessor; ts.forEach(node.members, function (member) { - if ((member.kind === 123 /* GetAccessor */ || member.kind === 124 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { if (!firstAccessor) { firstAccessor = member; } - if (member.kind === 123 /* GetAccessor */ && !getAccessor) { + if (member.kind === 127 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 124 /* SetAccessor */ && !setAccessor) { + if (member.kind === 128 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6906,7 +6505,7 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 175 /* FunctionDeclaration */ || node.kind === 144 /* FunctionExpression */ || node.kind === 121 /* Method */ || node.kind === 123 /* GetAccessor */ || node.kind === 124 /* SetAccessor */ || node.kind === 181 /* ModuleDeclaration */ || node.kind === 177 /* ClassDeclaration */ || node.kind === 180 /* EnumDeclaration */) { + else if (node.kind === 182 /* FunctionDeclaration */ || node.kind === 149 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 188 /* ModuleDeclaration */ || node.kind === 184 /* ClassDeclaration */ || node.kind === 187 /* EnumDeclaration */) { if (node.name) { scopeName = node.name.text; } @@ -6988,7 +6587,7 @@ var ts; } function emitNodeWithMap(node) { if (node) { - if (node.kind != 186 /* SourceFile */) { + if (node.kind != 193 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNode(node); recordEmitNodeEndSpan(node); @@ -7075,13 +6674,76 @@ var ts; } } function emitLiteral(node) { - var text = getSourceTextOfLocalNode(node); - if (node.kind === 7 /* StringLiteral */ && compilerOptions.sourceMap) { + var text = getLiteralText(); + if (compilerOptions.sourceMap && (node.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else { write(text); } + function getLiteralText() { + if (compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind)) { + return getTemplateLiteralAsStringLiteral(node); + } + return getSourceTextOfLocalNode(node); + } + } + function getTemplateLiteralAsStringLiteral(node) { + return '"' + ts.escapeString(node.text) + '"'; + } + function emitTemplateExpression(node) { + if (compilerOptions.target >= 2 /* ES6 */) { + ts.forEachChild(node, emit); + return; + } + ts.Debug.assert(node.parent.kind !== 146 /* TaggedTemplateExpression */); + var templateNeedsParens = ts.isExpression(node.parent) && node.parent.kind !== 148 /* ParenExpression */ && comparePrecedenceToBinaryPlus(node.parent) !== -1 /* LessThan */; + if (templateNeedsParens) { + write("("); + } + emitLiteral(node.head); + ts.forEach(node.templateSpans, function (templateSpan) { + var needsParens = templateSpan.expression.kind !== 148 /* ParenExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + write(" + "); + if (needsParens) { + write("("); + } + emit(templateSpan.expression); + if (needsParens) { + write(")"); + } + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + }); + if (templateNeedsParens) { + write(")"); + } + function comparePrecedenceToBinaryPlus(expression) { + ts.Debug.assert(compilerOptions.target <= 1 /* ES5 */); + switch (expression.kind) { + case 153 /* BinaryExpression */: + switch (expression.operator) { + case 34 /* AsteriskToken */: + case 35 /* SlashToken */: + case 36 /* PercentToken */: + return 1 /* GreaterThan */; + case 32 /* PlusToken */: + return 0 /* EqualTo */; + default: + return -1 /* LessThan */; + } + case 154 /* ConditionalExpression */: + return -1 /* LessThan */; + default: + return 1 /* GreaterThan */; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); } function emitQuotedIdentifier(node) { if (node.kind === 7 /* StringLiteral */) { @@ -7101,29 +6763,29 @@ var ts; function isNonExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 119 /* Parameter */: - case 174 /* VariableDeclaration */: - case 120 /* Property */: - case 137 /* PropertyAssignment */: - case 185 /* EnumMember */: - case 121 /* Method */: - case 175 /* FunctionDeclaration */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 144 /* FunctionExpression */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: - case 181 /* ModuleDeclaration */: - case 183 /* ImportDeclaration */: + case 123 /* Parameter */: + case 181 /* VariableDeclaration */: + case 124 /* Property */: + case 141 /* PropertyAssignment */: + case 192 /* EnumMember */: + case 125 /* Method */: + case 182 /* FunctionDeclaration */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 149 /* FunctionExpression */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: + case 188 /* ModuleDeclaration */: + case 190 /* ImportDeclaration */: return parent.name === node; - case 161 /* BreakStatement */: - case 160 /* ContinueStatement */: - case 184 /* ExportAssignment */: + case 168 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 191 /* ExportAssignment */: return false; - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return node.parent.label === node; - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: return node.parent.variable === node; } } @@ -7197,18 +6859,27 @@ var ts; emit(node.initializer); emitTrailingComments(node); } - function emitPropertyAccess(node) { + function tryEmitConstantValue(node) { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - write(constantValue.toString() + " /* " + ts.identifierToString(node.right) + " */"); + var propertyName = node.kind === 142 /* PropertyAccess */ ? ts.identifierToString(node.right) : ts.getTextOfNode(node.index); + write(constantValue.toString() + " /* " + propertyName + " */"); + return true; } - else { - emit(node.left); - write("."); - emit(node.right); + return false; + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; } + emit(node.left); + write("."); + emit(node.right); } function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } emit(node.object); write("["); emit(node.index); @@ -7216,13 +6887,13 @@ var ts; } function emitCallExpression(node) { var superCall = false; - if (node.func.kind === 85 /* SuperKeyword */) { + if (node.func.kind === 89 /* SuperKeyword */) { write("_super"); superCall = true; } else { emit(node.func); - superCall = node.func.kind === 138 /* PropertyAccess */ && node.func.left.kind === 85 /* SuperKeyword */; + superCall = node.func.kind === 142 /* PropertyAccess */ && node.func.left.kind === 89 /* SuperKeyword */; } if (superCall) { write(".call("); @@ -7248,13 +6919,19 @@ var ts; write(")"); } } + function emitTaggedTemplateExpression(node) { + ts.Debug.assert(compilerOptions.target >= 2 /* ES6 */, "Trying to emit a tagged template in pre-ES6 mode."); + emit(node.tag); + write(" "); + emit(node.template); + } function emitParenExpression(node) { - if (node.expression.kind === 142 /* TypeAssertion */) { + if (node.expression.kind === 147 /* TypeAssertion */) { var operand = node.expression.operand; - while (operand.kind == 142 /* TypeAssertion */) { + while (operand.kind == 147 /* TypeAssertion */) { operand = operand.operand; } - if (operand.kind !== 146 /* PrefixOperator */ && operand.kind !== 147 /* PostfixOperator */ && operand.kind !== 141 /* NewExpression */ && !(operand.kind === 140 /* CallExpression */ && node.parent.kind === 141 /* NewExpression */) && !(operand.kind === 144 /* FunctionExpression */ && node.parent.kind === 140 /* CallExpression */)) { + if (operand.kind !== 151 /* PrefixOperator */ && operand.kind !== 152 /* PostfixOperator */ && operand.kind !== 145 /* NewExpression */ && !(operand.kind === 144 /* CallExpression */ && node.parent.kind === 145 /* NewExpression */) && !(operand.kind === 149 /* FunctionExpression */ && node.parent.kind === 144 /* CallExpression */)) { emit(operand); return; } @@ -7264,29 +6941,29 @@ var ts; write(")"); } function emitUnaryExpression(node) { - if (node.kind === 146 /* PrefixOperator */) { + if (node.kind === 151 /* PrefixOperator */) { write(ts.tokenToString(node.operator)); } - if (node.operator >= 59 /* Identifier */) { + if (node.operator >= 63 /* Identifier */) { write(" "); } - else if (node.kind === 146 /* PrefixOperator */ && node.operand.kind === 146 /* PrefixOperator */) { + else if (node.kind === 151 /* PrefixOperator */ && node.operand.kind === 151 /* PrefixOperator */) { var operand = node.operand; - if (node.operator === 28 /* PlusToken */ && (operand.operator === 28 /* PlusToken */ || operand.operator === 33 /* PlusPlusToken */)) { + if (node.operator === 32 /* PlusToken */ && (operand.operator === 32 /* PlusToken */ || operand.operator === 37 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 29 /* MinusToken */ && (operand.operator === 29 /* MinusToken */ || operand.operator === 34 /* MinusMinusToken */)) { + else if (node.operator === 33 /* MinusToken */ && (operand.operator === 33 /* MinusToken */ || operand.operator === 38 /* MinusMinusToken */)) { write(" "); } } emit(node.operand); - if (node.kind === 147 /* PostfixOperator */) { + if (node.kind === 152 /* PostfixOperator */) { write(ts.tokenToString(node.operator)); } } function emitBinaryExpression(node) { emit(node.left); - if (node.operator !== 18 /* CommaToken */) + if (node.operator !== 22 /* CommaToken */) write(" "); write(ts.tokenToString(node.operator)); write(" "); @@ -7300,21 +6977,21 @@ var ts; emit(node.whenFalse); } function emitBlock(node) { - emitToken(9 /* OpenBraceToken */, node.pos); + emitToken(13 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 182 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 181 /* ModuleDeclaration */); + if (node.kind === 189 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 188 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); decreaseIndent(); writeLine(); - emitToken(10 /* CloseBraceToken */, node.statements.end); + emitToken(14 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 151 /* Block */) { + if (node.kind === 158 /* Block */) { write(" "); emit(node); } @@ -7326,7 +7003,7 @@ var ts; } } function emitExpressionStatement(node) { - var isArrowExpression = node.expression.kind === 145 /* ArrowFunction */; + var isArrowExpression = node.expression.kind === 150 /* ArrowFunction */; emitLeadingComments(node); if (isArrowExpression) write("("); @@ -7338,16 +7015,16 @@ var ts; } function emitIfStatement(node) { emitLeadingComments(node); - var endPos = emitToken(78 /* IfKeyword */, node.pos); + var endPos = emitToken(82 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(11 /* OpenParenToken */, endPos); + endPos = emitToken(15 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(12 /* CloseParenToken */, node.expression.end); + emitToken(16 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(70 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 155 /* IfStatement */) { + emitToken(74 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 162 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -7360,7 +7037,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 151 /* Block */) { + if (node.statement.kind === 158 /* Block */) { write(" "); } else { @@ -7377,18 +7054,18 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var endPos = emitToken(76 /* ForKeyword */, node.pos); + var endPos = emitToken(80 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(11 /* OpenParenToken */, endPos); + endPos = emitToken(15 /* OpenParenToken */, endPos); if (node.declarations) { if (node.declarations[0] && node.declarations[0].flags & 2048 /* Let */) { - emitToken(98 /* LetKeyword */, endPos); + emitToken(102 /* LetKeyword */, endPos); } else if (node.declarations[0] && node.declarations[0].flags & 4096 /* Const */) { - emitToken(64 /* ConstKeyword */, endPos); + emitToken(68 /* ConstKeyword */, endPos); } else { - emitToken(92 /* VarKeyword */, endPos); + emitToken(96 /* VarKeyword */, endPos); } write(" "); emitCommaList(node.declarations, false); @@ -7404,15 +7081,15 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var endPos = emitToken(76 /* ForKeyword */, node.pos); + var endPos = emitToken(80 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(11 /* OpenParenToken */, endPos); + endPos = emitToken(15 /* OpenParenToken */, endPos); if (node.declaration) { if (node.declaration.flags & 2048 /* Let */) { - emitToken(98 /* LetKeyword */, endPos); + emitToken(102 /* LetKeyword */, endPos); } else { - emitToken(92 /* VarKeyword */, endPos); + emitToken(96 /* VarKeyword */, endPos); } write(" "); emit(node.declaration); @@ -7422,17 +7099,17 @@ var ts; } write(" in "); emit(node.expression); - emitToken(12 /* CloseParenToken */, node.expression.end); + emitToken(16 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 161 /* BreakStatement */ ? 60 /* BreakKeyword */ : 65 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 168 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { emitLeadingComments(node); - emitToken(84 /* ReturnKeyword */, node.pos); + emitToken(88 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); emitTrailingComments(node); @@ -7444,21 +7121,24 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(86 /* SwitchKeyword */, node.pos); + var endPos = emitToken(90 /* SwitchKeyword */, node.pos); write(" "); - emitToken(11 /* OpenParenToken */, endPos); + emitToken(15 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(12 /* CloseParenToken */, node.expression.end); + endPos = emitToken(16 /* CloseParenToken */, node.expression.end); write(" "); - emitToken(9 /* OpenBraceToken */, endPos); + emitToken(13 /* OpenBraceToken */, endPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(10 /* CloseBraceToken */, node.clauses.end); + emitToken(14 /* CloseBraceToken */, node.clauses.end); + } + function isOnSameLine(node1, node2) { + return getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 165 /* CaseClause */) { + if (node.kind === 172 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -7466,9 +7146,15 @@ var ts; else { write("default:"); } - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); + if (node.statements.length === 1 && isOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } } function emitThrowStatement(node) { write("throw "); @@ -7487,16 +7173,16 @@ var ts; } function emitCatchBlock(node) { writeLine(); - var endPos = emitToken(62 /* CatchKeyword */, node.pos); + var endPos = emitToken(66 /* CatchKeyword */, node.pos); write(" "); - emitToken(11 /* OpenParenToken */, endPos); + emitToken(15 /* OpenParenToken */, endPos); emit(node.variable); - emitToken(12 /* CloseParenToken */, node.variable.end); + emitToken(16 /* CloseParenToken */, node.variable.end); write(" "); emitBlock(node); } function emitDebuggerStatement(node) { - emitToken(66 /* DebuggerKeyword */, node.pos); + emitToken(70 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -7507,7 +7193,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 181 /* ModuleDeclaration */); + } while (node && node.kind !== 188 /* ModuleDeclaration */); return node; } function emitModuleMemberName(node) { @@ -7606,7 +7292,7 @@ var ts; } function emitAccessor(node) { emitLeadingComments(node); - write(node.kind === 123 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 127 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); emitTrailingComments(node); @@ -7615,15 +7301,15 @@ var ts; if (!node.body) { return emitPinnedOrTripleSlashComments(node); } - if (node.kind !== 121 /* Method */) { + if (node.kind !== 125 /* Method */) { emitLeadingComments(node); } write("function "); - if (node.kind === 175 /* FunctionDeclaration */ || (node.kind === 144 /* FunctionExpression */ && node.name)) { + if (node.kind === 182 /* FunctionDeclaration */ || (node.kind === 149 /* FunctionExpression */ && node.name)) { emit(node.name); } emitSignatureAndBody(node); - if (node.kind !== 121 /* Method */) { + if (node.kind !== 125 /* Method */) { emitTrailingComments(node); } } @@ -7649,16 +7335,16 @@ var ts; write(" {"); scopeEmitStart(node); increaseIndent(); - emitDetachedComments(node.body.kind === 176 /* FunctionBlock */ ? node.body.statements : node.body); + emitDetachedComments(node.body.kind === 183 /* FunctionBlock */ ? node.body.statements : node.body); var startIndex = 0; - if (node.body.kind === 176 /* FunctionBlock */) { + if (node.body.kind === 183 /* FunctionBlock */) { startIndex = emitDirectivePrologues(node.body.statements, true); } var outPos = writer.getTextPos(); emitCaptureThisForNodeIfNecessary(node); emitDefaultValueAssignments(node); emitRestParameter(node); - if (node.body.kind !== 176 /* FunctionBlock */ && outPos === writer.getTextPos()) { + if (node.body.kind !== 183 /* FunctionBlock */ && outPos === writer.getTextPos()) { decreaseIndent(); write(" "); emitStart(node.body); @@ -7671,7 +7357,7 @@ var ts; emitEnd(node.body); } else { - if (node.body.kind === 176 /* FunctionBlock */) { + if (node.body.kind === 183 /* FunctionBlock */) { emitLinesStartingAt(node.body.statements, startIndex); } else { @@ -7683,10 +7369,10 @@ var ts; emitTrailingComments(node.body); } writeLine(); - if (node.body.kind === 176 /* FunctionBlock */) { + if (node.body.kind === 183 /* FunctionBlock */) { emitLeadingCommentsOfPosition(node.body.statements.end); decreaseIndent(); - emitToken(10 /* CloseBraceToken */, node.body.statements.end); + emitToken(14 /* CloseBraceToken */, node.body.statements.end); } else { decreaseIndent(); @@ -7709,11 +7395,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 154 /* ExpressionStatement */) { + if (statement && statement.kind === 161 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 140 /* CallExpression */) { + if (expr && expr.kind === 144 /* CallExpression */) { var func = expr.func; - if (func && func.kind === 85 /* SuperKeyword */) { + if (func && func.kind === 89 /* SuperKeyword */) { return statement; } } @@ -7722,7 +7408,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & ts.NodeFlags.AccessibilityModifier) { + if (param.flags & 112 /* AccessibilityModifier */) { writeLine(); emitStart(param); emitStart(param.name); @@ -7749,7 +7435,7 @@ var ts; } function emitMemberAssignments(node, staticFlag) { ts.forEach(node.members, function (member) { - if (member.kind === 120 /* Property */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { + if (member.kind === 124 /* Property */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -7772,7 +7458,7 @@ var ts; } function emitMemberFunctions(node) { ts.forEach(node.members, function (member) { - if (member.kind === 121 /* Method */) { + if (member.kind === 125 /* Method */) { if (!member.body) { return emitPinnedOrTripleSlashComments(member); } @@ -7794,7 +7480,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 123 /* GetAccessor */ || member.kind === 124 /* SetAccessor */) { + else if (member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) { var accessors = getAllAccessorDeclarations(node, member); if (member === accessors.firstAccessor) { writeLine(); @@ -7872,11 +7558,11 @@ var ts; write("return "); emitNode(node.name); } - emitToken(10 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); + emitToken(14 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); write(";"); decreaseIndent(); writeLine(); - emitToken(10 /* CloseBraceToken */, node.members.end); + emitToken(14 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -7897,7 +7583,7 @@ var ts; emitTrailingComments(node); function emitConstructorOfClass() { ts.forEach(node.members, function (member) { - if (member.kind === 122 /* Constructor */ && !member.body) { + if (member.kind === 126 /* Constructor */ && !member.body) { emitPinnedOrTripleSlashComments(member); } }); @@ -7948,7 +7634,7 @@ var ts; emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(10 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(14 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -7960,6 +7646,10 @@ var ts; emitPinnedOrTripleSlashComments(node); } function emitEnumDeclaration(node) { + var isConstEnum = ts.isConstEnumDeclaration(node); + if (isConstEnum && !compilerOptions.preserveConstEnums) { + return; + } emitLeadingComments(node); if (!(node.flags & 1 /* Export */)) { emitStart(node); @@ -7977,10 +7667,10 @@ var ts; write(") {"); increaseIndent(); scopeEmitStart(node); - emitEnumMemberDeclarations(); + emitEnumMemberDeclarations(isConstEnum); decreaseIndent(); writeLine(); - emitToken(10 /* CloseBraceToken */, node.members.end); + emitToken(14 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -7999,7 +7689,7 @@ var ts; write(";"); } emitTrailingComments(node); - function emitEnumMemberDeclarations() { + function emitEnumMemberDeclarations(isConstEnum) { ts.forEach(node.members, function (member) { writeLine(); emitLeadingComments(member); @@ -8010,7 +7700,7 @@ var ts; write("["); emitQuotedIdentifier(member.name); write("] = "); - if (member.initializer) { + if (member.initializer && !isConstEnum) { emit(member.initializer); } else { @@ -8025,13 +7715,13 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 181 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 188 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } function emitModuleDeclaration(node) { - if (!ts.isInstantiated(node)) { + if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return emitPinnedOrTripleSlashComments(node); } emitLeadingComments(node); @@ -8047,7 +7737,7 @@ var ts; write(resolver.getLocalNameOfContainer(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 182 /* ModuleBlock */) { + if (node.body.kind === 189 /* ModuleBlock */) { emit(node.body); } else { @@ -8060,7 +7750,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(10 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(14 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -8078,10 +7768,10 @@ var ts; function emitImportDeclaration(node) { var emitImportDeclaration = resolver.isReferencedImportDeclaration(node); if (!emitImportDeclaration) { - emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportedViaEntityName(node); + emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node); } if (emitImportDeclaration) { - if (node.externalModuleName && node.parent.kind === 186 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { + if (node.externalModuleName && node.parent.kind === 193 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { if (node.flags & 1 /* Export */) { writeLine(); emitLeadingComments(node); @@ -8110,7 +7800,7 @@ var ts; emitStart(node.externalModuleName); emitLiteral(node.externalModuleName); emitEnd(node.externalModuleName); - emitToken(12 /* CloseParenToken */, node.externalModuleName.end); + emitToken(16 /* CloseParenToken */, node.externalModuleName.end); } write(";"); emitEnd(node); @@ -8121,7 +7811,7 @@ var ts; function getExternalImportDeclarations(node) { var result = []; ts.forEach(node.statements, function (stat) { - if (stat.kind === 183 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) { + if (stat.kind === 190 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) { result.push(stat); } }); @@ -8129,7 +7819,7 @@ var ts; } function getFirstExportAssignment(sourceFile) { return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 184 /* ExportAssignment */) { + if (node.kind === 191 /* ExportAssignment */) { return node; } }); @@ -8245,117 +7935,127 @@ var ts; return emitPinnedOrTripleSlashComments(node); } switch (node.kind) { - case 59 /* Identifier */: + case 63 /* Identifier */: return emitIdentifier(node); - case 119 /* Parameter */: + case 123 /* Parameter */: return emitParameter(node); - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return emitAccessor(node); - case 87 /* ThisKeyword */: + case 91 /* ThisKeyword */: return emitThis(node); - case 85 /* SuperKeyword */: + case 89 /* SuperKeyword */: return emitSuper(node); - case 83 /* NullKeyword */: + case 87 /* NullKeyword */: return write("null"); - case 89 /* TrueKeyword */: + case 93 /* TrueKeyword */: return write("true"); - case 74 /* FalseKeyword */: + case 78 /* FalseKeyword */: return write("false"); case 6 /* NumericLiteral */: case 7 /* StringLiteral */: case 8 /* RegularExpressionLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: + case 10 /* TemplateHead */: + case 11 /* TemplateMiddle */: + case 12 /* TemplateTail */: return emitLiteral(node); - case 117 /* QualifiedName */: + case 155 /* TemplateExpression */: + return emitTemplateExpression(node); + case 156 /* TemplateSpan */: + return emitTemplateSpan(node); + case 121 /* QualifiedName */: return emitPropertyAccess(node); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return emitArrayLiteral(node); - case 136 /* ObjectLiteral */: + case 140 /* ObjectLiteral */: return emitObjectLiteral(node); - case 137 /* PropertyAssignment */: + case 141 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 138 /* PropertyAccess */: + case 142 /* PropertyAccess */: return emitPropertyAccess(node); - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return emitIndexedAccess(node); - case 140 /* CallExpression */: + case 144 /* CallExpression */: return emitCallExpression(node); - case 141 /* NewExpression */: + case 145 /* NewExpression */: return emitNewExpression(node); - case 142 /* TypeAssertion */: + case 146 /* TaggedTemplateExpression */: + return emitTaggedTemplateExpression(node); + case 147 /* TypeAssertion */: return emit(node.operand); - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return emitParenExpression(node); - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: return emitUnaryExpression(node); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return emitBinaryExpression(node); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return emitConditionalExpression(node); - case 150 /* OmittedExpression */: + case 157 /* OmittedExpression */: return; - case 151 /* Block */: - case 170 /* TryBlock */: - case 172 /* FinallyBlock */: - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: + case 158 /* Block */: + case 177 /* TryBlock */: + case 179 /* FinallyBlock */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: return emitBlock(node); - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return emitVariableStatement(node); - case 153 /* EmptyStatement */: + case 160 /* EmptyStatement */: return write(";"); - case 154 /* ExpressionStatement */: + case 161 /* ExpressionStatement */: return emitExpressionStatement(node); - case 155 /* IfStatement */: + case 162 /* IfStatement */: return emitIfStatement(node); - case 156 /* DoStatement */: + case 163 /* DoStatement */: return emitDoStatement(node); - case 157 /* WhileStatement */: + case 164 /* WhileStatement */: return emitWhileStatement(node); - case 158 /* ForStatement */: + case 165 /* ForStatement */: return emitForStatement(node); - case 159 /* ForInStatement */: + case 166 /* ForInStatement */: return emitForInStatement(node); - case 160 /* ContinueStatement */: - case 161 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 168 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return emitReturnStatement(node); - case 163 /* WithStatement */: + case 170 /* WithStatement */: return emitWithStatement(node); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return emitSwitchStatement(node); - case 165 /* CaseClause */: - case 166 /* DefaultClause */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return emitLabelledStatement(node); - case 168 /* ThrowStatement */: + case 175 /* ThrowStatement */: return emitThrowStatement(node); - case 169 /* TryStatement */: + case 176 /* TryStatement */: return emitTryStatement(node); - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: return emitCatchBlock(node); - case 173 /* DebuggerStatement */: + case 180 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return emitClassDeclaration(node); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return emitImportDeclaration(node); - case 186 /* SourceFile */: + case 193 /* SourceFile */: return emitSourceFile(node); } } @@ -8373,7 +8073,7 @@ var ts; return leadingComments; } function getLeadingCommentsToEmit(node) { - if (node.parent.kind === 186 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 193 /* SourceFile */ || node.pos !== node.parent.pos) { var leadingComments; if (hasDetachedComments(node.pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -8390,7 +8090,7 @@ var ts; emitComments(leadingComments, true, writer, writeComment); } function emitTrailingDeclarationComments(node) { - if (node.parent.kind === 186 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 193 /* SourceFile */ || node.end !== node.parent.end) { var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); emitComments(trailingComments, false, writer, writeComment); } @@ -8582,7 +8282,7 @@ var ts; if (node.flags & 1 /* Export */) { write("export "); } - if (node.kind !== 178 /* InterfaceDeclaration */) { + if (node.kind !== 185 /* InterfaceDeclaration */) { write("declare "); } } @@ -8638,7 +8338,7 @@ var ts; emitDeclarationFlags(node); write("module "); emitSourceTextOfNode(node.name); - while (node.body.kind !== 182 /* ModuleBlock */) { + while (node.body.kind !== 189 /* ModuleBlock */) { node = node.body; write("."); emitSourceTextOfNode(node.name); @@ -8680,6 +8380,9 @@ var ts; if (resolver.isDeclarationVisible(node)) { emitJsDocComments(node); emitDeclarationFlags(node); + if (ts.isConstEnumDeclaration(node)) { + write("const "); + } write("enum "); emitSourceTextOfNode(node.name); write(" {"); @@ -8707,34 +8410,34 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 125 /* CallSignature */: + case 129 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 121 /* Method */: + case 125 /* Method */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 177 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 184 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for type parameter: " + ts.SyntaxKind[node.parent.kind]); + ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -8746,7 +8449,7 @@ var ts; emitJsDocComments(node); decreaseIndent(); emitSourceTextOfNode(node.name); - if (node.constraint && (node.parent.kind !== 121 /* Method */ || !(node.parent.flags & 32 /* Private */))) { + if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) { write(" extends "); getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError; resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); @@ -8768,7 +8471,7 @@ var ts; resolver.writeTypeAtLocation(node, enclosingDeclaration, 1 /* WriteArrayAsGenericType */ | 2 /* UseTypeOfFunction */, writer); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.kind === 177 /* ClassDeclaration */) { + if (node.parent.kind === 184 /* ClassDeclaration */) { if (symbolAccesibilityResult.errorModuleName) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2; } @@ -8796,7 +8499,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & ts.NodeFlags.AccessibilityModifier) { + if (param.flags & 112 /* AccessibilityModifier */) { emitPropertyDeclaration(param); } }); @@ -8853,9 +8556,9 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 174 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 181 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { emitSourceTextOfNode(node.name); - if (node.kind === 120 /* Property */ && (node.flags & 4 /* QuestionMark */)) { + if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) { write("?"); } if (!(node.flags & 32 /* Private */)) { @@ -8866,14 +8569,14 @@ var ts; } function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.kind === 174 /* VariableDeclaration */) { + if (node.kind === 181 /* VariableDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 120 /* Property */) { + else if (node.kind === 124 /* Property */) { if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 177 /* ClassDeclaration */) { + else if (node.parent.kind === 184 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { @@ -8923,7 +8626,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.kind === 124 /* SetAccessor */) { + if (node.kind === 128 /* SetAccessor */) { if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -8952,14 +8655,14 @@ var ts; } } function emitFunctionDeclaration(node) { - if ((node.kind !== 175 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { + if ((node.kind !== 182 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); emitDeclarationFlags(node); - if (node.kind === 175 /* FunctionDeclaration */) { + if (node.kind === 182 /* FunctionDeclaration */) { write("function "); emitSourceTextOfNode(node.name); } - else if (node.kind === 122 /* Constructor */) { + else if (node.kind === 126 /* Constructor */) { write("constructor"); } else { @@ -8977,24 +8680,24 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 125 /* CallSignature */ || node.kind === 127 /* IndexSignature */) { + if (node.kind === 129 /* CallSignature */ || node.kind === 131 /* IndexSignature */) { emitJsDocComments(node); } emitTypeParameters(node.typeParameters); - if (node.kind === 127 /* IndexSignature */) { + if (node.kind === 131 /* IndexSignature */) { write("["); } else { write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 127 /* IndexSignature */) { + if (node.kind === 131 /* IndexSignature */) { write("]"); } else { write(")"); } - if (node.kind !== 122 /* Constructor */ && !(node.flags & 32 /* Private */)) { + if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) { write(": "); getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError; resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); @@ -9004,31 +8707,31 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 125 /* CallSignature */: + case 129 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 127 /* IndexSignature */: + case 131 /* IndexSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 121 /* Method */: + case 125 /* Method */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 177 /* ClassDeclaration */) { + else if (node.parent.kind === 184 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: - ts.Debug.fail("This is unknown kind for signature: " + ts.SyntaxKind[node.kind]); + ts.Debug.fail("This is unknown kind for signature: " + node.kind); } return { diagnosticMessage: diagnosticMessage, @@ -9055,31 +8758,31 @@ var ts; function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 122 /* Constructor */: + case 126 /* Constructor */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 125 /* CallSignature */: + case 129 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 121 /* Method */: + case 125 /* Method */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 177 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 184 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -9090,39 +8793,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 122 /* Constructor */: - case 175 /* FunctionDeclaration */: - case 121 /* Method */: + case 126 /* Constructor */: + case 182 /* FunctionDeclaration */: + case 125 /* Method */: return emitFunctionDeclaration(node); - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: return emitConstructSignatureDeclaration(node); - case 125 /* CallSignature */: - case 127 /* IndexSignature */: + case 129 /* CallSignature */: + case 131 /* IndexSignature */: return emitSignatureDeclaration(node); - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return emitAccessorDeclaration(node); - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return emitVariableStatement(node); - case 120 /* Property */: + case 124 /* Property */: return emitPropertyDeclaration(node); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return emitClassDeclaration(node); - case 179 /* TypeAliasDeclaration */: + case 186 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 185 /* EnumMember */: + case 192 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return emitImportDeclaration(node); - case 184 /* ExportAssignment */: + case 191 /* ExportAssignment */: return emitExportAssignment(node); - case 186 /* SourceFile */: + case 193 /* SourceFile */: return emitSourceFile(node); } } @@ -9329,10 +9032,10 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, hasEarlyErrors: hasEarlyErrors }; - var undefinedSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, "undefined"); - var argumentsSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, "arguments"); - var unknownSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(134217728 /* Transient */, "__resolving__"); + var undefinedSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "undefined"); + var argumentsSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "arguments"); + var unknownSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "unknown"); + var resolvingSymbol = createSymbol(268435456 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); @@ -9381,35 +9084,37 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= ts.SymbolFlags.BlockScopedVariableExcludes; + result |= 107455 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= ts.SymbolFlags.FunctionScopedVariableExcludes; + result |= 107454 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) - result |= ts.SymbolFlags.PropertyExcludes; + result |= 107455 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= ts.SymbolFlags.EnumMemberExcludes; + result |= 107455 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= ts.SymbolFlags.FunctionExcludes; + result |= 106927 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= ts.SymbolFlags.ClassExcludes; + result |= 3258879 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= ts.SymbolFlags.InterfaceExcludes; - if (flags & 128 /* Enum */) - result |= ts.SymbolFlags.EnumExcludes; - if (flags & 256 /* ValueModule */) - result |= ts.SymbolFlags.ValueModuleExcludes; - if (flags & 4096 /* Method */) - result |= ts.SymbolFlags.MethodExcludes; - if (flags & 16384 /* GetAccessor */) - result |= ts.SymbolFlags.GetAccessorExcludes; - if (flags & 32768 /* SetAccessor */) - result |= ts.SymbolFlags.SetAccessorExcludes; - if (flags & 524288 /* TypeParameter */) - result |= ts.SymbolFlags.TypeParameterExcludes; - if (flags & 1048576 /* TypeAlias */) - result |= ts.SymbolFlags.TypeAliasExcludes; - if (flags & 16777216 /* Import */) - result |= ts.SymbolFlags.ImportExcludes; + result |= 3152288 /* InterfaceExcludes */; + if (flags & 256 /* RegularEnum */) + result |= 3258623 /* RegularEnumExcludes */; + if (flags & 128 /* ConstEnum */) + result |= 3259263 /* ConstEnumExcludes */; + if (flags & 512 /* ValueModule */) + result |= 106639 /* ValueModuleExcludes */; + if (flags & 8192 /* Method */) + result |= 99263 /* MethodExcludes */; + if (flags & 32768 /* GetAccessor */) + result |= 41919 /* GetAccessorExcludes */; + if (flags & 65536 /* SetAccessor */) + result |= 74687 /* SetAccessorExcludes */; + if (flags & 1048576 /* TypeParameter */) + result |= 2103776 /* TypeParameterExcludes */; + if (flags & 2097152 /* TypeAlias */) + result |= 3152352 /* TypeAliasExcludes */; + if (flags & 33554432 /* Import */) + result |= 33554432 /* ImportExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -9418,11 +9123,13 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 67108864 /* Merged */, symbol.name); + var result = createSymbol(symbol.flags | 134217728 /* Merged */, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) + result.constEnumOnlyModule = true; if (symbol.members) result.members = cloneSymbolTable(symbol.members); if (symbol.exports) @@ -9432,6 +9139,9 @@ var ts; } function extendSymbol(target, source) { if (!(target.flags & getExcludedSymbolFlags(source.flags))) { + if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + target.constEnumOnlyModule = false; + } target.flags |= source.flags; if (!target.valueDeclaration && source.valueDeclaration) target.valueDeclaration = source.valueDeclaration; @@ -9477,7 +9187,7 @@ var ts; } else { var symbol = target[id]; - if (!(symbol.flags & 67108864 /* Merged */)) { + if (!(symbol.flags & 134217728 /* Merged */)) { target[id] = symbol = cloneSymbol(symbol); } extendSymbol(symbol, source[id]); @@ -9486,7 +9196,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 134217728 /* Transient */) + if (symbol.flags & 268435456 /* Transient */) return symbol; if (!symbol.id) symbol.id = nextSymbolId++; @@ -9498,19 +9208,19 @@ var ts; return nodeLinks[node.id] || (nodeLinks[node.id] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 186 /* SourceFile */); + return ts.getAncestor(node, 193 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 186 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 193 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 33554432 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 16777216 /* Import */) { + if (symbol.flags & 33554432 /* Import */) { var target = resolveImport(symbol); if (target === unknownSymbol || target.flags & meaning) { return symbol; @@ -9518,6 +9228,18 @@ var ts; } } } + function isDefinedBefore(node1, node2) { + var file1 = ts.getSourceFileOfNode(node1); + var file2 = ts.getSourceFileOfNode(node2); + if (file1 === file2) { + return node1.pos <= node2.pos; + } + if (!compilerOptions.out) { + return true; + } + var sourceFiles = program.getSourceFiles(); + return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); + } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; var lastLocation; @@ -9530,32 +9252,32 @@ var ts; } } switch (location.kind) { - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 181 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & ts.SymbolFlags.ModuleMember)) { + case 188 /* ModuleDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) { break loop; } break; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 120 /* Property */: - if (location.parent.kind === 177 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + case 124 /* Property */: + if (location.parent.kind === 184 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (getSymbol(ctor.locals, name, meaning & ts.SymbolFlags.Value)) { + if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { propertyWithInvalidInitializer = location; } } } break; - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & ts.SymbolFlags.Type)) { + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; @@ -9563,18 +9285,18 @@ var ts; break loop; } break; - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 144 /* FunctionExpression */: + case 149 /* FunctionExpression */: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -9585,7 +9307,7 @@ var ts; break loop; } break; - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: var id = location.variable; if (name === id.text) { result = location.symbol; @@ -9612,31 +9334,21 @@ var ts; return undefined; } if (result.flags & 2 /* BlockScopedVariable */) { - var declaration = ts.forEach(result.declarations, function (d) { return d.flags & ts.NodeFlags.BlockScoped ? d : undefined; }); - ts.Debug.assert(declaration, "Block-scoped variable declaration is undefined"); - var declarationSourceFile = ts.getSourceFileOfNode(declaration); - var referenceSourceFile = ts.getSourceFileOfNode(errorLocation); - if (declarationSourceFile === referenceSourceFile) { - if (declaration.pos > errorLocation.pos) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.identifierToString(declaration.name)); - } - } - else if (compilerOptions.out) { - var sourceFiles = program.getSourceFiles(); - if (sourceFiles.indexOf(referenceSourceFile) < sourceFiles.indexOf(declarationSourceFile)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.identifierToString(declaration.name)); - } + var declaration = ts.forEach(result.declarations, function (d) { return d.flags & 6144 /* BlockScoped */ ? d : undefined; }); + ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); + if (!isDefinedBefore(declaration, errorLocation)) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.identifierToString(declaration.name)); } } } return result; } function resolveImport(symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Import */) !== 0, "Should only get Imports here."); + ts.Debug.assert((symbol.flags & 33554432 /* Import */) !== 0, "Should only get Imports here."); var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; - var node = getDeclarationOfKind(symbol, 183 /* ImportDeclaration */); + var node = getDeclarationOfKind(symbol, 190 /* ImportDeclaration */); var target = node.externalModuleName ? resolveExternalModuleName(node, node.externalModuleName) : getSymbolOfPartOfRightHandSideOfImport(node.entityName, node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; @@ -9652,33 +9364,33 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 183 /* ImportDeclaration */); - ts.Debug.assert(importDeclaration); + importDeclaration = ts.getAncestor(entityName, 190 /* ImportDeclaration */); + ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 59 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 59 /* Identifier */ || entityName.parent.kind === 117 /* QualifiedName */) { - return resolveEntityName(importDeclaration, entityName, ts.SymbolFlags.Namespace); + if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 121 /* QualifiedName */) { + return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */); } else { - ts.Debug.assert(entityName.parent.kind === 183 /* ImportDeclaration */); - return resolveEntityName(importDeclaration, entityName, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace); + ts.Debug.assert(entityName.parent.kind === 190 /* ImportDeclaration */); + return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } function resolveEntityName(location, name, meaning) { - if (name.kind === 59 /* Identifier */) { + if (name.kind === 63 /* Identifier */) { var symbol = resolveName(location, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return; } } - else if (name.kind === 117 /* QualifiedName */) { - var namespace = resolveEntityName(location, name.left, ts.SymbolFlags.Namespace); - if (!namespace || namespace === unknownSymbol || name.right.kind === 116 /* Missing */) + else if (name.kind === 121 /* QualifiedName */) { + var namespace = resolveEntityName(location, name.left, 1536 /* Namespace */); + if (!namespace || namespace === unknownSymbol || name.right.kind === 120 /* Missing */) return; var symbol = getSymbol(namespace.exports, name.right.text, meaning); if (!symbol) { @@ -9689,7 +9401,7 @@ var ts; else { return; } - ts.Debug.assert((symbol.flags & 33554432 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveImport(symbol); } function isExternalModuleNameRelative(moduleName) { @@ -9702,7 +9414,7 @@ var ts; return; var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 256 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); if (symbol) { return getResolvedExportSymbol(symbol); } @@ -9729,10 +9441,10 @@ var ts; function getResolvedExportSymbol(moduleSymbol) { var symbol = getExportAssignmentSymbol(moduleSymbol); if (symbol) { - if (symbol.flags & (ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace)) { + if (symbol.flags & (107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */)) { return symbol; } - if (symbol.flags & 16777216 /* Import */) { + if (symbol.flags & 33554432 /* Import */) { return resolveImport(symbol); } } @@ -9756,7 +9468,7 @@ var ts; error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } if (node.exportName.text) { - var meaning = ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace; + var meaning = 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */; var exportSymbol = resolveName(node, node.exportName.text, meaning, ts.Diagnostics.Cannot_find_name_0, node.exportName); } } @@ -9767,9 +9479,9 @@ var ts; var seenExportedMember = false; var result = []; ts.forEach(symbol.declarations, function (declaration) { - var block = (declaration.kind === 186 /* SourceFile */ ? declaration : declaration.body); + var block = (declaration.kind === 193 /* SourceFile */ ? declaration : declaration.body); ts.forEach(block.statements, function (node) { - if (node.kind === 184 /* ExportAssignment */) { + if (node.kind === 191 /* ExportAssignment */) { result.push(node); } else { @@ -9793,17 +9505,17 @@ var ts; return getMergedSymbol(symbol.parent); } function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 2097152 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; + return symbol && (symbol.flags & 4194304 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; } function symbolIsValue(symbol) { - if (symbol.flags & 33554432 /* Instantiated */) { + if (symbol.flags & 67108864 /* Instantiated */) { return symbolIsValue(getSymbolLinks(symbol).target); } - if (symbol.flags & ts.SymbolFlags.Value) { + if (symbol.flags & 107455 /* Value */) { return true; } - if (symbol.flags & 16777216 /* Import */) { - return (resolveImport(symbol).flags & ts.SymbolFlags.Value) !== 0; + if (symbol.flags & 33554432 /* Import */) { + return (resolveImport(symbol).flags & 107455 /* Value */) !== 0; } return false; } @@ -9811,7 +9523,7 @@ var ts; var members = node.members; for (var i = 0; i < members.length; i++) { var member = members[i]; - if (member.kind === 122 /* Constructor */ && member.body) { + if (member.kind === 126 /* Constructor */ && member.body) { return member; } } @@ -9865,7 +9577,7 @@ var ts; return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function isOptionalProperty(propertySymbol) { - return propertySymbol.valueDeclaration && propertySymbol.valueDeclaration.flags & 4 /* QuestionMark */ && propertySymbol.valueDeclaration.kind !== 119 /* Parameter */; + return propertySymbol.valueDeclaration && propertySymbol.valueDeclaration.flags & 4 /* QuestionMark */ && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -9876,17 +9588,17 @@ var ts; } } switch (location.kind) { - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location).members)) { return result; } @@ -9896,7 +9608,7 @@ var ts; return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { - return rightMeaning === ts.SymbolFlags.Value ? ts.SymbolFlags.Value : ts.SymbolFlags.Namespace; + return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1536 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { function getAccessibleSymbolChainFromSymbolTable(symbols) { @@ -9916,8 +9628,8 @@ var ts; return [symbol]; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 16777216 /* Import */) { - if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 183 /* ImportDeclaration */ && declaration.externalModuleName; })) { + if (symbolFromSymbolTable.flags & 33554432 /* Import */) { + if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 190 /* ImportDeclaration */ && declaration.externalModuleName; })) { var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { return [symbolFromSymbolTable]; @@ -9944,7 +9656,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 16777216 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 33554432 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -9954,7 +9666,7 @@ var ts; return qualify; } function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 524288 /* TypeParameter */)) { + if (symbol && enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { var initialSymbol = symbol; var meaningToLook = meaning; while (symbol) { @@ -9965,7 +9677,7 @@ var ts; return { accessibility: 1 /* NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, ts.SymbolFlags.Namespace) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined }; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasAccessibleDeclarations.aliasesToMakeVisible }; @@ -9999,7 +9711,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 181 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 186 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 188 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 193 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -10009,7 +9721,7 @@ var ts; return { aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 183 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + if (declaration.kind === 190 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { if (!ts.contains(aliasesToMakeVisible, declaration)) { @@ -10028,7 +9740,7 @@ var ts; } function isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName) { var firstIdentifier = getFirstIdentifier(entityName); - var symbolOfNameSpace = resolveName(entityName.parent, firstIdentifier.text, ts.SymbolFlags.Namespace, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + var symbolOfNameSpace = resolveName(entityName.parent, firstIdentifier.text, 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); var hasNamespaceDeclarationsVisibile = hasVisibleDeclarations(symbolOfNameSpace); return hasNamespaceDeclarationsVisibile ? { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasNamespaceDeclarationsVisibile.aliasesToMakeVisible } : { accessibility: 1 /* NotAccessible */, errorSymbolName: ts.identifierToString(firstIdentifier) }; } @@ -10067,12 +9779,12 @@ var ts; return result; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 1024 /* TypeLiteral */) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 134 /* ParenType */) { + while (node.kind === 138 /* ParenType */) { node = node.parent; } - if (node.kind === 179 /* TypeAliasDeclaration */) { + if (node.kind === 186 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -10095,14 +9807,14 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 33554432 /* Instantiated */) { + if (symbol.flags & 67108864 /* Instantiated */) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 15 /* DotToken */); + writePunctuation(writer, 19 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -10123,14 +9835,14 @@ var ts; if (!parentSymbol && ts.forEach(symbol.declarations, function (declaration) { return hasExternalModuleSymbol(declaration); })) { return; } - if (symbol.flags & 1024 /* TypeLiteral */ || symbol.flags & 2048 /* ObjectLiteral */) { + if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) { return; } appendParentTypeArgumentsAndSymbolName(symbol); } } } - if (enclosingDeclaration && !(symbol.flags & 524288 /* TypeParameter */)) { + if (enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { walkSymbol(symbol, meaning); return; } @@ -10140,14 +9852,14 @@ var ts; var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & ts.TypeFlags.Intrinsic) { + if (type.flags & 127 /* Intrinsic */) { writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && (type.flags & 1 /* Any */) ? "any" : type.intrinsicName); } else if (type.flags & 4096 /* Reference */) { writeTypeReference(type, flags); } else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Type); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 3152352 /* Type */); } else if (type.flags & 8192 /* Tuple */) { writeTupleType(type); @@ -10162,11 +9874,11 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 9 /* OpenBraceToken */); + writePunctuation(writer, 13 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 16 /* DotDotDotToken */); + writePunctuation(writer, 20 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 10 /* CloseBraceToken */); + writePunctuation(writer, 14 /* CloseBraceToken */); } } function writeTypeList(types, union) { @@ -10175,7 +9887,7 @@ var ts; if (union) { writeSpace(writer); } - writePunctuation(writer, union ? 39 /* BarToken */ : 18 /* CommaToken */); + writePunctuation(writer, union ? 43 /* BarToken */ : 22 /* CommaToken */); writeSpace(writer); } writeType(types[i], union ? 64 /* InElementType */ : 0 /* None */); @@ -10184,32 +9896,32 @@ var ts; function writeTypeReference(type, flags) { if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(type.typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 13 /* OpenBracketToken */); - writePunctuation(writer, 14 /* CloseBracketToken */); + writePunctuation(writer, 17 /* OpenBracketToken */); + writePunctuation(writer, 18 /* CloseBracketToken */); } else { - buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Type); - writePunctuation(writer, 19 /* LessThanToken */); + buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, 3152352 /* Type */); + writePunctuation(writer, 23 /* LessThanToken */); writeTypeList(type.typeArguments, false); - writePunctuation(writer, 20 /* GreaterThanToken */); + writePunctuation(writer, 24 /* GreaterThanToken */); } } function writeTupleType(type) { - writePunctuation(writer, 13 /* OpenBracketToken */); + writePunctuation(writer, 17 /* OpenBracketToken */); writeTypeList(type.elementTypes, false); - writePunctuation(writer, 14 /* CloseBracketToken */); + writePunctuation(writer, 18 /* CloseBracketToken */); } function writeUnionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 11 /* OpenParenToken */); + writePunctuation(writer, 15 /* OpenParenToken */); } writeTypeList(type.types, true); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 12 /* CloseParenToken */); + writePunctuation(writer, 16 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { - if (type.symbol && type.symbol.flags & (32 /* Class */ | 128 /* Enum */ | 256 /* ValueModule */)) { + if (type.symbol && type.symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { writeTypeofSymbol(type); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -10218,10 +9930,10 @@ var ts; else if (typeStack && ts.contains(typeStack, type)) { var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, ts.SymbolFlags.Type); + buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 3152352 /* Type */); } else { - writeKeyword(writer, 105 /* AnyKeyword */); + writeKeyword(writer, 109 /* AnyKeyword */); } } else { @@ -10234,8 +9946,8 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { if (type.symbol) { - var isStaticMethodSymbol = !!(type.symbol.flags & 4096 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 186 /* SourceFile */ || declaration.parent.kind === 182 /* ModuleBlock */; })); + var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); + var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 193 /* SourceFile */ || declaration.parent.kind === 189 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type)); } @@ -10243,111 +9955,111 @@ var ts; } } function writeTypeofSymbol(type) { - writeKeyword(writer, 91 /* TypeOfKeyword */); + writeKeyword(writer, 95 /* TypeOfKeyword */); writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Value); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */); } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 9 /* OpenBraceToken */); - writePunctuation(writer, 10 /* CloseBraceToken */); + writePunctuation(writer, 13 /* OpenBraceToken */); + writePunctuation(writer, 14 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 11 /* OpenParenToken */); + writePunctuation(writer, 15 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 12 /* CloseParenToken */); + writePunctuation(writer, 16 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 11 /* OpenParenToken */); + writePunctuation(writer, 15 /* OpenParenToken */); } - writeKeyword(writer, 82 /* NewKeyword */); + writeKeyword(writer, 86 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 12 /* CloseParenToken */); + writePunctuation(writer, 16 /* CloseParenToken */); } return; } } - writePunctuation(writer, 9 /* OpenBraceToken */); + writePunctuation(writer, 13 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var i = 0; i < resolved.callSignatures.length; i++) { buildSignatureDisplay(resolved.callSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.constructSignatures.length; i++) { - writeKeyword(writer, 82 /* NewKeyword */); + writeKeyword(writer, 86 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 13 /* OpenBracketToken */); + writePunctuation(writer, 17 /* OpenBracketToken */); writer.writeParameter("x"); - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 114 /* StringKeyword */); - writePunctuation(writer, 14 /* CloseBracketToken */); - writePunctuation(writer, 46 /* ColonToken */); + writeKeyword(writer, 118 /* StringKeyword */); + writePunctuation(writer, 18 /* CloseBracketToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 13 /* OpenBracketToken */); + writePunctuation(writer, 17 /* OpenBracketToken */); writer.writeParameter("x"); - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 112 /* NumberKeyword */); - writePunctuation(writer, 14 /* CloseBracketToken */); - writePunctuation(writer, 46 /* ColonToken */); + writeKeyword(writer, 116 /* NumberKeyword */); + writePunctuation(writer, 18 /* CloseBracketToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.properties.length; i++) { var p = resolved.properties[i]; var t = getTypeOfSymbol(p); - if (p.flags & (16 /* Function */ | 4096 /* Method */) && !getPropertiesOfObjectType(t).length) { + if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); for (var j = 0; j < signatures.length; j++) { buildSymbolDisplay(p, writer); if (isOptionalProperty(p)) { - writePunctuation(writer, 45 /* QuestionToken */); + writePunctuation(writer, 49 /* QuestionToken */); } buildSignatureDisplay(signatures[j], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (isOptionalProperty(p)) { - writePunctuation(writer, 45 /* QuestionToken */); + writePunctuation(writer, 49 /* QuestionToken */); } - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 10 /* CloseBraceToken */); + writePunctuation(writer, 14 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -10361,67 +10073,67 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 73 /* ExtendsKeyword */); + writeKeyword(writer, 77 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, typeStack) { if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { - writePunctuation(writer, 16 /* DotDotDotToken */); + writePunctuation(writer, 20 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { - writePunctuation(writer, 45 /* QuestionToken */); + writePunctuation(writer, 49 /* QuestionToken */); } - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, typeStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 19 /* LessThanToken */); + writePunctuation(writer, 23 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 18 /* CommaToken */); + writePunctuation(writer, 22 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, 20 /* GreaterThanToken */); + writePunctuation(writer, 24 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, typeStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 19 /* LessThanToken */); + writePunctuation(writer, 23 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 18 /* CommaToken */); + writePunctuation(writer, 22 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 20 /* GreaterThanToken */); + writePunctuation(writer, 24 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, typeStack) { - writePunctuation(writer, 11 /* OpenParenToken */); + writePunctuation(writer, 15 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 18 /* CommaToken */); + writePunctuation(writer, 22 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, 12 /* CloseParenToken */); + writePunctuation(writer, 16 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, typeStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 27 /* EqualsGreaterThanToken */); + writePunctuation(writer, 31 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); } writeSpace(writer); buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); @@ -10454,12 +10166,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 181 /* ModuleDeclaration */) { + if (node.kind === 188 /* ModuleDeclaration */) { if (node.name.kind === 7 /* StringLiteral */) { return node; } } - else if (node.kind === 186 /* SourceFile */) { + else if (node.kind === 193 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10475,7 +10187,7 @@ var ts; if (isSymbolUsedInExportAssignment(symbolOfNode)) { return true; } - if (symbolOfNode.flags & 16777216 /* Import */) { + if (symbolOfNode.flags & 33554432 /* Import */) { return isSymbolUsedInExportAssignment(resolveImport(symbolOfNode)); } } @@ -10483,7 +10195,7 @@ var ts; if (exportAssignmentSymbol === symbol) { return true; } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 16777216 /* Import */)) { + if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 33554432 /* Import */)) { resolvedExportSymbol = resolvedExportSymbol || resolveImport(exportAssignmentSymbol); if (resolvedExportSymbol === symbol) { return true; @@ -10501,35 +10213,35 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174 /* VariableDeclaration */: - case 181 /* ModuleDeclaration */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 175 /* FunctionDeclaration */: - case 180 /* EnumDeclaration */: - case 183 /* ImportDeclaration */: - var parent = node.kind === 174 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (!(node.flags & 1 /* Export */) && !(node.kind !== 183 /* ImportDeclaration */ && parent.kind !== 186 /* SourceFile */ && ts.isInAmbientContext(parent))) { + case 181 /* VariableDeclaration */: + case 188 /* ModuleDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 182 /* FunctionDeclaration */: + case 187 /* EnumDeclaration */: + case 190 /* ImportDeclaration */: + var parent = node.kind === 181 /* VariableDeclaration */ ? node.parent.parent : node.parent; + if (!(node.flags & 1 /* Export */) && !(node.kind !== 190 /* ImportDeclaration */ && parent.kind !== 193 /* SourceFile */ && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); } return isDeclarationVisible(parent); - case 120 /* Property */: - case 121 /* Method */: + case 124 /* Property */: + case 125 /* Method */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { return false; } - case 122 /* Constructor */: - case 126 /* ConstructSignature */: - case 125 /* CallSignature */: - case 127 /* IndexSignature */: - case 119 /* Parameter */: - case 182 /* ModuleBlock */: + case 126 /* Constructor */: + case 130 /* ConstructSignature */: + case 129 /* CallSignature */: + case 131 /* IndexSignature */: + case 123 /* Parameter */: + case 189 /* ModuleBlock */: return isDeclarationVisible(node.parent); - case 186 /* SourceFile */: + case 193 /* SourceFile */: return true; default: - ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + ts.SyntaxKind[node.kind]); + ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } } if (node) { @@ -10545,16 +10257,16 @@ var ts; return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } function getTypeOfVariableDeclaration(declaration) { - if (declaration.parent.kind === 159 /* ForInStatement */) { + if (declaration.parent.kind === 166 /* ForInStatement */) { return anyType; } if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 119 /* Parameter */) { + if (declaration.kind === 123 /* Parameter */) { var func = declaration.parent; - if (func.kind === 124 /* SetAccessor */) { - var getter = getDeclarationOfKind(declaration.parent.symbol, 123 /* GetAccessor */); + if (func.kind === 128 /* SetAccessor */) { + var getter = getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -10566,7 +10278,7 @@ var ts; } if (declaration.initializer) { var type = checkAndMarkExpression(declaration.initializer); - if (declaration.kind !== 137 /* PropertyAssignment */) { + if (declaration.kind !== 141 /* PropertyAssignment */) { var unwidenedType = type; type = getWidenedType(type); if (type !== unwidenedType) { @@ -10585,14 +10297,14 @@ var ts; if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) { return; } - if (isPrivateWithinAmbient(declaration) || (declaration.kind === 119 /* Parameter */ && isPrivateWithinAmbient(declaration.parent))) { + if (isPrivateWithinAmbient(declaration) || (declaration.kind === 123 /* Parameter */ && isPrivateWithinAmbient(declaration.parent))) { return; } switch (declaration.kind) { - case 120 /* Property */: + case 124 /* Property */: var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 119 /* Parameter */: + case 123 /* Parameter */: var diagnostic = declaration.flags & 8 /* Rest */ ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; default: @@ -10604,11 +10316,11 @@ var ts; function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 268435456 /* Prototype */) { + if (symbol.flags & 536870912 /* Prototype */) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.kind === 171 /* CatchBlock */) { + if (declaration.kind === 178 /* CatchBlock */) { return links.type = anyType; } links.type = resolvingType; @@ -10631,7 +10343,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 123 /* GetAccessor */) { + if (accessor.kind === 127 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -10650,8 +10362,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = getDeclarationOfKind(symbol, 123 /* GetAccessor */); - var setter = getDeclarationOfKind(symbol, 124 /* SetAccessor */); + var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); + var setter = getDeclarationOfKind(symbol, 128 /* SetAccessor */); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -10681,7 +10393,7 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var getter = getDeclarationOfKind(symbol, 123 /* GetAccessor */); + var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -10715,22 +10427,22 @@ var ts; return links.type; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 33554432 /* Instantiated */) { + if (symbol.flags & 67108864 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (symbol.flags & (ts.SymbolFlags.Variable | 4 /* Property */)) { + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 4096 /* Method */ | 32 /* Class */ | 128 /* Enum */ | 256 /* ValueModule */)) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } if (symbol.flags & 8 /* EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & ts.SymbolFlags.Accessor) { + if (symbol.flags & 98304 /* Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 16777216 /* Import */) { + if (symbol.flags & 33554432 /* Import */) { return getTypeOfImport(symbol); } return unknownType; @@ -10748,7 +10460,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 178 /* InterfaceDeclaration */ || node.kind === 177 /* ClassDeclaration */) { + if (node.kind === 185 /* InterfaceDeclaration */ || node.kind === 184 /* ClassDeclaration */) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -10779,7 +10491,7 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = getDeclarationOfKind(symbol, 177 /* ClassDeclaration */); + var declaration = getDeclarationOfKind(symbol, 184 /* ClassDeclaration */); if (declaration.baseType) { var baseType = getTypeFromTypeReferenceNode(declaration.baseType); if (baseType !== unknownType) { @@ -10819,7 +10531,7 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 178 /* InterfaceDeclaration */ && declaration.baseTypes) { + if (declaration.kind === 185 /* InterfaceDeclaration */ && declaration.baseTypes) { ts.forEach(declaration.baseTypes, function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { @@ -10850,7 +10562,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = getDeclarationOfKind(symbol, 179 /* TypeAliasDeclaration */); + var declaration = getDeclarationOfKind(symbol, 186 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -10858,7 +10570,7 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var declaration = getDeclarationOfKind(symbol, 179 /* TypeAliasDeclaration */); + var declaration = getDeclarationOfKind(symbol, 186 /* TypeAliasDeclaration */); error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; @@ -10877,7 +10589,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!getDeclarationOfKind(symbol, 118 /* TypeParameter */).constraint) { + if (!getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -10892,23 +10604,23 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 33554432 /* Instantiated */) === 0); + ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0); if (symbol.flags & 32 /* Class */) { return getDeclaredTypeOfClass(symbol); } if (symbol.flags & 64 /* Interface */) { return getDeclaredTypeOfInterface(symbol); } - if (symbol.flags & 1048576 /* TypeAlias */) { + if (symbol.flags & 2097152 /* TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 128 /* Enum */) { + if (symbol.flags & 384 /* Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 524288 /* TypeParameter */) { + if (symbol.flags & 1048576 /* TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 16777216 /* Import */) { + if (symbol.flags & 33554432 /* Import */) { return getDeclaredTypeOfImport(symbol); } return unknownType; @@ -11010,7 +10722,7 @@ var ts; function createTupleTypeMemberSymbols(memberTypes) { var members = {}; for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, "" + i); + var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "" + i); symbol.type = memberTypes[i]; members[i] = symbol; } @@ -11027,7 +10739,7 @@ var ts; return false; } for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, isTypeIdenticalTo)) { + if (!compareSignatures(s[i], t[i], false, compareTypes)) { return false; } } @@ -11074,7 +10786,7 @@ var ts; } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; - if (symbol.flags & 1024 /* TypeLiteral */) { + if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; var callSignatures = getSignaturesOfSymbol(members["__call"]); var constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -11085,10 +10797,10 @@ var ts; var members = emptySymbols; var callSignatures = emptyArray; var constructSignatures = emptyArray; - if (symbol.flags & ts.SymbolFlags.HasExports) { + if (symbol.flags & 1952 /* HasExports */) { members = symbol.exports; } - if (symbol.flags & (16 /* Function */ | 4096 /* Method */)) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { callSignatures = getSignaturesOfSymbol(symbol); } if (symbol.flags & 32 /* Class */) { @@ -11103,7 +10815,7 @@ var ts; } } var stringIndexType = undefined; - var numberIndexType = (symbol.flags & 128 /* Enum */) ? stringType : undefined; + var numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } @@ -11128,13 +10840,13 @@ var ts; return type; } function getPropertiesOfObjectType(type) { - if (type.flags & ts.TypeFlags.ObjectType) { + if (type.flags & 48128 /* ObjectType */) { return resolveObjectOrUnionTypeMembers(type).properties; } return emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & ts.TypeFlags.ObjectType) { + if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; @@ -11169,10 +10881,10 @@ var ts; type = emptyObjectType; } } - if (type.flags & ts.TypeFlags.StringLike) { + if (type.flags & 258 /* StringLike */) { type = globalStringType; } - else if (type.flags & ts.TypeFlags.NumberLike) { + else if (type.flags & 132 /* NumberLike */) { type = globalNumberType; } else if (type.flags & 8 /* Boolean */) { @@ -11207,7 +10919,7 @@ var ts; } propTypes.push(getTypeOfSymbol(prop)); } - var result = createSymbol(4 /* Property */ | 134217728 /* Transient */ | 536870912 /* UnionProperty */, name); + var result = createSymbol(4 /* Property */ | 268435456 /* Transient */ | 1073741824 /* UnionProperty */, name); result.unionType = unionType; result.declarations = declarations; result.type = getUnionType(propTypes); @@ -11228,9 +10940,9 @@ var ts; if (type.flags & 16384 /* Union */) { return getPropertyOfUnionType(type, name); } - if (!(type.flags & ts.TypeFlags.ObjectType)) { + if (!(type.flags & 48128 /* ObjectType */)) { type = getApparentType(type); - if (!(type.flags & ts.TypeFlags.ObjectType)) { + if (!(type.flags & 48128 /* ObjectType */)) { return undefined; } } @@ -11249,7 +10961,7 @@ var ts; return getPropertyOfObjectType(globalObjectType, name); } function getSignaturesOfObjectOrUnionType(type, kind) { - if (type.flags & (ts.TypeFlags.ObjectType | 16384 /* Union */)) { + if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { var resolved = resolveObjectOrUnionTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -11259,7 +10971,7 @@ var ts; return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); } function getIndexTypeOfObjectOrUnionType(type, kind) { - if (type.flags & (ts.TypeFlags.ObjectType | 16384 /* Union */)) { + if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { var resolved = resolveObjectOrUnionTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; } @@ -11280,7 +10992,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 122 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 126 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; var hasStringLiterals = false; @@ -11308,8 +11020,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 123 /* GetAccessor */) { - var setter = getDeclarationOfKind(declaration.symbol, 124 /* SetAccessor */); + if (declaration.kind === 127 /* GetAccessor */) { + var setter = getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && !declaration.body) { @@ -11327,16 +11039,16 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 175 /* FunctionDeclaration */: - case 121 /* Method */: - case 122 /* Constructor */: - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 182 /* FunctionDeclaration */: + case 125 /* Method */: + case 126 /* Constructor */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -11405,7 +11117,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 122 /* Constructor */ || signature.declaration.kind === 126 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 126 /* Constructor */ || signature.declaration.kind === 130 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 65536 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -11419,7 +11131,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 112 /* NumberKeyword */ : 114 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 116 /* NumberKeyword */ : 118 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -11446,7 +11158,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(getDeclarationOfKind(type.symbol, 118 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -11486,17 +11198,17 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 118 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 122 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 128 /* TypeReference */ && n.typeName.kind === 59 /* Identifier */) { + if (n.kind === 132 /* TypeReference */ && n.typeName.kind === 63 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, ts.SymbolFlags.Type, undefined, undefined); - if (symbol && (symbol.flags & 524288 /* TypeParameter */)) { + var symbol = resolveName(typeParameter, n.typeName.text, 3152352 /* Type */, undefined, undefined); + if (symbol && (symbol.flags & 1048576 /* TypeParameter */)) { links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); } } @@ -11514,10 +11226,10 @@ var ts; function getTypeFromTypeReferenceNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var symbol = resolveEntityName(node, node.typeName, ts.SymbolFlags.Type); + var symbol = resolveEntityName(node, node.typeName, 3152352 /* Type */); if (symbol) { var type; - if ((symbol.flags & 524288 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + if ((symbol.flags & 1048576 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { type = unknownType; } else { @@ -11557,9 +11269,9 @@ var ts; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; switch (declaration.kind) { - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: return declaration; } } @@ -11568,7 +11280,7 @@ var ts; return emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & ts.TypeFlags.ObjectType)) { + if (!(type.flags & 48128 /* ObjectType */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return emptyObjectType; } @@ -11579,7 +11291,7 @@ var ts; return type; } function getGlobalSymbol(name) { - return resolveName(undefined, name, ts.SymbolFlags.Type, ts.Diagnostics.Cannot_find_global_type_0, name); + return resolveName(undefined, name, 3152352 /* Type */, ts.Diagnostics.Cannot_find_global_type_0, name); } function getGlobalType(name) { return getTypeOfGlobalSymbol(getGlobalSymbol(name), 0); @@ -11722,34 +11434,34 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 105 /* AnyKeyword */: + case 109 /* AnyKeyword */: return anyType; - case 114 /* StringKeyword */: + case 118 /* StringKeyword */: return stringType; - case 112 /* NumberKeyword */: + case 116 /* NumberKeyword */: return numberType; - case 106 /* BooleanKeyword */: + case 110 /* BooleanKeyword */: return booleanType; - case 93 /* VoidKeyword */: + case 97 /* VoidKeyword */: return voidType; case 7 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 128 /* TypeReference */: + case 132 /* TypeReference */: return getTypeFromTypeReferenceNode(node); - case 129 /* TypeQuery */: + case 133 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 131 /* ArrayType */: + case 135 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 132 /* TupleType */: + case 136 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 133 /* UnionType */: + case 137 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 134 /* ParenType */: + case 138 /* ParenType */: return getTypeFromTypeNode(node.type); - case 130 /* TypeLiteral */: + case 134 /* TypeLiteral */: return getTypeFromTypeLiteralNode(node); - case 59 /* Identifier */: - case 117 /* QualifiedName */: + case 63 /* Identifier */: + case 121 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -11774,10 +11486,8 @@ var ts; } function createTypeMapper(sources, targets) { switch (sources.length) { - case 1: - return createUnaryTypeMapper(sources[0], targets[0]); - case 2: - return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); + case 1: return createUnaryTypeMapper(sources[0], targets[0]); + case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); } return function (t) { for (var i = 0; i < sources.length; i++) { @@ -11795,10 +11505,8 @@ var ts; } function createTypeEraser(sources) { switch (sources.length) { - case 1: - return createUnaryTypeEraser(sources[0]); - case 2: - return createBinaryTypeEraser(sources[0], sources[1]); + case 1: return createUnaryTypeEraser(sources[0]); + case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { for (var i = 0; i < sources.length; i++) { @@ -11847,12 +11555,12 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 33554432 /* Instantiated */) { + if (symbol.flags & 67108864 /* Instantiated */) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(33554432 /* Instantiated */ | 134217728 /* Transient */ | symbol.flags, symbol.name); + var result = createSymbol(67108864 /* Instantiated */ | 268435456 /* Transient */ | symbol.flags, symbol.name); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -11882,7 +11590,7 @@ var ts; return mapper(type); } if (type.flags & 32768 /* Anonymous */) { - return type.symbol && type.symbol.flags & (16 /* Function */ | 4096 /* Method */ | 1024 /* TypeLiteral */ | 2048 /* ObjectLiteral */) ? instantiateAnonymousType(type, mapper) : type; + return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? instantiateAnonymousType(type, mapper) : type; } if (type.flags & 4096 /* Reference */) { return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); @@ -11898,22 +11606,22 @@ var ts; } function isContextSensitiveExpression(node) { switch (node.kind) { - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); - case 136 /* ObjectLiteral */: - return ts.forEach(node.properties, function (p) { return p.kind === 137 /* PropertyAssignment */ && isContextSensitiveExpression(p.initializer); }); - case 135 /* ArrayLiteral */: + case 140 /* ObjectLiteral */: + return ts.forEach(node.properties, function (p) { return p.kind === 141 /* PropertyAssignment */ && isContextSensitiveExpression(p.initializer); }); + case 139 /* ArrayLiteral */: return ts.forEach(node.elements, function (e) { return isContextSensitiveExpression(e); }); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return isContextSensitiveExpression(node.whenTrue) || isContextSensitiveExpression(node.whenFalse); - case 148 /* BinaryExpression */: - return node.operator === 44 /* BarBarToken */ && (isContextSensitiveExpression(node.left) || isContextSensitiveExpression(node.right)); + case 153 /* BinaryExpression */: + return node.operator === 48 /* BarBarToken */ && (isContextSensitiveExpression(node.left) || isContextSensitiveExpression(node.right)); } return false; } function getTypeWithoutConstructors(type) { - if (type.flags & ts.TypeFlags.ObjectType) { + if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768 /* Anonymous */, type.symbol); @@ -11932,78 +11640,26 @@ var ts; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } + function compareTypes(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return checkTypeSubtypeOf(source, target, undefined); } - function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); - } function isTypeAssignableTo(source, target) { return checkTypeAssignableTo(source, target, undefined); } + function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); + } function checkTypeAssignableTo(source, target, errorNode, headMessage) { return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); } - function isTypeRelatedTo(source, target, relation) { - return checkTypeRelatedTo(source, target, relation, undefined); - } function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); var targetType = getOrCreateTypeFromSignature(target); return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); } - function isPropertyIdenticalTo(sourceProp, targetProp) { - return isPropertyIdenticalToRecursive(sourceProp, targetProp, false, function (s, t, _reportErrors) { return isTypeIdenticalTo(s, t); }); - } - function checkInheritedPropertiesAreIdentical(type, typeNode) { - if (!type.baseTypes.length || type.baseTypes.length === 1) { - return true; - } - var seen = {}; - ts.forEach(type.declaredProperties, function (p) { - seen[p.name] = { prop: p, containingType: type }; - }); - var ok = true; - for (var i = 0, len = type.baseTypes.length; i < len; ++i) { - var base = type.baseTypes[i]; - var properties = getPropertiesOfObjectType(base); - for (var j = 0, proplen = properties.length; j < proplen; ++j) { - var prop = properties[j]; - if (!ts.hasProperty(seen, prop.name)) { - seen[prop.name] = { prop: prop, containingType: base }; - } - else { - var existing = seen[prop.name]; - var isInheritedProperty = existing.containingType !== type; - if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { - ok = false; - var typeName1 = typeToString(existing.containingType); - var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); - addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, program.getCompilerHost().getNewLine())); - } - } - } - } - return ok; - } - function isPropertyIdenticalToRecursive(sourceProp, targetProp, reportErrors, relate) { - if (sourceProp === targetProp) { - return true; - } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); - if (sourcePropAccessibility !== targetPropAccessibility) { - return false; - } - if (sourcePropAccessibility) { - return getTargetSymbol(sourceProp) === getTargetSymbol(targetProp) && relate(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - } - else { - return isOptionalProperty(sourceProp) === isOptionalProperty(targetProp) && relate(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - } - } function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { var errorInfo; var sourceStack; @@ -12012,7 +11668,7 @@ var ts; var depth = 0; var overflow = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedToWithCustomErrors(source, target, errorNode !== undefined, headMessage); + var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); if (overflow) { error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); } @@ -12022,109 +11678,114 @@ var ts; } addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, program.getCompilerHost().getNewLine())); } - return result; + return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } - function isRelatedTo(source, target, reportErrors) { - return isRelatedToWithCustomErrors(source, target, reportErrors, undefined); - } - function isRelatedToWithCustomErrors(source, target, reportErrors, headMessage) { + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; if (relation === identityRelation) { if (source === target) - return true; + return -1 /* True */; } else { if (source === target) - return true; + return -1 /* True */; if (target.flags & 1 /* Any */) - return true; + return -1 /* True */; if (source === undefinedType) - return true; + return -1 /* True */; if (source === nullType && target !== undefinedType) - return true; + return -1 /* True */; if (source.flags & 128 /* Enum */ && target === numberType) - return true; + return -1 /* True */; if (source.flags & 256 /* StringLiteral */ && target === stringType) - return true; + return -1 /* True */; if (relation === assignableRelation) { if (source.flags & 1 /* Any */) - return true; + return -1 /* True */; if (source === numberType && target.flags & 128 /* Enum */) - return true; + return -1 /* True */; } } if (source.flags & 16384 /* Union */) { - if (unionTypeRelatedToType(source, target, reportErrors)) { - return true; + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; } } else if (target.flags & 16384 /* Union */) { - if (typeRelatedToUnionType(source, target, reportErrors)) { - return true; + if (result = typeRelatedToUnionType(source, target, reportErrors)) { + return result; } } else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (typeParameterRelatedTo(source, target, reportErrors)) { - return true; + if (result = typeParameterRelatedTo(source, target, reportErrors)) { + return result; } } else { var saveErrorInfo = errorInfo; if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - if (typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return true; + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & ts.TypeFlags.ObjectType && target.flags & ts.TypeFlags.ObjectType && objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (sourceOrApparentType.flags & 48128 /* ObjectType */ && target.flags & 48128 /* ObjectType */ && (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { errorInfo = saveErrorInfo; - return true; + return result; } } if (reportErrors) { headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - ts.Debug.assert(headMessage); reportError(headMessage, typeToString(source), typeToString(target)); } - return false; + return 0 /* False */; } function typeRelatedToUnionType(source, target, reportErrors) { var targetTypes = target.types; for (var i = 0, len = targetTypes.length; i < len; i++) { - if (isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1)) { - return true; + var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + if (related) { + return related; } } - return false; + return 0 /* False */; } function unionTypeRelatedToType(source, target, reportErrors) { + var result = -1 /* True */; var sourceTypes = source.types; for (var i = 0, len = sourceTypes.length; i < len; i++) { - if (!isRelatedTo(sourceTypes[i], target, reportErrors)) { - return false; + var related = isRelatedTo(sourceTypes[i], target, reportErrors); + if (!related) { + return 0 /* False */; } + result &= related; } - return true; + return result; } function typesRelatedTo(sources, targets, reportErrors) { + var result = -1 /* True */; for (var i = 0, len = sources.length; i < len; i++) { - if (!isRelatedTo(sources[i], targets[i], reportErrors)) - return false; + var related = isRelatedTo(sources[i], targets[i], reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; } - return true; + return result; } function typeParameterRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { if (source.symbol.name !== target.symbol.name) { - return false; + return 0 /* False */; } if (source.constraint === target.constraint) { - return true; + return -1 /* True */; } if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return false; + return 0 /* False */; } return isRelatedTo(source.constraint, target.constraint, reportErrors); } @@ -12132,29 +11793,32 @@ var ts; while (true) { var constraint = getConstraintOfTypeParameter(source); if (constraint === target) - return true; + return -1 /* True */; if (!(constraint && constraint.flags & 512 /* TypeParameter */)) break; source = constraint; } - return false; + return 0 /* False */; } } function objectTypeRelatedTo(source, target, reportErrors) { - if (overflow) - return false; - var result; + if (overflow) { + return 0 /* False */; + } var id = source.id + "," + target.id; - if ((result = relation[id]) !== undefined) - return result; + var related = relation[id]; + if (related !== undefined) { + return related; + } if (depth > 0) { for (var i = 0; i < depth; i++) { - if (source === sourceStack[i] && target === targetStack[i]) - return true; + if (source === sourceStack[i] && target === targetStack[i]) { + return 1 /* Maybe */; + } } if (depth === 100) { overflow = true; - return false; + return 0 /* False */; } } else { @@ -12170,10 +11834,27 @@ var ts; expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) expandingFlags |= 2; - result = expandingFlags === 3 || propertiesRelatedTo(source, target, reportErrors) && signaturesRelatedTo(source, target, 0 /* Call */, reportErrors) && signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors) && stringIndexTypesRelatedTo(source, target, reportErrors) && numberIndexTypesRelatedTo(source, target, reportErrors); + if (expandingFlags === 3) { + var result = -1 /* True */; + } + else { + var result = propertiesRelatedTo(source, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0 /* Call */, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(source, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(source, target, reportErrors); + } + } + } + } + } expandingFlags = saveExpandingFlags; depth--; - if (depth === 0) { + if (result !== 1 /* Maybe */) { relation[id] = result; } return result; @@ -12195,8 +11876,9 @@ var ts; } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { - return propertiesIdenticalTo(source, target, reportErrors); + return propertiesIdenticalTo(source, target); } + var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); for (var i = 0; i < properties.length; i++) { var targetProp = properties[i]; @@ -12207,10 +11889,10 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } - return false; + return 0 /* False */; } } - else if (!(targetProp.flags & 268435456 /* Prototype */)) { + else if (!(targetProp.flags & 536870912 /* Prototype */)) { var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetFlags = getDeclarationFlagsFromSymbol(targetProp); if (sourceFlags & 32 /* Private */ || targetFlags & 32 /* Private */) { @@ -12223,7 +11905,7 @@ var ts; reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourceFlags & 32 /* Private */ ? source : target), typeToString(sourceFlags & 32 /* Private */ ? target : source)); } } - return false; + return 0 /* False */; } } else if (targetFlags & 64 /* Protected */) { @@ -12234,55 +11916,65 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); } - return false; + return 0 /* False */; } } else if (sourceFlags & 64 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return false; + return 0 /* False */; } - if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) { + var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); + if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return false; + return 0 /* False */; } + result &= related; if (isOptionalProperty(sourceProp) && !isOptionalProperty(targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return false; + return 0 /* False */; } } } } - return true; + return result; } - function propertiesIdenticalTo(source, target, reportErrors) { + function propertiesIdenticalTo(source, target) { var sourceProperties = getPropertiesOfObjectType(source); var targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { - return false; + return 0 /* False */; } + var result = -1 /* True */; for (var i = 0, len = sourceProperties.length; i < len; ++i) { var sourceProp = sourceProperties[i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || !isPropertyIdenticalToRecursive(sourceProp, targetProp, reportErrors, isRelatedTo)) { - return false; + if (!targetProp) { + return 0 /* False */; } + var related = compareProperties(sourceProp, targetProp, isRelatedTo); + if (!related) { + return 0 /* False */; + } + result &= related; } - return true; + return result; } function signaturesRelatedTo(source, target, kind, reportErrors) { if (relation === identityRelation) { - return signaturesIdenticalTo(source, target, kind, reportErrors); + return signaturesIdenticalTo(source, target, kind); + } + if (target === anyFunctionType || source === anyFunctionType) { + return -1 /* True */; } - if (target === anyFunctionType || source === anyFunctionType) - return true; var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); + var result = -1 /* True */; var saveErrorInfo = errorInfo; outer: for (var i = 0; i < targetSignatures.length; i++) { var t = targetSignatures[i]; @@ -12291,24 +11983,26 @@ var ts; for (var j = 0; j < sourceSignatures.length; j++) { var s = sourceSignatures[j]; if (!s.hasStringLiterals || source.flags & 65536 /* FromSignature */) { - if (signatureRelatedTo(s, t, localErrors)) { + var related = signatureRelatedTo(s, t, localErrors); + if (related) { + result &= related; errorInfo = saveErrorInfo; continue outer; } localErrors = false; } } - return false; + return 0 /* False */; } } - return true; + return result; } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { - return true; + return -1 /* True */; } if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return false; + return 0 /* False */; } var sourceMax = source.parameters.length; var targetMax = target.parameters.length; @@ -12331,42 +12025,49 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); + var result = -1 /* True */; for (var i = 0; i < checkCount; i++) { var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - if (!isRelatedTo(s, t, reportErrors)) { - if (!isRelatedTo(t, s, false)) { + var related = isRelatedTo(s, t, reportErrors); + if (!related) { + related = isRelatedTo(t, s, false); + if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); } - return false; + return 0 /* False */; } errorInfo = saveErrorInfo; } + result &= related; } var t = getReturnTypeOfSignature(target); if (t === voidType) - return true; + return result; var s = getReturnTypeOfSignature(source); - return isRelatedTo(s, t, reportErrors); + return result & isRelatedTo(s, t, reportErrors); } - function signaturesIdenticalTo(source, target, kind, reportErrors) { + function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return false; + return 0 /* False */; } + var result = -1 /* True */; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - if (!compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo)) { - return false; + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + if (!related) { + return 0 /* False */; } + result &= related; } - return true; + return result; } function stringIndexTypesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target, reportErrors); + return indexTypesIdenticalTo(0 /* String */, source, target); } var targetType = getIndexTypeOfType(target, 0 /* String */); if (targetType) { @@ -12375,20 +12076,22 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); } - return false; + return 0 /* False */; } - if (!isRelatedTo(sourceType, targetType, reportErrors)) { + var related = isRelatedTo(sourceType, targetType, reportErrors); + if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Index_signatures_are_incompatible); } - return false; + return 0 /* False */; } + return related; } - return true; + return -1 /* True */; } function numberIndexTypesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target, reportErrors); + return indexTypesIdenticalTo(1 /* Number */, source, target); } var targetType = getIndexTypeOfType(target, 1 /* Number */); if (targetType) { @@ -12398,59 +12101,98 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); } - return false; + return 0 /* False */; } if (sourceStringType && sourceNumberType) { - var compatible = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + var related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); } else { - var compatible = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + var related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); } - if (!compatible) { + if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Index_signatures_are_incompatible); } - return false; + return 0 /* False */; } + return related; } - return true; + return -1 /* True */; } - function indexTypesIdenticalTo(indexKind, source, target, reportErrors) { + function indexTypesIdenticalTo(indexKind, source, target) { var targetType = getIndexTypeOfType(target, indexKind); var sourceType = getIndexTypeOfType(source, indexKind); - return (!sourceType && !targetType) || (sourceType && targetType && isRelatedTo(sourceType, targetType, reportErrors)); + if (!sourceType && !targetType) { + return -1 /* True */; + } + if (sourceType && targetType) { + return isRelatedTo(sourceType, targetType); + } + return 0 /* False */; } } + function isPropertyIdenticalTo(sourceProp, targetProp) { + return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; + } + function compareProperties(sourceProp, targetProp, compareTypes) { + if (sourceProp === targetProp) { + return -1 /* True */; + } + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); + if (sourcePropAccessibility !== targetPropAccessibility) { + return 0 /* False */; + } + if (sourcePropAccessibility) { + if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { + return 0 /* False */; + } + } + else { + if (isOptionalProperty(sourceProp) !== isOptionalProperty(targetProp)) { + return 0 /* False */; + } + } + return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } function compareSignatures(source, target, compareReturnTypes, compareTypes) { if (source === target) { - return true; + return -1 /* True */; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return false; + return 0 /* False */; } + var result = -1 /* True */; if (source.typeParameters && target.typeParameters) { if (source.typeParameters.length !== target.typeParameters.length) { - return false; + return 0 /* False */; } for (var i = 0, len = source.typeParameters.length; i < len; ++i) { - if (!compareTypes(source.typeParameters[i], target.typeParameters[i])) { - return false; + var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); + if (!related) { + return 0 /* False */; } + result &= related; } } else if (source.typeParameters || source.typeParameters) { - return false; + return 0 /* False */; } source = getErasedSignature(source); target = getErasedSignature(target); for (var i = 0, len = source.parameters.length; i < len; i++) { var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - if (!compareTypes(s, t)) { - return false; + var related = compareTypes(s, t); + if (!related) { + return 0 /* False */; } + result &= related; } - return !compareReturnTypes || compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (compareReturnTypes) { + result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + return result; } function isSupertypeOfEach(candidate, types) { for (var i = 0, len = types.length; i < len; i++) { @@ -12489,7 +12231,7 @@ var ts; checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); } function isTypeOfObjectLiteral(type) { - return (type.flags & 32768 /* Anonymous */) && type.symbol && (type.symbol.flags & 2048 /* ObjectLiteral */) ? true : false; + return (type.flags & 32768 /* Anonymous */) && type.symbol && (type.symbol.flags & 4096 /* ObjectLiteral */) ? true : false; } function isArrayType(type) { return type.flags & 4096 /* Reference */ && type.target === globalArrayType; @@ -12537,7 +12279,7 @@ var ts; var members = {}; var index = 0; ts.forEach(properties, function (p) { - var symbol = createSymbol(4 /* Property */ | 134217728 /* Transient */ | p.flags, p.name); + var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */ | p.flags, p.name); symbol.declarations = p.declarations; symbol.parent = p.parent; symbol.type = widenedTypes[index++]; @@ -12672,7 +12414,7 @@ var ts; inferFromTypes(sourceTypes[i], target); } } - else if (source.flags & ts.TypeFlags.ObjectType && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (4096 /* Method */ | 1024 /* TypeLiteral */))) { + else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { if (depth === 0) { sourceStack = []; @@ -12756,17 +12498,17 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = resolveName(node, node.text, ts.SymbolFlags.Value | 2097152 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol; + links.resolvedSymbol = resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol; } return links.resolvedSymbol; } function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 129 /* TypeQuery */: + case 133 /* TypeQuery */: return true; - case 59 /* Identifier */: - case 117 /* QualifiedName */: + case 63 /* Identifier */: + case 121 /* QualifiedName */: node = node.parent; continue; default: @@ -12797,12 +12539,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operator >= ts.SyntaxKind.FirstAssignment && node.operator <= ts.SyntaxKind.LastAssignment) { + if (node.operator >= 51 /* FirstAssignment */ && node.operator <= 62 /* LastAssignment */) { var n = node.left; - while (n.kind === 143 /* ParenExpression */) { + while (n.kind === 148 /* ParenExpression */) { n = n.expression; } - if (n.kind === 59 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 63 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -12816,40 +12558,40 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: return isAssignedInVariableDeclaration(node); - case 135 /* ArrayLiteral */: - case 136 /* ObjectLiteral */: - case 138 /* PropertyAccess */: - case 139 /* IndexedAccess */: - case 140 /* CallExpression */: - case 141 /* NewExpression */: - case 142 /* TypeAssertion */: - case 143 /* ParenExpression */: - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: - case 149 /* ConditionalExpression */: - case 151 /* Block */: - case 152 /* VariableStatement */: - case 154 /* ExpressionStatement */: - case 155 /* IfStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 162 /* ReturnStatement */: - case 163 /* WithStatement */: - case 164 /* SwitchStatement */: - case 165 /* CaseClause */: - case 166 /* DefaultClause */: - case 167 /* LabeledStatement */: - case 168 /* ThrowStatement */: - case 169 /* TryStatement */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: + case 139 /* ArrayLiteral */: + case 140 /* ObjectLiteral */: + case 142 /* PropertyAccess */: + case 143 /* IndexedAccess */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: + case 147 /* TypeAssertion */: + case 148 /* ParenExpression */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: + case 154 /* ConditionalExpression */: + case 158 /* Block */: + case 159 /* VariableStatement */: + case 161 /* ExpressionStatement */: + case 162 /* IfStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 169 /* ReturnStatement */: + case 170 /* WithStatement */: + case 171 /* SwitchStatement */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: + case 174 /* LabeledStatement */: + case 175 /* ThrowStatement */: + case 176 /* TryStatement */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -12857,31 +12599,31 @@ var ts; } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); - if (symbol.flags & ts.SymbolFlags.Variable && type.flags & ts.TypeFlags.Structured) { + if (symbol.flags & 3 /* Variable */ && type.flags & 65025 /* Structured */) { while (true) { var child = node; node = node.parent; - if (!node || node.kind === 176 /* FunctionBlock */ || node.kind === 182 /* ModuleBlock */) { + if (!node || node.kind === 183 /* FunctionBlock */ || node.kind === 189 /* ModuleBlock */) { break; } var narrowedType = type; switch (node.kind) { - case 155 /* IfStatement */: + case 162 /* IfStatement */: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: if (child === node.right) { - if (node.operator === 43 /* AmpersandAmpersandToken */) { + if (node.operator === 47 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, true); } - else if (node.operator === 44 /* BarBarToken */) { + else if (node.operator === 48 /* BarBarToken */) { narrowedType = narrowType(type, node.left, false); } } @@ -12899,12 +12641,12 @@ var ts; function narrowTypeByEquality(type, expr, assumeTrue) { var left = expr.left; var right = expr.right; - if (left.kind !== 146 /* PrefixOperator */ || left.operator !== 91 /* TypeOfKeyword */ || left.operand.kind !== 59 /* Identifier */ || right.kind !== 7 /* StringLiteral */ || getResolvedSymbol(left.operand) !== symbol) { + if (left.kind !== 151 /* PrefixOperator */ || left.operator !== 95 /* TypeOfKeyword */ || left.operand.kind !== 63 /* Identifier */ || right.kind !== 7 /* StringLiteral */ || getResolvedSymbol(left.operand) !== symbol) { return type; } var t = right.text; var checkType = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType; - if (expr.operator === 26 /* ExclamationEqualsEqualsToken */) { + if (expr.operator === 30 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { @@ -12937,7 +12679,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (!assumeTrue || expr.left.kind !== 59 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (!assumeTrue || expr.left.kind !== 63 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -12953,25 +12695,25 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return narrowType(type, expr.expression, assumeTrue); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: var operator = expr.operator; - if (operator === 25 /* EqualsEqualsEqualsToken */ || operator === 26 /* ExclamationEqualsEqualsToken */) { + if (operator === 29 /* EqualsEqualsEqualsToken */ || operator === 30 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 43 /* AmpersandAmpersandToken */) { + else if (operator === 47 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 44 /* BarBarToken */) { + else if (operator === 48 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 81 /* InstanceOfKeyword */) { + else if (operator === 85 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 146 /* PrefixOperator */: - if (expr.operator === 41 /* ExclamationToken */) { + case 151 /* PrefixOperator */: + if (expr.operator === 45 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -12981,8 +12723,8 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol.flags & 16777216 /* Import */) { - getSymbolLinks(symbol).referenced = !isInTypeQuery(node); + if (symbol.flags & 33554432 /* Import */) { + getSymbolLinks(symbol).referenced = !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol)); } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); @@ -12990,9 +12732,9 @@ var ts; return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 177 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 184 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 120 /* Property */ || container.kind === 122 /* Constructor */) { + if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -13002,23 +12744,23 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 145 /* ArrowFunction */) { + if (container.kind === 150 /* ArrowFunction */) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = true; } switch (container.kind) { - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 122 /* Constructor */: + case 126 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 120 /* Property */: + case 124 /* Property */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } @@ -13027,7 +12769,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 177 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 184 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -13040,29 +12782,29 @@ var ts; if (!node) return node; switch (node.kind) { - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 120 /* Property */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 124 /* Property */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return node; } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 119 /* Parameter */) { + if (n.kind === 123 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 140 /* CallExpression */ && node.parent.func === node; - var enclosingClass = ts.getAncestor(node, 177 /* ClassDeclaration */); + var isCallExpression = node.parent.kind === 144 /* CallExpression */ && node.parent.func === node; + var enclosingClass = ts.getAncestor(node, 184 /* ClassDeclaration */); var baseClass; if (enclosingClass && enclosingClass.baseType) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -13076,20 +12818,20 @@ var ts; if (container) { var canUseSuperExpression = false; if (isCallExpression) { - canUseSuperExpression = container.kind === 122 /* Constructor */; + canUseSuperExpression = container.kind === 126 /* Constructor */; } else { var needToCaptureLexicalThis = false; - while (container && container.kind === 145 /* ArrowFunction */) { + while (container && container.kind === 150 /* ArrowFunction */) { container = getSuperContainer(container); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 177 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 184 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = container.kind === 121 /* Method */ || container.kind === 123 /* GetAccessor */ || container.kind === 124 /* SetAccessor */; + canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */; } else { - canUseSuperExpression = container.kind === 121 /* Method */ || container.kind === 123 /* GetAccessor */ || container.kind === 124 /* SetAccessor */ || container.kind === 120 /* Property */ || container.kind === 122 /* Constructor */; + canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */ || container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */; } } } @@ -13103,7 +12845,7 @@ var ts; getNodeLinks(node).flags |= 16 /* SuperInstance */; returnType = baseClass; } - if (container.kind === 122 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 126 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -13123,7 +12865,7 @@ var ts; } function getContextuallyTypedParameterType(parameter) { var func = parameter.parent; - if (func.kind === 144 /* FunctionExpression */ || func.kind === 145 /* ArrowFunction */) { + if (func.kind === 149 /* FunctionExpression */ || func.kind === 150 /* ArrowFunction */) { if (isContextSensitiveExpression(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -13147,7 +12889,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 119 /* Parameter */) { + if (declaration.kind === 123 /* Parameter */) { return getContextuallyTypedParameterType(declaration); } } @@ -13156,7 +12898,7 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 122 /* Constructor */ || func.kind === 123 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 124 /* SetAccessor */))) { + if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } var signature = getContextualSignature(func); @@ -13178,12 +12920,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operator; - if (operator >= ts.SyntaxKind.FirstAssignment && operator <= ts.SyntaxKind.LastAssignment) { + if (operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 44 /* BarBarToken */) { + else if (operator === 48 /* BarBarToken */) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -13262,25 +13004,25 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 174 /* VariableDeclaration */: - case 119 /* Parameter */: - case 120 /* Property */: + case 181 /* VariableDeclaration */: + case 123 /* Parameter */: + case 124 /* Property */: return getContextualTypeForInitializerExpression(node); - case 145 /* ArrowFunction */: - case 162 /* ReturnStatement */: + case 150 /* ArrowFunction */: + case 169 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return getContextualTypeForArgument(node); - case 142 /* TypeAssertion */: + case 147 /* TypeAssertion */: return getTypeFromTypeNode(parent.type); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 137 /* PropertyAssignment */: + case 141 /* PropertyAssignment */: return getContextualTypeForPropertyExpression(node); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return getContextualTypeForElementExpression(node); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); } return undefined; @@ -13310,7 +13052,7 @@ var ts; if (!result) { result = signature; } - else if (!compareSignatures(result, signature, true, isTypeIdenticalTo)) { + else if (!compareSignatures(result, signature, true, compareTypes)) { return undefined; } } @@ -13344,7 +13086,7 @@ var ts; var member = members[id]; if (member.flags & 4 /* Property */) { var type = checkExpression(member.declarations[0].initializer, contextualMapper); - var prop = createSymbol(4 /* Property */ | 134217728 /* Transient */ | member.flags, member.name); + var prop = createSymbol(4 /* Property */ | 268435456 /* Transient */ | member.flags, member.name); prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) @@ -13354,11 +13096,11 @@ var ts; member = prop; } else { - var getAccessor = getDeclarationOfKind(member, 123 /* GetAccessor */); + var getAccessor = getDeclarationOfKind(member, 127 /* GetAccessor */); if (getAccessor) { checkAccessorDeclaration(getAccessor); } - var setAccessor = getDeclarationOfKind(member, 124 /* SetAccessor */); + var setAccessor = getDeclarationOfKind(member, 128 /* SetAccessor */); if (setAccessor) { checkAccessorDeclaration(setAccessor); } @@ -13388,17 +13130,17 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 120 /* Property */; + return s.valueDeclaration ? s.valueDeclaration.kind : 124 /* Property */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 268435456 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 536870912 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; } function checkClassPropertyAccess(node, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); if (!(flags & (32 /* Private */ | 64 /* Protected */))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 177 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 184 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32 /* Private */) { @@ -13407,7 +13149,7 @@ var ts; } return; } - if (node.left.kind === 85 /* SuperKeyword */) { + if (node.left.kind === 89 /* SuperKeyword */) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -13439,7 +13181,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 85 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 121 /* Method */) { + if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { error(node.right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -13455,7 +13197,7 @@ var ts; if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 85 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 121 /* Method */) { + if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { return false; } else { @@ -13472,15 +13214,19 @@ var ts; var indexType = checkExpression(node.index); if (objectType === unknownType) return unknownType; + if (isConstEnumObjectType(objectType) && node.index.kind !== 7 /* StringLiteral */) { + error(node.index, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + } if (node.index.kind === 7 /* StringLiteral */ || node.index.kind === 6 /* NumericLiteral */) { var name = node.index.text; var prop = getPropertyOfType(objectType, name); if (prop) { + getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } } - if (indexType.flags & (1 /* Any */ | ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike)) { - if (indexType.flags & (1 /* Any */ | ts.TypeFlags.NumberLike)) { + if (indexType.flags & (1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */)) { + if (indexType.flags & (1 /* Any */ | 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); if (numberIndexType) { return numberIndexType; @@ -13524,7 +13270,7 @@ var ts; return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { - if (type.flags & ts.TypeFlags.ObjectType) { + if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -13544,7 +13290,7 @@ var ts; var context = createInferenceContext(typeParameters, false); var mapper = createInferenceMapper(context); for (var i = 0; i < args.length; i++) { - if (args[i].kind === 150 /* OmittedExpression */) { + if (args[i].kind === 157 /* OmittedExpression */) { continue; } if (!excludeArgument || excludeArgument[i] === undefined) { @@ -13554,7 +13300,7 @@ var ts; } if (excludeArgument) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 150 /* OmittedExpression */) { + if (args[i].kind === 157 /* OmittedExpression */) { continue; } if (excludeArgument[i] === false) { @@ -13592,7 +13338,7 @@ var ts; if (node.arguments) { for (var i = 0; i < node.arguments.length; i++) { var arg = node.arguments[i]; - if (arg.kind === 150 /* OmittedExpression */) { + if (arg.kind === 157 /* OmittedExpression */) { continue; } var paramType = getTypeAtPosition(signature, i); @@ -13727,33 +13473,31 @@ var ts; ts.Debug.assert(!result.length); for (var i = 0; i < signatures.length; i++) { var signature = signatures[i]; - if (true) { - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent === lastParent) { - pos++; - } - else { - lastParent = parent; - pos = cutoffPos; - } + var symbol = signature.declaration && getSymbolOfNode(signature.declaration); + var parent = signature.declaration && signature.declaration.parent; + if (!lastSymbol || symbol === lastSymbol) { + if (lastParent && parent === lastParent) { + pos++; } else { - pos = cutoffPos = result.length; lastParent = parent; + pos = cutoffPos; } - lastSymbol = symbol; - for (var j = result.length; j > pos; j--) { - result[j] = result[j - 1]; - } - result[pos] = signature; } + else { + pos = cutoffPos = result.length; + lastParent = parent; + } + lastSymbol = symbol; + for (var j = result.length; j > pos; j--) { + result[j] = result[j - 1]; + } + result[pos] = signature; } } } function resolveCallExpression(node, candidatesOutArray) { - if (node.func.kind === 85 /* SuperKeyword */) { + if (node.func.kind === 89 /* SuperKeyword */) { var superType = checkSuperExpression(node.func); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); @@ -13815,18 +13559,18 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - links.resolvedSignature = node.kind === 140 /* CallExpression */ ? resolveCallExpression(node, candidatesOutArray) : resolveNewExpression(node, candidatesOutArray); + links.resolvedSignature = node.kind === 144 /* CallExpression */ ? resolveCallExpression(node, candidatesOutArray) : resolveNewExpression(node, candidatesOutArray); } return links.resolvedSignature; } function checkCallExpression(node) { var signature = getResolvedSignature(node); - if (node.func.kind === 85 /* SuperKeyword */) { + if (node.func.kind === 89 /* SuperKeyword */) { return voidType; } - if (node.kind === 141 /* NewExpression */) { + if (node.kind === 145 /* NewExpression */) { var declaration = signature.declaration; - if (declaration && (declaration.kind !== 122 /* Constructor */ && declaration.kind !== 126 /* ConstructSignature */)) { + if (declaration && (declaration.kind !== 126 /* Constructor */ && declaration.kind !== 130 /* ConstructSignature */)) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -13835,6 +13579,11 @@ var ts; } return getReturnTypeOfSignature(signature); } + function checkTaggedTemplateExpression(node) { + checkExpression(node.tag); + checkExpression(node.template); + return anyType; + } function checkTypeAssertion(node) { var exprType = checkExpression(node.operand); var targetType = getTypeFromTypeNode(node.type); @@ -13864,7 +13613,7 @@ var ts; } function getReturnTypeFromBody(func, contextualMapper) { var contextualSignature = getContextualSignature(func); - if (func.body.kind !== 176 /* FunctionBlock */) { + if (func.body.kind !== 183 /* FunctionBlock */) { var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); var widenedType = getWidenedType(unwidenedType); if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { @@ -13912,7 +13661,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 168 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 175 /* ThrowStatement */); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!fullTypeCheck) { @@ -13921,7 +13670,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (!func.body || func.body.kind !== 176 /* FunctionBlock */) { + if (!func.body || func.body.kind !== 183 /* FunctionBlock */) { return; } var bodyBlock = func.body; @@ -13965,7 +13714,7 @@ var ts; if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } - if (node.body.kind === 176 /* FunctionBlock */) { + if (node.body.kind === 183 /* FunctionBlock */) { checkSourceElement(node.body); } else { @@ -13977,7 +13726,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!(type.flags & (1 /* Any */ | ts.TypeFlags.NumberLike))) { + if (!(type.flags & (1 /* Any */ | 132 /* NumberLike */))) { error(operand, diagnostic); return false; } @@ -13990,15 +13739,15 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 59 /* Identifier */: + case 63 /* Identifier */: var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & ts.SymbolFlags.Variable) !== 0; - case 138 /* PropertyAccess */: + return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; + case 142 /* PropertyAccess */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return true; - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -14006,20 +13755,20 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 59 /* Identifier */: - case 138 /* PropertyAccess */: + case 63 /* Identifier */: + case 142 /* PropertyAccess */: var symbol = findSymbol(n); - return symbol && (symbol.flags & ts.SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; - case 139 /* IndexedAccess */: + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; + case 143 /* IndexedAccess */: var index = n.index; var symbol = findSymbol(n.object); if (symbol && index.kind === 7 /* StringLiteral */) { var name = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name); - return prop && (prop.flags & ts.SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; } return false; - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return isConstVariableReference(n.expression); default: return false; @@ -14038,19 +13787,19 @@ var ts; function checkPrefixExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 28 /* PlusToken */: - case 29 /* MinusToken */: - case 42 /* TildeToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: + case 46 /* TildeToken */: return numberType; - case 41 /* ExclamationToken */: - case 68 /* DeleteKeyword */: + case 45 /* ExclamationToken */: + case 72 /* DeleteKeyword */: return booleanType; - case 91 /* TypeOfKeyword */: + case 95 /* TypeOfKeyword */: return stringType; - case 93 /* VoidKeyword */: + case 97 /* VoidKeyword */: return undefinedType; - case 33 /* PlusPlusToken */: - case 34 /* MinusMinusToken */: + case 37 /* PlusPlusToken */: + case 38 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -14071,7 +13820,13 @@ var ts; if (type.flags & 16384 /* Union */) { return !ts.forEach(type.types, function (t) { return !isStructuredType(t); }); } - return (type.flags & ts.TypeFlags.Structured) !== 0; + return (type.flags & 65025 /* Structured */) !== 0; + } + function isConstEnumObjectType(type) { + return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); + } + function isConstEnumSymbol(symbol) { + return (symbol.flags & 128 /* ConstEnum */) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { if (leftType !== unknownType && !isStructuredType(leftType)) { @@ -14096,26 +13851,26 @@ var ts; var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 30 /* AsteriskToken */: - case 50 /* AsteriskEqualsToken */: - case 31 /* SlashToken */: - case 51 /* SlashEqualsToken */: - case 32 /* PercentToken */: - case 52 /* PercentEqualsToken */: - case 29 /* MinusToken */: - case 49 /* MinusEqualsToken */: - case 35 /* LessThanLessThanToken */: - case 53 /* LessThanLessThanEqualsToken */: - case 36 /* GreaterThanGreaterThanToken */: - case 54 /* GreaterThanGreaterThanEqualsToken */: - case 37 /* GreaterThanGreaterThanGreaterThanToken */: - case 55 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 39 /* BarToken */: - case 57 /* BarEqualsToken */: - case 40 /* CaretToken */: - case 58 /* CaretEqualsToken */: - case 38 /* AmpersandToken */: - case 56 /* AmpersandEqualsToken */: + case 34 /* AsteriskToken */: + case 54 /* AsteriskEqualsToken */: + case 35 /* SlashToken */: + case 55 /* SlashEqualsToken */: + case 36 /* PercentToken */: + case 56 /* PercentEqualsToken */: + case 33 /* MinusToken */: + case 53 /* MinusEqualsToken */: + case 39 /* LessThanLessThanToken */: + case 57 /* LessThanLessThanEqualsToken */: + case 40 /* GreaterThanGreaterThanToken */: + case 58 /* GreaterThanGreaterThanEqualsToken */: + case 41 /* GreaterThanGreaterThanGreaterThanToken */: + case 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 43 /* BarToken */: + case 61 /* BarEqualsToken */: + case 44 /* CaretToken */: + case 62 /* CaretEqualsToken */: + case 42 /* AmpersandToken */: + case 60 /* AmpersandEqualsToken */: if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) @@ -14132,17 +13887,17 @@ var ts; } } return numberType; - case 28 /* PlusToken */: - case 48 /* PlusEqualsToken */: + case 32 /* PlusToken */: + case 52 /* PlusEqualsToken */: if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) rightType = leftType; var resultType; - if (leftType.flags & ts.TypeFlags.NumberLike && rightType.flags & ts.TypeFlags.NumberLike) { + if (leftType.flags & 132 /* NumberLike */ && rightType.flags & 132 /* NumberLike */) { resultType = numberType; } - else if (leftType.flags & ts.TypeFlags.StringLike || rightType.flags & ts.TypeFlags.StringLike) { + else if (leftType.flags & 258 /* StringLike */ || rightType.flags & 258 /* StringLike */) { resultType = stringType; } else if (leftType.flags & 1 /* Any */ || leftType === unknownType || rightType.flags & 1 /* Any */ || rightType === unknownType) { @@ -14152,53 +13907,53 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 48 /* PlusEqualsToken */) { + if (operator === 52 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 23 /* EqualsEqualsToken */: - case 24 /* ExclamationEqualsToken */: - case 25 /* EqualsEqualsEqualsToken */: - case 26 /* ExclamationEqualsEqualsToken */: - case 19 /* LessThanToken */: - case 20 /* GreaterThanToken */: - case 21 /* LessThanEqualsToken */: - case 22 /* GreaterThanEqualsToken */: + case 27 /* EqualsEqualsToken */: + case 28 /* ExclamationEqualsToken */: + case 29 /* EqualsEqualsEqualsToken */: + case 30 /* ExclamationEqualsEqualsToken */: + case 23 /* LessThanToken */: + case 24 /* GreaterThanToken */: + case 25 /* LessThanEqualsToken */: + case 26 /* GreaterThanEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 81 /* InstanceOfKeyword */: + case 85 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 80 /* InKeyword */: + case 84 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 43 /* AmpersandAmpersandToken */: + case 47 /* AmpersandAmpersandToken */: return rightType; - case 44 /* BarBarToken */: + case 48 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 47 /* EqualsToken */: + case 51 /* EqualsToken */: checkAssignmentOperator(rightType); return rightType; - case 18 /* CommaToken */: + case 22 /* CommaToken */: return rightType; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 39 /* BarToken */: - case 57 /* BarEqualsToken */: - return 44 /* BarBarToken */; - case 40 /* CaretToken */: - case 58 /* CaretEqualsToken */: - return 26 /* ExclamationEqualsEqualsToken */; - case 38 /* AmpersandToken */: - case 56 /* AmpersandEqualsToken */: - return 43 /* AmpersandAmpersandToken */; + case 43 /* BarToken */: + case 61 /* BarEqualsToken */: + return 48 /* BarBarToken */; + case 44 /* CaretToken */: + case 62 /* CaretEqualsToken */: + return 30 /* ExclamationEqualsEqualsToken */; + case 42 /* AmpersandToken */: + case 60 /* AmpersandEqualsToken */: + return 47 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (fullTypeCheck && operator >= ts.SyntaxKind.FirstAssignment && operator <= ts.SyntaxKind.LastAssignment) { + if (fullTypeCheck && operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -14215,6 +13970,12 @@ var ts; var type2 = checkExpression(node.whenFalse, contextualMapper); return getUnionType([type1, type2]); } + function checkTemplateExpression(node) { + ts.forEach(node.templateSpans, function (templateSpan) { + checkExpression(templateSpan.expression); + }); + return stringType; + } function checkExpressionWithContextualType(node, contextualType, contextualMapper) { var saveContextualType = node.contextualType; node.contextualType = contextualType; @@ -14241,56 +14002,67 @@ var ts; } } } + if (isConstEnumObjectType(type)) { + var ok = (node.parent.kind === 142 /* PropertyAccess */ && node.parent.left === node) || (node.parent.kind === 143 /* IndexedAccess */ && node.parent.object === node) || ((node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + if (!ok) { + error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); + } + } return type; } function checkExpressionNode(node, contextualMapper) { switch (node.kind) { - case 59 /* Identifier */: + case 63 /* Identifier */: return checkIdentifier(node); - case 87 /* ThisKeyword */: + case 91 /* ThisKeyword */: return checkThisExpression(node); - case 85 /* SuperKeyword */: + case 89 /* SuperKeyword */: return checkSuperExpression(node); - case 83 /* NullKeyword */: + case 87 /* NullKeyword */: return nullType; - case 89 /* TrueKeyword */: - case 74 /* FalseKeyword */: + case 93 /* TrueKeyword */: + case 78 /* FalseKeyword */: return booleanType; case 6 /* NumericLiteral */: return numberType; + case 155 /* TemplateExpression */: + return checkTemplateExpression(node); case 7 /* StringLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: return stringType; case 8 /* RegularExpressionLiteral */: return globalRegExpType; - case 117 /* QualifiedName */: + case 121 /* QualifiedName */: return checkPropertyAccess(node); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return checkArrayLiteral(node, contextualMapper); - case 136 /* ObjectLiteral */: + case 140 /* ObjectLiteral */: return checkObjectLiteral(node, contextualMapper); - case 138 /* PropertyAccess */: + case 142 /* PropertyAccess */: return checkPropertyAccess(node); - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return checkIndexedAccess(node); - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return checkCallExpression(node); - case 142 /* TypeAssertion */: + case 146 /* TaggedTemplateExpression */: + return checkTaggedTemplateExpression(node); + case 147 /* TypeAssertion */: return checkTypeAssertion(node); - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return checkExpression(node.expression); - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: return checkFunctionExpression(node, contextualMapper); - case 146 /* PrefixOperator */: + case 151 /* PrefixOperator */: return checkPrefixExpression(node); - case 147 /* PostfixOperator */: + case 152 /* PostfixOperator */: return checkPostfixExpression(node); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 150 /* OmittedExpression */: + case 157 /* OmittedExpression */: return undefinedType; } return unknownType; @@ -14306,7 +14078,7 @@ var ts; checkVariableDeclaration(parameterDeclaration); if (fullTypeCheck) { checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name); - if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 122 /* Constructor */ && parameterDeclaration.parent.body)) { + if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 126 /* Constructor */ && parameterDeclaration.parent.body)) { error(parameterDeclaration, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } if (parameterDeclaration.flags & 8 /* Rest */) { @@ -14321,10 +14093,10 @@ var ts; } } function checkReferencesInInitializer(n) { - if (n.kind === 59 /* Identifier */) { + if (n.kind === 63 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, ts.SymbolFlags.Value) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 119 /* Parameter */) { + if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { + if (referencedSymbol.valueDeclaration.kind === 123 /* Parameter */) { if (referencedSymbol.valueDeclaration === parameterDeclaration) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.identifierToString(parameterDeclaration.name)); return; @@ -14358,10 +14130,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 125 /* CallSignature */: + case 129 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -14370,7 +14142,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 178 /* InterfaceDeclaration */) { + if (node.kind === 185 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14384,7 +14156,7 @@ var ts; var declaration = indexSymbol.declarations[i]; if (declaration.parameters.length == 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 114 /* StringKeyword */: + case 118 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -14392,7 +14164,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 112 /* NumberKeyword */: + case 116 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -14426,39 +14198,37 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 140 /* CallExpression */ && n.func.kind === 85 /* SuperKeyword */; + return n.kind === 144 /* CallExpression */ && n.func.kind === 89 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 144 /* FunctionExpression */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: - case 136 /* ObjectLiteral */: - return false; - default: - return ts.forEachChild(n, containsSuperCall); + case 149 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: + case 140 /* ObjectLiteral */: return false; + default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 87 /* ThisKeyword */) { + if (n.kind === 91 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 144 /* FunctionExpression */ && n.kind !== 175 /* FunctionDeclaration */) { + else if (n.kind !== 149 /* FunctionExpression */ && n.kind !== 182 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 120 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; + return n.kind === 124 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; } if (node.parent.baseType) { if (containsSuperCall(node.body)) { var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 154 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 161 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -14473,15 +14243,15 @@ var ts; } function checkAccessorDeclaration(node) { if (fullTypeCheck) { - if (node.kind === 123 /* GetAccessor */) { + if (node.kind === 127 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } - var otherKind = node.kind === 123 /* GetAccessor */ ? 124 /* SetAccessor */ : 123 /* GetAccessor */; + var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; var otherAccessor = getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & ts.NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & ts.NodeFlags.AccessibilityModifier))) { + if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var thisType = getAnnotatedAccessorType(node); @@ -14547,9 +14317,9 @@ var ts; } var symbol = getSymbolOfNode(signatureDeclarationNode); var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 178 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 125 /* CallSignature */ || signatureDeclarationNode.kind === 126 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 125 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 185 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -14567,7 +14337,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = n.flags; - if (n.parent.kind !== 178 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 185 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { flags |= 1 /* Export */; } @@ -14609,9 +14379,9 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 8192 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; function reportImplementationExpectedError(node) { - if (node.name && node.name.kind === 116 /* Missing */) { + if (node.name && node.name.kind === 120 /* Missing */) { return; } var seen = false; @@ -14627,7 +14397,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 121 /* Method */); + ts.Debug.assert(node.kind === 125 /* Method */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode, diagnostic); @@ -14647,17 +14417,17 @@ var ts; error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); } } - var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & ts.SymbolFlags.Module; + var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; for (var i = 0; i < declarations.length; i++) { var node = declarations[i]; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 178 /* InterfaceDeclaration */ || node.parent.kind === 130 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 185 /* InterfaceDeclaration */ || node.parent.kind === 134 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 175 /* FunctionDeclaration */ || node.kind === 121 /* Method */ || node.kind === 122 /* Constructor */) { + if (node.kind === 182 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -14723,7 +14493,7 @@ var ts; var symbol = node.localSymbol; if (!symbol) { symbol = getSymbolOfNode(node); - if (!(symbol.flags & ts.SymbolFlags.Export)) { + if (!(symbol.flags & 29360128 /* Export */)) { return; } } @@ -14751,14 +14521,14 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 178 /* InterfaceDeclaration */: - return 4194304 /* ExportType */; - case 181 /* ModuleDeclaration */: - return d.name.kind === 7 /* StringLiteral */ || ts.isInstantiated(d) ? 8388608 /* ExportNamespace */ | 2097152 /* ExportValue */ : 8388608 /* ExportNamespace */; - case 177 /* ClassDeclaration */: - case 180 /* EnumDeclaration */: - return 4194304 /* ExportType */ | 2097152 /* ExportValue */; - case 183 /* ImportDeclaration */: + case 185 /* InterfaceDeclaration */: + return 8388608 /* ExportType */; + case 188 /* ModuleDeclaration */: + return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */; + case 184 /* ClassDeclaration */: + case 187 /* EnumDeclaration */: + return 8388608 /* ExportType */ | 4194304 /* ExportValue */; + case 190 /* ImportDeclaration */: var result = 0; var target = resolveImport(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { @@ -14766,7 +14536,7 @@ var ts; }); return result; default: - return 2097152 /* ExportValue */; + return 4194304 /* ExportValue */; } } } @@ -14816,7 +14586,7 @@ var ts; if (!(name && name.text === "_i")) { return; } - if (node.kind === 119 /* Parameter */) { + if (node.kind === 123 /* Parameter */) { if (node.parent.body && ts.hasRestParameters(node.parent) && !ts.isInAmbientContext(node)) { error(node, ts.Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter); } @@ -14833,11 +14603,11 @@ var ts; return; } switch (current.kind) { - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 121 /* Method */: - case 145 /* ArrowFunction */: - case 122 /* Constructor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 125 /* Method */: + case 150 /* ArrowFunction */: + case 126 /* Constructor */: if (ts.hasRestParameters(current)) { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter); return; @@ -14851,13 +14621,13 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 120 /* Property */ || node.kind === 121 /* Method */ || node.kind === 123 /* GetAccessor */ || node.kind === 124 /* SetAccessor */) { + if (node.kind === 124 /* Property */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */) { return false; } if (ts.isInAmbientContext(node)) { return false; } - if (node.kind === 119 /* Parameter */ && !node.parent.body) { + if (node.kind === 123 /* Parameter */ && !node.parent.body) { return false; } return true; @@ -14872,7 +14642,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration = node.kind !== 59 /* Identifier */; + var isDeclaration = node.kind !== 63 /* Identifier */; if (isDeclaration) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -14888,12 +14658,12 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 177 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 184 /* ClassDeclaration */); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } if (enclosingClass.baseType) { - var isDeclaration = node.kind !== 59 /* Identifier */; + var isDeclaration = node.kind !== 63 /* Identifier */; if (isDeclaration) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -14906,19 +14676,19 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 181 /* ModuleDeclaration */ && !ts.isInstantiated(node)) { + if (node.kind === 188 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } - var parent = node.kind === 174 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (parent.kind === 186 /* SourceFile */ && ts.isExternalModule(parent)) { + var parent = node.kind === 181 /* VariableDeclaration */ ? node.parent.parent : node.parent; + if (parent.kind === 193 /* SourceFile */ && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, name.text, name.text); } } function checkCollisionWithConstDeclarations(node) { - if (node.initializer && (node.flags & ts.NodeFlags.BlockScoped) === 0) { + if (node.initializer && (node.flags & 6144 /* BlockScoped */) === 0) { var symbol = getSymbolOfNode(node); if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, ts.SymbolFlags.Variable, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 4096 /* Const */) { error(node, ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0, symbolToString(localDeclarationSymbol)); @@ -15015,18 +14785,18 @@ var ts; if (node.expression && !(getNodeLinks(node.expression).flags & 1 /* TypeChecked */)) { var func = ts.getContainingFunction(node); if (func) { - if (func.kind === 124 /* SetAccessor */) { + if (func.kind === 128 /* SetAccessor */) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } else { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - var checkAssignability = func.type || (func.kind === 123 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 124 /* SetAccessor */))); + var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); if (checkAssignability) { checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, undefined); } - else if (func.kind == 122 /* Constructor */) { + else if (func.kind == 126 /* Constructor */) { if (!isTypeAssignableTo(checkExpression(node.expression), returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -15155,7 +14925,7 @@ var ts; checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); var staticBaseType = getTypeOfSymbol(baseType.symbol); checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, ts.SymbolFlags.Value)) { + if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, 107455 /* Value */)) { error(node.baseType, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); } checkKindsOfPropertyMemberOverrides(type, baseType); @@ -15186,13 +14956,13 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 33554432 /* Instantiated */ ? getSymbolLinks(s).target : s; + return s.flags & 67108864 /* Instantiated */ ? getSymbolLinks(s).target : s; } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfObjectType(baseType); for (var i = 0, len = baseProperties.length; i < len; ++i) { var base = getTargetSymbol(baseProperties[i]); - if (base.flags & 268435456 /* Prototype */) { + if (base.flags & 536870912 /* Prototype */) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -15205,26 +14975,26 @@ var ts; if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { continue; } - if ((base.flags & derived.flags & 4096 /* Method */) || ((base.flags & ts.SymbolFlags.PropertyOrAccessor) && (derived.flags & ts.SymbolFlags.PropertyOrAccessor))) { + if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { continue; } var errorMessage; - if (base.flags & 4096 /* Method */) { - if (derived.flags & ts.SymbolFlags.Accessor) { + if (base.flags & 8192 /* Method */) { + if (derived.flags & 98304 /* Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - ts.Debug.assert(derived.flags & 4 /* Property */); + ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & 4 /* Property */) { - ts.Debug.assert(derived.flags & 4096 /* Method */); + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert(base.flags & ts.SymbolFlags.Accessor); - ts.Debug.assert(derived.flags & 4096 /* Method */); + ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); @@ -15232,7 +15002,7 @@ var ts; } } function isAccessor(kind) { - return kind === 123 /* GetAccessor */ || kind === 124 /* SetAccessor */; + return kind === 127 /* GetAccessor */ || kind === 128 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -15259,13 +15029,46 @@ var ts; } return true; } + function checkInheritedPropertiesAreIdentical(type, typeNode) { + if (!type.baseTypes.length || type.baseTypes.length === 1) { + return true; + } + var seen = {}; + ts.forEach(type.declaredProperties, function (p) { + seen[p.name] = { prop: p, containingType: type }; + }); + var ok = true; + for (var i = 0, len = type.baseTypes.length; i < len; ++i) { + var base = type.baseTypes[i]; + var properties = getPropertiesOfObjectType(base); + for (var j = 0, proplen = properties.length; j < proplen; ++j) { + var prop = properties[j]; + if (!ts.hasProperty(seen, prop.name)) { + seen[prop.name] = { prop: prop, containingType: base }; + } + else { + var existing = seen[prop.name]; + var isInheritedProperty = existing.containingType !== type; + if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { + ok = false; + var typeName1 = typeToString(existing.containingType); + var typeName2 = typeToString(base); + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); + addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, program.getCompilerHost().getNewLine())); + } + } + } + } + return ok; + } function checkInterfaceDeclaration(node) { checkTypeParameters(node.typeParameters); if (fullTypeCheck) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = getDeclarationOfKind(symbol, 178 /* InterfaceDeclaration */); + var firstInterfaceDecl = getDeclarationOfKind(symbol, 185 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15288,23 +15091,9 @@ var ts; } } function checkTypeAliasDeclaration(node) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); } - function getConstantValueForExpression(node) { - var isNegative = false; - if (node.kind === 146 /* PrefixOperator */) { - var unaryExpression = node; - if (unaryExpression.operator === 29 /* MinusToken */ || unaryExpression.operator === 28 /* PlusToken */) { - node = unaryExpression.operand; - isNegative = unaryExpression.operator === 29 /* MinusToken */; - } - } - if (node.kind === 6 /* NumericLiteral */) { - var literalText = node.text; - return isNegative ? -literalText : +literalText; - } - return undefined; - } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); if (!(nodeLinks.flags & 128 /* EnumValuesComputed */)) { @@ -15312,18 +15101,32 @@ var ts; var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); + var enumIsConst = ts.isConstEnumDeclaration(node); ts.forEach(node.members, function (member) { if (isNumericName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForExpression(initializer); - if (autoValue === undefined && !ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); + if (autoValue === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(autoValue)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(autoValue)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } } } - else if (ambient) { + else if (ambient && !enumIsConst) { autoValue = undefined; } if (autoValue !== undefined) { @@ -15332,6 +15135,99 @@ var ts; }); nodeLinks.flags |= 128 /* EnumValuesComputed */; } + function getConstantValueForEnumMemberInitializer(initializer, enumIsConst) { + return evalConstant(initializer); + function evalConstant(e) { + switch (e.kind) { + case 151 /* PrefixOperator */: + var value = evalConstant(e.operand); + if (value === undefined) { + return undefined; + } + switch (e.operator) { + case 32 /* PlusToken */: return value; + case 33 /* MinusToken */: return -value; + case 46 /* TildeToken */: return enumIsConst ? ~value : undefined; + } + return undefined; + case 153 /* BinaryExpression */: + if (!enumIsConst) { + return undefined; + } + var left = evalConstant(e.left); + if (left === undefined) { + return undefined; + } + var right = evalConstant(e.right); + if (right === undefined) { + return undefined; + } + switch (e.operator) { + case 43 /* BarToken */: return left | right; + case 42 /* AmpersandToken */: return left & right; + case 40 /* GreaterThanGreaterThanToken */: return left >> right; + case 41 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 39 /* LessThanLessThanToken */: return left << right; + case 44 /* CaretToken */: return left ^ right; + case 34 /* AsteriskToken */: return left * right; + case 35 /* SlashToken */: return left / right; + case 32 /* PlusToken */: return left + right; + case 33 /* MinusToken */: return left - right; + case 36 /* PercentToken */: return left % right; + } + return undefined; + case 6 /* NumericLiteral */: + return +e.text; + case 148 /* ParenExpression */: + return enumIsConst ? evalConstant(e.expression) : undefined; + case 63 /* Identifier */: + case 143 /* IndexedAccess */: + case 142 /* PropertyAccess */: + if (!enumIsConst) { + return undefined; + } + var member = initializer.parent; + var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); + var enumType; + var propertyName; + if (e.kind === 63 /* Identifier */) { + enumType = currentType; + propertyName = e.text; + } + else { + if (e.kind === 143 /* IndexedAccess */) { + if (e.index.kind !== 7 /* StringLiteral */) { + return undefined; + } + var enumType = getTypeOfNode(e.object); + propertyName = e.index.text; + } + else { + var enumType = getTypeOfNode(e.left); + propertyName = e.right.text; + } + if (enumType !== currentType) { + return undefined; + } + } + if (propertyName === undefined) { + return undefined; + } + var property = getPropertyOfObjectType(enumType, propertyName); + if (!property || !(property.flags & 8 /* EnumMember */)) { + return undefined; + } + var propertyDecl = property.valueDeclaration; + if (member === propertyDecl) { + return undefined; + } + if (!isDefinedBefore(propertyDecl, member)) { + return undefined; + } + return getNodeLinks(propertyDecl).enumMemberValue; + } + } + } } function checkEnumDeclaration(node) { if (!fullTypeCheck) { @@ -15345,9 +15241,17 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { + if (enumSymbol.declarations.length > 1) { + var enumIsConst = ts.isConstEnumDeclaration(node); + ts.forEach(enumSymbol.declarations, function (decl) { + if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); + } + }); + } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 180 /* EnumDeclaration */) { + if (declaration.kind !== 187 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -15370,7 +15274,7 @@ var ts; var declarations = symbol.declarations; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; - if ((declaration.kind === 177 /* ClassDeclaration */ || (declaration.kind === 175 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 184 /* ClassDeclaration */ || (declaration.kind === 182 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -15382,7 +15286,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - if (symbol.flags & 256 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { + if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (classOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(classOrFunc)) { @@ -15405,7 +15309,7 @@ var ts; checkSourceElement(node.body); } function getFirstIdentifier(node) { - while (node.kind === 117 /* QualifiedName */) { + while (node.kind === 121 /* QualifiedName */) { node = node.left; } return node; @@ -15418,25 +15322,25 @@ var ts; if (node.entityName) { target = resolveImport(symbol); if (target !== unknownSymbol) { - if (target.flags & ts.SymbolFlags.Value) { + if (target.flags & 107455 /* Value */) { var moduleName = getFirstIdentifier(node.entityName); - if (resolveEntityName(node, moduleName, ts.SymbolFlags.Value | ts.SymbolFlags.Namespace).flags & ts.SymbolFlags.Namespace) { + if (resolveEntityName(node, moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */) { checkExpression(node.entityName); } else { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.identifierToString(moduleName)); } } - if (target.flags & ts.SymbolFlags.Type) { + if (target.flags & 3152352 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (node.parent.kind === 186 /* SourceFile */) { + if (node.parent.kind === 193 /* SourceFile */) { target = resolveImport(symbol); } - else if (node.parent.kind === 182 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { + else if (node.parent.kind === 189 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { if (isExternalModuleNameRelative(node.externalModuleName.text)) { error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); target = unknownSymbol; @@ -15450,7 +15354,7 @@ var ts; } } if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & ts.SymbolFlags.Value ? ts.SymbolFlags.Value : 0) | (symbol.flags & ts.SymbolFlags.Type ? ts.SymbolFlags.Type : 0) | (symbol.flags & ts.SymbolFlags.Namespace ? ts.SymbolFlags.Namespace : 0); + var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | (symbol.flags & 3152352 /* Type */ ? 3152352 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { error(node, ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0, symbolToString(symbol)); } @@ -15458,7 +15362,7 @@ var ts; } function checkExportAssignment(node) { var container = node.parent; - if (container.kind !== 186 /* SourceFile */) { + if (container.kind !== 193 /* SourceFile */) { container = container.parent; } checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container)); @@ -15467,150 +15371,151 @@ var ts; if (!node) return; switch (node.kind) { - case 118 /* TypeParameter */: + case 122 /* TypeParameter */: return checkTypeParameter(node); - case 119 /* Parameter */: + case 123 /* Parameter */: return checkParameter(node); - case 120 /* Property */: + case 124 /* Property */: return checkPropertyDeclaration(node); - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: return checkSignatureDeclaration(node); - case 121 /* Method */: + case 125 /* Method */: return checkMethodDeclaration(node); - case 122 /* Constructor */: + case 126 /* Constructor */: return checkConstructorDeclaration(node); - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return checkAccessorDeclaration(node); - case 128 /* TypeReference */: + case 132 /* TypeReference */: return checkTypeReference(node); - case 129 /* TypeQuery */: + case 133 /* TypeQuery */: return checkTypeQuery(node); - case 130 /* TypeLiteral */: + case 134 /* TypeLiteral */: return checkTypeLiteral(node); - case 131 /* ArrayType */: + case 135 /* ArrayType */: return checkArrayType(node); - case 132 /* TupleType */: + case 136 /* TupleType */: return checkTupleType(node); - case 133 /* UnionType */: + case 137 /* UnionType */: return checkUnionType(node); - case 134 /* ParenType */: + case 138 /* ParenType */: return checkSourceElement(node.type); - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 151 /* Block */: + case 158 /* Block */: return checkBlock(node); - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: return checkBody(node); - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return checkVariableStatement(node); - case 154 /* ExpressionStatement */: + case 161 /* ExpressionStatement */: return checkExpressionStatement(node); - case 155 /* IfStatement */: + case 162 /* IfStatement */: return checkIfStatement(node); - case 156 /* DoStatement */: + case 163 /* DoStatement */: return checkDoStatement(node); - case 157 /* WhileStatement */: + case 164 /* WhileStatement */: return checkWhileStatement(node); - case 158 /* ForStatement */: + case 165 /* ForStatement */: return checkForStatement(node); - case 159 /* ForInStatement */: + case 166 /* ForInStatement */: return checkForInStatement(node); - case 160 /* ContinueStatement */: - case 161 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 168 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return checkReturnStatement(node); - case 163 /* WithStatement */: + case 170 /* WithStatement */: return checkWithStatement(node); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return checkSwitchStatement(node); - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return checkLabeledStatement(node); - case 168 /* ThrowStatement */: + case 175 /* ThrowStatement */: return checkThrowStatement(node); - case 169 /* TryStatement */: + case 176 /* TryStatement */: return checkTryStatement(node); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: return ts.Debug.fail("Checker encountered variable declaration"); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return checkClassDeclaration(node); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 179 /* TypeAliasDeclaration */: + case 186 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return checkImportDeclaration(node); - case 184 /* ExportAssignment */: + case 191 /* ExportAssignment */: return checkExportAssignment(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionBody(node); break; - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 175 /* FunctionDeclaration */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 182 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 163 /* WithStatement */: + case 170 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; - case 119 /* Parameter */: - case 120 /* Property */: - case 135 /* ArrayLiteral */: - case 136 /* ObjectLiteral */: - case 137 /* PropertyAssignment */: - case 138 /* PropertyAccess */: - case 139 /* IndexedAccess */: - case 140 /* CallExpression */: - case 141 /* NewExpression */: - case 142 /* TypeAssertion */: - case 143 /* ParenExpression */: - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: - case 148 /* BinaryExpression */: - case 149 /* ConditionalExpression */: - case 151 /* Block */: - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: - case 152 /* VariableStatement */: - case 154 /* ExpressionStatement */: - case 155 /* IfStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 160 /* ContinueStatement */: - case 161 /* BreakStatement */: - case 162 /* ReturnStatement */: - case 164 /* SwitchStatement */: - case 165 /* CaseClause */: - case 166 /* DefaultClause */: - case 167 /* LabeledStatement */: - case 168 /* ThrowStatement */: - case 169 /* TryStatement */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: - case 174 /* VariableDeclaration */: - case 177 /* ClassDeclaration */: - case 180 /* EnumDeclaration */: - case 185 /* EnumMember */: - case 186 /* SourceFile */: + case 123 /* Parameter */: + case 124 /* Property */: + case 139 /* ArrayLiteral */: + case 140 /* ObjectLiteral */: + case 141 /* PropertyAssignment */: + case 142 /* PropertyAccess */: + case 143 /* IndexedAccess */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: + case 146 /* TaggedTemplateExpression */: + case 147 /* TypeAssertion */: + case 148 /* ParenExpression */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: + case 153 /* BinaryExpression */: + case 154 /* ConditionalExpression */: + case 158 /* Block */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: + case 159 /* VariableStatement */: + case 161 /* ExpressionStatement */: + case 162 /* IfStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 167 /* ContinueStatement */: + case 168 /* BreakStatement */: + case 169 /* ReturnStatement */: + case 171 /* SwitchStatement */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: + case 174 /* LabeledStatement */: + case 175 /* ThrowStatement */: + case 176 /* TryStatement */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: + case 181 /* VariableDeclaration */: + case 184 /* ClassDeclaration */: + case 187 /* EnumDeclaration */: + case 192 /* EnumMember */: + case 193 /* SourceFile */: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -15627,7 +15532,7 @@ var ts; checkBody(node); if (ts.isExternalModule(node)) { var symbol = getExportAssignmentSymbol(node.symbol); - if (symbol && symbol.flags & 16777216 /* Import */) { + if (symbol && symbol.flags & 33554432 /* Import */) { getSymbolLinks(symbol).referenced = true; } } @@ -15681,7 +15586,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 163 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 170 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -15717,27 +15622,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 181 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & ts.SymbolFlags.ModuleMember); + case 188 /* ModuleDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */); break; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & ts.SymbolFlags.Type); + copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */); } break; - case 144 /* FunctionExpression */: + case 149 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } break; - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: if (location.variable.text) { copySymbol(location.symbol, meaning); } @@ -15750,100 +15655,102 @@ var ts; return ts.mapToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 59 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; + return name.kind == 63 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 118 /* TypeParameter */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 180 /* EnumDeclaration */: + case 122 /* TypeParameter */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 187 /* EnumDeclaration */: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 117 /* QualifiedName */) + while (node.parent && node.parent.kind === 121 /* QualifiedName */) node = node.parent; - return node.parent && node.parent.kind === 128 /* TypeReference */; + return node.parent && node.parent.kind === 132 /* TypeReference */; } function isTypeNode(node) { - if (ts.SyntaxKind.FirstTypeNode <= node.kind && node.kind <= ts.SyntaxKind.LastTypeNode) { + if (132 /* FirstTypeNode */ <= node.kind && node.kind <= 138 /* LastTypeNode */) { return true; } switch (node.kind) { - case 105 /* AnyKeyword */: - case 112 /* NumberKeyword */: - case 114 /* StringKeyword */: - case 106 /* BooleanKeyword */: + case 109 /* AnyKeyword */: + case 116 /* NumberKeyword */: + case 118 /* StringKeyword */: + case 110 /* BooleanKeyword */: return true; - case 93 /* VoidKeyword */: - return node.parent.kind !== 146 /* PrefixOperator */; + case 97 /* VoidKeyword */: + return node.parent.kind !== 151 /* PrefixOperator */; case 7 /* StringLiteral */: - return node.parent.kind === 119 /* Parameter */; - case 59 /* Identifier */: - if (node.parent.kind === 117 /* QualifiedName */) { + return node.parent.kind === 123 /* Parameter */; + case 63 /* Identifier */: + if (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; } - case 117 /* QualifiedName */: - ts.Debug.assert(node.kind === 59 /* Identifier */ || node.kind === 117 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + case 121 /* QualifiedName */: + ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var parent = node.parent; - if (parent.kind === 129 /* TypeQuery */) { + if (parent.kind === 133 /* TypeQuery */) { return false; } - if (ts.SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= ts.SyntaxKind.LastTypeNode) { + if (132 /* FirstTypeNode */ <= parent.kind && parent.kind <= 138 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 118 /* TypeParameter */: + case 122 /* TypeParameter */: return node === parent.constraint; - case 120 /* Property */: - case 119 /* Parameter */: - case 174 /* VariableDeclaration */: + case 124 /* Property */: + case 123 /* Parameter */: + case 181 /* VariableDeclaration */: return node === parent.type; - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 122 /* Constructor */: - case 121 /* Method */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 126 /* Constructor */: + case 125 /* Method */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return node === parent.type; - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: return node === parent.type; - case 142 /* TypeAssertion */: + case 147 /* TypeAssertion */: return node === parent.type; - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return parent.typeArguments && parent.typeArguments.indexOf(node) >= 0; + case 146 /* TaggedTemplateExpression */: + return false; } } return false; } function isInRightSideOfImportOrExportAssignment(node) { - while (node.parent.kind === 117 /* QualifiedName */) { + while (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; } - if (node.parent.kind === 183 /* ImportDeclaration */) { + if (node.parent.kind === 190 /* ImportDeclaration */) { return node.parent.entityName === node; } - if (node.parent.kind === 184 /* ExportAssignment */) { + if (node.parent.kind === 191 /* ExportAssignment */) { return node.parent.exportName === node; } return false; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 117 /* QualifiedName */ || node.parent.kind === 138 /* PropertyAccess */) && node.parent.right === node; + return (node.parent.kind === 121 /* QualifiedName */ || node.parent.kind === 142 /* PropertyAccess */) && node.parent.right === node; } function getSymbolOfEntityName(entityName) { if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 184 /* ExportAssignment */) { - return resolveEntityName(entityName.parent.parent, entityName, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace | 16777216 /* Import */); + if (entityName.parent.kind === 191 /* ExportAssignment */) { + return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */); } if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImport(entityName); @@ -15852,11 +15759,11 @@ var ts; entityName = entityName.parent; } if (ts.isExpression(entityName)) { - if (entityName.kind === 59 /* Identifier */) { - var meaning = ts.SymbolFlags.Value | 16777216 /* Import */; + if (entityName.kind === 63 /* Identifier */) { + var meaning = 107455 /* Value */ | 33554432 /* Import */; return resolveEntityName(entityName, entityName, meaning); } - else if (entityName.kind === 117 /* QualifiedName */ || entityName.kind === 138 /* PropertyAccess */) { + else if (entityName.kind === 121 /* QualifiedName */ || entityName.kind === 142 /* PropertyAccess */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccess(entityName); @@ -15868,8 +15775,8 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 128 /* TypeReference */ ? ts.SymbolFlags.Type : ts.SymbolFlags.Namespace; - meaning |= 16777216 /* Import */; + var meaning = entityName.parent.kind === 132 /* TypeReference */ ? 3152352 /* Type */ : 1536 /* Namespace */; + meaning |= 33554432 /* Import */; return resolveEntityName(entityName, entityName, meaning); } return undefined; @@ -15881,32 +15788,32 @@ var ts; if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 59 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 184 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node); + if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 191 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node); } switch (node.kind) { - case 59 /* Identifier */: - case 138 /* PropertyAccess */: - case 117 /* QualifiedName */: + case 63 /* Identifier */: + case 142 /* PropertyAccess */: + case 121 /* QualifiedName */: return getSymbolOfEntityName(node); - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 107 /* ConstructorKeyword */: + case 111 /* ConstructorKeyword */: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 122 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 126 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; case 7 /* StringLiteral */: - if (node.parent.kind === 183 /* ImportDeclaration */ && node.parent.externalModuleName === node) { + if (node.parent.kind === 190 /* ImportDeclaration */ && node.parent.externalModuleName === node) { var importSymbol = getSymbolOfNode(node.parent); var moduleType = getTypeOfSymbol(importSymbol); return moduleType ? moduleType.symbol : undefined; } case 6 /* NumericLiteral */: - if (node.parent.kind == 139 /* IndexedAccess */ && node.parent.index === node) { + if (node.parent.kind == 143 /* IndexedAccess */ && node.parent.index === node) { var objectType = checkExpression(node.parent.object); if (objectType === unknownType) return undefined; @@ -15971,7 +15878,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 536870912 /* UnionProperty */) { + if (symbol.flags & 1073741824 /* UnionProperty */) { var symbols = []; var name = symbol.name; ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { @@ -15979,7 +15886,7 @@ var ts; }); return symbols; } - else if (symbol.flags & 134217728 /* Transient */) { + else if (symbol.flags & 268435456 /* Transient */) { var target = getSymbolLinks(symbol).target; if (target) { return [target]; @@ -15988,7 +15895,7 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 256 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 186 /* SourceFile */; + return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 193 /* SourceFile */; } function isNodeDescendentOf(node, ancestor) { while (node) { @@ -16000,7 +15907,7 @@ var ts; } function isUniqueLocalName(name, container) { for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name) && node.locals[name].flags & (ts.SymbolFlags.Value | 2097152 /* ExportValue */)) { + if (node.locals && ts.hasProperty(node.locals, name) && node.locals[name].flags & (107455 /* Value */ | 4194304 /* ExportValue */)) { return false; } } @@ -16021,7 +15928,7 @@ var ts; function getLocalNameForSymbol(symbol, location) { var node = location; while (node) { - if ((node.kind === 181 /* ModuleDeclaration */ || node.kind === 180 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { + if ((node.kind === 188 /* ModuleDeclaration */ || node.kind === 187 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { return getLocalNameOfContainer(node); } node = node.parent; @@ -16032,7 +15939,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & ts.SymbolFlags.ExportHasLocal)) { + if (symbol !== exportSymbol && !(exportSymbol.flags & 944 /* ExportHasLocal */)) { symbol = exportSymbol; } if (symbol.parent) { @@ -16042,15 +15949,14 @@ var ts; } function getExportAssignmentName(node) { var symbol = getExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbolIsValue(symbol) ? symbolToString(symbol) : undefined; + return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined; } - function isTopLevelValueImportedViaEntityName(node) { - if (node.parent.kind !== 186 /* SourceFile */ || !node.entityName) { + function isTopLevelValueImportWithEntityName(node) { + if (node.parent.kind !== 193 /* SourceFile */ || !node.entityName) { return false; } var symbol = getSymbolOfNode(node); - var target = resolveImport(symbol); - return target !== unknownSymbol && ((target.flags & ts.SymbolFlags.Value) !== 0); + return isImportResolvedToValue(getSymbolOfNode(node)); } function hasSemanticErrors() { return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0; @@ -16058,16 +15964,20 @@ var ts; function hasEarlyErrors(sourceFile) { return ts.forEach(getDiagnostics(sourceFile), function (d) { return d.isEarly; }); } + function isImportResolvedToValue(symbol) { + var target = resolveImport(symbol); + return target !== unknownSymbol && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); + } + function isConstEnumOrConstEnumOnlyModule(s) { + return isConstEnumSymbol(s) || s.constEnumOnlyModule; + } function isReferencedImportDeclaration(node) { var symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { return true; } if (node.flags & 1 /* Export */) { - var target = resolveImport(symbol); - if (target !== unknownSymbol && target.flags & ts.SymbolFlags.Value) { - return true; - } + return isImportResolvedToValue(symbol); } return false; } @@ -16091,7 +16001,7 @@ var ts; if (symbol && (symbol.flags & 8 /* EnumMember */)) { var declaration = symbol.valueDeclaration; var constantValue; - if (declaration.kind === 185 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { + if (declaration.kind === 192 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { return constantValue; } } @@ -16099,7 +16009,7 @@ var ts; } function writeTypeAtLocation(location, enclosingDeclaration, flags, writer) { var symbol = getSymbolOfNode(location); - var type = symbol && !(symbol.flags & 1024 /* TypeLiteral */) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); + var type = symbol && !(symbol.flags & 2048 /* TypeLiteral */) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -16115,7 +16025,7 @@ var ts; isReferencedImportDeclaration: isReferencedImportDeclaration, getNodeCheckFlags: getNodeCheckFlags, getEnumMemberValue: getEnumMemberValue, - isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName, + isTopLevelValueImportWithEntityName: isTopLevelValueImportWithEntityName, hasSemanticErrors: hasSemanticErrors, hasEarlyErrors: hasEarlyErrors, isDeclarationVisible: isDeclarationVisible, @@ -16273,6 +16183,11 @@ var ts; shortName: "w", type: "boolean", description: ts.Diagnostics.Watch_input_files + }, + { + name: "preserveConstEnums", + type: "boolean", + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code } ]; var shortOptionNames = {}; diff --git a/bin/typescriptServices.js b/bin/typescriptServices.js index 8aebc0f642a..ea97ea9ea75 100644 --- a/bin/typescriptServices.js +++ b/bin/typescriptServices.js @@ -134,7 +134,8 @@ var ts; const_declarations_must_be_initialized: { code: 1155, category: 1 /* Error */, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: 1 /* Error */, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: 1 /* Error */, key: "'let' declarations can only be declared inside a block." }, - Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead: { code: 1158, category: 1 /* Error */, key: "Aliased type cannot be an object type literal. Use an interface declaration instead." }, + Invalid_template_literal_expected: { code: 1158, category: 1 /* Error */, key: "Invalid template literal; expected '}'" }, + Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: 1 /* Error */, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Duplicate_identifier_0: { code: 2300, category: 1 /* Error */, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: 1 /* Error */, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: 1 /* Error */, key: "Static members cannot reference class type parameters." }, @@ -282,6 +283,7 @@ var ts; The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: 1 /* Error */, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: 1 /* Error */, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: 1 /* Error */, key: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: 1 /* Error */, key: "Type alias name cannot be '{0}'" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: 1 /* Error */, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: 1 /* Error */, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, @@ -364,6 +366,12 @@ var ts; Exported_type_alias_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4079, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2: { code: 4080, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: 1 /* Error */, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: 1 /* Error */, key: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: 1 /* Error */, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 4084, category: 1 /* Error */, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: 1 /* Error */, key: "Index expression arguments in 'const' enums must be of type 'string'." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: 1 /* Error */, key: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: 1 /* Error */, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: 1 /* Error */, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: 1 /* Error */, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: 1 /* Error */, key: "Cannot read file '{0}': {1}" }, @@ -378,6 +386,7 @@ var ts; Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: 2 /* Message */, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, Watch_input_files: { code: 6005, category: 2 /* Message */, key: "Watch input files." }, Redirect_output_structure_to_the_directory: { code: 6006, category: 2 /* Message */, key: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: 2 /* Message */, key: "Do not erase const enum declarations in generated code." }, Do_not_emit_comments_to_output: { code: 6009, category: 2 /* Message */, key: "Do not emit comments to output." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: 2 /* Message */, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: 2 /* Message */, key: "Specify module code generation: 'commonjs' or 'amd'" }, @@ -431,112 +440,112 @@ var ts; var ts; (function (ts) { var textToToken = { - "any": 105 /* AnyKeyword */, - "boolean": 106 /* BooleanKeyword */, - "break": 60 /* BreakKeyword */, - "case": 61 /* CaseKeyword */, - "catch": 62 /* CatchKeyword */, - "class": 63 /* ClassKeyword */, - "continue": 65 /* ContinueKeyword */, - "const": 64 /* ConstKeyword */, - "constructor": 107 /* ConstructorKeyword */, - "debugger": 66 /* DebuggerKeyword */, - "declare": 108 /* DeclareKeyword */, - "default": 67 /* DefaultKeyword */, - "delete": 68 /* DeleteKeyword */, - "do": 69 /* DoKeyword */, - "else": 70 /* ElseKeyword */, - "enum": 71 /* EnumKeyword */, - "export": 72 /* ExportKeyword */, - "extends": 73 /* ExtendsKeyword */, - "false": 74 /* FalseKeyword */, - "finally": 75 /* FinallyKeyword */, - "for": 76 /* ForKeyword */, - "function": 77 /* FunctionKeyword */, - "get": 109 /* GetKeyword */, - "if": 78 /* IfKeyword */, - "implements": 96 /* ImplementsKeyword */, - "import": 79 /* ImportKeyword */, - "in": 80 /* InKeyword */, - "instanceof": 81 /* InstanceOfKeyword */, - "interface": 97 /* InterfaceKeyword */, - "let": 98 /* LetKeyword */, - "module": 110 /* ModuleKeyword */, - "new": 82 /* NewKeyword */, - "null": 83 /* NullKeyword */, - "number": 112 /* NumberKeyword */, - "package": 99 /* PackageKeyword */, - "private": 100 /* PrivateKeyword */, - "protected": 101 /* ProtectedKeyword */, - "public": 102 /* PublicKeyword */, - "require": 111 /* RequireKeyword */, - "return": 84 /* ReturnKeyword */, - "set": 113 /* SetKeyword */, - "static": 103 /* StaticKeyword */, - "string": 114 /* StringKeyword */, - "super": 85 /* SuperKeyword */, - "switch": 86 /* SwitchKeyword */, - "this": 87 /* ThisKeyword */, - "throw": 88 /* ThrowKeyword */, - "true": 89 /* TrueKeyword */, - "try": 90 /* TryKeyword */, - "type": 115 /* TypeKeyword */, - "typeof": 91 /* TypeOfKeyword */, - "var": 92 /* VarKeyword */, - "void": 93 /* VoidKeyword */, - "while": 94 /* WhileKeyword */, - "with": 95 /* WithKeyword */, - "yield": 104 /* YieldKeyword */, - "{": 9 /* OpenBraceToken */, - "}": 10 /* CloseBraceToken */, - "(": 11 /* OpenParenToken */, - ")": 12 /* CloseParenToken */, - "[": 13 /* OpenBracketToken */, - "]": 14 /* CloseBracketToken */, - ".": 15 /* DotToken */, - "...": 16 /* DotDotDotToken */, - ";": 17 /* SemicolonToken */, - ",": 18 /* CommaToken */, - "<": 19 /* LessThanToken */, - ">": 20 /* GreaterThanToken */, - "<=": 21 /* LessThanEqualsToken */, - ">=": 22 /* GreaterThanEqualsToken */, - "==": 23 /* EqualsEqualsToken */, - "!=": 24 /* ExclamationEqualsToken */, - "===": 25 /* EqualsEqualsEqualsToken */, - "!==": 26 /* ExclamationEqualsEqualsToken */, - "=>": 27 /* EqualsGreaterThanToken */, - "+": 28 /* PlusToken */, - "-": 29 /* MinusToken */, - "*": 30 /* AsteriskToken */, - "/": 31 /* SlashToken */, - "%": 32 /* PercentToken */, - "++": 33 /* PlusPlusToken */, - "--": 34 /* MinusMinusToken */, - "<<": 35 /* LessThanLessThanToken */, - ">>": 36 /* GreaterThanGreaterThanToken */, - ">>>": 37 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 38 /* AmpersandToken */, - "|": 39 /* BarToken */, - "^": 40 /* CaretToken */, - "!": 41 /* ExclamationToken */, - "~": 42 /* TildeToken */, - "&&": 43 /* AmpersandAmpersandToken */, - "||": 44 /* BarBarToken */, - "?": 45 /* QuestionToken */, - ":": 46 /* ColonToken */, - "=": 47 /* EqualsToken */, - "+=": 48 /* PlusEqualsToken */, - "-=": 49 /* MinusEqualsToken */, - "*=": 50 /* AsteriskEqualsToken */, - "/=": 51 /* SlashEqualsToken */, - "%=": 52 /* PercentEqualsToken */, - "<<=": 53 /* LessThanLessThanEqualsToken */, - ">>=": 54 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 55 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 56 /* AmpersandEqualsToken */, - "|=": 57 /* BarEqualsToken */, - "^=": 58 /* CaretEqualsToken */ + "any": 109 /* AnyKeyword */, + "boolean": 110 /* BooleanKeyword */, + "break": 64 /* BreakKeyword */, + "case": 65 /* CaseKeyword */, + "catch": 66 /* CatchKeyword */, + "class": 67 /* ClassKeyword */, + "continue": 69 /* ContinueKeyword */, + "const": 68 /* ConstKeyword */, + "constructor": 111 /* ConstructorKeyword */, + "debugger": 70 /* DebuggerKeyword */, + "declare": 112 /* DeclareKeyword */, + "default": 71 /* DefaultKeyword */, + "delete": 72 /* DeleteKeyword */, + "do": 73 /* DoKeyword */, + "else": 74 /* ElseKeyword */, + "enum": 75 /* EnumKeyword */, + "export": 76 /* ExportKeyword */, + "extends": 77 /* ExtendsKeyword */, + "false": 78 /* FalseKeyword */, + "finally": 79 /* FinallyKeyword */, + "for": 80 /* ForKeyword */, + "function": 81 /* FunctionKeyword */, + "get": 113 /* GetKeyword */, + "if": 82 /* IfKeyword */, + "implements": 100 /* ImplementsKeyword */, + "import": 83 /* ImportKeyword */, + "in": 84 /* InKeyword */, + "instanceof": 85 /* InstanceOfKeyword */, + "interface": 101 /* InterfaceKeyword */, + "let": 102 /* LetKeyword */, + "module": 114 /* ModuleKeyword */, + "new": 86 /* NewKeyword */, + "null": 87 /* NullKeyword */, + "number": 116 /* NumberKeyword */, + "package": 103 /* PackageKeyword */, + "private": 104 /* PrivateKeyword */, + "protected": 105 /* ProtectedKeyword */, + "public": 106 /* PublicKeyword */, + "require": 115 /* RequireKeyword */, + "return": 88 /* ReturnKeyword */, + "set": 117 /* SetKeyword */, + "static": 107 /* StaticKeyword */, + "string": 118 /* StringKeyword */, + "super": 89 /* SuperKeyword */, + "switch": 90 /* SwitchKeyword */, + "this": 91 /* ThisKeyword */, + "throw": 92 /* ThrowKeyword */, + "true": 93 /* TrueKeyword */, + "try": 94 /* TryKeyword */, + "type": 119 /* TypeKeyword */, + "typeof": 95 /* TypeOfKeyword */, + "var": 96 /* VarKeyword */, + "void": 97 /* VoidKeyword */, + "while": 98 /* WhileKeyword */, + "with": 99 /* WithKeyword */, + "yield": 108 /* YieldKeyword */, + "{": 13 /* OpenBraceToken */, + "}": 14 /* CloseBraceToken */, + "(": 15 /* OpenParenToken */, + ")": 16 /* CloseParenToken */, + "[": 17 /* OpenBracketToken */, + "]": 18 /* CloseBracketToken */, + ".": 19 /* DotToken */, + "...": 20 /* DotDotDotToken */, + ";": 21 /* SemicolonToken */, + ",": 22 /* CommaToken */, + "<": 23 /* LessThanToken */, + ">": 24 /* GreaterThanToken */, + "<=": 25 /* LessThanEqualsToken */, + ">=": 26 /* GreaterThanEqualsToken */, + "==": 27 /* EqualsEqualsToken */, + "!=": 28 /* ExclamationEqualsToken */, + "===": 29 /* EqualsEqualsEqualsToken */, + "!==": 30 /* ExclamationEqualsEqualsToken */, + "=>": 31 /* EqualsGreaterThanToken */, + "+": 32 /* PlusToken */, + "-": 33 /* MinusToken */, + "*": 34 /* AsteriskToken */, + "/": 35 /* SlashToken */, + "%": 36 /* PercentToken */, + "++": 37 /* PlusPlusToken */, + "--": 38 /* MinusMinusToken */, + "<<": 39 /* LessThanLessThanToken */, + ">>": 40 /* GreaterThanGreaterThanToken */, + ">>>": 41 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 42 /* AmpersandToken */, + "|": 43 /* BarToken */, + "^": 44 /* CaretToken */, + "!": 45 /* ExclamationToken */, + "~": 46 /* TildeToken */, + "&&": 47 /* AmpersandAmpersandToken */, + "||": 48 /* BarBarToken */, + "?": 49 /* QuestionToken */, + ":": 50 /* ColonToken */, + "=": 51 /* EqualsToken */, + "+=": 52 /* PlusEqualsToken */, + "-=": 53 /* MinusEqualsToken */, + "*=": 54 /* AsteriskEqualsToken */, + "/=": 55 /* SlashEqualsToken */, + "%=": 56 /* PercentEqualsToken */, + "<<=": 57 /* LessThanLessThanEqualsToken */, + ">>=": 58 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 60 /* AmpersandEqualsToken */, + "|=": 61 /* BarEqualsToken */, + "^=": 62 /* CaretEqualsToken */ }; var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -838,10 +847,10 @@ var ts; } return +(text.substring(start, pos)); } - function scanHexDigits(count, exact) { + function scanHexDigits(count, mustMatchCount) { var digits = 0; var value = 0; - while (digits < count || !exact) { + while (digits < count || !mustMatchCount) { var ch = text.charCodeAt(pos); if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) { value = value * 16 + ch - 48 /* _0 */; @@ -881,61 +890,7 @@ var ts; } if (ch === 92 /* backslash */) { result += text.substring(start, pos); - pos++; - if (pos >= len) { - error(ts.Diagnostics.Unexpected_end_of_text); - break; - } - ch = text.charCodeAt(pos++); - switch (ch) { - case 48 /* _0 */: - result += "\0"; - break; - case 98 /* b */: - result += "\b"; - break; - case 116 /* t */: - result += "\t"; - break; - case 110 /* n */: - result += "\n"; - break; - case 118 /* v */: - result += "\v"; - break; - case 102 /* f */: - result += "\f"; - break; - case 114 /* r */: - result += "\r"; - break; - case 39 /* singleQuote */: - result += "\'"; - break; - case 34 /* doubleQuote */: - result += "\""; - break; - case 120 /* x */: - case 117 /* u */: - var ch = scanHexDigits(ch === 120 /* x */ ? 2 : 4, true); - if (ch >= 0) { - result += String.fromCharCode(ch); - } - else { - error(ts.Diagnostics.Hexadecimal_digit_expected); - } - break; - case 13 /* carriageReturn */: - if (pos < len && text.charCodeAt(pos) === 10 /* lineFeed */) - pos++; - break; - case 10 /* lineFeed */: - case 8232 /* lineSeparator */: - case 8233 /* paragraphSeparator */: - break; - default: - result += String.fromCharCode(ch); - } + result += scanEscapeSequence(); start = pos; continue; } @@ -948,6 +903,102 @@ var ts; } return result; } + function scanTemplateAndSetTokenValue() { + var startedWithBacktick = text.charCodeAt(pos) === 96 /* backtick */; + pos++; + var start = pos; + var contents = ""; + var resultingToken; + while (true) { + if (pos >= len) { + contents += text.substring(start, pos); + error(ts.Diagnostics.Unexpected_end_of_text); + resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; + break; + } + var currChar = text.charCodeAt(pos); + if (currChar === 96 /* backtick */) { + contents += text.substring(start, pos); + pos++; + resultingToken = startedWithBacktick ? 9 /* NoSubstitutionTemplateLiteral */ : 12 /* TemplateTail */; + break; + } + if (currChar === 36 /* $ */ && pos + 1 < len && text.charCodeAt(pos + 1) === 123 /* openBrace */) { + contents += text.substring(start, pos); + pos += 2; + resultingToken = startedWithBacktick ? 10 /* TemplateHead */ : 11 /* TemplateMiddle */; + break; + } + if (currChar === 92 /* backslash */) { + contents += text.substring(start, pos); + contents += scanEscapeSequence(); + start = pos; + continue; + } + if (currChar === 13 /* carriageReturn */) { + contents += text.substring(start, pos); + if (pos + 1 < len && text.charCodeAt(pos + 1) === 10 /* lineFeed */) { + pos++; + } + pos++; + contents += "\n"; + start = pos; + continue; + } + pos++; + } + ts.Debug.assert(resultingToken !== undefined); + tokenValue = contents; + return resultingToken; + } + function scanEscapeSequence() { + pos++; + if (pos >= len) { + error(ts.Diagnostics.Unexpected_end_of_text); + return ""; + } + var ch = text.charCodeAt(pos++); + switch (ch) { + case 48 /* _0 */: + return "\0"; + case 98 /* b */: + return "\b"; + case 116 /* t */: + return "\t"; + case 110 /* n */: + return "\n"; + case 118 /* v */: + return "\v"; + case 102 /* f */: + return "\f"; + case 114 /* r */: + return "\r"; + case 39 /* singleQuote */: + return "\'"; + case 34 /* doubleQuote */: + return "\""; + case 120 /* x */: + case 117 /* u */: + var ch = scanHexDigits(ch === 120 /* x */ ? 2 : 4, true); + if (ch >= 0) { + return String.fromCharCode(ch); + } + else { + error(ts.Diagnostics.Hexadecimal_digit_expected); + return ""; + } + case 13 /* carriageReturn */: + if (pos < len && text.charCodeAt(pos) === 10 /* lineFeed */) { + pos++; + } + case 10 /* lineFeed */: + case 8232 /* lineSeparator */: + case 8233 /* paragraphSeparator */: + return ""; + default: + return String.fromCharCode(ch); + } + } function peekUnicodeEscape() { if (pos + 5 < len && text.charCodeAt(pos + 1) === 117 /* u */) { var start = pos; @@ -991,7 +1042,7 @@ var ts; return token = textToToken[tokenValue]; } } - return token = 59 /* Identifier */; + return token = 63 /* Identifier */; } function scan() { startPos = pos; @@ -1036,64 +1087,66 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 26 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 30 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 24 /* ExclamationEqualsToken */; + return pos += 2, token = 28 /* ExclamationEqualsToken */; } - return pos++, token = 41 /* ExclamationToken */; + return pos++, token = 45 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); return token = 7 /* StringLiteral */; + case 96 /* backtick */: + return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 52 /* PercentEqualsToken */; + return pos += 2, token = 56 /* PercentEqualsToken */; } - return pos++, token = 32 /* PercentToken */; + return pos++, token = 36 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 43 /* AmpersandAmpersandToken */; + return pos += 2, token = 47 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 56 /* AmpersandEqualsToken */; + return pos += 2, token = 60 /* AmpersandEqualsToken */; } - return pos++, token = 38 /* AmpersandToken */; + return pos++, token = 42 /* AmpersandToken */; case 40 /* openParen */: - return pos++, token = 11 /* OpenParenToken */; + return pos++, token = 15 /* OpenParenToken */; case 41 /* closeParen */: - return pos++, token = 12 /* CloseParenToken */; + return pos++, token = 16 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 50 /* AsteriskEqualsToken */; + return pos += 2, token = 54 /* AsteriskEqualsToken */; } - return pos++, token = 30 /* AsteriskToken */; + return pos++, token = 34 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 33 /* PlusPlusToken */; + return pos += 2, token = 37 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 48 /* PlusEqualsToken */; + return pos += 2, token = 52 /* PlusEqualsToken */; } - return pos++, token = 28 /* PlusToken */; + return pos++, token = 32 /* PlusToken */; case 44 /* comma */: - return pos++, token = 18 /* CommaToken */; + return pos++, token = 22 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 34 /* MinusMinusToken */; + return pos += 2, token = 38 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 49 /* MinusEqualsToken */; + return pos += 2, token = 53 /* MinusEqualsToken */; } - return pos++, token = 29 /* MinusToken */; + return pos++, token = 33 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanNumber(); return token = 6 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 16 /* DotDotDotToken */; + return pos += 3, token = 20 /* DotDotDotToken */; } - return pos++, token = 15 /* DotToken */; + return pos++, token = 19 /* DotToken */; case 47 /* slash */: if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; @@ -1142,9 +1195,9 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 51 /* SlashEqualsToken */; + return pos += 2, token = 55 /* SlashEqualsToken */; } - return pos++, token = 31 /* SlashToken */; + return pos++, token = 35 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < len && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -1172,58 +1225,58 @@ var ts; tokenValue = "" + scanNumber(); return token = 6 /* NumericLiteral */; case 58 /* colon */: - return pos++, token = 46 /* ColonToken */; + return pos++, token = 50 /* ColonToken */; case 59 /* semicolon */: - return pos++, token = 17 /* SemicolonToken */; + return pos++, token = 21 /* SemicolonToken */; case 60 /* lessThan */: if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 53 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 57 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 35 /* LessThanLessThanToken */; + return pos += 2, token = 39 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 21 /* LessThanEqualsToken */; + return pos += 2, token = 25 /* LessThanEqualsToken */; } - return pos++, token = 19 /* LessThanToken */; + return pos++, token = 23 /* LessThanToken */; case 61 /* equals */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 25 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 29 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 23 /* EqualsEqualsToken */; + return pos += 2, token = 27 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 27 /* EqualsGreaterThanToken */; + return pos += 2, token = 31 /* EqualsGreaterThanToken */; } - return pos++, token = 47 /* EqualsToken */; + return pos++, token = 51 /* EqualsToken */; case 62 /* greaterThan */: - return pos++, token = 20 /* GreaterThanToken */; + return pos++, token = 24 /* GreaterThanToken */; case 63 /* question */: - return pos++, token = 45 /* QuestionToken */; + return pos++, token = 49 /* QuestionToken */; case 91 /* openBracket */: - return pos++, token = 13 /* OpenBracketToken */; + return pos++, token = 17 /* OpenBracketToken */; case 93 /* closeBracket */: - return pos++, token = 14 /* CloseBracketToken */; + return pos++, token = 18 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* CaretEqualsToken */; + return pos += 2, token = 62 /* CaretEqualsToken */; } - return pos++, token = 40 /* CaretToken */; + return pos++, token = 44 /* CaretToken */; case 123 /* openBrace */: - return pos++, token = 9 /* OpenBraceToken */; + return pos++, token = 13 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 44 /* BarBarToken */; + return pos += 2, token = 48 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 57 /* BarEqualsToken */; + return pos += 2, token = 61 /* BarEqualsToken */; } - return pos++, token = 39 /* BarToken */; + return pos++, token = 43 /* BarToken */; case 125 /* closeBrace */: - return pos++, token = 10 /* CloseBraceToken */; + return pos++, token = 14 /* CloseBraceToken */; case 126 /* tilde */: - return pos++, token = 42 /* TildeToken */; + return pos++, token = 46 /* TildeToken */; case 92 /* backslash */: var ch = peekUnicodeEscape(); if (ch >= 0 && isIdentifierStart(ch)) { @@ -1259,27 +1312,27 @@ var ts; } } function reScanGreaterToken() { - if (token === 20 /* GreaterThanToken */) { + if (token === 24 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 55 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 37 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 41 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 54 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 58 /* GreaterThanGreaterThanEqualsToken */; } - return pos++, token = 36 /* GreaterThanGreaterThanToken */; + return pos++, token = 40 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { - return pos++, token = 22 /* GreaterThanEqualsToken */; + return pos++, token = 26 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 31 /* SlashToken */ || token === 51 /* SlashEqualsToken */) { + if (token === 35 /* SlashToken */ || token === 55 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -1318,6 +1371,11 @@ var ts; } return token; } + function reScanTemplateToken() { + ts.Debug.assert(token === 14 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + pos = tokenPos; + return token = scanTemplateAndSetTokenValue(); + } function tryScan(callback) { var savePos = pos; var saveStartPos = startPos; @@ -1357,10 +1415,11 @@ var ts; getTokenText: function () { return text.substring(tokenPos, pos); }, getTokenValue: function () { return tokenValue; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 59 /* Identifier */ || token > ts.SyntaxKind.LastReservedWord; }, - isReservedWord: function () { return token >= ts.SyntaxKind.FirstReservedWord && token <= ts.SyntaxKind.LastReservedWord; }, + isIdentifier: function () { return token === 63 /* Identifier */ || token > 99 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 64 /* FirstReservedWord */ && token <= 99 /* LastReservedWord */; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, + reScanTemplateToken: reScanTemplateToken, scan: scan, setText: setText, setTextPos: setTextPos, @@ -1371,234 +1430,6 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - (function (SyntaxKind) { - SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 6] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 7] = "StringLiteral"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 8] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 9] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 10] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 11] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 12] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 13] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 14] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 15] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 16] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 17] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 18] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 19] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 20] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 21] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 22] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 23] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 24] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 25] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 26] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 27] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 28] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 29] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 30] = "AsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 31] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 32] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 33] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 34] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 35] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 36] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 37] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 38] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 39] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 40] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 41] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 42] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 43] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 44] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 45] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 46] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 47] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 48] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 49] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 50] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 51] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 52] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 53] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 54] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 55] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 56] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 57] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 58] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 59] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 60] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 61] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 62] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 63] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 64] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 65] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 66] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 67] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 68] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 69] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 70] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 71] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 72] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 73] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 74] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 75] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 76] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 77] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 78] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 79] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 80] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 81] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 82] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 83] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 84] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 85] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 86] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 87] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 88] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 89] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 90] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 91] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 92] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 93] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 94] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 95] = "WithKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 96] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 97] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 98] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 99] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 100] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 101] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 102] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 103] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 104] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 105] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 106] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 107] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 108] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 109] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 110] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 111] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 112] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 113] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 114] = "StringKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 115] = "TypeKeyword"; - SyntaxKind[SyntaxKind["Missing"] = 116] = "Missing"; - SyntaxKind[SyntaxKind["QualifiedName"] = 117] = "QualifiedName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 118] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 119] = "Parameter"; - SyntaxKind[SyntaxKind["Property"] = 120] = "Property"; - SyntaxKind[SyntaxKind["Method"] = 121] = "Method"; - SyntaxKind[SyntaxKind["Constructor"] = 122] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 123] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 124] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 125] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 126] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 127] = "IndexSignature"; - SyntaxKind[SyntaxKind["TypeReference"] = 128] = "TypeReference"; - SyntaxKind[SyntaxKind["TypeQuery"] = 129] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 130] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 131] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 132] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 133] = "UnionType"; - SyntaxKind[SyntaxKind["ParenType"] = 134] = "ParenType"; - SyntaxKind[SyntaxKind["ArrayLiteral"] = 135] = "ArrayLiteral"; - SyntaxKind[SyntaxKind["ObjectLiteral"] = 136] = "ObjectLiteral"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 137] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["PropertyAccess"] = 138] = "PropertyAccess"; - SyntaxKind[SyntaxKind["IndexedAccess"] = 139] = "IndexedAccess"; - SyntaxKind[SyntaxKind["CallExpression"] = 140] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 141] = "NewExpression"; - SyntaxKind[SyntaxKind["TypeAssertion"] = 142] = "TypeAssertion"; - SyntaxKind[SyntaxKind["ParenExpression"] = 143] = "ParenExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 144] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 145] = "ArrowFunction"; - SyntaxKind[SyntaxKind["PrefixOperator"] = 146] = "PrefixOperator"; - SyntaxKind[SyntaxKind["PostfixOperator"] = 147] = "PostfixOperator"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 148] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 149] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 150] = "OmittedExpression"; - SyntaxKind[SyntaxKind["Block"] = 151] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 152] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 153] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 154] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 155] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 156] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 157] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 158] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 159] = "ForInStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 160] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 161] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 162] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 163] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 164] = "SwitchStatement"; - SyntaxKind[SyntaxKind["CaseClause"] = 165] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 166] = "DefaultClause"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 167] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 168] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 169] = "TryStatement"; - SyntaxKind[SyntaxKind["TryBlock"] = 170] = "TryBlock"; - SyntaxKind[SyntaxKind["CatchBlock"] = 171] = "CatchBlock"; - SyntaxKind[SyntaxKind["FinallyBlock"] = 172] = "FinallyBlock"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 173] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 174] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 175] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["FunctionBlock"] = 176] = "FunctionBlock"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 177] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 178] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 179] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 180] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 181] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 182] = "ModuleBlock"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 183] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 184] = "ExportAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 185] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 186] = "SourceFile"; - SyntaxKind[SyntaxKind["Program"] = 187] = "Program"; - SyntaxKind[SyntaxKind["SyntaxList"] = 188] = "SyntaxList"; - SyntaxKind[SyntaxKind["Count"] = 189] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = SyntaxKind.EqualsToken] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = SyntaxKind.CaretEqualsToken] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = SyntaxKind.BreakKeyword] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = SyntaxKind.WithKeyword] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.BreakKeyword] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.TypeKeyword] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = SyntaxKind.YieldKeyword] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = SyntaxKind.TypeReference] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = SyntaxKind.ParenType] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.CaretEqualsToken] = "LastPunctuation"; - SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.EndOfFileToken] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.TypeKeyword] = "LastToken"; - SyntaxKind[SyntaxKind["FirstTriviaToken"] = SyntaxKind.SingleLineCommentTrivia] = "FirstTriviaToken"; - SyntaxKind[SyntaxKind["LastTriviaToken"] = SyntaxKind.WhitespaceTrivia] = "LastTriviaToken"; - })(ts.SyntaxKind || (ts.SyntaxKind = {})); - var SyntaxKind = ts.SyntaxKind; - (function (NodeFlags) { - NodeFlags[NodeFlags["Export"] = 0x00000001] = "Export"; - NodeFlags[NodeFlags["Ambient"] = 0x00000002] = "Ambient"; - NodeFlags[NodeFlags["QuestionMark"] = 0x00000004] = "QuestionMark"; - NodeFlags[NodeFlags["Rest"] = 0x00000008] = "Rest"; - NodeFlags[NodeFlags["Public"] = 0x00000010] = "Public"; - NodeFlags[NodeFlags["Private"] = 0x00000020] = "Private"; - NodeFlags[NodeFlags["Protected"] = 0x00000040] = "Protected"; - NodeFlags[NodeFlags["Static"] = 0x00000080] = "Static"; - NodeFlags[NodeFlags["MultiLine"] = 0x00000100] = "MultiLine"; - NodeFlags[NodeFlags["Synthetic"] = 0x00000200] = "Synthetic"; - NodeFlags[NodeFlags["DeclarationFile"] = 0x00000400] = "DeclarationFile"; - NodeFlags[NodeFlags["Let"] = 0x00000800] = "Let"; - NodeFlags[NodeFlags["Const"] = 0x00001000] = "Const"; - NodeFlags[NodeFlags["Modifier"] = NodeFlags.Export | NodeFlags.Ambient | NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected | NodeFlags.Static] = "Modifier"; - NodeFlags[NodeFlags["AccessibilityModifier"] = NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected] = "AccessibilityModifier"; - NodeFlags[NodeFlags["BlockScoped"] = NodeFlags.Let | NodeFlags.Const] = "BlockScoped"; - })(ts.NodeFlags || (ts.NodeFlags = {})); - var NodeFlags = ts.NodeFlags; (function (EmitReturnStatus) { EmitReturnStatus[EmitReturnStatus["Succeeded"] = 0] = "Succeeded"; EmitReturnStatus[EmitReturnStatus["AllOutputGenerationSkipped"] = 1] = "AllOutputGenerationSkipped"; @@ -1608,284 +1439,12 @@ var ts; EmitReturnStatus[EmitReturnStatus["CompilerOptionsErrors"] = 5] = "CompilerOptionsErrors"; })(ts.EmitReturnStatus || (ts.EmitReturnStatus = {})); var EmitReturnStatus = ts.EmitReturnStatus; - (function (TypeFormatFlags) { - TypeFormatFlags[TypeFormatFlags["None"] = 0x00000000] = "None"; - TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 0x00000001] = "WriteArrayAsGenericType"; - TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 0x00000002] = "UseTypeOfFunction"; - TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 0x00000004] = "NoTruncation"; - TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 0x00000008] = "WriteArrowStyleSignature"; - TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0x00000010] = "WriteOwnNameForAnyLike"; - TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 0x00000020] = "WriteTypeArgumentsOfSignature"; - TypeFormatFlags[TypeFormatFlags["InElementType"] = 0x00000040] = "InElementType"; - })(ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); - var TypeFormatFlags = ts.TypeFormatFlags; - (function (SymbolFormatFlags) { - SymbolFormatFlags[SymbolFormatFlags["None"] = 0x00000000] = "None"; - SymbolFormatFlags[SymbolFormatFlags["WriteTypeParametersOrArguments"] = 0x00000001] = "WriteTypeParametersOrArguments"; - SymbolFormatFlags[SymbolFormatFlags["UseOnlyExternalAliasing"] = 0x00000002] = "UseOnlyExternalAliasing"; - })(ts.SymbolFormatFlags || (ts.SymbolFormatFlags = {})); - var SymbolFormatFlags = ts.SymbolFormatFlags; - (function (SymbolAccessibility) { - SymbolAccessibility[SymbolAccessibility["Accessible"] = 0] = "Accessible"; - SymbolAccessibility[SymbolAccessibility["NotAccessible"] = 1] = "NotAccessible"; - SymbolAccessibility[SymbolAccessibility["CannotBeNamed"] = 2] = "CannotBeNamed"; - })(ts.SymbolAccessibility || (ts.SymbolAccessibility = {})); - var SymbolAccessibility = ts.SymbolAccessibility; - (function (SymbolFlags) { - SymbolFlags[SymbolFlags["FunctionScopedVariable"] = 0x00000001] = "FunctionScopedVariable"; - SymbolFlags[SymbolFlags["BlockScopedVariable"] = 0x00000002] = "BlockScopedVariable"; - SymbolFlags[SymbolFlags["Property"] = 0x00000004] = "Property"; - SymbolFlags[SymbolFlags["EnumMember"] = 0x00000008] = "EnumMember"; - SymbolFlags[SymbolFlags["Function"] = 0x00000010] = "Function"; - SymbolFlags[SymbolFlags["Class"] = 0x00000020] = "Class"; - SymbolFlags[SymbolFlags["Interface"] = 0x00000040] = "Interface"; - SymbolFlags[SymbolFlags["Enum"] = 0x00000080] = "Enum"; - SymbolFlags[SymbolFlags["ValueModule"] = 0x00000100] = "ValueModule"; - SymbolFlags[SymbolFlags["NamespaceModule"] = 0x00000200] = "NamespaceModule"; - SymbolFlags[SymbolFlags["TypeLiteral"] = 0x00000400] = "TypeLiteral"; - SymbolFlags[SymbolFlags["ObjectLiteral"] = 0x00000800] = "ObjectLiteral"; - SymbolFlags[SymbolFlags["Method"] = 0x00001000] = "Method"; - SymbolFlags[SymbolFlags["Constructor"] = 0x00002000] = "Constructor"; - SymbolFlags[SymbolFlags["GetAccessor"] = 0x00004000] = "GetAccessor"; - SymbolFlags[SymbolFlags["SetAccessor"] = 0x00008000] = "SetAccessor"; - SymbolFlags[SymbolFlags["CallSignature"] = 0x00010000] = "CallSignature"; - SymbolFlags[SymbolFlags["ConstructSignature"] = 0x00020000] = "ConstructSignature"; - SymbolFlags[SymbolFlags["IndexSignature"] = 0x00040000] = "IndexSignature"; - SymbolFlags[SymbolFlags["TypeParameter"] = 0x00080000] = "TypeParameter"; - SymbolFlags[SymbolFlags["TypeAlias"] = 0x00100000] = "TypeAlias"; - SymbolFlags[SymbolFlags["ExportValue"] = 0x00200000] = "ExportValue"; - SymbolFlags[SymbolFlags["ExportType"] = 0x00400000] = "ExportType"; - SymbolFlags[SymbolFlags["ExportNamespace"] = 0x00800000] = "ExportNamespace"; - SymbolFlags[SymbolFlags["Import"] = 0x01000000] = "Import"; - SymbolFlags[SymbolFlags["Instantiated"] = 0x02000000] = "Instantiated"; - SymbolFlags[SymbolFlags["Merged"] = 0x04000000] = "Merged"; - SymbolFlags[SymbolFlags["Transient"] = 0x08000000] = "Transient"; - SymbolFlags[SymbolFlags["Prototype"] = 0x10000000] = "Prototype"; - SymbolFlags[SymbolFlags["UnionProperty"] = 0x20000000] = "UnionProperty"; - SymbolFlags[SymbolFlags["Variable"] = SymbolFlags.FunctionScopedVariable | SymbolFlags.BlockScopedVariable] = "Variable"; - SymbolFlags[SymbolFlags["Value"] = SymbolFlags.Variable | SymbolFlags.Property | SymbolFlags.EnumMember | SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule | SymbolFlags.Method | SymbolFlags.GetAccessor | SymbolFlags.SetAccessor] = "Value"; - SymbolFlags[SymbolFlags["Type"] = SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.Enum | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral | SymbolFlags.TypeParameter | SymbolFlags.TypeAlias] = "Type"; - SymbolFlags[SymbolFlags["Namespace"] = SymbolFlags.ValueModule | SymbolFlags.NamespaceModule] = "Namespace"; - SymbolFlags[SymbolFlags["Module"] = SymbolFlags.ValueModule | SymbolFlags.NamespaceModule] = "Module"; - SymbolFlags[SymbolFlags["Accessor"] = SymbolFlags.GetAccessor | SymbolFlags.SetAccessor] = "Accessor"; - SymbolFlags[SymbolFlags["Signature"] = SymbolFlags.CallSignature | SymbolFlags.ConstructSignature | SymbolFlags.IndexSignature] = "Signature"; - SymbolFlags[SymbolFlags["FunctionScopedVariableExcludes"] = SymbolFlags.Value & ~SymbolFlags.FunctionScopedVariable] = "FunctionScopedVariableExcludes"; - SymbolFlags[SymbolFlags["BlockScopedVariableExcludes"] = SymbolFlags.Value] = "BlockScopedVariableExcludes"; - SymbolFlags[SymbolFlags["ParameterExcludes"] = SymbolFlags.Value] = "ParameterExcludes"; - SymbolFlags[SymbolFlags["PropertyExcludes"] = SymbolFlags.Value] = "PropertyExcludes"; - SymbolFlags[SymbolFlags["EnumMemberExcludes"] = SymbolFlags.Value] = "EnumMemberExcludes"; - SymbolFlags[SymbolFlags["FunctionExcludes"] = SymbolFlags.Value & ~(SymbolFlags.Function | SymbolFlags.ValueModule)] = "FunctionExcludes"; - SymbolFlags[SymbolFlags["ClassExcludes"] = (SymbolFlags.Value | SymbolFlags.Type) & ~SymbolFlags.ValueModule] = "ClassExcludes"; - SymbolFlags[SymbolFlags["InterfaceExcludes"] = SymbolFlags.Type & ~SymbolFlags.Interface] = "InterfaceExcludes"; - SymbolFlags[SymbolFlags["EnumExcludes"] = (SymbolFlags.Value | SymbolFlags.Type) & ~(SymbolFlags.Enum | SymbolFlags.ValueModule)] = "EnumExcludes"; - SymbolFlags[SymbolFlags["ValueModuleExcludes"] = SymbolFlags.Value & ~(SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)] = "ValueModuleExcludes"; - SymbolFlags[SymbolFlags["NamespaceModuleExcludes"] = 0] = "NamespaceModuleExcludes"; - SymbolFlags[SymbolFlags["MethodExcludes"] = SymbolFlags.Value & ~SymbolFlags.Method] = "MethodExcludes"; - SymbolFlags[SymbolFlags["GetAccessorExcludes"] = SymbolFlags.Value & ~SymbolFlags.SetAccessor] = "GetAccessorExcludes"; - SymbolFlags[SymbolFlags["SetAccessorExcludes"] = SymbolFlags.Value & ~SymbolFlags.GetAccessor] = "SetAccessorExcludes"; - SymbolFlags[SymbolFlags["TypeParameterExcludes"] = SymbolFlags.Type & ~SymbolFlags.TypeParameter] = "TypeParameterExcludes"; - SymbolFlags[SymbolFlags["TypeAliasExcludes"] = SymbolFlags.Type] = "TypeAliasExcludes"; - SymbolFlags[SymbolFlags["ImportExcludes"] = SymbolFlags.Import] = "ImportExcludes"; - SymbolFlags[SymbolFlags["ModuleMember"] = SymbolFlags.Variable | SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.Enum | SymbolFlags.Module | SymbolFlags.TypeAlias | SymbolFlags.Import] = "ModuleMember"; - SymbolFlags[SymbolFlags["ExportHasLocal"] = SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule] = "ExportHasLocal"; - SymbolFlags[SymbolFlags["HasLocals"] = SymbolFlags.Function | SymbolFlags.Module | SymbolFlags.Method | SymbolFlags.Constructor | SymbolFlags.Accessor | SymbolFlags.Signature] = "HasLocals"; - SymbolFlags[SymbolFlags["HasExports"] = SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.Module] = "HasExports"; - SymbolFlags[SymbolFlags["HasMembers"] = SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral] = "HasMembers"; - SymbolFlags[SymbolFlags["IsContainer"] = SymbolFlags.HasLocals | SymbolFlags.HasExports | SymbolFlags.HasMembers] = "IsContainer"; - SymbolFlags[SymbolFlags["PropertyOrAccessor"] = SymbolFlags.Property | SymbolFlags.Accessor] = "PropertyOrAccessor"; - SymbolFlags[SymbolFlags["Export"] = SymbolFlags.ExportNamespace | SymbolFlags.ExportType | SymbolFlags.ExportValue] = "Export"; - })(ts.SymbolFlags || (ts.SymbolFlags = {})); - var SymbolFlags = ts.SymbolFlags; - (function (NodeCheckFlags) { - NodeCheckFlags[NodeCheckFlags["TypeChecked"] = 0x00000001] = "TypeChecked"; - NodeCheckFlags[NodeCheckFlags["LexicalThis"] = 0x00000002] = "LexicalThis"; - NodeCheckFlags[NodeCheckFlags["CaptureThis"] = 0x00000004] = "CaptureThis"; - NodeCheckFlags[NodeCheckFlags["EmitExtends"] = 0x00000008] = "EmitExtends"; - NodeCheckFlags[NodeCheckFlags["SuperInstance"] = 0x00000010] = "SuperInstance"; - NodeCheckFlags[NodeCheckFlags["SuperStatic"] = 0x00000020] = "SuperStatic"; - NodeCheckFlags[NodeCheckFlags["ContextChecked"] = 0x00000040] = "ContextChecked"; - NodeCheckFlags[NodeCheckFlags["EnumValuesComputed"] = 0x00000080] = "EnumValuesComputed"; - })(ts.NodeCheckFlags || (ts.NodeCheckFlags = {})); - var NodeCheckFlags = ts.NodeCheckFlags; - (function (TypeFlags) { - TypeFlags[TypeFlags["Any"] = 0x00000001] = "Any"; - TypeFlags[TypeFlags["String"] = 0x00000002] = "String"; - TypeFlags[TypeFlags["Number"] = 0x00000004] = "Number"; - TypeFlags[TypeFlags["Boolean"] = 0x00000008] = "Boolean"; - TypeFlags[TypeFlags["Void"] = 0x00000010] = "Void"; - TypeFlags[TypeFlags["Undefined"] = 0x00000020] = "Undefined"; - TypeFlags[TypeFlags["Null"] = 0x00000040] = "Null"; - TypeFlags[TypeFlags["Enum"] = 0x00000080] = "Enum"; - TypeFlags[TypeFlags["StringLiteral"] = 0x00000100] = "StringLiteral"; - TypeFlags[TypeFlags["TypeParameter"] = 0x00000200] = "TypeParameter"; - TypeFlags[TypeFlags["Class"] = 0x00000400] = "Class"; - TypeFlags[TypeFlags["Interface"] = 0x00000800] = "Interface"; - TypeFlags[TypeFlags["Reference"] = 0x00001000] = "Reference"; - TypeFlags[TypeFlags["Tuple"] = 0x00002000] = "Tuple"; - TypeFlags[TypeFlags["Union"] = 0x00004000] = "Union"; - TypeFlags[TypeFlags["Anonymous"] = 0x00008000] = "Anonymous"; - TypeFlags[TypeFlags["FromSignature"] = 0x00010000] = "FromSignature"; - TypeFlags[TypeFlags["Intrinsic"] = TypeFlags.Any | TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Void | TypeFlags.Undefined | TypeFlags.Null] = "Intrinsic"; - TypeFlags[TypeFlags["StringLike"] = TypeFlags.String | TypeFlags.StringLiteral] = "StringLike"; - TypeFlags[TypeFlags["NumberLike"] = TypeFlags.Number | TypeFlags.Enum] = "NumberLike"; - TypeFlags[TypeFlags["ObjectType"] = TypeFlags.Class | TypeFlags.Interface | TypeFlags.Reference | TypeFlags.Tuple | TypeFlags.Anonymous] = "ObjectType"; - TypeFlags[TypeFlags["Structured"] = TypeFlags.Any | TypeFlags.ObjectType | TypeFlags.Union | TypeFlags.TypeParameter] = "Structured"; - })(ts.TypeFlags || (ts.TypeFlags = {})); - var TypeFlags = ts.TypeFlags; - (function (SignatureKind) { - SignatureKind[SignatureKind["Call"] = 0] = "Call"; - SignatureKind[SignatureKind["Construct"] = 1] = "Construct"; - })(ts.SignatureKind || (ts.SignatureKind = {})); - var SignatureKind = ts.SignatureKind; - (function (IndexKind) { - IndexKind[IndexKind["String"] = 0] = "String"; - IndexKind[IndexKind["Number"] = 1] = "Number"; - })(ts.IndexKind || (ts.IndexKind = {})); - var IndexKind = ts.IndexKind; (function (DiagnosticCategory) { DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning"; DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error"; DiagnosticCategory[DiagnosticCategory["Message"] = 2] = "Message"; })(ts.DiagnosticCategory || (ts.DiagnosticCategory = {})); var DiagnosticCategory = ts.DiagnosticCategory; - (function (ModuleKind) { - ModuleKind[ModuleKind["None"] = 0] = "None"; - ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS"; - ModuleKind[ModuleKind["AMD"] = 2] = "AMD"; - })(ts.ModuleKind || (ts.ModuleKind = {})); - var ModuleKind = ts.ModuleKind; - (function (ScriptTarget) { - ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3"; - ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5"; - ScriptTarget[ScriptTarget["ES6"] = 2] = "ES6"; - ScriptTarget[ScriptTarget["Latest"] = ScriptTarget.ES6] = "Latest"; - })(ts.ScriptTarget || (ts.ScriptTarget = {})); - var ScriptTarget = ts.ScriptTarget; - (function (CharacterCodes) { - CharacterCodes[CharacterCodes["nullCharacter"] = 0] = "nullCharacter"; - CharacterCodes[CharacterCodes["maxAsciiCharacter"] = 0x7F] = "maxAsciiCharacter"; - CharacterCodes[CharacterCodes["lineFeed"] = 0x0A] = "lineFeed"; - CharacterCodes[CharacterCodes["carriageReturn"] = 0x0D] = "carriageReturn"; - CharacterCodes[CharacterCodes["lineSeparator"] = 0x2028] = "lineSeparator"; - CharacterCodes[CharacterCodes["paragraphSeparator"] = 0x2029] = "paragraphSeparator"; - CharacterCodes[CharacterCodes["nextLine"] = 0x0085] = "nextLine"; - CharacterCodes[CharacterCodes["space"] = 0x0020] = "space"; - CharacterCodes[CharacterCodes["nonBreakingSpace"] = 0x00A0] = "nonBreakingSpace"; - CharacterCodes[CharacterCodes["enQuad"] = 0x2000] = "enQuad"; - CharacterCodes[CharacterCodes["emQuad"] = 0x2001] = "emQuad"; - CharacterCodes[CharacterCodes["enSpace"] = 0x2002] = "enSpace"; - CharacterCodes[CharacterCodes["emSpace"] = 0x2003] = "emSpace"; - CharacterCodes[CharacterCodes["threePerEmSpace"] = 0x2004] = "threePerEmSpace"; - CharacterCodes[CharacterCodes["fourPerEmSpace"] = 0x2005] = "fourPerEmSpace"; - CharacterCodes[CharacterCodes["sixPerEmSpace"] = 0x2006] = "sixPerEmSpace"; - CharacterCodes[CharacterCodes["figureSpace"] = 0x2007] = "figureSpace"; - CharacterCodes[CharacterCodes["punctuationSpace"] = 0x2008] = "punctuationSpace"; - CharacterCodes[CharacterCodes["thinSpace"] = 0x2009] = "thinSpace"; - CharacterCodes[CharacterCodes["hairSpace"] = 0x200A] = "hairSpace"; - CharacterCodes[CharacterCodes["zeroWidthSpace"] = 0x200B] = "zeroWidthSpace"; - CharacterCodes[CharacterCodes["narrowNoBreakSpace"] = 0x202F] = "narrowNoBreakSpace"; - CharacterCodes[CharacterCodes["ideographicSpace"] = 0x3000] = "ideographicSpace"; - CharacterCodes[CharacterCodes["mathematicalSpace"] = 0x205F] = "mathematicalSpace"; - CharacterCodes[CharacterCodes["ogham"] = 0x1680] = "ogham"; - CharacterCodes[CharacterCodes["_"] = 0x5F] = "_"; - CharacterCodes[CharacterCodes["$"] = 0x24] = "$"; - CharacterCodes[CharacterCodes["_0"] = 0x30] = "_0"; - CharacterCodes[CharacterCodes["_1"] = 0x31] = "_1"; - CharacterCodes[CharacterCodes["_2"] = 0x32] = "_2"; - CharacterCodes[CharacterCodes["_3"] = 0x33] = "_3"; - CharacterCodes[CharacterCodes["_4"] = 0x34] = "_4"; - CharacterCodes[CharacterCodes["_5"] = 0x35] = "_5"; - CharacterCodes[CharacterCodes["_6"] = 0x36] = "_6"; - CharacterCodes[CharacterCodes["_7"] = 0x37] = "_7"; - CharacterCodes[CharacterCodes["_8"] = 0x38] = "_8"; - CharacterCodes[CharacterCodes["_9"] = 0x39] = "_9"; - CharacterCodes[CharacterCodes["a"] = 0x61] = "a"; - CharacterCodes[CharacterCodes["b"] = 0x62] = "b"; - CharacterCodes[CharacterCodes["c"] = 0x63] = "c"; - CharacterCodes[CharacterCodes["d"] = 0x64] = "d"; - CharacterCodes[CharacterCodes["e"] = 0x65] = "e"; - CharacterCodes[CharacterCodes["f"] = 0x66] = "f"; - CharacterCodes[CharacterCodes["g"] = 0x67] = "g"; - CharacterCodes[CharacterCodes["h"] = 0x68] = "h"; - CharacterCodes[CharacterCodes["i"] = 0x69] = "i"; - CharacterCodes[CharacterCodes["j"] = 0x6A] = "j"; - CharacterCodes[CharacterCodes["k"] = 0x6B] = "k"; - CharacterCodes[CharacterCodes["l"] = 0x6C] = "l"; - CharacterCodes[CharacterCodes["m"] = 0x6D] = "m"; - CharacterCodes[CharacterCodes["n"] = 0x6E] = "n"; - CharacterCodes[CharacterCodes["o"] = 0x6F] = "o"; - CharacterCodes[CharacterCodes["p"] = 0x70] = "p"; - CharacterCodes[CharacterCodes["q"] = 0x71] = "q"; - CharacterCodes[CharacterCodes["r"] = 0x72] = "r"; - CharacterCodes[CharacterCodes["s"] = 0x73] = "s"; - CharacterCodes[CharacterCodes["t"] = 0x74] = "t"; - CharacterCodes[CharacterCodes["u"] = 0x75] = "u"; - CharacterCodes[CharacterCodes["v"] = 0x76] = "v"; - CharacterCodes[CharacterCodes["w"] = 0x77] = "w"; - CharacterCodes[CharacterCodes["x"] = 0x78] = "x"; - CharacterCodes[CharacterCodes["y"] = 0x79] = "y"; - CharacterCodes[CharacterCodes["z"] = 0x7A] = "z"; - CharacterCodes[CharacterCodes["A"] = 0x41] = "A"; - CharacterCodes[CharacterCodes["B"] = 0x42] = "B"; - CharacterCodes[CharacterCodes["C"] = 0x43] = "C"; - CharacterCodes[CharacterCodes["D"] = 0x44] = "D"; - CharacterCodes[CharacterCodes["E"] = 0x45] = "E"; - CharacterCodes[CharacterCodes["F"] = 0x46] = "F"; - CharacterCodes[CharacterCodes["G"] = 0x47] = "G"; - CharacterCodes[CharacterCodes["H"] = 0x48] = "H"; - CharacterCodes[CharacterCodes["I"] = 0x49] = "I"; - CharacterCodes[CharacterCodes["J"] = 0x4A] = "J"; - CharacterCodes[CharacterCodes["K"] = 0x4B] = "K"; - CharacterCodes[CharacterCodes["L"] = 0x4C] = "L"; - CharacterCodes[CharacterCodes["M"] = 0x4D] = "M"; - CharacterCodes[CharacterCodes["N"] = 0x4E] = "N"; - CharacterCodes[CharacterCodes["O"] = 0x4F] = "O"; - CharacterCodes[CharacterCodes["P"] = 0x50] = "P"; - CharacterCodes[CharacterCodes["Q"] = 0x51] = "Q"; - CharacterCodes[CharacterCodes["R"] = 0x52] = "R"; - CharacterCodes[CharacterCodes["S"] = 0x53] = "S"; - CharacterCodes[CharacterCodes["T"] = 0x54] = "T"; - CharacterCodes[CharacterCodes["U"] = 0x55] = "U"; - CharacterCodes[CharacterCodes["V"] = 0x56] = "V"; - CharacterCodes[CharacterCodes["W"] = 0x57] = "W"; - CharacterCodes[CharacterCodes["X"] = 0x58] = "X"; - CharacterCodes[CharacterCodes["Y"] = 0x59] = "Y"; - CharacterCodes[CharacterCodes["Z"] = 0x5a] = "Z"; - CharacterCodes[CharacterCodes["ampersand"] = 0x26] = "ampersand"; - CharacterCodes[CharacterCodes["asterisk"] = 0x2A] = "asterisk"; - CharacterCodes[CharacterCodes["at"] = 0x40] = "at"; - CharacterCodes[CharacterCodes["backslash"] = 0x5C] = "backslash"; - CharacterCodes[CharacterCodes["bar"] = 0x7C] = "bar"; - CharacterCodes[CharacterCodes["caret"] = 0x5E] = "caret"; - CharacterCodes[CharacterCodes["closeBrace"] = 0x7D] = "closeBrace"; - CharacterCodes[CharacterCodes["closeBracket"] = 0x5D] = "closeBracket"; - CharacterCodes[CharacterCodes["closeParen"] = 0x29] = "closeParen"; - CharacterCodes[CharacterCodes["colon"] = 0x3A] = "colon"; - CharacterCodes[CharacterCodes["comma"] = 0x2C] = "comma"; - CharacterCodes[CharacterCodes["dot"] = 0x2E] = "dot"; - CharacterCodes[CharacterCodes["doubleQuote"] = 0x22] = "doubleQuote"; - CharacterCodes[CharacterCodes["equals"] = 0x3D] = "equals"; - CharacterCodes[CharacterCodes["exclamation"] = 0x21] = "exclamation"; - CharacterCodes[CharacterCodes["greaterThan"] = 0x3E] = "greaterThan"; - CharacterCodes[CharacterCodes["lessThan"] = 0x3C] = "lessThan"; - CharacterCodes[CharacterCodes["minus"] = 0x2D] = "minus"; - CharacterCodes[CharacterCodes["openBrace"] = 0x7B] = "openBrace"; - CharacterCodes[CharacterCodes["openBracket"] = 0x5B] = "openBracket"; - CharacterCodes[CharacterCodes["openParen"] = 0x28] = "openParen"; - CharacterCodes[CharacterCodes["percent"] = 0x25] = "percent"; - CharacterCodes[CharacterCodes["plus"] = 0x2B] = "plus"; - CharacterCodes[CharacterCodes["question"] = 0x3F] = "question"; - CharacterCodes[CharacterCodes["semicolon"] = 0x3B] = "semicolon"; - CharacterCodes[CharacterCodes["singleQuote"] = 0x27] = "singleQuote"; - CharacterCodes[CharacterCodes["slash"] = 0x2F] = "slash"; - CharacterCodes[CharacterCodes["tilde"] = 0x7E] = "tilde"; - CharacterCodes[CharacterCodes["backspace"] = 0x08] = "backspace"; - CharacterCodes[CharacterCodes["formFeed"] = 0x0C] = "formFeed"; - CharacterCodes[CharacterCodes["byteOrderMark"] = 0xFEFF] = "byteOrderMark"; - CharacterCodes[CharacterCodes["tab"] = 0x09] = "tab"; - CharacterCodes[CharacterCodes["verticalTab"] = 0x0B] = "verticalTab"; - })(ts.CharacterCodes || (ts.CharacterCodes = {})); - var CharacterCodes = ts.CharacterCodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -2161,12 +1720,12 @@ var ts; ts.flattenDiagnosticChain = flattenDiagnosticChain; function compareValues(a, b) { if (a === b) - return 0; + return 0 /* EqualTo */; if (a === undefined) - return -1; + return -1 /* LessThan */; if (b === undefined) - return 1; - return a < b ? -1 : 1; + return 1 /* GreaterThan */; + return a < b ? -1 /* LessThan */ : 1 /* GreaterThan */; } ts.compareValues = compareValues; function getDiagnosticFilename(diagnostic) { @@ -2184,7 +1743,7 @@ var ts; var previousDiagnostic = diagnostics[0]; for (var i = 1; i < diagnostics.length; i++) { var currentDiagnostic = diagnostics[i]; - var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0; + var isDupe = compareDiagnostics(currentDiagnostic, previousDiagnostic) === 0 /* EqualTo */; if (!isDupe) { newDiagnostics.push(currentDiagnostic); previousDiagnostic = currentDiagnostic; @@ -2413,13 +1972,6 @@ var ts; getTypeConstructor: function () { return Type; }, getSignatureConstructor: function () { return Signature; } }; - (function (AssertionLevel) { - AssertionLevel[AssertionLevel["None"] = 0] = "None"; - AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; - AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; - AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; - })(ts.AssertionLevel || (ts.AssertionLevel = {})); - var AssertionLevel = ts.AssertionLevel; var Debug; (function (Debug) { var currentAssertionLevel = 0 /* None */; @@ -2445,7 +1997,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - var nodeConstructors = new Array(189 /* Count */); + var nodeConstructors = new Array(196 /* Count */); function getNodeConstructor(kind) { return nodeConstructors[kind] || (nodeConstructors[kind] = ts.objectAllocator.getNodeConstructor(kind)); } @@ -2458,7 +2010,7 @@ var ts; return node; } function getSourceFileOfNode(node) { - while (node && node.kind !== 186 /* SourceFile */) + while (node && node.kind !== 193 /* SourceFile */) node = node.parent; return node; } @@ -2495,81 +2047,13 @@ var ts; } ts.unescapeIdentifier = unescapeIdentifier; function identifierToString(identifier) { - return identifier.kind === 116 /* Missing */ ? "(Missing)" : getTextOfNode(identifier); + return identifier.kind === 120 /* Missing */ ? "(Missing)" : getTextOfNode(identifier); } ts.identifierToString = identifierToString; - function isExpression(node) { - switch (node.kind) { - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: - case 83 /* NullKeyword */: - case 89 /* TrueKeyword */: - case 74 /* FalseKeyword */: - case 8 /* RegularExpressionLiteral */: - case 135 /* ArrayLiteral */: - case 136 /* ObjectLiteral */: - case 138 /* PropertyAccess */: - case 139 /* IndexedAccess */: - case 140 /* CallExpression */: - case 141 /* NewExpression */: - case 142 /* TypeAssertion */: - case 143 /* ParenExpression */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: - case 148 /* BinaryExpression */: - case 149 /* ConditionalExpression */: - case 150 /* OmittedExpression */: - return true; - case 117 /* QualifiedName */: - while (node.parent.kind === 117 /* QualifiedName */) - node = node.parent; - return node.parent.kind === 129 /* TypeQuery */; - case 59 /* Identifier */: - if (node.parent.kind === 129 /* TypeQuery */) { - return true; - } - case 6 /* NumericLiteral */: - case 7 /* StringLiteral */: - var parent = node.parent; - switch (parent.kind) { - case 174 /* VariableDeclaration */: - case 119 /* Parameter */: - case 120 /* Property */: - case 185 /* EnumMember */: - case 137 /* PropertyAssignment */: - return parent.initializer === node; - case 154 /* ExpressionStatement */: - case 155 /* IfStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 162 /* ReturnStatement */: - case 163 /* WithStatement */: - case 164 /* SwitchStatement */: - case 165 /* CaseClause */: - case 168 /* ThrowStatement */: - case 164 /* SwitchStatement */: - return parent.expression === node; - case 158 /* ForStatement */: - return parent.initializer === node || parent.condition === node || parent.iterator === node; - case 159 /* ForInStatement */: - return parent.variable === node || parent.expression === node; - case 142 /* TypeAssertion */: - return node === parent.operand; - default: - if (isExpression(parent)) { - return true; - } - } - } - return false; - } - ts.isExpression = isExpression; function createDiagnosticForNode(node, message, arg0, arg1, arg2) { node = getErrorSpanForNode(node); var file = getSourceFileOfNode(node); - var start = node.kind === 116 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos); + var start = node.kind === 120 /* Missing */ ? node.pos : ts.skipTrivia(file.text, node.pos); var length = node.end - start; return ts.createFileDiagnostic(file, start, length, message, arg0, arg1, arg2); } @@ -2585,12 +2069,12 @@ var ts; function getErrorSpanForNode(node) { var errorSpan; switch (node.kind) { - case 174 /* VariableDeclaration */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 181 /* ModuleDeclaration */: - case 180 /* EnumDeclaration */: - case 185 /* EnumMember */: + case 181 /* VariableDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 188 /* ModuleDeclaration */: + case 187 /* EnumDeclaration */: + case 192 /* EnumMember */: errorSpan = node.name; break; } @@ -2605,12 +2089,16 @@ var ts; return (file.flags & 1024 /* DeclarationFile */) !== 0; } ts.isDeclarationFile = isDeclarationFile; + function isConstEnumDeclaration(node) { + return (node.flags & 4096 /* Const */) !== 0; + } + ts.isConstEnumDeclaration = isConstEnumDeclaration; function isPrologueDirective(node) { - return node.kind === 154 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; + return node.kind === 161 /* ExpressionStatement */ && node.expression.kind === 7 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; function isEvalOrArgumentsIdentifier(node) { - return node.kind === 59 /* Identifier */ && node.text && (node.text === "eval" || node.text === "arguments"); + return node.kind === 63 /* Identifier */ && node.text && (node.text === "eval" || node.text === "arguments"); } function isUseStrictPrologueDirective(node) { ts.Debug.assert(isPrologueDirective(node)); @@ -2618,7 +2106,7 @@ var ts; } function getLeadingCommentRangesOfNode(node, sourceFileOfNode) { sourceFileOfNode = sourceFileOfNode || getSourceFileOfNode(node); - if (node.kind === 119 /* Parameter */ || node.kind === 118 /* TypeParameter */) { + if (node.kind === 123 /* Parameter */ || node.kind === 122 /* TypeParameter */) { return ts.concatenate(ts.getTrailingCommentRanges(sourceFileOfNode.text, node.pos), ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos)); } else { @@ -2654,122 +2142,128 @@ var ts; if (!node) return; switch (node.kind) { - case 117 /* QualifiedName */: + case 121 /* QualifiedName */: return child(node.left) || child(node.right); - case 118 /* TypeParameter */: + case 122 /* TypeParameter */: return child(node.name) || child(node.constraint); - case 119 /* Parameter */: + case 123 /* Parameter */: return child(node.name) || child(node.type) || child(node.initializer); - case 120 /* Property */: - case 137 /* PropertyAssignment */: + case 124 /* Property */: + case 141 /* PropertyAssignment */: return child(node.name) || child(node.type) || child(node.initializer); - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: return children(node.typeParameters) || children(node.parameters) || child(node.type); - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 144 /* FunctionExpression */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 149 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: return child(node.name) || children(node.typeParameters) || children(node.parameters) || child(node.type) || child(node.body); - case 128 /* TypeReference */: + case 132 /* TypeReference */: return child(node.typeName) || children(node.typeArguments); - case 129 /* TypeQuery */: + case 133 /* TypeQuery */: return child(node.exprName); - case 130 /* TypeLiteral */: + case 134 /* TypeLiteral */: return children(node.members); - case 131 /* ArrayType */: + case 135 /* ArrayType */: return child(node.elementType); - case 132 /* TupleType */: + case 136 /* TupleType */: return children(node.elementTypes); - case 133 /* UnionType */: + case 137 /* UnionType */: return children(node.types); - case 134 /* ParenType */: + case 138 /* ParenType */: return child(node.type); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return children(node.elements); - case 136 /* ObjectLiteral */: + case 140 /* ObjectLiteral */: return children(node.properties); - case 138 /* PropertyAccess */: + case 142 /* PropertyAccess */: return child(node.left) || child(node.right); - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return child(node.object) || child(node.index); - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return child(node.func) || children(node.typeArguments) || children(node.arguments); - case 142 /* TypeAssertion */: + case 146 /* TaggedTemplateExpression */: + return child(node.tag) || child(node.template); + case 147 /* TypeAssertion */: return child(node.type) || child(node.operand); - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return child(node.expression); - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: return child(node.operand); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return child(node.left) || child(node.right); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return child(node.condition) || child(node.whenTrue) || child(node.whenFalse); - case 151 /* Block */: - case 170 /* TryBlock */: - case 172 /* FinallyBlock */: - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: - case 186 /* SourceFile */: + case 158 /* Block */: + case 177 /* TryBlock */: + case 179 /* FinallyBlock */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: + case 193 /* SourceFile */: return children(node.statements); - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return children(node.declarations); - case 154 /* ExpressionStatement */: + case 161 /* ExpressionStatement */: return child(node.expression); - case 155 /* IfStatement */: + case 162 /* IfStatement */: return child(node.expression) || child(node.thenStatement) || child(node.elseStatement); - case 156 /* DoStatement */: + case 163 /* DoStatement */: return child(node.statement) || child(node.expression); - case 157 /* WhileStatement */: + case 164 /* WhileStatement */: return child(node.expression) || child(node.statement); - case 158 /* ForStatement */: + case 165 /* ForStatement */: return children(node.declarations) || child(node.initializer) || child(node.condition) || child(node.iterator) || child(node.statement); - case 159 /* ForInStatement */: + case 166 /* ForInStatement */: return child(node.declaration) || child(node.variable) || child(node.expression) || child(node.statement); - case 160 /* ContinueStatement */: - case 161 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 168 /* BreakStatement */: return child(node.label); - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return child(node.expression); - case 163 /* WithStatement */: + case 170 /* WithStatement */: return child(node.expression) || child(node.statement); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return child(node.expression) || children(node.clauses); - case 165 /* CaseClause */: - case 166 /* DefaultClause */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: return child(node.expression) || children(node.statements); - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return child(node.label) || child(node.statement); - case 168 /* ThrowStatement */: + case 175 /* ThrowStatement */: return child(node.expression); - case 169 /* TryStatement */: + case 176 /* TryStatement */: return child(node.tryBlock) || child(node.catchBlock) || child(node.finallyBlock); - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: return child(node.variable) || children(node.statements); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: return child(node.name) || child(node.type) || child(node.initializer); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return child(node.name) || children(node.typeParameters) || child(node.baseType) || children(node.implementedTypes) || children(node.members); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return child(node.name) || children(node.typeParameters) || children(node.baseTypes) || children(node.members); - case 179 /* TypeAliasDeclaration */: + case 186 /* TypeAliasDeclaration */: return child(node.name) || child(node.type); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return child(node.name) || children(node.members); - case 185 /* EnumMember */: + case 192 /* EnumMember */: return child(node.name) || child(node.initializer); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return child(node.name) || child(node.body); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return child(node.name) || child(node.entityName) || child(node.externalModuleName); - case 184 /* ExportAssignment */: + case 191 /* ExportAssignment */: return child(node.exportName); + case 155 /* TemplateExpression */: + return child(node.head) || children(node.templateSpans); + case 156 /* TemplateSpan */: + return child(node.expression) || child(node.literal); } } ts.forEachChild = forEachChild; @@ -2777,24 +2271,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return visitor(node); - case 151 /* Block */: - case 176 /* FunctionBlock */: - case 155 /* IfStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 163 /* WithStatement */: - case 164 /* SwitchStatement */: - case 165 /* CaseClause */: - case 166 /* DefaultClause */: - case 167 /* LabeledStatement */: - case 169 /* TryStatement */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: + case 158 /* Block */: + case 183 /* FunctionBlock */: + case 162 /* IfStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 170 /* WithStatement */: + case 171 /* SwitchStatement */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: + case 174 /* LabeledStatement */: + case 176 /* TryStatement */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: return forEachChild(node, traverse); } } @@ -2803,13 +2297,13 @@ var ts; function isAnyFunction(node) { if (node) { switch (node.kind) { - case 144 /* FunctionExpression */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: - case 121 /* Method */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 122 /* Constructor */: + case 149 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: + case 125 /* Method */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 126 /* Constructor */: return true; } } @@ -2832,20 +2326,20 @@ var ts; return undefined; } switch (node.kind) { - case 145 /* ArrowFunction */: + case 150 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 181 /* ModuleDeclaration */: - case 120 /* Property */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 180 /* EnumDeclaration */: - case 186 /* SourceFile */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 188 /* ModuleDeclaration */: + case 124 /* Property */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 187 /* EnumDeclaration */: + case 193 /* SourceFile */: return node; } } @@ -2858,20 +2352,103 @@ var ts; return undefined; } switch (node.kind) { - case 120 /* Property */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 124 /* Property */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return node; } } } ts.getSuperContainer = getSuperContainer; + function isExpression(node) { + switch (node.kind) { + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: + case 87 /* NullKeyword */: + case 93 /* TrueKeyword */: + case 78 /* FalseKeyword */: + case 8 /* RegularExpressionLiteral */: + case 139 /* ArrayLiteral */: + case 140 /* ObjectLiteral */: + case 142 /* PropertyAccess */: + case 143 /* IndexedAccess */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: + case 146 /* TaggedTemplateExpression */: + case 147 /* TypeAssertion */: + case 148 /* ParenExpression */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: + case 153 /* BinaryExpression */: + case 154 /* ConditionalExpression */: + case 155 /* TemplateExpression */: + case 157 /* OmittedExpression */: + return true; + case 121 /* QualifiedName */: + while (node.parent.kind === 121 /* QualifiedName */) + node = node.parent; + return node.parent.kind === 133 /* TypeQuery */; + case 63 /* Identifier */: + if (node.parent.kind === 133 /* TypeQuery */) { + return true; + } + case 6 /* NumericLiteral */: + case 7 /* StringLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: + var parent = node.parent; + switch (parent.kind) { + case 181 /* VariableDeclaration */: + case 123 /* Parameter */: + case 124 /* Property */: + case 192 /* EnumMember */: + case 141 /* PropertyAssignment */: + return parent.initializer === node; + case 161 /* ExpressionStatement */: + case 162 /* IfStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 169 /* ReturnStatement */: + case 170 /* WithStatement */: + case 171 /* SwitchStatement */: + case 172 /* CaseClause */: + case 175 /* ThrowStatement */: + case 171 /* SwitchStatement */: + return parent.expression === node; + case 165 /* ForStatement */: + return parent.initializer === node || parent.condition === node || parent.iterator === node; + case 166 /* ForInStatement */: + return parent.variable === node || parent.expression === node; + case 147 /* TypeAssertion */: + return node === parent.operand; + default: + if (isExpression(parent)) { + return true; + } + } + } + return false; + } + ts.isExpression = isExpression; function hasRestParameters(s) { return s.parameters.length > 0 && (s.parameters[s.parameters.length - 1].flags & 8 /* Rest */) !== 0; } ts.hasRestParameters = hasRestParameters; + function isLiteralKind(kind) { + return 6 /* FirstLiteralToken */ <= kind && kind <= 9 /* LastLiteralToken */; + } + ts.isLiteralKind = isLiteralKind; + function isTextualLiteralKind(kind) { + return kind === 7 /* StringLiteral */ || kind === 9 /* NoSubstitutionTemplateLiteral */; + } + ts.isTextualLiteralKind = isTextualLiteralKind; + function isTemplateLiteralKind(kind) { + return 9 /* FirstTemplateToken */ <= kind && kind <= 12 /* LastTemplateToken */; + } + ts.isTemplateLiteralKind = isTemplateLiteralKind; function isInAmbientContext(node) { while (node) { if (node.flags & (2 /* Ambient */ | 1024 /* DeclarationFile */)) @@ -2883,22 +2460,22 @@ var ts; ts.isInAmbientContext = isInAmbientContext; function isDeclaration(node) { switch (node.kind) { - case 118 /* TypeParameter */: - case 119 /* Parameter */: - case 174 /* VariableDeclaration */: - case 120 /* Property */: - case 137 /* PropertyAssignment */: - case 185 /* EnumMember */: - case 121 /* Method */: - case 175 /* FunctionDeclaration */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 180 /* EnumDeclaration */: - case 181 /* ModuleDeclaration */: - case 183 /* ImportDeclaration */: + case 122 /* TypeParameter */: + case 123 /* Parameter */: + case 181 /* VariableDeclaration */: + case 124 /* Property */: + case 141 /* PropertyAssignment */: + case 192 /* EnumMember */: + case 125 /* Method */: + case 182 /* FunctionDeclaration */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 187 /* EnumDeclaration */: + case 188 /* ModuleDeclaration */: + case 190 /* ImportDeclaration */: return true; } return false; @@ -2906,24 +2483,24 @@ var ts; ts.isDeclaration = isDeclaration; function isStatement(n) { switch (n.kind) { - case 161 /* BreakStatement */: - case 160 /* ContinueStatement */: - case 173 /* DebuggerStatement */: - case 156 /* DoStatement */: - case 154 /* ExpressionStatement */: - case 153 /* EmptyStatement */: - case 159 /* ForInStatement */: - case 158 /* ForStatement */: - case 155 /* IfStatement */: - case 167 /* LabeledStatement */: - case 162 /* ReturnStatement */: - case 164 /* SwitchStatement */: - case 88 /* ThrowKeyword */: - case 169 /* TryStatement */: - case 152 /* VariableStatement */: - case 157 /* WhileStatement */: - case 163 /* WithStatement */: - case 184 /* ExportAssignment */: + case 168 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 180 /* DebuggerStatement */: + case 163 /* DoStatement */: + case 161 /* ExpressionStatement */: + case 160 /* EmptyStatement */: + case 166 /* ForInStatement */: + case 165 /* ForStatement */: + case 162 /* IfStatement */: + case 174 /* LabeledStatement */: + case 169 /* ReturnStatement */: + case 171 /* SwitchStatement */: + case 92 /* ThrowKeyword */: + case 176 /* TryStatement */: + case 159 /* VariableStatement */: + case 164 /* WhileStatement */: + case 170 /* WithStatement */: + case 191 /* ExportAssignment */: return true; default: return false; @@ -2931,14 +2508,14 @@ var ts; } ts.isStatement = isStatement; function isDeclarationOrFunctionExpressionOrCatchVariableName(name) { - if (name.kind !== 59 /* Identifier */ && name.kind !== 7 /* StringLiteral */ && name.kind !== 6 /* NumericLiteral */) { + if (name.kind !== 63 /* Identifier */ && name.kind !== 7 /* StringLiteral */ && name.kind !== 6 /* NumericLiteral */) { return false; } var parent = name.parent; - if (isDeclaration(parent) || parent.kind === 144 /* FunctionExpression */) { + if (isDeclaration(parent) || parent.kind === 149 /* FunctionExpression */) { return parent.name === name; } - if (parent.kind === 171 /* CatchBlock */) { + if (parent.kind === 178 /* CatchBlock */) { return parent.variable === name; } return false; @@ -2946,16 +2523,16 @@ var ts; ts.isDeclarationOrFunctionExpressionOrCatchVariableName = isDeclarationOrFunctionExpressionOrCatchVariableName; function getAncestor(node, kind) { switch (kind) { - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: while (node) { switch (node.kind) { - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return node; - case 180 /* EnumDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 181 /* ModuleDeclaration */: - case 183 /* ImportDeclaration */: + case 187 /* EnumDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 188 /* ModuleDeclaration */: + case 190 /* ImportDeclaration */: return undefined; default: node = node.parent; @@ -2975,107 +2552,44 @@ var ts; return undefined; } ts.getAncestor = getAncestor; - var ParsingContext; - (function (ParsingContext) { - ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements"; - ParsingContext[ParsingContext["ModuleElements"] = 1] = "ModuleElements"; - ParsingContext[ParsingContext["BlockStatements"] = 2] = "BlockStatements"; - ParsingContext[ParsingContext["SwitchClauses"] = 3] = "SwitchClauses"; - ParsingContext[ParsingContext["SwitchClauseStatements"] = 4] = "SwitchClauseStatements"; - ParsingContext[ParsingContext["TypeMembers"] = 5] = "TypeMembers"; - ParsingContext[ParsingContext["ClassMembers"] = 6] = "ClassMembers"; - ParsingContext[ParsingContext["EnumMembers"] = 7] = "EnumMembers"; - ParsingContext[ParsingContext["BaseTypeReferences"] = 8] = "BaseTypeReferences"; - ParsingContext[ParsingContext["VariableDeclarations"] = 9] = "VariableDeclarations"; - ParsingContext[ParsingContext["ArgumentExpressions"] = 10] = "ArgumentExpressions"; - ParsingContext[ParsingContext["ObjectLiteralMembers"] = 11] = "ObjectLiteralMembers"; - ParsingContext[ParsingContext["ArrayLiteralMembers"] = 12] = "ArrayLiteralMembers"; - ParsingContext[ParsingContext["Parameters"] = 13] = "Parameters"; - ParsingContext[ParsingContext["TypeParameters"] = 14] = "TypeParameters"; - ParsingContext[ParsingContext["TypeArguments"] = 15] = "TypeArguments"; - ParsingContext[ParsingContext["TupleElementTypes"] = 16] = "TupleElementTypes"; - ParsingContext[ParsingContext["Count"] = 17] = "Count"; - })(ParsingContext || (ParsingContext = {})); - var Tristate; - (function (Tristate) { - Tristate[Tristate["False"] = 0] = "False"; - Tristate[Tristate["True"] = 1] = "True"; - Tristate[Tristate["Unknown"] = 2] = "Unknown"; - })(Tristate || (Tristate = {})); function parsingContextErrors(context) { switch (context) { - case 0 /* SourceElements */: - return ts.Diagnostics.Declaration_or_statement_expected; - case 1 /* ModuleElements */: - return ts.Diagnostics.Declaration_or_statement_expected; - case 2 /* BlockStatements */: - return ts.Diagnostics.Statement_expected; - case 3 /* SwitchClauses */: - return ts.Diagnostics.case_or_default_expected; - case 4 /* SwitchClauseStatements */: - return ts.Diagnostics.Statement_expected; - case 5 /* TypeMembers */: - return ts.Diagnostics.Property_or_signature_expected; - case 6 /* ClassMembers */: - return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; - case 7 /* EnumMembers */: - return ts.Diagnostics.Enum_member_expected; - case 8 /* BaseTypeReferences */: - return ts.Diagnostics.Type_reference_expected; - case 9 /* VariableDeclarations */: - return ts.Diagnostics.Variable_declaration_expected; - case 10 /* ArgumentExpressions */: - return ts.Diagnostics.Argument_expression_expected; - case 11 /* ObjectLiteralMembers */: - return ts.Diagnostics.Property_assignment_expected; - case 12 /* ArrayLiteralMembers */: - return ts.Diagnostics.Expression_or_comma_expected; - case 13 /* Parameters */: - return ts.Diagnostics.Parameter_declaration_expected; - case 14 /* TypeParameters */: - return ts.Diagnostics.Type_parameter_declaration_expected; - case 15 /* TypeArguments */: - return ts.Diagnostics.Type_argument_expected; - case 16 /* TupleElementTypes */: - return ts.Diagnostics.Type_expected; + case 0 /* SourceElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 1 /* ModuleElements */: return ts.Diagnostics.Declaration_or_statement_expected; + case 2 /* BlockStatements */: return ts.Diagnostics.Statement_expected; + case 3 /* SwitchClauses */: return ts.Diagnostics.case_or_default_expected; + case 4 /* SwitchClauseStatements */: return ts.Diagnostics.Statement_expected; + case 5 /* TypeMembers */: return ts.Diagnostics.Property_or_signature_expected; + case 6 /* ClassMembers */: return ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected; + case 7 /* EnumMembers */: return ts.Diagnostics.Enum_member_expected; + case 8 /* BaseTypeReferences */: return ts.Diagnostics.Type_reference_expected; + case 9 /* VariableDeclarations */: return ts.Diagnostics.Variable_declaration_expected; + case 10 /* ArgumentExpressions */: return ts.Diagnostics.Argument_expression_expected; + case 11 /* ObjectLiteralMembers */: return ts.Diagnostics.Property_assignment_expected; + case 12 /* ArrayLiteralMembers */: return ts.Diagnostics.Expression_or_comma_expected; + case 13 /* Parameters */: return ts.Diagnostics.Parameter_declaration_expected; + case 14 /* TypeParameters */: return ts.Diagnostics.Type_parameter_declaration_expected; + case 15 /* TypeArguments */: return ts.Diagnostics.Type_argument_expected; + case 16 /* TupleElementTypes */: return ts.Diagnostics.Type_expected; } } ; - var LookAheadMode; - (function (LookAheadMode) { - LookAheadMode[LookAheadMode["NotLookingAhead"] = 0] = "NotLookingAhead"; - LookAheadMode[LookAheadMode["NoErrorYet"] = 1] = "NoErrorYet"; - LookAheadMode[LookAheadMode["Error"] = 2] = "Error"; - })(LookAheadMode || (LookAheadMode = {})); - var ModifierContext; - (function (ModifierContext) { - ModifierContext[ModifierContext["SourceElements"] = 0] = "SourceElements"; - ModifierContext[ModifierContext["ModuleElements"] = 1] = "ModuleElements"; - ModifierContext[ModifierContext["ClassMembers"] = 2] = "ClassMembers"; - ModifierContext[ModifierContext["Parameters"] = 3] = "Parameters"; - })(ModifierContext || (ModifierContext = {})); - var ControlBlockContext; - (function (ControlBlockContext) { - ControlBlockContext[ControlBlockContext["NotNested"] = 0] = "NotNested"; - ControlBlockContext[ControlBlockContext["Nested"] = 1] = "Nested"; - ControlBlockContext[ControlBlockContext["CrossingFunctionBoundary"] = 2] = "CrossingFunctionBoundary"; - })(ControlBlockContext || (ControlBlockContext = {})); function isKeyword(token) { - return ts.SyntaxKind.FirstKeyword <= token && token <= ts.SyntaxKind.LastKeyword; + return 64 /* FirstKeyword */ <= token && token <= 119 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { - return ts.SyntaxKind.FirstTriviaToken <= token && token <= ts.SyntaxKind.LastTriviaToken; + return 2 /* FirstTriviaToken */ <= token && token <= 5 /* LastTriviaToken */; } ts.isTrivia = isTrivia; function isModifier(token) { switch (token) { - case 102 /* PublicKeyword */: - case 100 /* PrivateKeyword */: - case 101 /* ProtectedKeyword */: - case 103 /* StaticKeyword */: - case 72 /* ExportKeyword */: - case 108 /* DeclareKeyword */: + case 106 /* PublicKeyword */: + case 104 /* PrivateKeyword */: + case 105 /* ProtectedKeyword */: + case 107 /* StaticKeyword */: + case 76 /* ExportKeyword */: + case 112 /* DeclareKeyword */: return true; } return false; @@ -3237,6 +2751,9 @@ var ts; function reScanSlashToken() { return token = scanner.reScanSlashToken(); } + function reScanTemplateToken() { + return token = scanner.reScanTemplateToken(); + } function lookAheadHelper(callback, alwaysResetState) { var saveToken = token; var saveSyntacticErrorsLength = file.syntacticErrors.length; @@ -3266,7 +2783,7 @@ var ts; return scanner.tryScan(function () { return lookAheadHelper(callback, false); }); } function isIdentifier() { - return token === 59 /* Identifier */ || (isInStrictMode ? token > ts.SyntaxKind.LastFutureReservedWord : token > ts.SyntaxKind.LastReservedWord); + return token === 63 /* Identifier */ || (isInStrictMode ? token > 108 /* LastFutureReservedWord */ : token > 99 /* LastReservedWord */); } function parseExpected(t) { if (token === t) { @@ -3284,14 +2801,14 @@ var ts; return false; } function canParseSemicolon() { - if (token === 17 /* SemicolonToken */) { + if (token === 21 /* SemicolonToken */) { return true; } - return token === 10 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token === 14 /* CloseBraceToken */ || token === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token === 17 /* SemicolonToken */) { + if (token === 21 /* SemicolonToken */) { nextToken(); } } @@ -3313,7 +2830,7 @@ var ts; return node; } function createMissingNode() { - return createNode(116 /* Missing */); + return createNode(120 /* Missing */); } function internIdentifier(text) { return ts.hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); @@ -3321,7 +2838,7 @@ var ts; function createIdentifier(isIdentifier) { identifierCount++; if (isIdentifier) { - var node = createNode(59 /* Identifier */); + var node = createNode(63 /* Identifier */); var text = escapeIdentifier(scanner.getTokenValue()); node.text = internIdentifier(text); nextToken(); @@ -3336,10 +2853,10 @@ var ts; return createIdentifier(isIdentifier()); } function parseIdentifierName() { - return createIdentifier(token >= 59 /* Identifier */); + return createIdentifier(token >= 63 /* Identifier */); } function isPropertyName() { - return token >= 59 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; + return token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */; } function parsePropertyName() { if (token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { @@ -3350,13 +2867,13 @@ var ts; function parseContextualModifier(t) { return token === t && tryParse(function () { nextToken(); - return token === 13 /* OpenBracketToken */ || isPropertyName(); + return token === 17 /* OpenBracketToken */ || isPropertyName(); }); } function parseAnyContextualModifier() { return isModifier(token) && tryParse(function () { nextToken(); - return token === 13 /* OpenBracketToken */ || isPropertyName(); + return token === 17 /* OpenBracketToken */ || isPropertyName(); }); } function isListElement(kind, inErrorRecovery) { @@ -3368,28 +2885,28 @@ var ts; case 4 /* SwitchClauseStatements */: return isStatement(inErrorRecovery); case 3 /* SwitchClauses */: - return token === 61 /* CaseKeyword */ || token === 67 /* DefaultKeyword */; + return token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; case 5 /* TypeMembers */: - return isTypeMember(); + return isStartOfTypeMember(); case 6 /* ClassMembers */: return lookAhead(isClassMemberStart); case 7 /* EnumMembers */: case 11 /* ObjectLiteralMembers */: return isPropertyName(); case 8 /* BaseTypeReferences */: - return isIdentifier() && ((token !== 73 /* ExtendsKeyword */ && token !== 96 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); })); + return isIdentifier() && ((token !== 77 /* ExtendsKeyword */ && token !== 100 /* ImplementsKeyword */) || !lookAhead(function () { return (nextToken(), isIdentifier()); })); case 9 /* VariableDeclarations */: case 14 /* TypeParameters */: return isIdentifier(); case 10 /* ArgumentExpressions */: - return token === 18 /* CommaToken */ || isExpression(); + return token === 22 /* CommaToken */ || isStartOfExpression(); case 12 /* ArrayLiteralMembers */: - return token === 18 /* CommaToken */ || isExpression(); + return token === 22 /* CommaToken */ || isStartOfExpression(); case 13 /* Parameters */: - return isParameter(); + return isStartOfParameter(); case 15 /* TypeArguments */: case 16 /* TupleElementTypes */: - return token === 18 /* CommaToken */ || isType(); + return token === 22 /* CommaToken */ || isStartOfType(); } ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } @@ -3405,34 +2922,34 @@ var ts; case 6 /* ClassMembers */: case 7 /* EnumMembers */: case 11 /* ObjectLiteralMembers */: - return token === 10 /* CloseBraceToken */; + return token === 14 /* CloseBraceToken */; case 4 /* SwitchClauseStatements */: - return token === 10 /* CloseBraceToken */ || token === 61 /* CaseKeyword */ || token === 67 /* DefaultKeyword */; + return token === 14 /* CloseBraceToken */ || token === 65 /* CaseKeyword */ || token === 71 /* DefaultKeyword */; case 8 /* BaseTypeReferences */: - return token === 9 /* OpenBraceToken */ || token === 73 /* ExtendsKeyword */ || token === 96 /* ImplementsKeyword */; + return token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; case 9 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 14 /* TypeParameters */: - return token === 20 /* GreaterThanToken */ || token === 11 /* OpenParenToken */ || token === 9 /* OpenBraceToken */ || token === 73 /* ExtendsKeyword */ || token === 96 /* ImplementsKeyword */; + return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */ || token === 13 /* OpenBraceToken */ || token === 77 /* ExtendsKeyword */ || token === 100 /* ImplementsKeyword */; case 10 /* ArgumentExpressions */: - return token === 12 /* CloseParenToken */ || token === 17 /* SemicolonToken */; + return token === 16 /* CloseParenToken */ || token === 21 /* SemicolonToken */; case 12 /* ArrayLiteralMembers */: case 16 /* TupleElementTypes */: - return token === 14 /* CloseBracketToken */; + return token === 18 /* CloseBracketToken */; case 13 /* Parameters */: - return token === 12 /* CloseParenToken */ || token === 14 /* CloseBracketToken */ || token === 9 /* OpenBraceToken */; + return token === 16 /* CloseParenToken */ || token === 18 /* CloseBracketToken */ || token === 13 /* OpenBraceToken */; case 15 /* TypeArguments */: - return token === 20 /* GreaterThanToken */ || token === 11 /* OpenParenToken */; + return token === 24 /* GreaterThanToken */ || token === 15 /* OpenParenToken */; } } function isVariableDeclaratorListTerminator() { if (canParseSemicolon()) { return true; } - if (token === 80 /* InKeyword */) { + if (token === 84 /* InKeyword */) { return true; } - if (token === 27 /* EqualsGreaterThanToken */) { + if (token === 31 /* EqualsGreaterThanToken */) { return true; } return false; @@ -3493,7 +3010,7 @@ var ts; if (isListElement(kind, false)) { result.push(parseElement()); commaStart = scanner.getTokenPos(); - if (parseOptional(18 /* CommaToken */)) { + if (parseOptional(22 /* CommaToken */)) { continue; } commaStart = -1; @@ -3548,8 +3065,8 @@ var ts; } function parseEntityName(allowReservedWords) { var entity = parseIdentifier(); - while (parseOptional(15 /* DotToken */)) { - var node = createNode(117 /* QualifiedName */, entity.pos); + while (parseOptional(19 /* DotToken */)) { + var node = createNode(121 /* QualifiedName */, entity.pos); node.left = entity; node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier(); entity = finishNode(node); @@ -3561,6 +3078,35 @@ var ts; nextToken(); return finishNode(node); } + function parseTemplateExpression() { + var template = createNode(155 /* TemplateExpression */); + template.head = parseLiteralNode(); + ts.Debug.assert(template.head.kind === 10 /* TemplateHead */, "Template head has wrong token kind"); + var templateSpans = []; + templateSpans.pos = getNodePos(); + do { + templateSpans.push(parseTemplateSpan()); + } while (templateSpans[templateSpans.length - 1].literal.kind === 11 /* TemplateMiddle */); + templateSpans.end = getNodeEnd(); + template.templateSpans = templateSpans; + return finishNode(template); + } + function parseTemplateSpan() { + var span = createNode(156 /* TemplateSpan */); + span.expression = parseExpression(false); + var literal; + if (token === 14 /* CloseBraceToken */) { + reScanTemplateToken(); + literal = parseLiteralNode(); + } + else { + error(ts.Diagnostics.Invalid_template_literal_expected); + literal = createMissingNode(); + literal.text = ""; + } + span.literal = literal; + return finishNode(span); + } function parseLiteralNode(internName) { var node = createNode(token); var text = scanner.getTokenValue(); @@ -3579,30 +3125,31 @@ var ts; return node; } function parseStringLiteral() { - if (token === 7 /* StringLiteral */) + if (token === 7 /* StringLiteral */) { return parseLiteralNode(true); + } error(ts.Diagnostics.String_literal_expected); return createMissingNode(); } function parseTypeReference() { - var node = createNode(128 /* TypeReference */); + var node = createNode(132 /* TypeReference */); node.typeName = parseEntityName(false); - if (!scanner.hasPrecedingLineBreak() && token === 19 /* LessThanToken */) { + if (!scanner.hasPrecedingLineBreak() && token === 23 /* LessThanToken */) { node.typeArguments = parseTypeArguments(); } return finishNode(node); } function parseTypeQuery() { - var node = createNode(129 /* TypeQuery */); - parseExpected(91 /* TypeOfKeyword */); + var node = createNode(133 /* TypeQuery */); + parseExpected(95 /* TypeOfKeyword */); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(118 /* TypeParameter */); + var node = createNode(122 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(73 /* ExtendsKeyword */)) { - if (isType() || !isExpression()) { + if (parseOptional(77 /* ExtendsKeyword */)) { + if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } else { @@ -3613,9 +3160,9 @@ var ts; return finishNode(node); } function parseTypeParameters() { - if (token === 19 /* LessThanToken */) { + if (token === 23 /* LessThanToken */) { var pos = getNodePos(); - var result = parseBracketedList(14 /* TypeParameters */, parseTypeParameter, 19 /* LessThanToken */, 20 /* GreaterThanToken */); + var result = parseBracketedList(14 /* TypeParameters */, parseTypeParameter, 23 /* LessThanToken */, 24 /* GreaterThanToken */); if (!result.length) { var start = getTokenPos(pos); var length = getNodePos() - start; @@ -3625,23 +3172,23 @@ var ts; } } function parseParameterType() { - return parseOptional(46 /* ColonToken */) ? token === 7 /* StringLiteral */ ? parseStringLiteral() : parseType() : undefined; + return parseOptional(50 /* ColonToken */) ? token === 7 /* StringLiteral */ ? parseStringLiteral() : parseType() : undefined; } - function isParameter() { - return token === 16 /* DotDotDotToken */ || isIdentifier() || isModifier(token); + function isStartOfParameter() { + return token === 20 /* DotDotDotToken */ || isIdentifier() || isModifier(token); } function parseParameter(flags) { if (flags === void 0) { flags = 0; } - var node = createNode(119 /* Parameter */); + var node = createNode(123 /* Parameter */); node.flags |= parseAndCheckModifiers(3 /* Parameters */); - if (parseOptional(16 /* DotDotDotToken */)) { + if (parseOptional(20 /* DotDotDotToken */)) { node.flags |= 8 /* Rest */; } node.name = parseIdentifier(); - if (node.name.kind === 116 /* Missing */ && node.flags === 0 && isModifier(token)) { + if (node.name.kind === 120 /* Missing */ && node.flags === 0 && isModifier(token)) { nextToken(); } - if (parseOptional(45 /* QuestionToken */)) { + if (parseOptional(49 /* QuestionToken */)) { node.flags |= 4 /* QuestionMark */; } node.type = parseParameterType(); @@ -3649,11 +3196,11 @@ var ts; return finishNode(node); } function parseSignature(kind, returnToken, returnTokenRequired) { - if (kind === 126 /* ConstructSignature */) { - parseExpected(82 /* NewKeyword */); + if (kind === 130 /* ConstructSignature */) { + parseExpected(86 /* NewKeyword */); } var typeParameters = parseTypeParameters(); - var parameters = parseParameterList(11 /* OpenParenToken */, 12 /* CloseParenToken */); + var parameters = parseParameterList(15 /* OpenParenToken */, 16 /* CloseParenToken */); checkParameterList(parameters); var type; if (returnTokenRequired) { @@ -3720,10 +3267,10 @@ var ts; return finishNode(node); } function parseIndexSignatureMember() { - var node = createNode(127 /* IndexSignature */); + var node = createNode(131 /* IndexSignature */); var errorCountBeforeIndexSignature = file.syntacticErrors.length; var indexerStart = scanner.getTokenPos(); - node.parameters = parseParameterList(13 /* OpenBracketToken */, 14 /* CloseBracketToken */); + node.parameters = parseParameterList(17 /* OpenBracketToken */, 18 /* CloseBracketToken */); var indexerLength = scanner.getStartPos() - indexerStart; node.type = parseTypeAnnotation(); parseSemicolon(); @@ -3748,7 +3295,7 @@ var ts; grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter); return; } - else if (parameter.flags & ts.NodeFlags.Modifier) { + else if (parameter.flags & 243 /* Modifier */) { grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier); return; } @@ -3764,7 +3311,7 @@ var ts; grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); return; } - else if (parameter.type.kind !== 114 /* StringKeyword */ && parameter.type.kind !== 112 /* NumberKeyword */) { + else if (parameter.type.kind !== 118 /* StringKeyword */ && parameter.type.kind !== 116 /* NumberKeyword */) { grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); return; } @@ -3776,58 +3323,58 @@ var ts; function parsePropertyOrMethod() { var node = createNode(0 /* Unknown */); node.name = parsePropertyName(); - if (parseOptional(45 /* QuestionToken */)) { + if (parseOptional(49 /* QuestionToken */)) { node.flags |= 4 /* QuestionMark */; } - if (token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) { - node.kind = 121 /* Method */; - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { + node.kind = 125 /* Method */; + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; node.type = sig.type; } else { - node.kind = 120 /* Property */; + node.kind = 124 /* Property */; node.type = parseTypeAnnotation(); } parseSemicolon(); return finishNode(node); } - function isTypeMember() { + function isStartOfTypeMember() { switch (token) { - case 11 /* OpenParenToken */: - case 19 /* LessThanToken */: - case 13 /* OpenBracketToken */: + case 15 /* OpenParenToken */: + case 23 /* LessThanToken */: + case 17 /* OpenBracketToken */: return true; default: - return isPropertyName() && lookAhead(function () { return nextToken() === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */ || token === 45 /* QuestionToken */ || token === 46 /* ColonToken */ || canParseSemicolon(); }); + return isPropertyName() && lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */ || token === 49 /* QuestionToken */ || token === 50 /* ColonToken */ || canParseSemicolon(); }); } } function parseTypeMember() { switch (token) { - case 11 /* OpenParenToken */: - case 19 /* LessThanToken */: - return parseSignatureMember(125 /* CallSignature */, 46 /* ColonToken */); - case 13 /* OpenBracketToken */: + case 15 /* OpenParenToken */: + case 23 /* LessThanToken */: + return parseSignatureMember(129 /* CallSignature */, 50 /* ColonToken */); + case 17 /* OpenBracketToken */: return parseIndexSignatureMember(); - case 82 /* NewKeyword */: - if (lookAhead(function () { return nextToken() === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */; })) { - return parseSignatureMember(126 /* ConstructSignature */, 46 /* ColonToken */); + case 86 /* NewKeyword */: + if (lookAhead(function () { return nextToken() === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */; })) { + return parseSignatureMember(130 /* ConstructSignature */, 50 /* ColonToken */); } case 7 /* StringLiteral */: case 6 /* NumericLiteral */: return parsePropertyOrMethod(); default: - if (token >= 59 /* Identifier */) { + if (token >= 63 /* Identifier */) { return parsePropertyOrMethod(); } } } function parseTypeLiteral() { - var node = createNode(130 /* TypeLiteral */); - if (parseExpected(9 /* OpenBraceToken */)) { + var node = createNode(134 /* TypeLiteral */); + if (parseExpected(13 /* OpenBraceToken */)) { node.members = parseList(5 /* TypeMembers */, false, parseTypeMember); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -3835,26 +3382,26 @@ var ts; return finishNode(node); } function parseTupleType() { - var node = createNode(132 /* TupleType */); + var node = createNode(136 /* TupleType */); var startTokenPos = scanner.getTokenPos(); var startErrorCount = file.syntacticErrors.length; - node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 13 /* OpenBracketToken */, 14 /* CloseBracketToken */); + node.elementTypes = parseBracketedList(16 /* TupleElementTypes */, parseType, 17 /* OpenBracketToken */, 18 /* CloseBracketToken */); if (!node.elementTypes.length && file.syntacticErrors.length === startErrorCount) { grammarErrorAtPos(startTokenPos, scanner.getStartPos() - startTokenPos, ts.Diagnostics.A_tuple_type_element_list_cannot_be_empty); } return finishNode(node); } function parseParenType() { - var node = createNode(134 /* ParenType */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(138 /* ParenType */); + parseExpected(15 /* OpenParenToken */); node.type = parseType(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); return finishNode(node); } function parseFunctionType(signatureKind) { - var node = createNode(130 /* TypeLiteral */); + var node = createNode(134 /* TypeLiteral */); var member = createNode(signatureKind); - var sig = parseSignature(signatureKind, 27 /* EqualsGreaterThanToken */, true); + var sig = parseSignature(signatureKind, 31 /* EqualsGreaterThanToken */, true); member.typeParameters = sig.typeParameters; member.parameters = sig.parameters; member.type = sig.type; @@ -3864,24 +3411,24 @@ var ts; } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token === 15 /* DotToken */ ? undefined : node; + return token === 19 /* DotToken */ ? undefined : node; } function parseNonArrayType() { switch (token) { - case 105 /* AnyKeyword */: - case 114 /* StringKeyword */: - case 112 /* NumberKeyword */: - case 106 /* BooleanKeyword */: - case 93 /* VoidKeyword */: + case 109 /* AnyKeyword */: + case 118 /* StringKeyword */: + case 116 /* NumberKeyword */: + case 110 /* BooleanKeyword */: + case 97 /* VoidKeyword */: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); - case 91 /* TypeOfKeyword */: + case 95 /* TypeOfKeyword */: return parseTypeQuery(); - case 9 /* OpenBraceToken */: + case 13 /* OpenBraceToken */: return parseTypeLiteral(); - case 13 /* OpenBracketToken */: + case 17 /* OpenBracketToken */: return parseTupleType(); - case 11 /* OpenParenToken */: + case 15 /* OpenParenToken */: return parseParenType(); default: if (isIdentifier()) { @@ -3891,23 +3438,23 @@ var ts; error(ts.Diagnostics.Type_expected); return createMissingNode(); } - function isType() { + function isStartOfType() { switch (token) { - case 105 /* AnyKeyword */: - case 114 /* StringKeyword */: - case 112 /* NumberKeyword */: - case 106 /* BooleanKeyword */: - case 93 /* VoidKeyword */: - case 91 /* TypeOfKeyword */: - case 9 /* OpenBraceToken */: - case 13 /* OpenBracketToken */: - case 19 /* LessThanToken */: - case 82 /* NewKeyword */: + case 109 /* AnyKeyword */: + case 118 /* StringKeyword */: + case 116 /* NumberKeyword */: + case 110 /* BooleanKeyword */: + case 97 /* VoidKeyword */: + case 95 /* TypeOfKeyword */: + case 13 /* OpenBraceToken */: + case 17 /* OpenBracketToken */: + case 23 /* LessThanToken */: + case 86 /* NewKeyword */: return true; - case 11 /* OpenParenToken */: + case 15 /* OpenParenToken */: return lookAhead(function () { nextToken(); - return token === 12 /* CloseParenToken */ || isParameter() || isType(); + return token === 16 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); }); default: return isIdentifier(); @@ -3915,9 +3462,9 @@ var ts; } function parsePrimaryType() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(13 /* OpenBracketToken */)) { - parseExpected(14 /* CloseBracketToken */); - var node = createNode(131 /* ArrayType */, type.pos); + while (!scanner.hasPrecedingLineBreak() && parseOptional(17 /* OpenBracketToken */)) { + parseExpected(18 /* CloseBracketToken */); + var node = createNode(135 /* ArrayType */, type.pos); node.elementType = type; type = finishNode(node); } @@ -3925,33 +3472,33 @@ var ts; } function parseUnionType() { var type = parsePrimaryType(); - if (token === 39 /* BarToken */) { + if (token === 43 /* BarToken */) { var types = [type]; types.pos = type.pos; - while (parseOptional(39 /* BarToken */)) { + while (parseOptional(43 /* BarToken */)) { types.push(parsePrimaryType()); } types.end = getNodeEnd(); - var node = createNode(133 /* UnionType */, type.pos); + var node = createNode(137 /* UnionType */, type.pos); node.types = types; type = finishNode(node); } return type; } - function isFunctionType() { - return token === 19 /* LessThanToken */ || token === 11 /* OpenParenToken */ && lookAhead(function () { + function isStartOfFunctionType() { + return token === 23 /* LessThanToken */ || token === 15 /* OpenParenToken */ && lookAhead(function () { nextToken(); - if (token === 12 /* CloseParenToken */ || token === 16 /* DotDotDotToken */) { + if (token === 16 /* CloseParenToken */ || token === 20 /* DotDotDotToken */) { return true; } if (isIdentifier() || isModifier(token)) { nextToken(); - if (token === 46 /* ColonToken */ || token === 18 /* CommaToken */ || token === 45 /* QuestionToken */ || token === 47 /* EqualsToken */ || isIdentifier() || isModifier(token)) { + if (token === 50 /* ColonToken */ || token === 22 /* CommaToken */ || token === 49 /* QuestionToken */ || token === 51 /* EqualsToken */ || isIdentifier() || isModifier(token)) { return true; } - if (token === 12 /* CloseParenToken */) { + if (token === 16 /* CloseParenToken */) { nextToken(); - if (token === 27 /* EqualsGreaterThanToken */) { + if (token === 31 /* EqualsGreaterThanToken */) { return true; } } @@ -3960,66 +3507,68 @@ var ts; }); } function parseType() { - if (isFunctionType()) { - return parseFunctionType(125 /* CallSignature */); + if (isStartOfFunctionType()) { + return parseFunctionType(129 /* CallSignature */); } - if (token === 82 /* NewKeyword */) { - return parseFunctionType(126 /* ConstructSignature */); + if (token === 86 /* NewKeyword */) { + return parseFunctionType(130 /* ConstructSignature */); } return parseUnionType(); } function parseTypeAnnotation() { - return parseOptional(46 /* ColonToken */) ? parseType() : undefined; + return parseOptional(50 /* ColonToken */) ? parseType() : undefined; } - function isExpression() { + function isStartOfExpression() { switch (token) { - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: - case 83 /* NullKeyword */: - case 89 /* TrueKeyword */: - case 74 /* FalseKeyword */: + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: + case 87 /* NullKeyword */: + case 93 /* TrueKeyword */: + case 78 /* FalseKeyword */: case 6 /* NumericLiteral */: case 7 /* StringLiteral */: - case 11 /* OpenParenToken */: - case 13 /* OpenBracketToken */: - case 9 /* OpenBraceToken */: - case 77 /* FunctionKeyword */: - case 82 /* NewKeyword */: - case 31 /* SlashToken */: - case 51 /* SlashEqualsToken */: - case 28 /* PlusToken */: - case 29 /* MinusToken */: - case 42 /* TildeToken */: - case 41 /* ExclamationToken */: - case 68 /* DeleteKeyword */: - case 91 /* TypeOfKeyword */: - case 93 /* VoidKeyword */: - case 33 /* PlusPlusToken */: - case 34 /* MinusMinusToken */: - case 19 /* LessThanToken */: - case 59 /* Identifier */: + case 9 /* NoSubstitutionTemplateLiteral */: + case 10 /* TemplateHead */: + case 15 /* OpenParenToken */: + case 17 /* OpenBracketToken */: + case 13 /* OpenBraceToken */: + case 81 /* FunctionKeyword */: + case 86 /* NewKeyword */: + case 35 /* SlashToken */: + case 55 /* SlashEqualsToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: + case 46 /* TildeToken */: + case 45 /* ExclamationToken */: + case 72 /* DeleteKeyword */: + case 95 /* TypeOfKeyword */: + case 97 /* VoidKeyword */: + case 37 /* PlusPlusToken */: + case 38 /* MinusMinusToken */: + case 23 /* LessThanToken */: + case 63 /* Identifier */: return true; default: return isIdentifier(); } } - function isExpressionStatement() { - return token !== 9 /* OpenBraceToken */ && token !== 77 /* FunctionKeyword */ && isExpression(); + function isStartOfExpressionStatement() { + return token !== 13 /* OpenBraceToken */ && token !== 81 /* FunctionKeyword */ && isStartOfExpression(); } function parseExpression(noIn) { var expr = parseAssignmentExpression(noIn); - while (parseOptional(18 /* CommaToken */)) { - expr = makeBinaryExpression(expr, 18 /* CommaToken */, parseAssignmentExpression(noIn)); + while (parseOptional(22 /* CommaToken */)) { + expr = makeBinaryExpression(expr, 22 /* CommaToken */, parseAssignmentExpression(noIn)); } return expr; } function parseInitializer(inParameter, noIn) { - if (token !== 47 /* EqualsToken */) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token === 9 /* OpenBraceToken */) || !isExpression()) { + if (token !== 51 /* EqualsToken */) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token === 13 /* OpenBraceToken */) || !isStartOfExpression()) { return undefined; } } - parseExpected(47 /* EqualsToken */); + parseExpected(51 /* EqualsToken */); return parseAssignmentExpression(noIn); } function parseAssignmentExpression(noIn) { @@ -4028,7 +3577,7 @@ var ts; return arrowExpression; } var expr = parseConditionalExpression(noIn); - if (expr.kind === 59 /* Identifier */ && token === 27 /* EqualsGreaterThanToken */) { + if (expr.kind === 63 /* Identifier */ && token === 31 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } if (isLeftHandSideExpression(expr) && isAssignmentOperator()) { @@ -4044,33 +3593,36 @@ var ts; function isLeftHandSideExpression(expr) { if (expr) { switch (expr.kind) { - case 138 /* PropertyAccess */: - case 139 /* IndexedAccess */: - case 141 /* NewExpression */: - case 140 /* CallExpression */: - case 135 /* ArrayLiteral */: - case 143 /* ParenExpression */: - case 136 /* ObjectLiteral */: - case 144 /* FunctionExpression */: - case 59 /* Identifier */: - case 116 /* Missing */: + case 142 /* PropertyAccess */: + case 143 /* IndexedAccess */: + case 145 /* NewExpression */: + case 144 /* CallExpression */: + case 146 /* TaggedTemplateExpression */: + case 139 /* ArrayLiteral */: + case 148 /* ParenExpression */: + case 140 /* ObjectLiteral */: + case 149 /* FunctionExpression */: + case 63 /* Identifier */: + case 120 /* Missing */: case 8 /* RegularExpressionLiteral */: case 6 /* NumericLiteral */: case 7 /* StringLiteral */: - case 74 /* FalseKeyword */: - case 83 /* NullKeyword */: - case 87 /* ThisKeyword */: - case 89 /* TrueKeyword */: - case 85 /* SuperKeyword */: + case 9 /* NoSubstitutionTemplateLiteral */: + case 155 /* TemplateExpression */: + case 78 /* FalseKeyword */: + case 87 /* NullKeyword */: + case 91 /* ThisKeyword */: + case 93 /* TrueKeyword */: + case 89 /* SuperKeyword */: return true; } } return false; } function parseSimpleArrowFunctionExpression(identifier) { - ts.Debug.assert(token === 27 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); - parseExpected(27 /* EqualsGreaterThanToken */); - var parameter = createNode(119 /* Parameter */, identifier.pos); + ts.Debug.assert(token === 31 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + parseExpected(31 /* EqualsGreaterThanToken */); + var parameter = createNode(123 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); var parameters = []; @@ -4087,17 +3639,17 @@ var ts; } var pos = getNodePos(); if (triState === 1 /* True */) { - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); - if (parseExpected(27 /* EqualsGreaterThanToken */) || token === 9 /* OpenBraceToken */) { + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); + if (parseExpected(31 /* EqualsGreaterThanToken */) || token === 13 /* OpenBraceToken */) { return parseArrowExpressionTail(pos, sig, false); } else { - return makeFunctionExpression(145 /* ArrowFunction */, pos, undefined, sig, createMissingNode()); + return makeFunctionExpression(150 /* ArrowFunction */, pos, undefined, sig, createMissingNode()); } } var sig = tryParseSignatureIfArrowOrBraceFollows(); if (sig) { - parseExpected(27 /* EqualsGreaterThanToken */); + parseExpected(31 /* EqualsGreaterThanToken */); return parseArrowExpressionTail(pos, sig, false); } else { @@ -4105,35 +3657,35 @@ var ts; } } function isParenthesizedArrowFunctionExpression() { - if (token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) { + if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { return lookAhead(function () { var first = token; var second = nextToken(); - if (first === 11 /* OpenParenToken */) { - if (second === 12 /* CloseParenToken */) { + if (first === 15 /* OpenParenToken */) { + if (second === 16 /* CloseParenToken */) { var third = nextToken(); switch (third) { - case 27 /* EqualsGreaterThanToken */: - case 46 /* ColonToken */: - case 9 /* OpenBraceToken */: + case 31 /* EqualsGreaterThanToken */: + case 50 /* ColonToken */: + case 13 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; } } - if (second === 16 /* DotDotDotToken */) { + if (second === 20 /* DotDotDotToken */) { return 1 /* True */; } if (!isIdentifier()) { return 0 /* False */; } - if (nextToken() === 46 /* ColonToken */) { + if (nextToken() === 50 /* ColonToken */) { return 1 /* True */; } return 2 /* Unknown */; } else { - ts.Debug.assert(first === 19 /* LessThanToken */); + ts.Debug.assert(first === 23 /* LessThanToken */); if (!isIdentifier()) { return 0 /* False */; } @@ -4141,15 +3693,15 @@ var ts; } }); } - if (token === 27 /* EqualsGreaterThanToken */) { + if (token === 31 /* EqualsGreaterThanToken */) { return 1 /* True */; } return 0 /* False */; } function tryParseSignatureIfArrowOrBraceFollows() { return tryParse(function () { - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); - if (token === 27 /* EqualsGreaterThanToken */ || token === 9 /* OpenBraceToken */) { + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); + if (token === 31 /* EqualsGreaterThanToken */ || token === 13 /* OpenBraceToken */) { return sig; } return undefined; @@ -4157,27 +3709,27 @@ var ts; } function parseArrowExpressionTail(pos, sig, noIn) { var body; - if (token === 9 /* OpenBraceToken */) { + if (token === 13 /* OpenBraceToken */) { body = parseBody(false); } - else if (isStatement(true) && !isExpressionStatement() && token !== 77 /* FunctionKeyword */) { + else if (isStatement(true) && !isStartOfExpressionStatement() && token !== 81 /* FunctionKeyword */) { body = parseBody(true); } else { body = parseAssignmentExpression(noIn); } - return makeFunctionExpression(145 /* ArrowFunction */, pos, undefined, sig, body); + return makeFunctionExpression(150 /* ArrowFunction */, pos, undefined, sig, body); } function isAssignmentOperator() { - return token >= ts.SyntaxKind.FirstAssignment && token <= ts.SyntaxKind.LastAssignment; + return token >= 51 /* FirstAssignment */ && token <= 62 /* LastAssignment */; } function parseConditionalExpression(noIn) { var expr = parseBinaryExpression(noIn); - while (parseOptional(45 /* QuestionToken */)) { - var node = createNode(149 /* ConditionalExpression */, expr.pos); + while (parseOptional(49 /* QuestionToken */)) { + var node = createNode(154 /* ConditionalExpression */, expr.pos); node.condition = expr; node.whenTrue = parseAssignmentExpression(false); - parseExpected(46 /* ColonToken */); + parseExpected(50 /* ColonToken */); node.whenFalse = parseAssignmentExpression(noIn); expr = finishNode(node); } @@ -4190,7 +3742,7 @@ var ts; while (true) { reScanGreaterToken(); var precedence = getOperatorPrecedence(); - if (precedence && precedence > minPrecedence && (!noIn || token !== 80 /* InKeyword */)) { + if (precedence && precedence > minPrecedence && (!noIn || token !== 84 /* InKeyword */)) { var operator = token; nextToken(); expr = makeBinaryExpression(expr, operator, parseBinaryOperators(parseUnaryExpression(), precedence, noIn)); @@ -4201,44 +3753,44 @@ var ts; } function getOperatorPrecedence() { switch (token) { - case 44 /* BarBarToken */: + case 48 /* BarBarToken */: return 1; - case 43 /* AmpersandAmpersandToken */: + case 47 /* AmpersandAmpersandToken */: return 2; - case 39 /* BarToken */: + case 43 /* BarToken */: return 3; - case 40 /* CaretToken */: + case 44 /* CaretToken */: return 4; - case 38 /* AmpersandToken */: + case 42 /* AmpersandToken */: return 5; - case 23 /* EqualsEqualsToken */: - case 24 /* ExclamationEqualsToken */: - case 25 /* EqualsEqualsEqualsToken */: - case 26 /* ExclamationEqualsEqualsToken */: + case 27 /* EqualsEqualsToken */: + case 28 /* ExclamationEqualsToken */: + case 29 /* EqualsEqualsEqualsToken */: + case 30 /* ExclamationEqualsEqualsToken */: return 6; - case 19 /* LessThanToken */: - case 20 /* GreaterThanToken */: - case 21 /* LessThanEqualsToken */: - case 22 /* GreaterThanEqualsToken */: - case 81 /* InstanceOfKeyword */: - case 80 /* InKeyword */: + case 23 /* LessThanToken */: + case 24 /* GreaterThanToken */: + case 25 /* LessThanEqualsToken */: + case 26 /* GreaterThanEqualsToken */: + case 85 /* InstanceOfKeyword */: + case 84 /* InKeyword */: return 7; - case 35 /* LessThanLessThanToken */: - case 36 /* GreaterThanGreaterThanToken */: - case 37 /* GreaterThanGreaterThanGreaterThanToken */: + case 39 /* LessThanLessThanToken */: + case 40 /* GreaterThanGreaterThanToken */: + case 41 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 28 /* PlusToken */: - case 29 /* MinusToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: return 9; - case 30 /* AsteriskToken */: - case 31 /* SlashToken */: - case 32 /* PercentToken */: + case 34 /* AsteriskToken */: + case 35 /* SlashToken */: + case 36 /* PercentToken */: return 10; } return undefined; } function makeBinaryExpression(left, operator, right) { - var node = createNode(148 /* BinaryExpression */, left.pos); + var node = createNode(153 /* BinaryExpression */, left.pos); node.left = left; node.operator = operator; node.right = right; @@ -4247,52 +3799,52 @@ var ts; function parseUnaryExpression() { var pos = getNodePos(); switch (token) { - case 28 /* PlusToken */: - case 29 /* MinusToken */: - case 42 /* TildeToken */: - case 41 /* ExclamationToken */: - case 68 /* DeleteKeyword */: - case 91 /* TypeOfKeyword */: - case 93 /* VoidKeyword */: - case 33 /* PlusPlusToken */: - case 34 /* MinusMinusToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: + case 46 /* TildeToken */: + case 45 /* ExclamationToken */: + case 72 /* DeleteKeyword */: + case 95 /* TypeOfKeyword */: + case 97 /* VoidKeyword */: + case 37 /* PlusPlusToken */: + case 38 /* MinusMinusToken */: var operator = token; nextToken(); var operand = parseUnaryExpression(); if (isInStrictMode) { - if ((operator === 33 /* PlusPlusToken */ || operator === 34 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(operand)) { + if ((operator === 37 /* PlusPlusToken */ || operator === 38 /* MinusMinusToken */) && isEvalOrArgumentsIdentifier(operand)) { reportInvalidUseInStrictMode(operand); } - else if (operator === 68 /* DeleteKeyword */ && operand.kind === 59 /* Identifier */) { + else if (operator === 72 /* DeleteKeyword */ && operand.kind === 63 /* Identifier */) { grammarErrorOnNode(operand, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode); } } - return makeUnaryExpression(146 /* PrefixOperator */, pos, operator, operand); - case 19 /* LessThanToken */: + return makeUnaryExpression(151 /* PrefixOperator */, pos, operator, operand); + case 23 /* LessThanToken */: return parseTypeAssertion(); } var primaryExpression = parsePrimaryExpression(); - var illegalUsageOfSuperKeyword = primaryExpression.kind === 85 /* SuperKeyword */ && token !== 11 /* OpenParenToken */ && token !== 15 /* DotToken */; + var illegalUsageOfSuperKeyword = primaryExpression.kind === 89 /* SuperKeyword */ && token !== 15 /* OpenParenToken */ && token !== 19 /* DotToken */; if (illegalUsageOfSuperKeyword) { error(ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); } var expr = parseCallAndAccess(primaryExpression, false); ts.Debug.assert(isLeftHandSideExpression(expr)); - if ((token === 33 /* PlusPlusToken */ || token === 34 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + if ((token === 37 /* PlusPlusToken */ || token === 38 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { if (isInStrictMode && isEvalOrArgumentsIdentifier(expr)) { reportInvalidUseInStrictMode(expr); } var operator = token; nextToken(); - expr = makeUnaryExpression(147 /* PostfixOperator */, expr.pos, operator, expr); + expr = makeUnaryExpression(152 /* PostfixOperator */, expr.pos, operator, expr); } return expr; } function parseTypeAssertion() { - var node = createNode(142 /* TypeAssertion */); - parseExpected(19 /* LessThanToken */); + var node = createNode(147 /* TypeAssertion */); + parseExpected(23 /* LessThanToken */); node.type = parseType(); - parseExpected(20 /* GreaterThanToken */); + parseExpected(24 /* GreaterThanToken */); node.operand = parseUnaryExpression(); return finishNode(node); } @@ -4304,11 +3856,11 @@ var ts; } function parseCallAndAccess(expr, inNewExpression) { while (true) { - var dotStart = scanner.getTokenPos(); - if (parseOptional(15 /* DotToken */)) { - var propertyAccess = createNode(138 /* PropertyAccess */, expr.pos); + var dotOrBracketStart = scanner.getTokenPos(); + if (parseOptional(19 /* DotToken */)) { + var propertyAccess = createNode(142 /* PropertyAccess */, expr.pos); if (scanner.hasPrecedingLineBreak() && scanner.isReservedWord() && lookAhead(function () { return scanner.isReservedWord(); })) { - grammarErrorAtPos(dotStart, scanner.getStartPos() - dotStart, ts.Diagnostics.Identifier_expected); + grammarErrorAtPos(dotOrBracketStart, scanner.getStartPos() - dotOrBracketStart, ts.Diagnostics.Identifier_expected); var id = createMissingNode(); } else { @@ -4319,13 +3871,12 @@ var ts; expr = finishNode(propertyAccess); continue; } - var bracketStart = scanner.getTokenPos(); - if (parseOptional(13 /* OpenBracketToken */)) { - var indexedAccess = createNode(139 /* IndexedAccess */, expr.pos); + if (parseOptional(17 /* OpenBracketToken */)) { + var indexedAccess = createNode(143 /* IndexedAccess */, expr.pos); indexedAccess.object = expr; - if (inNewExpression && parseOptional(14 /* CloseBracketToken */)) { + if (inNewExpression && parseOptional(18 /* CloseBracketToken */)) { indexedAccess.index = createMissingNode(); - grammarErrorAtPos(bracketStart, scanner.getStartPos() - bracketStart, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); + grammarErrorAtPos(dotOrBracketStart, scanner.getStartPos() - dotOrBracketStart, ts.Diagnostics.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead); } else { indexedAccess.index = parseExpression(); @@ -4333,79 +3884,92 @@ var ts; var literal = indexedAccess.index; literal.text = internIdentifier(literal.text); } - parseExpected(14 /* CloseBracketToken */); + parseExpected(18 /* CloseBracketToken */); } expr = finishNode(indexedAccess); continue; } - if ((token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) && !inNewExpression) { - var callExpr = createNode(140 /* CallExpression */, expr.pos); + if ((token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) && !inNewExpression) { + var callExpr = createNode(144 /* CallExpression */, expr.pos); callExpr.func = expr; - if (token === 19 /* LessThanToken */) { + if (token === 23 /* LessThanToken */) { if (!(callExpr.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) return expr; } else { - parseExpected(11 /* OpenParenToken */); + parseExpected(15 /* OpenParenToken */); } callExpr.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression, false); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); expr = finishNode(callExpr); continue; } + if (token === 9 /* NoSubstitutionTemplateLiteral */ || token === 10 /* TemplateHead */) { + var tagExpression = createNode(146 /* TaggedTemplateExpression */, expr.pos); + tagExpression.tag = expr; + tagExpression.template = token === 9 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); + expr = finishNode(tagExpression); + if (languageVersion < 2 /* ES6 */) { + grammarErrorOnNode(expr, ts.Diagnostics.Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher); + } + continue; + } return expr; } } function parseTypeArgumentsAndOpenParen() { var result = parseTypeArguments(); - parseExpected(11 /* OpenParenToken */); + parseExpected(15 /* OpenParenToken */); return result; } function parseTypeArguments() { var typeArgumentListStart = scanner.getTokenPos(); var errorCountBeforeTypeParameterList = file.syntacticErrors.length; - var result = parseBracketedList(15 /* TypeArguments */, parseSingleTypeArgument, 19 /* LessThanToken */, 20 /* GreaterThanToken */); + var result = parseBracketedList(15 /* TypeArguments */, parseSingleTypeArgument, 23 /* LessThanToken */, 24 /* GreaterThanToken */); if (!result.length && file.syntacticErrors.length === errorCountBeforeTypeParameterList) { grammarErrorAtPos(typeArgumentListStart, scanner.getStartPos() - typeArgumentListStart, ts.Diagnostics.Type_argument_list_cannot_be_empty); } return result; } function parseSingleTypeArgument() { - if (token === 18 /* CommaToken */) { + if (token === 22 /* CommaToken */) { var errorStart = scanner.getTokenPos(); var errorLength = scanner.getTextPos() - errorStart; grammarErrorAtPos(errorStart, errorLength, ts.Diagnostics.Type_expected); - return createNode(116 /* Missing */); + return createNode(120 /* Missing */); } return parseType(); } function parsePrimaryExpression() { switch (token) { - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: - case 83 /* NullKeyword */: - case 89 /* TrueKeyword */: - case 74 /* FalseKeyword */: + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: + case 87 /* NullKeyword */: + case 93 /* TrueKeyword */: + case 78 /* FalseKeyword */: return parseTokenNode(); case 6 /* NumericLiteral */: case 7 /* StringLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 11 /* OpenParenToken */: + case 15 /* OpenParenToken */: return parseParenExpression(); - case 13 /* OpenBracketToken */: + case 17 /* OpenBracketToken */: return parseArrayLiteral(); - case 9 /* OpenBraceToken */: + case 13 /* OpenBraceToken */: return parseObjectLiteral(); - case 77 /* FunctionKeyword */: + case 81 /* FunctionKeyword */: return parseFunctionExpression(); - case 82 /* NewKeyword */: + case 86 /* NewKeyword */: return parseNewExpression(); - case 31 /* SlashToken */: - case 51 /* SlashEqualsToken */: + case 35 /* SlashToken */: + case 55 /* SlashEqualsToken */: if (reScanSlashToken() === 8 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; + case 10 /* TemplateHead */: + return parseTemplateExpression(); default: if (isIdentifier()) { return parseIdentifier(); @@ -4415,20 +3979,20 @@ var ts; return createMissingNode(); } function parseParenExpression() { - var node = createNode(143 /* ParenExpression */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(148 /* ParenExpression */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); return finishNode(node); } function parseAssignmentExpressionOrOmittedExpression(omittedExpressionDiagnostic) { - if (token === 18 /* CommaToken */) { + if (token === 22 /* CommaToken */) { if (omittedExpressionDiagnostic) { var errorStart = scanner.getTokenPos(); var errorLength = scanner.getTextPos() - errorStart; grammarErrorAtPos(errorStart, errorLength, omittedExpressionDiagnostic); } - return createNode(150 /* OmittedExpression */); + return createNode(157 /* OmittedExpression */); } return parseAssignmentExpression(); } @@ -4439,24 +4003,24 @@ var ts; return parseAssignmentExpressionOrOmittedExpression(ts.Diagnostics.Argument_expression_expected); } function parseArrayLiteral() { - var node = createNode(135 /* ArrayLiteral */); - parseExpected(13 /* OpenBracketToken */); + var node = createNode(139 /* ArrayLiteral */); + parseExpected(17 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) node.flags |= 256 /* MultiLine */; node.elements = parseDelimitedList(12 /* ArrayLiteralMembers */, parseArrayLiteralElement, true); - parseExpected(14 /* CloseBracketToken */); + parseExpected(18 /* CloseBracketToken */); return finishNode(node); } function parsePropertyAssignment() { - var node = createNode(137 /* PropertyAssignment */); + var node = createNode(141 /* PropertyAssignment */); node.name = parsePropertyName(); - if (token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) { - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); var body = parseBody(false); - node.initializer = makeFunctionExpression(144 /* FunctionExpression */, node.pos, undefined, sig, body); + node.initializer = makeFunctionExpression(149 /* FunctionExpression */, node.pos, undefined, sig, body); } else { - parseExpected(46 /* ColonToken */); + parseExpected(50 /* ColonToken */); node.initializer = parseAssignmentExpression(false); } return finishNode(node); @@ -4464,41 +4028,41 @@ var ts; function parseObjectLiteralMember() { var initialPos = getNodePos(); var initialToken = token; - if (parseContextualModifier(109 /* GetKeyword */) || parseContextualModifier(113 /* SetKeyword */)) { - var kind = initialToken === 109 /* GetKeyword */ ? 123 /* GetAccessor */ : 124 /* SetAccessor */; + if (parseContextualModifier(113 /* GetKeyword */) || parseContextualModifier(117 /* SetKeyword */)) { + var kind = initialToken === 113 /* GetKeyword */ ? 127 /* GetAccessor */ : 128 /* SetAccessor */; return parseAndCheckMemberAccessorDeclaration(kind, initialPos, 0); } return parsePropertyAssignment(); } function parseObjectLiteral() { - var node = createNode(136 /* ObjectLiteral */); - parseExpected(9 /* OpenBraceToken */); + var node = createNode(140 /* ObjectLiteral */); + parseExpected(13 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.flags |= 256 /* MultiLine */; } node.properties = parseDelimitedList(11 /* ObjectLiteralMembers */, parseObjectLiteralMember, true); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); var seen = {}; var Property = 1; var GetAccessor = 2; var SetAccesor = 4; var GetOrSetAccessor = GetAccessor | SetAccesor; ts.forEach(node.properties, function (p) { - if (p.kind === 150 /* OmittedExpression */) { + if (p.kind === 157 /* OmittedExpression */) { return; } var currentKind; - if (p.kind === 137 /* PropertyAssignment */) { + if (p.kind === 141 /* PropertyAssignment */) { currentKind = Property; } - else if (p.kind === 123 /* GetAccessor */) { + else if (p.kind === 127 /* GetAccessor */) { currentKind = GetAccessor; } - else if (p.kind === 124 /* SetAccessor */) { + else if (p.kind === 128 /* SetAccessor */) { currentKind = SetAccesor; } else { - ts.Debug.fail("Unexpected syntax kind:" + ts.SyntaxKind[p.kind]); + ts.Debug.fail("Unexpected syntax kind:" + p.kind); } if (!ts.hasProperty(seen, p.name.text)) { seen[p.name.text] = currentKind; @@ -4527,14 +4091,14 @@ var ts; } function parseFunctionExpression() { var pos = getNodePos(); - parseExpected(77 /* FunctionKeyword */); + parseExpected(81 /* FunctionKeyword */); var name = isIdentifier() ? parseIdentifier() : undefined; - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); var body = parseBody(false); if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) { reportInvalidUseInStrictMode(name); } - return makeFunctionExpression(144 /* FunctionExpression */, pos, name, sig, body); + return makeFunctionExpression(149 /* FunctionExpression */, pos, name, sig, body); } function makeFunctionExpression(kind, pos, name, sig, body) { var node = createNode(kind, pos); @@ -4546,12 +4110,12 @@ var ts; return finishNode(node); } function parseNewExpression() { - var node = createNode(141 /* NewExpression */); - parseExpected(82 /* NewKeyword */); + var node = createNode(145 /* NewExpression */); + parseExpected(86 /* NewKeyword */); node.func = parseCallAndAccess(parsePrimaryExpression(), true); - if (parseOptional(11 /* OpenParenToken */) || token === 19 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { + if (parseOptional(15 /* OpenParenToken */) || token === 23 /* LessThanToken */ && (node.typeArguments = tryParse(parseTypeArgumentsAndOpenParen))) { node.arguments = parseDelimitedList(10 /* ArgumentExpressions */, parseArgumentExpression, false); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); } return finishNode(node); } @@ -4559,10 +4123,10 @@ var ts; return parseStatement(true); } function parseBlock(ignoreMissingOpenBrace, checkForStrictMode) { - var node = createNode(151 /* Block */); - if (parseExpected(9 /* OpenBraceToken */) || ignoreMissingOpenBrace) { + var node = createNode(158 /* Block */); + if (parseExpected(13 /* OpenBraceToken */) || ignoreMissingOpenBrace) { node.statements = parseList(2 /* BlockStatements */, checkForStrictMode, parseStatementAllowingLetDeclaration); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -4582,7 +4146,7 @@ var ts; } labelledStatementInfo.pushFunctionBoundary(); var block = parseBlock(ignoreMissingOpenBrace, true); - block.kind = 176 /* FunctionBlock */; + block.kind = 183 /* FunctionBlock */; labelledStatementInfo.pop(); inFunctionBody = saveInFunctionBody; inSwitchStatement = saveInSwitchStatement; @@ -4590,40 +4154,40 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(153 /* EmptyStatement */); - parseExpected(17 /* SemicolonToken */); + var node = createNode(160 /* EmptyStatement */); + parseExpected(21 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(155 /* IfStatement */); - parseExpected(78 /* IfKeyword */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(162 /* IfStatement */); + parseExpected(82 /* IfKeyword */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); node.thenStatement = parseStatement(false); - node.elseStatement = parseOptional(70 /* ElseKeyword */) ? parseStatement(false) : undefined; + node.elseStatement = parseOptional(74 /* ElseKeyword */) ? parseStatement(false) : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(156 /* DoStatement */); - parseExpected(69 /* DoKeyword */); + var node = createNode(163 /* DoStatement */); + parseExpected(73 /* DoKeyword */); var saveInIterationStatement = inIterationStatement; inIterationStatement = 1 /* Nested */; node.statement = parseStatement(false); inIterationStatement = saveInIterationStatement; - parseExpected(94 /* WhileKeyword */); - parseExpected(11 /* OpenParenToken */); + parseExpected(98 /* WhileKeyword */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); - parseOptional(17 /* SemicolonToken */); + parseExpected(16 /* CloseParenToken */); + parseOptional(21 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(157 /* WhileStatement */); - parseExpected(94 /* WhileKeyword */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(164 /* WhileStatement */); + parseExpected(98 /* WhileKeyword */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); var saveInIterationStatement = inIterationStatement; inIterationStatement = 1 /* Nested */; node.statement = parseStatement(false); @@ -4632,16 +4196,16 @@ var ts; } function parseForOrForInStatement() { var pos = getNodePos(); - parseExpected(76 /* ForKeyword */); - parseExpected(11 /* OpenParenToken */); - if (token !== 17 /* SemicolonToken */) { - if (parseOptional(92 /* VarKeyword */)) { + parseExpected(80 /* ForKeyword */); + parseExpected(15 /* OpenParenToken */); + if (token !== 21 /* SemicolonToken */) { + if (parseOptional(96 /* VarKeyword */)) { var declarations = parseVariableDeclarationList(0, true); if (!declarations.length) { error(ts.Diagnostics.Variable_declaration_list_cannot_be_empty); } } - else if (parseOptional(98 /* LetKeyword */)) { + else if (parseOptional(102 /* LetKeyword */)) { var declarations = parseVariableDeclarationList(2048 /* Let */, true); if (!declarations.length) { error(ts.Diagnostics.Variable_declaration_list_cannot_be_empty); @@ -4650,7 +4214,7 @@ var ts; grammarErrorAtPos(declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.let_declarations_are_only_available_when_targeting_ECMAScript_6_and_higher); } } - else if (parseOptional(64 /* ConstKeyword */)) { + else if (parseOptional(68 /* ConstKeyword */)) { var declarations = parseVariableDeclarationList(4096 /* Const */, true); if (!declarations.length) { error(ts.Diagnostics.Variable_declaration_list_cannot_be_empty); @@ -4664,8 +4228,8 @@ var ts; } } var forOrForInStatement; - if (parseOptional(80 /* InKeyword */)) { - var forInStatement = createNode(159 /* ForInStatement */, pos); + if (parseOptional(84 /* InKeyword */)) { + var forInStatement = createNode(166 /* ForInStatement */, pos); if (declarations) { if (declarations.length > 1) { error(ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement); @@ -4676,24 +4240,24 @@ var ts; forInStatement.variable = varOrInit; } forInStatement.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); forOrForInStatement = forInStatement; } else { - var forStatement = createNode(158 /* ForStatement */, pos); + var forStatement = createNode(165 /* ForStatement */, pos); if (declarations) forStatement.declarations = declarations; if (varOrInit) forStatement.initializer = varOrInit; - parseExpected(17 /* SemicolonToken */); - if (token !== 17 /* SemicolonToken */ && token !== 12 /* CloseParenToken */) { + parseExpected(21 /* SemicolonToken */); + if (token !== 21 /* SemicolonToken */ && token !== 16 /* CloseParenToken */) { forStatement.condition = parseExpression(); } - parseExpected(17 /* SemicolonToken */); - if (token !== 12 /* CloseParenToken */) { + parseExpected(21 /* SemicolonToken */); + if (token !== 16 /* CloseParenToken */) { forStatement.iterator = parseExpression(); } - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); forOrForInStatement = forStatement; } var saveInIterationStatement = inIterationStatement; @@ -4705,7 +4269,7 @@ var ts; function parseBreakOrContinueStatement(kind) { var node = createNode(kind); var errorCountBeforeStatement = file.syntacticErrors.length; - parseExpected(kind === 161 /* BreakStatement */ ? 60 /* BreakKeyword */ : 65 /* ContinueKeyword */); + parseExpected(kind === 168 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */); if (!canParseSemicolon()) node.label = parseIdentifier(); parseSemicolon(); @@ -4721,7 +4285,7 @@ var ts; return node; } function checkBareBreakOrContinueStatement(node) { - if (node.kind === 161 /* BreakStatement */) { + if (node.kind === 168 /* BreakStatement */) { if (inIterationStatement === 1 /* Nested */ || inSwitchStatement === 1 /* Nested */) { return; } @@ -4730,7 +4294,7 @@ var ts; return; } } - else if (node.kind === 160 /* ContinueStatement */) { + else if (node.kind === 167 /* ContinueStatement */) { if (inIterationStatement === 1 /* Nested */) { return; } @@ -4746,7 +4310,7 @@ var ts; grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } function checkBreakOrContinueStatementWithLabel(node) { - var nodeIsNestedInLabel = labelledStatementInfo.nodeIsNestedInLabel(node.label, node.kind === 160 /* ContinueStatement */, false); + var nodeIsNestedInLabel = labelledStatementInfo.nodeIsNestedInLabel(node.label, node.kind === 167 /* ContinueStatement */, false); if (nodeIsNestedInLabel === 1 /* Nested */) { return; } @@ -4754,10 +4318,10 @@ var ts; grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); return; } - if (node.kind === 160 /* ContinueStatement */) { + if (node.kind === 167 /* ContinueStatement */) { grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement); } - else if (node.kind === 161 /* BreakStatement */) { + else if (node.kind === 168 /* BreakStatement */) { grammarErrorOnNode(node, ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement); } else { @@ -4765,11 +4329,11 @@ var ts; } } function parseReturnStatement() { - var node = createNode(162 /* ReturnStatement */); + var node = createNode(169 /* ReturnStatement */); var errorCountBeforeReturnStatement = file.syntacticErrors.length; var returnTokenStart = scanner.getTokenPos(); var returnTokenLength = scanner.getTextPos() - returnTokenStart; - parseExpected(84 /* ReturnKeyword */); + parseExpected(88 /* ReturnKeyword */); if (!canParseSemicolon()) node.expression = parseExpression(); parseSemicolon(); @@ -4779,13 +4343,13 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(163 /* WithStatement */); + var node = createNode(170 /* WithStatement */); var startPos = scanner.getTokenPos(); - parseExpected(95 /* WithKeyword */); + parseExpected(99 /* WithKeyword */); var endPos = scanner.getStartPos(); - parseExpected(11 /* OpenParenToken */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); node.statement = parseStatement(false); node = finishNode(node); if (isInStrictMode) { @@ -4794,36 +4358,36 @@ var ts; return node; } function parseCaseClause() { - var node = createNode(165 /* CaseClause */); - parseExpected(61 /* CaseKeyword */); + var node = createNode(172 /* CaseClause */); + parseExpected(65 /* CaseKeyword */); node.expression = parseExpression(); - parseExpected(46 /* ColonToken */); + parseExpected(50 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatementAllowingLetDeclaration); return finishNode(node); } function parseDefaultClause() { - var node = createNode(166 /* DefaultClause */); - parseExpected(67 /* DefaultKeyword */); - parseExpected(46 /* ColonToken */); + var node = createNode(173 /* DefaultClause */); + parseExpected(71 /* DefaultKeyword */); + parseExpected(50 /* ColonToken */); node.statements = parseList(4 /* SwitchClauseStatements */, false, parseStatementAllowingLetDeclaration); return finishNode(node); } function parseCaseOrDefaultClause() { - return token === 61 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token === 65 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(164 /* SwitchStatement */); - parseExpected(86 /* SwitchKeyword */); - parseExpected(11 /* OpenParenToken */); + var node = createNode(171 /* SwitchStatement */); + parseExpected(90 /* SwitchKeyword */); + parseExpected(15 /* OpenParenToken */); node.expression = parseExpression(); - parseExpected(12 /* CloseParenToken */); - parseExpected(9 /* OpenBraceToken */); + parseExpected(16 /* CloseParenToken */); + parseExpected(13 /* OpenBraceToken */); var saveInSwitchStatement = inSwitchStatement; inSwitchStatement = 1 /* Nested */; node.clauses = parseList(3 /* SwitchClauses */, false, parseCaseOrDefaultClause); inSwitchStatement = saveInSwitchStatement; - parseExpected(10 /* CloseBraceToken */); - var defaultClauses = ts.filter(node.clauses, function (clause) { return clause.kind === 166 /* DefaultClause */; }); + parseExpected(14 /* CloseBraceToken */); + var defaultClauses = ts.filter(node.clauses, function (clause) { return clause.kind === 173 /* DefaultClause */; }); for (var i = 1, n = defaultClauses.length; i < n; i++) { var clause = defaultClauses[i]; var start = ts.skipTrivia(file.text, clause.pos); @@ -4833,8 +4397,8 @@ var ts; return finishNode(node); } function parseThrowStatement() { - var node = createNode(168 /* ThrowStatement */); - parseExpected(88 /* ThrowKeyword */); + var node = createNode(175 /* ThrowStatement */); + parseExpected(92 /* ThrowKeyword */); if (scanner.hasPrecedingLineBreak()) { error(ts.Diagnostics.Line_break_not_permitted_here); } @@ -4843,13 +4407,13 @@ var ts; return finishNode(node); } function parseTryStatement() { - var node = createNode(169 /* TryStatement */); - node.tryBlock = parseTokenAndBlock(90 /* TryKeyword */, 170 /* TryBlock */); - if (token === 62 /* CatchKeyword */) { + var node = createNode(176 /* TryStatement */); + node.tryBlock = parseTokenAndBlock(94 /* TryKeyword */, 177 /* TryBlock */); + if (token === 66 /* CatchKeyword */) { node.catchBlock = parseCatchBlock(); } - if (token === 75 /* FinallyKeyword */) { - node.finallyBlock = parseTokenAndBlock(75 /* FinallyKeyword */, 172 /* FinallyBlock */); + if (token === 79 /* FinallyKeyword */) { + node.finallyBlock = parseTokenAndBlock(79 /* FinallyKeyword */, 179 /* FinallyBlock */); } if (!(node.catchBlock || node.finallyBlock)) { error(ts.Diagnostics.catch_or_finally_expected); @@ -4866,15 +4430,15 @@ var ts; } function parseCatchBlock() { var pos = getNodePos(); - parseExpected(62 /* CatchKeyword */); - parseExpected(11 /* OpenParenToken */); + parseExpected(66 /* CatchKeyword */); + parseExpected(15 /* OpenParenToken */); var variable = parseIdentifier(); var typeAnnotationColonStart = scanner.getTokenPos(); var typeAnnotationColonLength = scanner.getTextPos() - typeAnnotationColonStart; var typeAnnotation = parseTypeAnnotation(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); var result = parseBlock(false, false); - result.kind = 171 /* CatchBlock */; + result.kind = 178 /* CatchBlock */; result.pos = pos; result.variable = variable; if (typeAnnotation) { @@ -4886,13 +4450,13 @@ var ts; return result; } function parseDebuggerStatement() { - var node = createNode(173 /* DebuggerStatement */); - parseExpected(66 /* DebuggerKeyword */); + var node = createNode(180 /* DebuggerStatement */); + parseExpected(70 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } function isIterationStatementStart() { - return token === 94 /* WhileKeyword */ || token === 69 /* DoKeyword */ || token === 76 /* ForKeyword */; + return token === 98 /* WhileKeyword */ || token === 73 /* DoKeyword */ || token === 80 /* ForKeyword */; } function parseStatementWithLabelSet(allowLetAndConstDeclarations) { labelledStatementInfo.pushCurrentLabelSet(isIterationStatementStart()); @@ -4901,12 +4465,12 @@ var ts; return statement; } function isLabel() { - return isIdentifier() && lookAhead(function () { return nextToken() === 46 /* ColonToken */; }); + return isIdentifier() && lookAhead(function () { return nextToken() === 50 /* ColonToken */; }); } function parseLabeledStatement(allowLetAndConstDeclarations) { - var node = createNode(167 /* LabeledStatement */); + var node = createNode(174 /* LabeledStatement */); node.label = parseIdentifier(); - parseExpected(46 /* ColonToken */); + parseExpected(50 /* ColonToken */); if (labelledStatementInfo.nodeIsNestedInLabel(node.label, false, true)) { grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, getTextOfNodeFromSourceText(sourceText, node.label)); } @@ -4915,91 +4479,93 @@ var ts; return finishNode(node); } function parseExpressionStatement() { - var node = createNode(154 /* ExpressionStatement */); + var node = createNode(161 /* ExpressionStatement */); node.expression = parseExpression(); parseSemicolon(); return finishNode(node); } function isStatement(inErrorRecovery) { switch (token) { - case 17 /* SemicolonToken */: + case 21 /* SemicolonToken */: return !inErrorRecovery; - case 9 /* OpenBraceToken */: - case 92 /* VarKeyword */: - case 98 /* LetKeyword */: - case 64 /* ConstKeyword */: - case 77 /* FunctionKeyword */: - case 78 /* IfKeyword */: - case 69 /* DoKeyword */: - case 94 /* WhileKeyword */: - case 76 /* ForKeyword */: - case 65 /* ContinueKeyword */: - case 60 /* BreakKeyword */: - case 84 /* ReturnKeyword */: - case 95 /* WithKeyword */: - case 86 /* SwitchKeyword */: - case 88 /* ThrowKeyword */: - case 90 /* TryKeyword */: - case 66 /* DebuggerKeyword */: - case 62 /* CatchKeyword */: - case 75 /* FinallyKeyword */: + case 13 /* OpenBraceToken */: + case 96 /* VarKeyword */: + case 102 /* LetKeyword */: + case 81 /* FunctionKeyword */: + case 82 /* IfKeyword */: + case 73 /* DoKeyword */: + case 98 /* WhileKeyword */: + case 80 /* ForKeyword */: + case 69 /* ContinueKeyword */: + case 64 /* BreakKeyword */: + case 88 /* ReturnKeyword */: + case 99 /* WithKeyword */: + case 90 /* SwitchKeyword */: + case 92 /* ThrowKeyword */: + case 94 /* TryKeyword */: + case 70 /* DebuggerKeyword */: + case 66 /* CatchKeyword */: + case 79 /* FinallyKeyword */: return true; - case 97 /* InterfaceKeyword */: - case 63 /* ClassKeyword */: - case 110 /* ModuleKeyword */: - case 71 /* EnumKeyword */: - case 115 /* TypeKeyword */: - if (isDeclaration()) { + case 68 /* ConstKeyword */: + var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); + return !isConstEnum; + case 101 /* InterfaceKeyword */: + case 67 /* ClassKeyword */: + case 114 /* ModuleKeyword */: + case 75 /* EnumKeyword */: + case 119 /* TypeKeyword */: + if (isDeclarationStart()) { return false; } - case 102 /* PublicKeyword */: - case 100 /* PrivateKeyword */: - case 101 /* ProtectedKeyword */: - case 103 /* StaticKeyword */: - if (lookAhead(function () { return nextToken() >= 59 /* Identifier */; })) { + case 106 /* PublicKeyword */: + case 104 /* PrivateKeyword */: + case 105 /* ProtectedKeyword */: + case 107 /* StaticKeyword */: + if (lookAhead(function () { return nextToken() >= 63 /* Identifier */; })) { return false; } default: - return isExpression(); + return isStartOfExpression(); } } function parseStatement(allowLetAndConstDeclarations) { switch (token) { - case 9 /* OpenBraceToken */: + case 13 /* OpenBraceToken */: return parseBlock(false, false); - case 92 /* VarKeyword */: - case 98 /* LetKeyword */: - case 64 /* ConstKeyword */: + case 96 /* VarKeyword */: + case 102 /* LetKeyword */: + case 68 /* ConstKeyword */: return parseVariableStatement(allowLetAndConstDeclarations); - case 77 /* FunctionKeyword */: + case 81 /* FunctionKeyword */: return parseFunctionDeclaration(); - case 17 /* SemicolonToken */: + case 21 /* SemicolonToken */: return parseEmptyStatement(); - case 78 /* IfKeyword */: + case 82 /* IfKeyword */: return parseIfStatement(); - case 69 /* DoKeyword */: + case 73 /* DoKeyword */: return parseDoStatement(); - case 94 /* WhileKeyword */: + case 98 /* WhileKeyword */: return parseWhileStatement(); - case 76 /* ForKeyword */: + case 80 /* ForKeyword */: return parseForOrForInStatement(); - case 65 /* ContinueKeyword */: - return parseBreakOrContinueStatement(160 /* ContinueStatement */); - case 60 /* BreakKeyword */: - return parseBreakOrContinueStatement(161 /* BreakStatement */); - case 84 /* ReturnKeyword */: + case 69 /* ContinueKeyword */: + return parseBreakOrContinueStatement(167 /* ContinueStatement */); + case 64 /* BreakKeyword */: + return parseBreakOrContinueStatement(168 /* BreakStatement */); + case 88 /* ReturnKeyword */: return parseReturnStatement(); - case 95 /* WithKeyword */: + case 99 /* WithKeyword */: return parseWithStatement(); - case 86 /* SwitchKeyword */: + case 90 /* SwitchKeyword */: return parseSwitchStatement(); - case 88 /* ThrowKeyword */: + case 92 /* ThrowKeyword */: return parseThrowStatement(); - case 90 /* TryKeyword */: - case 62 /* CatchKeyword */: - case 75 /* FinallyKeyword */: + case 94 /* TryKeyword */: + case 66 /* CatchKeyword */: + case 79 /* FinallyKeyword */: return parseTryStatement(); - case 66 /* DebuggerKeyword */: + case 70 /* DebuggerKeyword */: return parseDebuggerStatement(); default: if (isLabel()) { @@ -5011,7 +4577,7 @@ var ts; function parseAndCheckFunctionBody(isConstructor) { var initialPosition = scanner.getTokenPos(); var errorCountBeforeBody = file.syntacticErrors.length; - if (token === 9 /* OpenBraceToken */) { + if (token === 13 /* OpenBraceToken */) { var body = parseBody(false); if (body && inAmbientContext && file.syntacticErrors.length === errorCountBeforeBody) { var diagnostic = isConstructor ? ts.Diagnostics.A_constructor_implementation_cannot_be_declared_in_an_ambient_context : ts.Diagnostics.A_function_implementation_cannot_be_declared_in_an_ambient_context; @@ -5026,7 +4592,7 @@ var ts; error(ts.Diagnostics.Block_or_expected); } function parseVariableDeclaration(flags, noIn) { - var node = createNode(174 /* VariableDeclaration */); + var node = createNode(181 /* VariableDeclaration */); node.flags = flags; var errorCountBeforeVariableDeclaration = file.syntacticErrors.length; node.name = parseIdentifier(); @@ -5049,17 +4615,17 @@ var ts; return parseDelimitedList(9 /* VariableDeclarations */, function () { return parseVariableDeclaration(flags, noIn); }, false); } function parseVariableStatement(allowLetAndConstDeclarations, pos, flags) { - var node = createNode(152 /* VariableStatement */, pos); + var node = createNode(159 /* VariableStatement */, pos); if (flags) node.flags = flags; var errorCountBeforeVarStatement = file.syntacticErrors.length; - if (token === 98 /* LetKeyword */) { + if (token === 102 /* LetKeyword */) { node.flags |= 2048 /* Let */; } - else if (token === 64 /* ConstKeyword */) { + else if (token === 68 /* ConstKeyword */) { node.flags |= 4096 /* Const */; } - else if (token !== 92 /* VarKeyword */) { + else if (token !== 96 /* VarKeyword */) { error(ts.Diagnostics.var_let_or_const_expected); } nextToken(); @@ -5088,12 +4654,12 @@ var ts; return node; } function parseFunctionDeclaration(pos, flags) { - var node = createNode(175 /* FunctionDeclaration */, pos); + var node = createNode(182 /* FunctionDeclaration */, pos); if (flags) node.flags = flags; - parseExpected(77 /* FunctionKeyword */); + parseExpected(81 /* FunctionKeyword */); node.name = parseIdentifier(); - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; node.type = sig.type; @@ -5104,10 +4670,10 @@ var ts; return finishNode(node); } function parseConstructorDeclaration(pos, flags) { - var node = createNode(122 /* Constructor */, pos); + var node = createNode(126 /* Constructor */, pos); node.flags = flags; - parseExpected(107 /* ConstructorKeyword */); - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + parseExpected(111 /* ConstructorKeyword */); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; node.type = sig.type; @@ -5124,14 +4690,14 @@ var ts; var errorCountBeforePropertyDeclaration = file.syntacticErrors.length; var name = parsePropertyName(); var questionStart = scanner.getTokenPos(); - if (parseOptional(45 /* QuestionToken */)) { + if (parseOptional(49 /* QuestionToken */)) { errorAtPos(questionStart, scanner.getStartPos() - questionStart, ts.Diagnostics.A_class_member_cannot_be_declared_optional); } - if (token === 11 /* OpenParenToken */ || token === 19 /* LessThanToken */) { - var method = createNode(121 /* Method */, pos); + if (token === 15 /* OpenParenToken */ || token === 23 /* LessThanToken */) { + var method = createNode(125 /* Method */, pos); method.flags = flags; method.name = name; - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); method.typeParameters = sig.typeParameters; method.parameters = sig.parameters; method.type = sig.type; @@ -5139,7 +4705,7 @@ var ts; return finishNode(method); } else { - var property = createNode(120 /* Property */, pos); + var property = createNode(124 /* Property */, pos); property.flags = flags; property.name = name; property.type = parseTypeAnnotation(); @@ -5166,10 +4732,10 @@ var ts; else if (accessor.typeParameters) { grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } - else if (kind === 123 /* GetAccessor */ && accessor.parameters.length) { + else if (kind === 127 /* GetAccessor */ && accessor.parameters.length) { grammarErrorOnNode(accessor.name, ts.Diagnostics.A_get_accessor_cannot_have_parameters); } - else if (kind === 124 /* SetAccessor */) { + else if (kind === 128 /* SetAccessor */) { if (accessor.type) { grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -5181,7 +4747,7 @@ var ts; if (parameter.flags & 8 /* Rest */) { grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter); } - else if (parameter.flags & ts.NodeFlags.Modifier) { + else if (parameter.flags & 243 /* Modifier */) { grammarErrorOnNode(accessor.name, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } else if (parameter.flags & 4 /* QuestionMark */) { @@ -5199,7 +4765,7 @@ var ts; var node = createNode(kind, pos); node.flags = flags; node.name = parsePropertyName(); - var sig = parseSignature(125 /* CallSignature */, 46 /* ColonToken */, false); + var sig = parseSignature(129 /* CallSignature */, 50 /* ColonToken */, false); node.typeParameters = sig.typeParameters; node.parameters = sig.parameters; node.type = sig.type; @@ -5222,19 +4788,19 @@ var ts; idToken = token; nextToken(); } - if (token === 13 /* OpenBracketToken */) { + if (token === 17 /* OpenBracketToken */) { return true; } if (idToken !== undefined) { - if (!isKeyword(idToken) || idToken === 113 /* SetKeyword */ || idToken === 109 /* GetKeyword */) { + if (!isKeyword(idToken) || idToken === 117 /* SetKeyword */ || idToken === 113 /* GetKeyword */) { return true; } switch (token) { - case 11 /* OpenParenToken */: - case 19 /* LessThanToken */: - case 46 /* ColonToken */: - case 47 /* EqualsToken */: - case 45 /* QuestionToken */: + case 15 /* OpenParenToken */: + case 23 /* LessThanToken */: + case 50 /* ColonToken */: + case 51 /* EqualsToken */: + case 49 /* QuestionToken */: return true; default: return canParseSemicolon(); @@ -5259,8 +4825,8 @@ var ts; break; var modifierLength = scanner.getStartPos() - modifierStart; switch (modifierToken) { - case 102 /* PublicKeyword */: - if (flags & ts.NodeFlags.AccessibilityModifier) { + case 106 /* PublicKeyword */: + if (flags & 112 /* AccessibilityModifier */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics.Accessibility_modifier_already_seen); } else if (flags & 128 /* Static */) { @@ -5271,8 +4837,8 @@ var ts; } flags |= 16 /* Public */; break; - case 100 /* PrivateKeyword */: - if (flags & ts.NodeFlags.AccessibilityModifier) { + case 104 /* PrivateKeyword */: + if (flags & 112 /* AccessibilityModifier */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics.Accessibility_modifier_already_seen); } else if (flags & 128 /* Static */) { @@ -5285,7 +4851,7 @@ var ts; lastPrivateModifierLength = modifierLength; flags |= 32 /* Private */; break; - case 101 /* ProtectedKeyword */: + case 105 /* ProtectedKeyword */: if (flags & 16 /* Public */ || flags & 32 /* Private */ || flags & 64 /* Protected */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics.Accessibility_modifier_already_seen); } @@ -5299,7 +4865,7 @@ var ts; lastProtectedModifierLength = modifierLength; flags |= 64 /* Protected */; break; - case 103 /* StaticKeyword */: + case 107 /* StaticKeyword */: if (flags & 128 /* Static */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -5313,7 +4879,7 @@ var ts; lastStaticModifierLength = modifierLength; flags |= 128 /* Static */; break; - case 72 /* ExportKeyword */: + case 76 /* ExportKeyword */: if (flags & 1 /* Export */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -5328,7 +4894,7 @@ var ts; } flags |= 1 /* Export */; break; - case 108 /* DeclareKeyword */: + case 112 /* DeclareKeyword */: if (flags & 2 /* Ambient */) { grammarErrorAtPos(modifierStart, modifierLength, ts.Diagnostics._0_modifier_already_seen, "declare"); } @@ -5347,26 +4913,26 @@ var ts; break; } } - if (token === 107 /* ConstructorKeyword */ && flags & 128 /* Static */) { + if (token === 111 /* ConstructorKeyword */ && flags & 128 /* Static */) { grammarErrorAtPos(lastStaticModifierStart, lastStaticModifierLength, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } - else if (token === 107 /* ConstructorKeyword */ && flags & 32 /* Private */) { + else if (token === 111 /* ConstructorKeyword */ && flags & 32 /* Private */) { grammarErrorAtPos(lastPrivateModifierStart, lastPrivateModifierLength, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "private"); } - else if (token === 107 /* ConstructorKeyword */ && flags & 64 /* Protected */) { + else if (token === 111 /* ConstructorKeyword */ && flags & 64 /* Protected */) { grammarErrorAtPos(lastProtectedModifierStart, lastProtectedModifierLength, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "protected"); } - else if (token === 79 /* ImportKeyword */) { + else if (token === 83 /* ImportKeyword */) { if (flags & 2 /* Ambient */) { grammarErrorAtPos(lastDeclareModifierStart, lastDeclareModifierLength, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_import_declaration, "declare"); } } - else if (token === 97 /* InterfaceKeyword */) { + else if (token === 101 /* InterfaceKeyword */) { if (flags & 2 /* Ambient */) { grammarErrorAtPos(lastDeclareModifierStart, lastDeclareModifierLength, ts.Diagnostics.A_declare_modifier_cannot_be_used_with_an_interface_declaration, "declare"); } } - else if (token !== 72 /* ExportKeyword */ && !(flags & 2 /* Ambient */) && inAmbientContext && context === 0 /* SourceElements */) { + else if (token !== 76 /* ExportKeyword */ && !(flags & 2 /* Ambient */) && inAmbientContext && context === 0 /* SourceElements */) { var declarationStart = scanner.getTokenPos(); var declarationFirstTokenLength = scanner.getTextPos() - declarationStart; grammarErrorAtPos(declarationStart, declarationFirstTokenLength, ts.Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); @@ -5376,19 +4942,19 @@ var ts; function parseClassMemberDeclaration() { var pos = getNodePos(); var flags = parseAndCheckModifiers(2 /* ClassMembers */); - if (parseContextualModifier(109 /* GetKeyword */)) { - return parseAndCheckMemberAccessorDeclaration(123 /* GetAccessor */, pos, flags); + if (parseContextualModifier(113 /* GetKeyword */)) { + return parseAndCheckMemberAccessorDeclaration(127 /* GetAccessor */, pos, flags); } - if (parseContextualModifier(113 /* SetKeyword */)) { - return parseAndCheckMemberAccessorDeclaration(124 /* SetAccessor */, pos, flags); + if (parseContextualModifier(117 /* SetKeyword */)) { + return parseAndCheckMemberAccessorDeclaration(128 /* SetAccessor */, pos, flags); } - if (token === 107 /* ConstructorKeyword */) { + if (token === 111 /* ConstructorKeyword */) { return parseConstructorDeclaration(pos, flags); } - if (token >= 59 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { + if (token >= 63 /* Identifier */ || token === 7 /* StringLiteral */ || token === 6 /* NumericLiteral */) { return parsePropertyMemberDeclaration(pos, flags); } - if (token === 13 /* OpenBracketToken */) { + if (token === 17 /* OpenBracketToken */) { if (flags) { var start = getTokenPos(pos); var length = getNodePos() - start; @@ -5399,23 +4965,23 @@ var ts; ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassDeclaration(pos, flags) { - var node = createNode(177 /* ClassDeclaration */, pos); + var node = createNode(184 /* ClassDeclaration */, pos); node.flags = flags; var errorCountBeforeClassDeclaration = file.syntacticErrors.length; - parseExpected(63 /* ClassKeyword */); + parseExpected(67 /* ClassKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - node.baseType = parseOptional(73 /* ExtendsKeyword */) ? parseTypeReference() : undefined; + node.baseType = parseOptional(77 /* ExtendsKeyword */) ? parseTypeReference() : undefined; var implementsKeywordStart = scanner.getTokenPos(); var implementsKeywordLength; - if (parseOptional(96 /* ImplementsKeyword */)) { + if (parseOptional(100 /* ImplementsKeyword */)) { implementsKeywordLength = scanner.getStartPos() - implementsKeywordStart; node.implementedTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, false); } var errorCountBeforeClassBody = file.syntacticErrors.length; - if (parseExpected(9 /* OpenBraceToken */)) { + if (parseExpected(13 /* OpenBraceToken */)) { node.members = parseList(6 /* ClassMembers */, false, parseClassMemberDeclaration); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -5426,15 +4992,15 @@ var ts; return finishNode(node); } function parseInterfaceDeclaration(pos, flags) { - var node = createNode(178 /* InterfaceDeclaration */, pos); + var node = createNode(185 /* InterfaceDeclaration */, pos); node.flags = flags; var errorCountBeforeInterfaceDeclaration = file.syntacticErrors.length; - parseExpected(97 /* InterfaceKeyword */); + parseExpected(101 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); var extendsKeywordStart = scanner.getTokenPos(); var extendsKeywordLength; - if (parseOptional(73 /* ExtendsKeyword */)) { + if (parseOptional(77 /* ExtendsKeyword */)) { extendsKeywordLength = scanner.getStartPos() - extendsKeywordStart; node.baseTypes = parseDelimitedList(8 /* BaseTypeReferences */, parseTypeReference, false); } @@ -5446,30 +5012,24 @@ var ts; return finishNode(node); } function parseTypeAliasDeclaration(pos, flags) { - var node = createNode(179 /* TypeAliasDeclaration */, pos); + var node = createNode(186 /* TypeAliasDeclaration */, pos); node.flags = flags; - parseExpected(115 /* TypeKeyword */); + parseExpected(119 /* TypeKeyword */); node.name = parseIdentifier(); - parseExpected(47 /* EqualsToken */); + parseExpected(51 /* EqualsToken */); node.type = parseType(); parseSemicolon(); - var n = node.type; - while (n.kind === 134 /* ParenType */) { - n = n.type; - } - if (n.kind === 130 /* TypeLiteral */ && (n.pos !== n.members.pos || n.end !== n.members.end)) { - grammarErrorOnNode(node.type, ts.Diagnostics.Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead); - } return finishNode(node); } function parseAndCheckEnumDeclaration(pos, flags) { + var enumIsConst = flags & 4096 /* Const */; function isIntegerLiteral(expression) { function isInteger(literalExpression) { return /^[0-9]+([eE]\+?[0-9]+)?$/.test(literalExpression.text); } - if (expression.kind === 146 /* PrefixOperator */) { + if (expression.kind === 151 /* PrefixOperator */) { var unaryExpression = expression; - if (unaryExpression.operator === 28 /* PlusToken */ || unaryExpression.operator === 29 /* MinusToken */) { + if (unaryExpression.operator === 32 /* PlusToken */ || unaryExpression.operator === 33 /* MinusToken */) { expression = unaryExpression.operand; } } @@ -5480,30 +5040,35 @@ var ts; } var inConstantEnumMemberSection = true; function parseAndCheckEnumMember() { - var node = createNode(185 /* EnumMember */); + var node = createNode(192 /* EnumMember */); var errorCountBeforeEnumMember = file.syntacticErrors.length; node.name = parsePropertyName(); node.initializer = parseInitializer(false); - if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer) && errorCountBeforeEnumMember === file.syntacticErrors.length) { - grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers); + if (!enumIsConst) { + if (inAmbientContext) { + if (node.initializer && !isIntegerLiteral(node.initializer) && errorCountBeforeEnumMember === file.syntacticErrors.length) { + grammarErrorOnNode(node.name, ts.Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers); + } + } + else if (node.initializer) { + inConstantEnumMemberSection = isIntegerLiteral(node.initializer); + } + else if (!inConstantEnumMemberSection && errorCountBeforeEnumMember === file.syntacticErrors.length) { + grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer); } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection && errorCountBeforeEnumMember === file.syntacticErrors.length) { - grammarErrorOnNode(node.name, ts.Diagnostics.Enum_member_must_have_initializer); } return finishNode(node); } - var node = createNode(180 /* EnumDeclaration */, pos); + var node = createNode(187 /* EnumDeclaration */, pos); node.flags = flags; - parseExpected(71 /* EnumKeyword */); + if (enumIsConst) { + parseExpected(68 /* ConstKeyword */); + } + parseExpected(75 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(9 /* OpenBraceToken */)) { + if (parseExpected(13 /* OpenBraceToken */)) { node.members = parseDelimitedList(7 /* EnumMembers */, parseAndCheckEnumMember, true); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -5511,10 +5076,10 @@ var ts; return finishNode(node); } function parseModuleBody() { - var node = createNode(182 /* ModuleBlock */); - if (parseExpected(9 /* OpenBraceToken */)) { + var node = createNode(189 /* ModuleBlock */); + if (parseExpected(13 /* OpenBraceToken */)) { node.statements = parseList(1 /* ModuleElements */, false, parseModuleElement); - parseExpected(10 /* CloseBraceToken */); + parseExpected(14 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -5522,19 +5087,19 @@ var ts; return finishNode(node); } function parseInternalModuleTail(pos, flags) { - var node = createNode(181 /* ModuleDeclaration */, pos); + var node = createNode(188 /* ModuleDeclaration */, pos); node.flags = flags; node.name = parseIdentifier(); - if (parseOptional(15 /* DotToken */)) { + if (parseOptional(19 /* DotToken */)) { node.body = parseInternalModuleTail(getNodePos(), 1 /* Export */); } else { node.body = parseModuleBody(); ts.forEach(node.body.statements, function (s) { - if (s.kind === 184 /* ExportAssignment */) { + if (s.kind === 191 /* ExportAssignment */) { grammarErrorOnNode(s, ts.Diagnostics.An_export_assignment_cannot_be_used_in_an_internal_module); } - else if (s.kind === 183 /* ImportDeclaration */ && s.externalModuleName) { + else if (s.kind === 190 /* ImportDeclaration */ && s.externalModuleName) { grammarErrorOnNode(s, ts.Diagnostics.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); } }); @@ -5542,7 +5107,7 @@ var ts; return finishNode(node); } function parseAmbientExternalModuleDeclaration(pos, flags) { - var node = createNode(181 /* ModuleDeclaration */, pos); + var node = createNode(188 /* ModuleDeclaration */, pos); node.flags = flags; node.name = parseStringLiteral(); if (!inAmbientContext) { @@ -5558,19 +5123,19 @@ var ts; return finishNode(node); } function parseModuleDeclaration(pos, flags) { - parseExpected(110 /* ModuleKeyword */); + parseExpected(114 /* ModuleKeyword */); return token === 7 /* StringLiteral */ ? parseAmbientExternalModuleDeclaration(pos, flags) : parseInternalModuleTail(pos, flags); } function parseImportDeclaration(pos, flags) { - var node = createNode(183 /* ImportDeclaration */, pos); + var node = createNode(190 /* ImportDeclaration */, pos); node.flags = flags; - parseExpected(79 /* ImportKeyword */); + parseExpected(83 /* ImportKeyword */); node.name = parseIdentifier(); - parseExpected(47 /* EqualsToken */); + parseExpected(51 /* EqualsToken */); var entityName = parseEntityName(false); - if (entityName.kind === 59 /* Identifier */ && entityName.text === "require" && parseOptional(11 /* OpenParenToken */)) { + if (entityName.kind === 63 /* Identifier */ && entityName.text === "require" && parseOptional(15 /* OpenParenToken */)) { node.externalModuleName = parseStringLiteral(); - parseExpected(12 /* CloseParenToken */); + parseExpected(16 /* CloseParenToken */); } else { node.entityName = entityName; @@ -5579,36 +5144,36 @@ var ts; return finishNode(node); } function parseExportAssignmentTail(pos) { - var node = createNode(184 /* ExportAssignment */, pos); + var node = createNode(191 /* ExportAssignment */, pos); node.exportName = parseIdentifier(); parseSemicolon(); return finishNode(node); } - function isDeclaration() { + function isDeclarationStart() { switch (token) { - case 92 /* VarKeyword */: - case 98 /* LetKeyword */: - case 64 /* ConstKeyword */: - case 77 /* FunctionKeyword */: + case 96 /* VarKeyword */: + case 102 /* LetKeyword */: + case 68 /* ConstKeyword */: + case 81 /* FunctionKeyword */: return true; - case 63 /* ClassKeyword */: - case 97 /* InterfaceKeyword */: - case 71 /* EnumKeyword */: - case 79 /* ImportKeyword */: - case 115 /* TypeKeyword */: - return lookAhead(function () { return nextToken() >= 59 /* Identifier */; }); - case 110 /* ModuleKeyword */: - return lookAhead(function () { return nextToken() >= 59 /* Identifier */ || token === 7 /* StringLiteral */; }); - case 72 /* ExportKeyword */: - return lookAhead(function () { return nextToken() === 47 /* EqualsToken */ || isDeclaration(); }); - case 108 /* DeclareKeyword */: - case 102 /* PublicKeyword */: - case 100 /* PrivateKeyword */: - case 101 /* ProtectedKeyword */: - case 103 /* StaticKeyword */: + case 67 /* ClassKeyword */: + case 101 /* InterfaceKeyword */: + case 75 /* EnumKeyword */: + case 83 /* ImportKeyword */: + case 119 /* TypeKeyword */: + return lookAhead(function () { return nextToken() >= 63 /* Identifier */; }); + case 114 /* ModuleKeyword */: + return lookAhead(function () { return nextToken() >= 63 /* Identifier */ || token === 7 /* StringLiteral */; }); + case 76 /* ExportKeyword */: + return lookAhead(function () { return nextToken() === 51 /* EqualsToken */ || isDeclarationStart(); }); + case 112 /* DeclareKeyword */: + case 106 /* PublicKeyword */: + case 104 /* PrivateKeyword */: + case 105 /* ProtectedKeyword */: + case 107 /* StaticKeyword */: return lookAhead(function () { nextToken(); - return isDeclaration(); + return isDeclarationStart(); }); } } @@ -5616,10 +5181,10 @@ var ts; var pos = getNodePos(); var errorCountBeforeModifiers = file.syntacticErrors.length; var flags = parseAndCheckModifiers(modifierContext); - if (token === 72 /* ExportKeyword */) { + if (token === 76 /* ExportKeyword */) { var modifiersEnd = scanner.getStartPos(); nextToken(); - if (parseOptional(47 /* EqualsToken */)) { + if (parseOptional(51 /* EqualsToken */)) { var exportAssignmentTail = parseExportAssignmentTail(pos); if (flags !== 0 && errorCountBeforeModifiers === file.syntacticErrors.length) { var modifiersStart = ts.skipTrivia(sourceText, pos); @@ -5634,30 +5199,38 @@ var ts; } var result; switch (token) { - case 92 /* VarKeyword */: - case 98 /* LetKeyword */: - case 64 /* ConstKeyword */: + case 96 /* VarKeyword */: + case 102 /* LetKeyword */: result = parseVariableStatement(true, pos, flags); break; - case 77 /* FunctionKeyword */: + case 68 /* ConstKeyword */: + var isConstEnum = lookAhead(function () { return nextToken() === 75 /* EnumKeyword */; }); + if (isConstEnum) { + result = parseAndCheckEnumDeclaration(pos, flags | 4096 /* Const */); + } + else { + result = parseVariableStatement(true, pos, flags); + } + break; + case 81 /* FunctionKeyword */: result = parseFunctionDeclaration(pos, flags); break; - case 63 /* ClassKeyword */: + case 67 /* ClassKeyword */: result = parseClassDeclaration(pos, flags); break; - case 97 /* InterfaceKeyword */: + case 101 /* InterfaceKeyword */: result = parseInterfaceDeclaration(pos, flags); break; - case 115 /* TypeKeyword */: + case 119 /* TypeKeyword */: result = parseTypeAliasDeclaration(pos, flags); break; - case 71 /* EnumKeyword */: + case 75 /* EnumKeyword */: result = parseAndCheckEnumDeclaration(pos, flags); break; - case 110 /* ModuleKeyword */: + case 114 /* ModuleKeyword */: result = parseModuleDeclaration(pos, flags); break; - case 79 /* ImportKeyword */: + case 83 /* ImportKeyword */: result = parseImportDeclaration(pos, flags); break; default: @@ -5667,7 +5240,7 @@ var ts; return result; } function isSourceElement(inErrorRecovery) { - return isDeclaration() || isStatement(inErrorRecovery); + return isDeclarationStart() || isStatement(inErrorRecovery); } function parseSourceElement() { return parseSourceElementOrModuleElement(0 /* SourceElements */); @@ -5676,7 +5249,7 @@ var ts; return parseSourceElementOrModuleElement(1 /* ModuleElements */); } function parseSourceElementOrModuleElement(modifierContext) { - if (isDeclaration()) { + if (isDeclarationStart()) { return parseDeclaration(modifierContext); } var statementStart = scanner.getTokenPos(); @@ -5734,7 +5307,7 @@ var ts; }; } function getExternalModuleIndicator() { - return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 183 /* ImportDeclaration */ && node.externalModuleName || node.kind === 184 /* ExportAssignment */ ? node : undefined; }); + return ts.forEach(file.statements, function (node) { return node.flags & 1 /* Export */ || node.kind === 190 /* ImportDeclaration */ && node.externalModuleName || node.kind === 191 /* ExportAssignment */ ? node : undefined; }); } scanner = ts.createScanner(languageVersion, true, sourceText, scanError, onComment); var rootNodeFlags = 0; @@ -5742,7 +5315,7 @@ var ts; rootNodeFlags = 1024 /* DeclarationFile */; inAmbientContext = true; } - file = createRootNode(186 /* SourceFile */, 0, sourceText.length, rootNodeFlags); + file = createRootNode(193 /* SourceFile */, 0, sourceText.length, rootNodeFlags); file.filename = ts.normalizePath(filename); file.text = sourceText; file.getLineAndCharacterFromPosition = getLineAndCharacterlFromSourcePosition; @@ -5875,7 +5448,7 @@ var ts; } function processImportedModules(file, basePath) { ts.forEach(file.statements, function (node) { - if (node.kind === 183 /* ImportDeclaration */ && node.externalModuleName) { + if (node.kind === 190 /* ImportDeclaration */ && node.externalModuleName) { var nameLiteral = node.externalModuleName; var moduleName = nameLiteral.text; if (moduleName) { @@ -5893,9 +5466,9 @@ var ts; } } } - else if (node.kind === 181 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { + else if (node.kind === 188 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */ && (node.flags & 2 /* Ambient */ || isDeclarationFile(file))) { forEachChild(node.body, function (node) { - if (node.kind === 183 /* ImportDeclaration */ && node.externalModuleName) { + if (node.kind === 190 /* ImportDeclaration */ && node.externalModuleName) { var nameLiteral = node.externalModuleName; var moduleName = nameLiteral.text; if (moduleName) { @@ -5967,24 +5540,40 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function isInstantiated(node) { - if (node.kind === 178 /* InterfaceDeclaration */) { - return false; + function getModuleInstanceState(node) { + if (node.kind === 185 /* InterfaceDeclaration */) { + return 0 /* NonInstantiated */; } - else if (node.kind === 183 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { - return false; + else if (node.kind === 187 /* EnumDeclaration */ && ts.isConstEnumDeclaration(node)) { + return 2 /* ConstEnumOnly */; } - else if (node.kind === 182 /* ModuleBlock */ && !ts.forEachChild(node, isInstantiated)) { - return false; + else if (node.kind === 190 /* ImportDeclaration */ && !(node.flags & 1 /* Export */)) { + return 0 /* NonInstantiated */; } - else if (node.kind === 181 /* ModuleDeclaration */ && !isInstantiated(node.body)) { - return false; + else if (node.kind === 189 /* ModuleBlock */) { + var state = 0 /* NonInstantiated */; + ts.forEachChild(node, function (n) { + switch (getModuleInstanceState(n)) { + case 0 /* NonInstantiated */: + return false; + case 2 /* ConstEnumOnly */: + state = 2 /* ConstEnumOnly */; + return false; + case 1 /* Instantiated */: + state = 1 /* Instantiated */; + return true; + } + }); + return state; + } + else if (node.kind === 188 /* ModuleDeclaration */) { + return getModuleInstanceState(node.body); } else { - return true; + return 1 /* Instantiated */; } } - ts.isInstantiated = isInstantiated; + ts.getModuleInstanceState = getModuleInstanceState; function bindSourceFile(file) { var parent; var container; @@ -6007,30 +5596,26 @@ var ts; if (!symbol.declarations) symbol.declarations = []; symbol.declarations.push(node); - if (symbolKind & ts.SymbolFlags.HasExports && !symbol.exports) + if (symbolKind & 1952 /* HasExports */ && !symbol.exports) symbol.exports = {}; - if (symbolKind & ts.SymbolFlags.HasMembers && !symbol.members) + if (symbolKind & 6240 /* HasMembers */ && !symbol.members) symbol.members = {}; node.symbol = symbol; - if (symbolKind & ts.SymbolFlags.Value && !symbol.valueDeclaration) + if (symbolKind & 107455 /* Value */ && !symbol.valueDeclaration) symbol.valueDeclaration = node; } function getDeclarationName(node) { if (node.name) { - if (node.kind === 181 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { + if (node.kind === 188 /* ModuleDeclaration */ && node.name.kind === 7 /* StringLiteral */) { return '"' + node.name.text + '"'; } return node.name.text; } switch (node.kind) { - case 122 /* Constructor */: - return "__constructor"; - case 125 /* CallSignature */: - return "__call"; - case 126 /* ConstructSignature */: - return "__new"; - case 127 /* IndexSignature */: - return "__index"; + case 126 /* Constructor */: return "__constructor"; + case 129 /* CallSignature */: return "__call"; + case 130 /* ConstructSignature */: return "__new"; + case 131 /* IndexSignature */: return "__index"; } } function getDisplayName(node) { @@ -6057,8 +5642,8 @@ var ts; } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; - if (node.kind === 177 /* ClassDeclaration */ && symbol.exports) { - var prototypeSymbol = createSymbol(4 /* Property */ | 268435456 /* Prototype */, "prototype"); + if (node.kind === 184 /* ClassDeclaration */ && symbol.exports) { + var prototypeSymbol = createSymbol(4 /* Property */ | 536870912 /* Prototype */, "prototype"); if (ts.hasProperty(symbol.exports, prototypeSymbol.name)) { if (node.name) { node.name.parent = node; @@ -6080,16 +5665,16 @@ var ts; } function declareModuleMember(node, symbolKind, symbolExcludes) { var exportKind = 0; - if (symbolKind & ts.SymbolFlags.Value) { - exportKind |= 2097152 /* ExportValue */; + if (symbolKind & 107455 /* Value */) { + exportKind |= 4194304 /* ExportValue */; } - if (symbolKind & ts.SymbolFlags.Type) { - exportKind |= 4194304 /* ExportType */; + if (symbolKind & 3152352 /* Type */) { + exportKind |= 8388608 /* ExportType */; } - if (symbolKind & ts.SymbolFlags.Namespace) { - exportKind |= 8388608 /* ExportNamespace */; + if (symbolKind & 1536 /* Namespace */) { + exportKind |= 16777216 /* ExportNamespace */; } - if (node.flags & 1 /* Export */ || (node.kind !== 183 /* ImportDeclaration */ && isAmbientContext(container))) { + if (node.flags & 1 /* Export */ || (node.kind !== 190 /* ImportDeclaration */ && isAmbientContext(container))) { if (exportKind) { var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); @@ -6104,14 +5689,14 @@ var ts; } } function bindChildren(node, symbolKind, isBlockScopeContainer) { - if (symbolKind & ts.SymbolFlags.HasLocals) { + if (symbolKind & 1041936 /* HasLocals */) { node.locals = {}; } var saveParent = parent; var saveContainer = container; var savedBlockScopeContainer = blockScopeContainer; parent = node; - if (symbolKind & ts.SymbolFlags.IsContainer) { + if (symbolKind & 1048560 /* IsContainer */) { container = node; if (lastContainer !== container && !container.nextContainer) { if (lastContainer) { @@ -6130,59 +5715,68 @@ var ts; } function bindDeclaration(node, symbolKind, symbolExcludes, isBlockScopeContainer) { switch (container.kind) { - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: declareModuleMember(node, symbolKind, symbolExcludes); break; - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolKind, symbolExcludes); break; } - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: declareSymbol(container.locals, undefined, node, symbolKind, symbolExcludes); break; - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: if (node.flags & 128 /* Static */) { declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } - case 130 /* TypeLiteral */: - case 136 /* ObjectLiteral */: - case 178 /* InterfaceDeclaration */: + case 134 /* TypeLiteral */: + case 140 /* ObjectLiteral */: + case 185 /* InterfaceDeclaration */: declareSymbol(container.symbol.members, container.symbol, node, symbolKind, symbolExcludes); break; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: declareSymbol(container.symbol.exports, container.symbol, node, symbolKind, symbolExcludes); break; } bindChildren(node, symbolKind, isBlockScopeContainer); } function bindConstructorDeclaration(node) { - bindDeclaration(node, 8192 /* Constructor */, 0, true); + bindDeclaration(node, 16384 /* Constructor */, 0, true); ts.forEach(node.parameters, function (p) { if (p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */)) { - bindDeclaration(p, 4 /* Property */, ts.SymbolFlags.PropertyExcludes, false); + bindDeclaration(p, 4 /* Property */, 107455 /* PropertyExcludes */, false); } }); } function bindModuleDeclaration(node) { if (node.name.kind === 7 /* StringLiteral */) { - bindDeclaration(node, 256 /* ValueModule */, ts.SymbolFlags.ValueModuleExcludes, true); - } - else if (isInstantiated(node)) { - bindDeclaration(node, 256 /* ValueModule */, ts.SymbolFlags.ValueModuleExcludes, true); + bindDeclaration(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */, true); } else { - bindDeclaration(node, 512 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */, true); + var state = getModuleInstanceState(node); + if (state === 0 /* NonInstantiated */) { + bindDeclaration(node, 1024 /* NamespaceModule */, 0 /* NamespaceModuleExcludes */, true); + } + else { + bindDeclaration(node, 512 /* ValueModule */, 106639 /* ValueModuleExcludes */, true); + if (state === 2 /* ConstEnumOnly */) { + node.symbol.constEnumOnlyModule = true; + } + else if (node.symbol.constEnumOnlyModule) { + node.symbol.constEnumOnlyModule = false; + } + } } } function bindAnonymousDeclaration(node, symbolKind, name, isBlockScopeContainer) { @@ -6202,113 +5796,118 @@ var ts; } function bindBlockScopedVariableDeclaration(node) { switch (blockScopeContainer.kind) { - case 181 /* ModuleDeclaration */: - declareModuleMember(node, 2 /* BlockScopedVariable */, ts.SymbolFlags.BlockScopedVariableExcludes); + case 188 /* ModuleDeclaration */: + declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (ts.isExternalModule(container)) { - declareModuleMember(node, 2 /* BlockScopedVariable */, ts.SymbolFlags.BlockScopedVariableExcludes); + declareModuleMember(node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); break; } default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = {}; } - declareSymbol(blockScopeContainer.locals, undefined, node, 2 /* BlockScopedVariable */, ts.SymbolFlags.BlockScopedVariableExcludes); + declareSymbol(blockScopeContainer.locals, undefined, node, 2 /* BlockScopedVariable */, 107455 /* BlockScopedVariableExcludes */); } bindChildren(node, 2 /* BlockScopedVariable */, false); } function bind(node) { node.parent = parent; switch (node.kind) { - case 118 /* TypeParameter */: - bindDeclaration(node, 524288 /* TypeParameter */, ts.SymbolFlags.TypeParameterExcludes, false); + case 122 /* TypeParameter */: + bindDeclaration(node, 1048576 /* TypeParameter */, 2103776 /* TypeParameterExcludes */, false); break; - case 119 /* Parameter */: - bindDeclaration(node, 1 /* FunctionScopedVariable */, ts.SymbolFlags.ParameterExcludes, false); + case 123 /* Parameter */: + bindDeclaration(node, 1 /* FunctionScopedVariable */, 107455 /* ParameterExcludes */, false); break; - case 174 /* VariableDeclaration */: - if (node.flags & ts.NodeFlags.BlockScoped) { + case 181 /* VariableDeclaration */: + if (node.flags & 6144 /* BlockScoped */) { bindBlockScopedVariableDeclaration(node); } else { - bindDeclaration(node, 1 /* FunctionScopedVariable */, ts.SymbolFlags.FunctionScopedVariableExcludes, false); + bindDeclaration(node, 1 /* FunctionScopedVariable */, 107454 /* FunctionScopedVariableExcludes */, false); } break; - case 120 /* Property */: - case 137 /* PropertyAssignment */: - bindDeclaration(node, 4 /* Property */, ts.SymbolFlags.PropertyExcludes, false); + case 124 /* Property */: + case 141 /* PropertyAssignment */: + bindDeclaration(node, 4 /* Property */, 107455 /* PropertyExcludes */, false); break; - case 185 /* EnumMember */: - bindDeclaration(node, 8 /* EnumMember */, ts.SymbolFlags.EnumMemberExcludes, false); + case 192 /* EnumMember */: + bindDeclaration(node, 8 /* EnumMember */, 107455 /* EnumMemberExcludes */, false); break; - case 125 /* CallSignature */: - bindDeclaration(node, 65536 /* CallSignature */, 0, false); + case 129 /* CallSignature */: + bindDeclaration(node, 131072 /* CallSignature */, 0, false); break; - case 121 /* Method */: - bindDeclaration(node, 4096 /* Method */, ts.SymbolFlags.MethodExcludes, true); + case 125 /* Method */: + bindDeclaration(node, 8192 /* Method */, 99263 /* MethodExcludes */, true); break; - case 126 /* ConstructSignature */: - bindDeclaration(node, 131072 /* ConstructSignature */, 0, true); + case 130 /* ConstructSignature */: + bindDeclaration(node, 262144 /* ConstructSignature */, 0, true); break; - case 127 /* IndexSignature */: - bindDeclaration(node, 262144 /* IndexSignature */, 0, false); + case 131 /* IndexSignature */: + bindDeclaration(node, 524288 /* IndexSignature */, 0, false); break; - case 175 /* FunctionDeclaration */: - bindDeclaration(node, 16 /* Function */, ts.SymbolFlags.FunctionExcludes, true); + case 182 /* FunctionDeclaration */: + bindDeclaration(node, 16 /* Function */, 106927 /* FunctionExcludes */, true); break; - case 122 /* Constructor */: + case 126 /* Constructor */: bindConstructorDeclaration(node); break; - case 123 /* GetAccessor */: - bindDeclaration(node, 16384 /* GetAccessor */, ts.SymbolFlags.GetAccessorExcludes, true); + case 127 /* GetAccessor */: + bindDeclaration(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */, true); break; - case 124 /* SetAccessor */: - bindDeclaration(node, 32768 /* SetAccessor */, ts.SymbolFlags.SetAccessorExcludes, true); + case 128 /* SetAccessor */: + bindDeclaration(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */, true); break; - case 130 /* TypeLiteral */: - bindAnonymousDeclaration(node, 1024 /* TypeLiteral */, "__type", false); + case 134 /* TypeLiteral */: + bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type", false); break; - case 136 /* ObjectLiteral */: - bindAnonymousDeclaration(node, 2048 /* ObjectLiteral */, "__object", false); + case 140 /* ObjectLiteral */: + bindAnonymousDeclaration(node, 4096 /* ObjectLiteral */, "__object", false); break; - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: bindAnonymousDeclaration(node, 16 /* Function */, "__function", true); break; - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: bindCatchVariableDeclaration(node); break; - case 177 /* ClassDeclaration */: - bindDeclaration(node, 32 /* Class */, ts.SymbolFlags.ClassExcludes, false); + case 184 /* ClassDeclaration */: + bindDeclaration(node, 32 /* Class */, 3258879 /* ClassExcludes */, false); break; - case 178 /* InterfaceDeclaration */: - bindDeclaration(node, 64 /* Interface */, ts.SymbolFlags.InterfaceExcludes, false); + case 185 /* InterfaceDeclaration */: + bindDeclaration(node, 64 /* Interface */, 3152288 /* InterfaceExcludes */, false); break; - case 179 /* TypeAliasDeclaration */: - bindDeclaration(node, 1048576 /* TypeAlias */, ts.SymbolFlags.TypeAliasExcludes, false); + case 186 /* TypeAliasDeclaration */: + bindDeclaration(node, 2097152 /* TypeAlias */, 3152352 /* TypeAliasExcludes */, false); break; - case 180 /* EnumDeclaration */: - bindDeclaration(node, 128 /* Enum */, ts.SymbolFlags.EnumExcludes, false); + case 187 /* EnumDeclaration */: + if (ts.isConstEnumDeclaration(node)) { + bindDeclaration(node, 128 /* ConstEnum */, 3259263 /* ConstEnumExcludes */, false); + } + else { + bindDeclaration(node, 256 /* RegularEnum */, 3258623 /* RegularEnumExcludes */, false); + } break; - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: bindModuleDeclaration(node); break; - case 183 /* ImportDeclaration */: - bindDeclaration(node, 16777216 /* Import */, ts.SymbolFlags.ImportExcludes, false); + case 190 /* ImportDeclaration */: + bindDeclaration(node, 33554432 /* Import */, 33554432 /* ImportExcludes */, false); break; - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (ts.isExternalModule(node)) { - bindAnonymousDeclaration(node, 256 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); + bindAnonymousDeclaration(node, 512 /* ValueModule */, '"' + ts.removeFileExtension(node.filename) + '"', true); break; } - case 151 /* Block */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 164 /* SwitchStatement */: + case 158 /* Block */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 171 /* SwitchStatement */: bindChildren(node, 0, true); break; default: @@ -6371,7 +5970,7 @@ var ts; } function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 122 /* Constructor */ && member.body) { + if (member.kind === 126 /* Constructor */ && member.body) { return member; } }); @@ -6381,14 +5980,14 @@ var ts; var getAccessor; var setAccessor; ts.forEach(node.members, function (member) { - if ((member.kind === 123 /* GetAccessor */ || member.kind === 124 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { + if ((member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) && member.name.text === accessor.name.text && (member.flags & 128 /* Static */) === (accessor.flags & 128 /* Static */)) { if (!firstAccessor) { firstAccessor = member; } - if (member.kind === 123 /* GetAccessor */ && !getAccessor) { + if (member.kind === 127 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 124 /* SetAccessor */ && !setAccessor) { + if (member.kind === 128 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -6711,7 +6310,7 @@ var ts; if (scopeName) { recordScopeNameStart(scopeName); } - else if (node.kind === 175 /* FunctionDeclaration */ || node.kind === 144 /* FunctionExpression */ || node.kind === 121 /* Method */ || node.kind === 123 /* GetAccessor */ || node.kind === 124 /* SetAccessor */ || node.kind === 181 /* ModuleDeclaration */ || node.kind === 177 /* ClassDeclaration */ || node.kind === 180 /* EnumDeclaration */) { + else if (node.kind === 182 /* FunctionDeclaration */ || node.kind === 149 /* FunctionExpression */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */ || node.kind === 188 /* ModuleDeclaration */ || node.kind === 184 /* ClassDeclaration */ || node.kind === 187 /* EnumDeclaration */) { if (node.name) { scopeName = node.name.text; } @@ -6793,7 +6392,7 @@ var ts; } function emitNodeWithMap(node) { if (node) { - if (node.kind != 186 /* SourceFile */) { + if (node.kind != 193 /* SourceFile */) { recordEmitNodeStartSpan(node); emitNode(node); recordEmitNodeEndSpan(node); @@ -6880,13 +6479,76 @@ var ts; } } function emitLiteral(node) { - var text = getSourceTextOfLocalNode(node); - if (node.kind === 7 /* StringLiteral */ && compilerOptions.sourceMap) { + var text = getLiteralText(); + if (compilerOptions.sourceMap && (node.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(node.kind))) { writer.writeLiteral(text); } else { write(text); } + function getLiteralText() { + if (compilerOptions.target < 2 /* ES6 */ && ts.isTemplateLiteralKind(node.kind)) { + return getTemplateLiteralAsStringLiteral(node); + } + return getSourceTextOfLocalNode(node); + } + } + function getTemplateLiteralAsStringLiteral(node) { + return '"' + ts.escapeString(node.text) + '"'; + } + function emitTemplateExpression(node) { + if (compilerOptions.target >= 2 /* ES6 */) { + ts.forEachChild(node, emit); + return; + } + ts.Debug.assert(node.parent.kind !== 146 /* TaggedTemplateExpression */); + var templateNeedsParens = ts.isExpression(node.parent) && node.parent.kind !== 148 /* ParenExpression */ && comparePrecedenceToBinaryPlus(node.parent) !== -1 /* LessThan */; + if (templateNeedsParens) { + write("("); + } + emitLiteral(node.head); + ts.forEach(node.templateSpans, function (templateSpan) { + var needsParens = templateSpan.expression.kind !== 148 /* ParenExpression */ && comparePrecedenceToBinaryPlus(templateSpan.expression) !== 1 /* GreaterThan */; + write(" + "); + if (needsParens) { + write("("); + } + emit(templateSpan.expression); + if (needsParens) { + write(")"); + } + if (templateSpan.literal.text.length !== 0) { + write(" + "); + emitLiteral(templateSpan.literal); + } + }); + if (templateNeedsParens) { + write(")"); + } + function comparePrecedenceToBinaryPlus(expression) { + ts.Debug.assert(compilerOptions.target <= 1 /* ES5 */); + switch (expression.kind) { + case 153 /* BinaryExpression */: + switch (expression.operator) { + case 34 /* AsteriskToken */: + case 35 /* SlashToken */: + case 36 /* PercentToken */: + return 1 /* GreaterThan */; + case 32 /* PlusToken */: + return 0 /* EqualTo */; + default: + return -1 /* LessThan */; + } + case 154 /* ConditionalExpression */: + return -1 /* LessThan */; + default: + return 1 /* GreaterThan */; + } + } + } + function emitTemplateSpan(span) { + emit(span.expression); + emit(span.literal); } function emitQuotedIdentifier(node) { if (node.kind === 7 /* StringLiteral */) { @@ -6906,29 +6568,29 @@ var ts; function isNonExpressionIdentifier(node) { var parent = node.parent; switch (parent.kind) { - case 119 /* Parameter */: - case 174 /* VariableDeclaration */: - case 120 /* Property */: - case 137 /* PropertyAssignment */: - case 185 /* EnumMember */: - case 121 /* Method */: - case 175 /* FunctionDeclaration */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 144 /* FunctionExpression */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: - case 181 /* ModuleDeclaration */: - case 183 /* ImportDeclaration */: + case 123 /* Parameter */: + case 181 /* VariableDeclaration */: + case 124 /* Property */: + case 141 /* PropertyAssignment */: + case 192 /* EnumMember */: + case 125 /* Method */: + case 182 /* FunctionDeclaration */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 149 /* FunctionExpression */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: + case 188 /* ModuleDeclaration */: + case 190 /* ImportDeclaration */: return parent.name === node; - case 161 /* BreakStatement */: - case 160 /* ContinueStatement */: - case 184 /* ExportAssignment */: + case 168 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 191 /* ExportAssignment */: return false; - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return node.parent.label === node; - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: return node.parent.variable === node; } } @@ -7002,18 +6664,27 @@ var ts; emit(node.initializer); emitTrailingComments(node); } - function emitPropertyAccess(node) { + function tryEmitConstantValue(node) { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - write(constantValue.toString() + " /* " + ts.identifierToString(node.right) + " */"); + var propertyName = node.kind === 142 /* PropertyAccess */ ? ts.identifierToString(node.right) : ts.getTextOfNode(node.index); + write(constantValue.toString() + " /* " + propertyName + " */"); + return true; } - else { - emit(node.left); - write("."); - emit(node.right); + return false; + } + function emitPropertyAccess(node) { + if (tryEmitConstantValue(node)) { + return; } + emit(node.left); + write("."); + emit(node.right); } function emitIndexedAccess(node) { + if (tryEmitConstantValue(node)) { + return; + } emit(node.object); write("["); emit(node.index); @@ -7021,13 +6692,13 @@ var ts; } function emitCallExpression(node) { var superCall = false; - if (node.func.kind === 85 /* SuperKeyword */) { + if (node.func.kind === 89 /* SuperKeyword */) { write("_super"); superCall = true; } else { emit(node.func); - superCall = node.func.kind === 138 /* PropertyAccess */ && node.func.left.kind === 85 /* SuperKeyword */; + superCall = node.func.kind === 142 /* PropertyAccess */ && node.func.left.kind === 89 /* SuperKeyword */; } if (superCall) { write(".call("); @@ -7053,13 +6724,19 @@ var ts; write(")"); } } + function emitTaggedTemplateExpression(node) { + ts.Debug.assert(compilerOptions.target >= 2 /* ES6 */, "Trying to emit a tagged template in pre-ES6 mode."); + emit(node.tag); + write(" "); + emit(node.template); + } function emitParenExpression(node) { - if (node.expression.kind === 142 /* TypeAssertion */) { + if (node.expression.kind === 147 /* TypeAssertion */) { var operand = node.expression.operand; - while (operand.kind == 142 /* TypeAssertion */) { + while (operand.kind == 147 /* TypeAssertion */) { operand = operand.operand; } - if (operand.kind !== 146 /* PrefixOperator */ && operand.kind !== 147 /* PostfixOperator */ && operand.kind !== 141 /* NewExpression */ && !(operand.kind === 140 /* CallExpression */ && node.parent.kind === 141 /* NewExpression */) && !(operand.kind === 144 /* FunctionExpression */ && node.parent.kind === 140 /* CallExpression */)) { + if (operand.kind !== 151 /* PrefixOperator */ && operand.kind !== 152 /* PostfixOperator */ && operand.kind !== 145 /* NewExpression */ && !(operand.kind === 144 /* CallExpression */ && node.parent.kind === 145 /* NewExpression */) && !(operand.kind === 149 /* FunctionExpression */ && node.parent.kind === 144 /* CallExpression */)) { emit(operand); return; } @@ -7069,29 +6746,29 @@ var ts; write(")"); } function emitUnaryExpression(node) { - if (node.kind === 146 /* PrefixOperator */) { + if (node.kind === 151 /* PrefixOperator */) { write(ts.tokenToString(node.operator)); } - if (node.operator >= 59 /* Identifier */) { + if (node.operator >= 63 /* Identifier */) { write(" "); } - else if (node.kind === 146 /* PrefixOperator */ && node.operand.kind === 146 /* PrefixOperator */) { + else if (node.kind === 151 /* PrefixOperator */ && node.operand.kind === 151 /* PrefixOperator */) { var operand = node.operand; - if (node.operator === 28 /* PlusToken */ && (operand.operator === 28 /* PlusToken */ || operand.operator === 33 /* PlusPlusToken */)) { + if (node.operator === 32 /* PlusToken */ && (operand.operator === 32 /* PlusToken */ || operand.operator === 37 /* PlusPlusToken */)) { write(" "); } - else if (node.operator === 29 /* MinusToken */ && (operand.operator === 29 /* MinusToken */ || operand.operator === 34 /* MinusMinusToken */)) { + else if (node.operator === 33 /* MinusToken */ && (operand.operator === 33 /* MinusToken */ || operand.operator === 38 /* MinusMinusToken */)) { write(" "); } } emit(node.operand); - if (node.kind === 147 /* PostfixOperator */) { + if (node.kind === 152 /* PostfixOperator */) { write(ts.tokenToString(node.operator)); } } function emitBinaryExpression(node) { emit(node.left); - if (node.operator !== 18 /* CommaToken */) + if (node.operator !== 22 /* CommaToken */) write(" "); write(ts.tokenToString(node.operator)); write(" "); @@ -7105,21 +6782,21 @@ var ts; emit(node.whenFalse); } function emitBlock(node) { - emitToken(9 /* OpenBraceToken */, node.pos); + emitToken(13 /* OpenBraceToken */, node.pos); increaseIndent(); scopeEmitStart(node.parent); - if (node.kind === 182 /* ModuleBlock */) { - ts.Debug.assert(node.parent.kind === 181 /* ModuleDeclaration */); + if (node.kind === 189 /* ModuleBlock */) { + ts.Debug.assert(node.parent.kind === 188 /* ModuleDeclaration */); emitCaptureThisForNodeIfNecessary(node.parent); } emitLines(node.statements); decreaseIndent(); writeLine(); - emitToken(10 /* CloseBraceToken */, node.statements.end); + emitToken(14 /* CloseBraceToken */, node.statements.end); scopeEmitEnd(); } function emitEmbeddedStatement(node) { - if (node.kind === 151 /* Block */) { + if (node.kind === 158 /* Block */) { write(" "); emit(node); } @@ -7131,7 +6808,7 @@ var ts; } } function emitExpressionStatement(node) { - var isArrowExpression = node.expression.kind === 145 /* ArrowFunction */; + var isArrowExpression = node.expression.kind === 150 /* ArrowFunction */; emitLeadingComments(node); if (isArrowExpression) write("("); @@ -7143,16 +6820,16 @@ var ts; } function emitIfStatement(node) { emitLeadingComments(node); - var endPos = emitToken(78 /* IfKeyword */, node.pos); + var endPos = emitToken(82 /* IfKeyword */, node.pos); write(" "); - endPos = emitToken(11 /* OpenParenToken */, endPos); + endPos = emitToken(15 /* OpenParenToken */, endPos); emit(node.expression); - emitToken(12 /* CloseParenToken */, node.expression.end); + emitToken(16 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.thenStatement); if (node.elseStatement) { writeLine(); - emitToken(70 /* ElseKeyword */, node.thenStatement.end); - if (node.elseStatement.kind === 155 /* IfStatement */) { + emitToken(74 /* ElseKeyword */, node.thenStatement.end); + if (node.elseStatement.kind === 162 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -7165,7 +6842,7 @@ var ts; function emitDoStatement(node) { write("do"); emitEmbeddedStatement(node.statement); - if (node.statement.kind === 151 /* Block */) { + if (node.statement.kind === 158 /* Block */) { write(" "); } else { @@ -7182,18 +6859,18 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForStatement(node) { - var endPos = emitToken(76 /* ForKeyword */, node.pos); + var endPos = emitToken(80 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(11 /* OpenParenToken */, endPos); + endPos = emitToken(15 /* OpenParenToken */, endPos); if (node.declarations) { if (node.declarations[0] && node.declarations[0].flags & 2048 /* Let */) { - emitToken(98 /* LetKeyword */, endPos); + emitToken(102 /* LetKeyword */, endPos); } else if (node.declarations[0] && node.declarations[0].flags & 4096 /* Const */) { - emitToken(64 /* ConstKeyword */, endPos); + emitToken(68 /* ConstKeyword */, endPos); } else { - emitToken(92 /* VarKeyword */, endPos); + emitToken(96 /* VarKeyword */, endPos); } write(" "); emitCommaList(node.declarations, false); @@ -7209,15 +6886,15 @@ var ts; emitEmbeddedStatement(node.statement); } function emitForInStatement(node) { - var endPos = emitToken(76 /* ForKeyword */, node.pos); + var endPos = emitToken(80 /* ForKeyword */, node.pos); write(" "); - endPos = emitToken(11 /* OpenParenToken */, endPos); + endPos = emitToken(15 /* OpenParenToken */, endPos); if (node.declaration) { if (node.declaration.flags & 2048 /* Let */) { - emitToken(98 /* LetKeyword */, endPos); + emitToken(102 /* LetKeyword */, endPos); } else { - emitToken(92 /* VarKeyword */, endPos); + emitToken(96 /* VarKeyword */, endPos); } write(" "); emit(node.declaration); @@ -7227,17 +6904,17 @@ var ts; } write(" in "); emit(node.expression); - emitToken(12 /* CloseParenToken */, node.expression.end); + emitToken(16 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node.statement); } function emitBreakOrContinueStatement(node) { - emitToken(node.kind === 161 /* BreakStatement */ ? 60 /* BreakKeyword */ : 65 /* ContinueKeyword */, node.pos); + emitToken(node.kind === 168 /* BreakStatement */ ? 64 /* BreakKeyword */ : 69 /* ContinueKeyword */, node.pos); emitOptional(" ", node.label); write(";"); } function emitReturnStatement(node) { emitLeadingComments(node); - emitToken(84 /* ReturnKeyword */, node.pos); + emitToken(88 /* ReturnKeyword */, node.pos); emitOptional(" ", node.expression); write(";"); emitTrailingComments(node); @@ -7249,21 +6926,24 @@ var ts; emitEmbeddedStatement(node.statement); } function emitSwitchStatement(node) { - var endPos = emitToken(86 /* SwitchKeyword */, node.pos); + var endPos = emitToken(90 /* SwitchKeyword */, node.pos); write(" "); - emitToken(11 /* OpenParenToken */, endPos); + emitToken(15 /* OpenParenToken */, endPos); emit(node.expression); - endPos = emitToken(12 /* CloseParenToken */, node.expression.end); + endPos = emitToken(16 /* CloseParenToken */, node.expression.end); write(" "); - emitToken(9 /* OpenBraceToken */, endPos); + emitToken(13 /* OpenBraceToken */, endPos); increaseIndent(); emitLines(node.clauses); decreaseIndent(); writeLine(); - emitToken(10 /* CloseBraceToken */, node.clauses.end); + emitToken(14 /* CloseBraceToken */, node.clauses.end); + } + function isOnSameLine(node1, node2) { + return getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node2.pos)); } function emitCaseOrDefaultClause(node) { - if (node.kind === 165 /* CaseClause */) { + if (node.kind === 172 /* CaseClause */) { write("case "); emit(node.expression); write(":"); @@ -7271,9 +6951,15 @@ var ts; else { write("default:"); } - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); + if (node.statements.length === 1 && isOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } } function emitThrowStatement(node) { write("throw "); @@ -7292,16 +6978,16 @@ var ts; } function emitCatchBlock(node) { writeLine(); - var endPos = emitToken(62 /* CatchKeyword */, node.pos); + var endPos = emitToken(66 /* CatchKeyword */, node.pos); write(" "); - emitToken(11 /* OpenParenToken */, endPos); + emitToken(15 /* OpenParenToken */, endPos); emit(node.variable); - emitToken(12 /* CloseParenToken */, node.variable.end); + emitToken(16 /* CloseParenToken */, node.variable.end); write(" "); emitBlock(node); } function emitDebuggerStatement(node) { - emitToken(66 /* DebuggerKeyword */, node.pos); + emitToken(70 /* DebuggerKeyword */, node.pos); write(";"); } function emitLabelledStatement(node) { @@ -7312,7 +6998,7 @@ var ts; function getContainingModule(node) { do { node = node.parent; - } while (node && node.kind !== 181 /* ModuleDeclaration */); + } while (node && node.kind !== 188 /* ModuleDeclaration */); return node; } function emitModuleMemberName(node) { @@ -7411,7 +7097,7 @@ var ts; } function emitAccessor(node) { emitLeadingComments(node); - write(node.kind === 123 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 127 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node); emitTrailingComments(node); @@ -7420,15 +7106,15 @@ var ts; if (!node.body) { return emitPinnedOrTripleSlashComments(node); } - if (node.kind !== 121 /* Method */) { + if (node.kind !== 125 /* Method */) { emitLeadingComments(node); } write("function "); - if (node.kind === 175 /* FunctionDeclaration */ || (node.kind === 144 /* FunctionExpression */ && node.name)) { + if (node.kind === 182 /* FunctionDeclaration */ || (node.kind === 149 /* FunctionExpression */ && node.name)) { emit(node.name); } emitSignatureAndBody(node); - if (node.kind !== 121 /* Method */) { + if (node.kind !== 125 /* Method */) { emitTrailingComments(node); } } @@ -7454,16 +7140,16 @@ var ts; write(" {"); scopeEmitStart(node); increaseIndent(); - emitDetachedComments(node.body.kind === 176 /* FunctionBlock */ ? node.body.statements : node.body); + emitDetachedComments(node.body.kind === 183 /* FunctionBlock */ ? node.body.statements : node.body); var startIndex = 0; - if (node.body.kind === 176 /* FunctionBlock */) { + if (node.body.kind === 183 /* FunctionBlock */) { startIndex = emitDirectivePrologues(node.body.statements, true); } var outPos = writer.getTextPos(); emitCaptureThisForNodeIfNecessary(node); emitDefaultValueAssignments(node); emitRestParameter(node); - if (node.body.kind !== 176 /* FunctionBlock */ && outPos === writer.getTextPos()) { + if (node.body.kind !== 183 /* FunctionBlock */ && outPos === writer.getTextPos()) { decreaseIndent(); write(" "); emitStart(node.body); @@ -7476,7 +7162,7 @@ var ts; emitEnd(node.body); } else { - if (node.body.kind === 176 /* FunctionBlock */) { + if (node.body.kind === 183 /* FunctionBlock */) { emitLinesStartingAt(node.body.statements, startIndex); } else { @@ -7488,10 +7174,10 @@ var ts; emitTrailingComments(node.body); } writeLine(); - if (node.body.kind === 176 /* FunctionBlock */) { + if (node.body.kind === 183 /* FunctionBlock */) { emitLeadingCommentsOfPosition(node.body.statements.end); decreaseIndent(); - emitToken(10 /* CloseBraceToken */, node.body.statements.end); + emitToken(14 /* CloseBraceToken */, node.body.statements.end); } else { decreaseIndent(); @@ -7514,11 +7200,11 @@ var ts; function findInitialSuperCall(ctor) { if (ctor.body) { var statement = ctor.body.statements[0]; - if (statement && statement.kind === 154 /* ExpressionStatement */) { + if (statement && statement.kind === 161 /* ExpressionStatement */) { var expr = statement.expression; - if (expr && expr.kind === 140 /* CallExpression */) { + if (expr && expr.kind === 144 /* CallExpression */) { var func = expr.func; - if (func && func.kind === 85 /* SuperKeyword */) { + if (func && func.kind === 89 /* SuperKeyword */) { return statement; } } @@ -7527,7 +7213,7 @@ var ts; } function emitParameterPropertyAssignments(node) { ts.forEach(node.parameters, function (param) { - if (param.flags & ts.NodeFlags.AccessibilityModifier) { + if (param.flags & 112 /* AccessibilityModifier */) { writeLine(); emitStart(param); emitStart(param.name); @@ -7554,7 +7240,7 @@ var ts; } function emitMemberAssignments(node, staticFlag) { ts.forEach(node.members, function (member) { - if (member.kind === 120 /* Property */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { + if (member.kind === 124 /* Property */ && (member.flags & 128 /* Static */) === staticFlag && member.initializer) { writeLine(); emitLeadingComments(member); emitStart(member); @@ -7577,7 +7263,7 @@ var ts; } function emitMemberFunctions(node) { ts.forEach(node.members, function (member) { - if (member.kind === 121 /* Method */) { + if (member.kind === 125 /* Method */) { if (!member.body) { return emitPinnedOrTripleSlashComments(member); } @@ -7599,7 +7285,7 @@ var ts; write(";"); emitTrailingComments(member); } - else if (member.kind === 123 /* GetAccessor */ || member.kind === 124 /* SetAccessor */) { + else if (member.kind === 127 /* GetAccessor */ || member.kind === 128 /* SetAccessor */) { var accessors = getAllAccessorDeclarations(node, member); if (member === accessors.firstAccessor) { writeLine(); @@ -7677,11 +7363,11 @@ var ts; write("return "); emitNode(node.name); } - emitToken(10 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); + emitToken(14 /* CloseBraceToken */, node.members.end, emitClassReturnStatement); write(";"); decreaseIndent(); writeLine(); - emitToken(10 /* CloseBraceToken */, node.members.end); + emitToken(14 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); emitStart(node); write(")("); @@ -7702,7 +7388,7 @@ var ts; emitTrailingComments(node); function emitConstructorOfClass() { ts.forEach(node.members, function (member) { - if (member.kind === 122 /* Constructor */ && !member.body) { + if (member.kind === 126 /* Constructor */ && !member.body) { emitPinnedOrTripleSlashComments(member); } }); @@ -7753,7 +7439,7 @@ var ts; emitLeadingCommentsOfPosition(ctor.body.statements.end); } decreaseIndent(); - emitToken(10 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); + emitToken(14 /* CloseBraceToken */, ctor ? ctor.body.statements.end : node.members.end); scopeEmitEnd(); emitEnd(ctor || node); if (ctor) { @@ -7765,6 +7451,10 @@ var ts; emitPinnedOrTripleSlashComments(node); } function emitEnumDeclaration(node) { + var isConstEnum = ts.isConstEnumDeclaration(node); + if (isConstEnum && !compilerOptions.preserveConstEnums) { + return; + } emitLeadingComments(node); if (!(node.flags & 1 /* Export */)) { emitStart(node); @@ -7782,10 +7472,10 @@ var ts; write(") {"); increaseIndent(); scopeEmitStart(node); - emitEnumMemberDeclarations(); + emitEnumMemberDeclarations(isConstEnum); decreaseIndent(); writeLine(); - emitToken(10 /* CloseBraceToken */, node.members.end); + emitToken(14 /* CloseBraceToken */, node.members.end); scopeEmitEnd(); write(")("); emitModuleMemberName(node); @@ -7804,7 +7494,7 @@ var ts; write(";"); } emitTrailingComments(node); - function emitEnumMemberDeclarations() { + function emitEnumMemberDeclarations(isConstEnum) { ts.forEach(node.members, function (member) { writeLine(); emitLeadingComments(member); @@ -7815,7 +7505,7 @@ var ts; write("["); emitQuotedIdentifier(member.name); write("] = "); - if (member.initializer) { + if (member.initializer && !isConstEnum) { emit(member.initializer); } else { @@ -7830,13 +7520,13 @@ var ts; } } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 181 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 188 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } } function emitModuleDeclaration(node) { - if (!ts.isInstantiated(node)) { + if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return emitPinnedOrTripleSlashComments(node); } emitLeadingComments(node); @@ -7852,7 +7542,7 @@ var ts; write(resolver.getLocalNameOfContainer(node)); emitEnd(node.name); write(") "); - if (node.body.kind === 182 /* ModuleBlock */) { + if (node.body.kind === 189 /* ModuleBlock */) { emit(node.body); } else { @@ -7865,7 +7555,7 @@ var ts; decreaseIndent(); writeLine(); var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body; - emitToken(10 /* CloseBraceToken */, moduleBlock.statements.end); + emitToken(14 /* CloseBraceToken */, moduleBlock.statements.end); scopeEmitEnd(); } write(")("); @@ -7883,10 +7573,10 @@ var ts; function emitImportDeclaration(node) { var emitImportDeclaration = resolver.isReferencedImportDeclaration(node); if (!emitImportDeclaration) { - emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportedViaEntityName(node); + emitImportDeclaration = !ts.isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node); } if (emitImportDeclaration) { - if (node.externalModuleName && node.parent.kind === 186 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { + if (node.externalModuleName && node.parent.kind === 193 /* SourceFile */ && compilerOptions.module === 2 /* AMD */) { if (node.flags & 1 /* Export */) { writeLine(); emitLeadingComments(node); @@ -7915,7 +7605,7 @@ var ts; emitStart(node.externalModuleName); emitLiteral(node.externalModuleName); emitEnd(node.externalModuleName); - emitToken(12 /* CloseParenToken */, node.externalModuleName.end); + emitToken(16 /* CloseParenToken */, node.externalModuleName.end); } write(";"); emitEnd(node); @@ -7926,7 +7616,7 @@ var ts; function getExternalImportDeclarations(node) { var result = []; ts.forEach(node.statements, function (stat) { - if (stat.kind === 183 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) { + if (stat.kind === 190 /* ImportDeclaration */ && stat.externalModuleName && resolver.isReferencedImportDeclaration(stat)) { result.push(stat); } }); @@ -7934,7 +7624,7 @@ var ts; } function getFirstExportAssignment(sourceFile) { return ts.forEach(sourceFile.statements, function (node) { - if (node.kind === 184 /* ExportAssignment */) { + if (node.kind === 191 /* ExportAssignment */) { return node; } }); @@ -8050,117 +7740,127 @@ var ts; return emitPinnedOrTripleSlashComments(node); } switch (node.kind) { - case 59 /* Identifier */: + case 63 /* Identifier */: return emitIdentifier(node); - case 119 /* Parameter */: + case 123 /* Parameter */: return emitParameter(node); - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return emitAccessor(node); - case 87 /* ThisKeyword */: + case 91 /* ThisKeyword */: return emitThis(node); - case 85 /* SuperKeyword */: + case 89 /* SuperKeyword */: return emitSuper(node); - case 83 /* NullKeyword */: + case 87 /* NullKeyword */: return write("null"); - case 89 /* TrueKeyword */: + case 93 /* TrueKeyword */: return write("true"); - case 74 /* FalseKeyword */: + case 78 /* FalseKeyword */: return write("false"); case 6 /* NumericLiteral */: case 7 /* StringLiteral */: case 8 /* RegularExpressionLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: + case 10 /* TemplateHead */: + case 11 /* TemplateMiddle */: + case 12 /* TemplateTail */: return emitLiteral(node); - case 117 /* QualifiedName */: + case 155 /* TemplateExpression */: + return emitTemplateExpression(node); + case 156 /* TemplateSpan */: + return emitTemplateSpan(node); + case 121 /* QualifiedName */: return emitPropertyAccess(node); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return emitArrayLiteral(node); - case 136 /* ObjectLiteral */: + case 140 /* ObjectLiteral */: return emitObjectLiteral(node); - case 137 /* PropertyAssignment */: + case 141 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 138 /* PropertyAccess */: + case 142 /* PropertyAccess */: return emitPropertyAccess(node); - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return emitIndexedAccess(node); - case 140 /* CallExpression */: + case 144 /* CallExpression */: return emitCallExpression(node); - case 141 /* NewExpression */: + case 145 /* NewExpression */: return emitNewExpression(node); - case 142 /* TypeAssertion */: + case 146 /* TaggedTemplateExpression */: + return emitTaggedTemplateExpression(node); + case 147 /* TypeAssertion */: return emit(node.operand); - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return emitParenExpression(node); - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: return emitFunctionDeclaration(node); - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: return emitUnaryExpression(node); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return emitBinaryExpression(node); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return emitConditionalExpression(node); - case 150 /* OmittedExpression */: + case 157 /* OmittedExpression */: return; - case 151 /* Block */: - case 170 /* TryBlock */: - case 172 /* FinallyBlock */: - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: + case 158 /* Block */: + case 177 /* TryBlock */: + case 179 /* FinallyBlock */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: return emitBlock(node); - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return emitVariableStatement(node); - case 153 /* EmptyStatement */: + case 160 /* EmptyStatement */: return write(";"); - case 154 /* ExpressionStatement */: + case 161 /* ExpressionStatement */: return emitExpressionStatement(node); - case 155 /* IfStatement */: + case 162 /* IfStatement */: return emitIfStatement(node); - case 156 /* DoStatement */: + case 163 /* DoStatement */: return emitDoStatement(node); - case 157 /* WhileStatement */: + case 164 /* WhileStatement */: return emitWhileStatement(node); - case 158 /* ForStatement */: + case 165 /* ForStatement */: return emitForStatement(node); - case 159 /* ForInStatement */: + case 166 /* ForInStatement */: return emitForInStatement(node); - case 160 /* ContinueStatement */: - case 161 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 168 /* BreakStatement */: return emitBreakOrContinueStatement(node); - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return emitReturnStatement(node); - case 163 /* WithStatement */: + case 170 /* WithStatement */: return emitWithStatement(node); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return emitSwitchStatement(node); - case 165 /* CaseClause */: - case 166 /* DefaultClause */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: return emitCaseOrDefaultClause(node); - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return emitLabelledStatement(node); - case 168 /* ThrowStatement */: + case 175 /* ThrowStatement */: return emitThrowStatement(node); - case 169 /* TryStatement */: + case 176 /* TryStatement */: return emitTryStatement(node); - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: return emitCatchBlock(node); - case 173 /* DebuggerStatement */: + case 180 /* DebuggerStatement */: return emitDebuggerStatement(node); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return emitClassDeclaration(node); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return emitImportDeclaration(node); - case 186 /* SourceFile */: + case 193 /* SourceFile */: return emitSourceFile(node); } } @@ -8178,7 +7878,7 @@ var ts; return leadingComments; } function getLeadingCommentsToEmit(node) { - if (node.parent.kind === 186 /* SourceFile */ || node.pos !== node.parent.pos) { + if (node.parent.kind === 193 /* SourceFile */ || node.pos !== node.parent.pos) { var leadingComments; if (hasDetachedComments(node.pos)) { leadingComments = getLeadingCommentsWithoutDetachedComments(); @@ -8195,7 +7895,7 @@ var ts; emitComments(leadingComments, true, writer, writeComment); } function emitTrailingDeclarationComments(node) { - if (node.parent.kind === 186 /* SourceFile */ || node.end !== node.parent.end) { + if (node.parent.kind === 193 /* SourceFile */ || node.end !== node.parent.end) { var trailingComments = ts.getTrailingCommentRanges(currentSourceFile.text, node.end); emitComments(trailingComments, false, writer, writeComment); } @@ -8387,7 +8087,7 @@ var ts; if (node.flags & 1 /* Export */) { write("export "); } - if (node.kind !== 178 /* InterfaceDeclaration */) { + if (node.kind !== 185 /* InterfaceDeclaration */) { write("declare "); } } @@ -8443,7 +8143,7 @@ var ts; emitDeclarationFlags(node); write("module "); emitSourceTextOfNode(node.name); - while (node.body.kind !== 182 /* ModuleBlock */) { + while (node.body.kind !== 189 /* ModuleBlock */) { node = node.body; write("."); emitSourceTextOfNode(node.name); @@ -8485,6 +8185,9 @@ var ts; if (resolver.isDeclarationVisible(node)) { emitJsDocComments(node); emitDeclarationFlags(node); + if (ts.isConstEnumDeclaration(node)) { + write("const "); + } write("enum "); emitSourceTextOfNode(node.name); write(" {"); @@ -8512,34 +8215,34 @@ var ts; function getTypeParameterConstraintVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 125 /* CallSignature */: + case 129 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 121 /* Method */: + case 125 /* Method */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 177 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 184 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for type parameter: " + ts.SyntaxKind[node.parent.kind]); + ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -8551,7 +8254,7 @@ var ts; emitJsDocComments(node); decreaseIndent(); emitSourceTextOfNode(node.name); - if (node.constraint && (node.parent.kind !== 121 /* Method */ || !(node.parent.flags & 32 /* Private */))) { + if (node.constraint && (node.parent.kind !== 125 /* Method */ || !(node.parent.flags & 32 /* Private */))) { write(" extends "); getSymbolVisibilityDiagnosticMessage = getTypeParameterConstraintVisibilityError; resolver.writeTypeAtLocation(node.constraint, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); @@ -8573,7 +8276,7 @@ var ts; resolver.writeTypeAtLocation(node, enclosingDeclaration, 1 /* WriteArrayAsGenericType */ | 2 /* UseTypeOfFunction */, writer); function getHeritageClauseVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.parent.kind === 177 /* ClassDeclaration */) { + if (node.parent.kind === 184 /* ClassDeclaration */) { if (symbolAccesibilityResult.errorModuleName) { diagnosticMessage = isImplementsList ? ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Extends_clause_of_exported_class_0_has_or_is_using_name_1_from_private_module_2; } @@ -8601,7 +8304,7 @@ var ts; function emitParameterProperties(constructorDeclaration) { if (constructorDeclaration) { ts.forEach(constructorDeclaration.parameters, function (param) { - if (param.flags & ts.NodeFlags.AccessibilityModifier) { + if (param.flags & 112 /* AccessibilityModifier */) { emitPropertyDeclaration(param); } }); @@ -8658,9 +8361,9 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 174 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 181 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { emitSourceTextOfNode(node.name); - if (node.kind === 120 /* Property */ && (node.flags & 4 /* QuestionMark */)) { + if (node.kind === 124 /* Property */ && (node.flags & 4 /* QuestionMark */)) { write("?"); } if (!(node.flags & 32 /* Private */)) { @@ -8671,14 +8374,14 @@ var ts; } function getVariableDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.kind === 174 /* VariableDeclaration */) { + if (node.kind === 181 /* VariableDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } - else if (node.kind === 120 /* Property */) { + else if (node.kind === 124 /* Property */) { if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 177 /* ClassDeclaration */) { + else if (node.parent.kind === 184 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1; } else { @@ -8728,7 +8431,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; - if (node.kind === 124 /* SetAccessor */) { + if (node.kind === 128 /* SetAccessor */) { if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_property_setter_from_exported_class_has_or_is_using_private_name_1; } @@ -8757,14 +8460,14 @@ var ts; } } function emitFunctionDeclaration(node) { - if ((node.kind !== 175 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { + if ((node.kind !== 182 /* FunctionDeclaration */ || resolver.isDeclarationVisible(node)) && !resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); emitDeclarationFlags(node); - if (node.kind === 175 /* FunctionDeclaration */) { + if (node.kind === 182 /* FunctionDeclaration */) { write("function "); emitSourceTextOfNode(node.name); } - else if (node.kind === 122 /* Constructor */) { + else if (node.kind === 126 /* Constructor */) { write("constructor"); } else { @@ -8782,24 +8485,24 @@ var ts; emitSignatureDeclaration(node); } function emitSignatureDeclaration(node) { - if (node.kind === 125 /* CallSignature */ || node.kind === 127 /* IndexSignature */) { + if (node.kind === 129 /* CallSignature */ || node.kind === 131 /* IndexSignature */) { emitJsDocComments(node); } emitTypeParameters(node.typeParameters); - if (node.kind === 127 /* IndexSignature */) { + if (node.kind === 131 /* IndexSignature */) { write("["); } else { write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 127 /* IndexSignature */) { + if (node.kind === 131 /* IndexSignature */) { write("]"); } else { write(")"); } - if (node.kind !== 122 /* Constructor */ && !(node.flags & 32 /* Private */)) { + if (node.kind !== 126 /* Constructor */ && !(node.flags & 32 /* Private */)) { write(": "); getSymbolVisibilityDiagnosticMessage = getReturnTypeVisibilityError; resolver.writeReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, 2 /* UseTypeOfFunction */, writer); @@ -8809,31 +8512,31 @@ var ts; function getReturnTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.kind) { - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 125 /* CallSignature */: + case 129 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 127 /* IndexSignature */: + case 131 /* IndexSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0; break; - case 121 /* Method */: + case 125 /* Method */: if (node.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 177 /* ClassDeclaration */) { + else if (node.parent.kind === 184 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0; break; default: - ts.Debug.fail("This is unknown kind for signature: " + ts.SyntaxKind[node.kind]); + ts.Debug.fail("This is unknown kind for signature: " + node.kind); } return { diagnosticMessage: diagnosticMessage, @@ -8860,31 +8563,31 @@ var ts; function getParameterDeclarationTypeVisibilityError(symbolAccesibilityResult) { var diagnosticMessage; switch (node.parent.kind) { - case 122 /* Constructor */: + case 126 /* Constructor */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1; break; - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 125 /* CallSignature */: + case 129 /* CallSignature */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 121 /* Method */: + case 125 /* Method */: if (node.parent.flags & 128 /* Static */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 177 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 184 /* ClassDeclaration */) { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1; } else { diagnosticMessage = symbolAccesibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } break; - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: diagnosticMessage = symbolAccesibilityResult.errorModuleName ? symbolAccesibilityResult.accessibility === 2 /* CannotBeNamed */ ? ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1; break; default: - ts.Debug.fail("This is unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]); + ts.Debug.fail("This is unknown parent for parameter: " + node.parent.kind); } return { diagnosticMessage: diagnosticMessage, @@ -8895,39 +8598,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 122 /* Constructor */: - case 175 /* FunctionDeclaration */: - case 121 /* Method */: + case 126 /* Constructor */: + case 182 /* FunctionDeclaration */: + case 125 /* Method */: return emitFunctionDeclaration(node); - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: return emitConstructSignatureDeclaration(node); - case 125 /* CallSignature */: - case 127 /* IndexSignature */: + case 129 /* CallSignature */: + case 131 /* IndexSignature */: return emitSignatureDeclaration(node); - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return emitAccessorDeclaration(node); - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return emitVariableStatement(node); - case 120 /* Property */: + case 124 /* Property */: return emitPropertyDeclaration(node); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return emitClassDeclaration(node); - case 179 /* TypeAliasDeclaration */: + case 186 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 185 /* EnumMember */: + case 192 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return emitImportDeclaration(node); - case 184 /* ExportAssignment */: + case 191 /* ExportAssignment */: return emitExportAssignment(node); - case 186 /* SourceFile */: + case 193 /* SourceFile */: return emitSourceFile(node); } } @@ -9134,10 +8837,10 @@ var ts; isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, hasEarlyErrors: hasEarlyErrors }; - var undefinedSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, "undefined"); - var argumentsSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, "arguments"); - var unknownSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, "unknown"); - var resolvingSymbol = createSymbol(134217728 /* Transient */, "__resolving__"); + var undefinedSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "undefined"); + var argumentsSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "arguments"); + var unknownSymbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "unknown"); + var resolvingSymbol = createSymbol(268435456 /* Transient */, "__resolving__"); var anyType = createIntrinsicType(1 /* Any */, "any"); var stringType = createIntrinsicType(2 /* String */, "string"); var numberType = createIntrinsicType(4 /* Number */, "number"); @@ -9186,35 +8889,37 @@ var ts; function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) - result |= ts.SymbolFlags.BlockScopedVariableExcludes; + result |= 107455 /* BlockScopedVariableExcludes */; if (flags & 1 /* FunctionScopedVariable */) - result |= ts.SymbolFlags.FunctionScopedVariableExcludes; + result |= 107454 /* FunctionScopedVariableExcludes */; if (flags & 4 /* Property */) - result |= ts.SymbolFlags.PropertyExcludes; + result |= 107455 /* PropertyExcludes */; if (flags & 8 /* EnumMember */) - result |= ts.SymbolFlags.EnumMemberExcludes; + result |= 107455 /* EnumMemberExcludes */; if (flags & 16 /* Function */) - result |= ts.SymbolFlags.FunctionExcludes; + result |= 106927 /* FunctionExcludes */; if (flags & 32 /* Class */) - result |= ts.SymbolFlags.ClassExcludes; + result |= 3258879 /* ClassExcludes */; if (flags & 64 /* Interface */) - result |= ts.SymbolFlags.InterfaceExcludes; - if (flags & 128 /* Enum */) - result |= ts.SymbolFlags.EnumExcludes; - if (flags & 256 /* ValueModule */) - result |= ts.SymbolFlags.ValueModuleExcludes; - if (flags & 4096 /* Method */) - result |= ts.SymbolFlags.MethodExcludes; - if (flags & 16384 /* GetAccessor */) - result |= ts.SymbolFlags.GetAccessorExcludes; - if (flags & 32768 /* SetAccessor */) - result |= ts.SymbolFlags.SetAccessorExcludes; - if (flags & 524288 /* TypeParameter */) - result |= ts.SymbolFlags.TypeParameterExcludes; - if (flags & 1048576 /* TypeAlias */) - result |= ts.SymbolFlags.TypeAliasExcludes; - if (flags & 16777216 /* Import */) - result |= ts.SymbolFlags.ImportExcludes; + result |= 3152288 /* InterfaceExcludes */; + if (flags & 256 /* RegularEnum */) + result |= 3258623 /* RegularEnumExcludes */; + if (flags & 128 /* ConstEnum */) + result |= 3259263 /* ConstEnumExcludes */; + if (flags & 512 /* ValueModule */) + result |= 106639 /* ValueModuleExcludes */; + if (flags & 8192 /* Method */) + result |= 99263 /* MethodExcludes */; + if (flags & 32768 /* GetAccessor */) + result |= 41919 /* GetAccessorExcludes */; + if (flags & 65536 /* SetAccessor */) + result |= 74687 /* SetAccessorExcludes */; + if (flags & 1048576 /* TypeParameter */) + result |= 2103776 /* TypeParameterExcludes */; + if (flags & 2097152 /* TypeAlias */) + result |= 3152352 /* TypeAliasExcludes */; + if (flags & 33554432 /* Import */) + result |= 33554432 /* ImportExcludes */; return result; } function recordMergedSymbol(target, source) { @@ -9223,11 +8928,13 @@ var ts; mergedSymbols[source.mergeId] = target; } function cloneSymbol(symbol) { - var result = createSymbol(symbol.flags | 67108864 /* Merged */, symbol.name); + var result = createSymbol(symbol.flags | 134217728 /* Merged */, symbol.name); result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) + result.constEnumOnlyModule = true; if (symbol.members) result.members = cloneSymbolTable(symbol.members); if (symbol.exports) @@ -9237,6 +8944,9 @@ var ts; } function extendSymbol(target, source) { if (!(target.flags & getExcludedSymbolFlags(source.flags))) { + if (source.flags & 512 /* ValueModule */ && target.flags & 512 /* ValueModule */ && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + target.constEnumOnlyModule = false; + } target.flags |= source.flags; if (!target.valueDeclaration && source.valueDeclaration) target.valueDeclaration = source.valueDeclaration; @@ -9282,7 +8992,7 @@ var ts; } else { var symbol = target[id]; - if (!(symbol.flags & 67108864 /* Merged */)) { + if (!(symbol.flags & 134217728 /* Merged */)) { target[id] = symbol = cloneSymbol(symbol); } extendSymbol(symbol, source[id]); @@ -9291,7 +9001,7 @@ var ts; } } function getSymbolLinks(symbol) { - if (symbol.flags & 134217728 /* Transient */) + if (symbol.flags & 268435456 /* Transient */) return symbol; if (!symbol.id) symbol.id = nextSymbolId++; @@ -9303,19 +9013,19 @@ var ts; return nodeLinks[node.id] || (nodeLinks[node.id] = {}); } function getSourceFile(node) { - return ts.getAncestor(node, 186 /* SourceFile */); + return ts.getAncestor(node, 193 /* SourceFile */); } function isGlobalSourceFile(node) { - return node.kind === 186 /* SourceFile */ && !ts.isExternalModule(node); + return node.kind === 193 /* SourceFile */ && !ts.isExternalModule(node); } function getSymbol(symbols, name, meaning) { if (meaning && ts.hasProperty(symbols, name)) { var symbol = symbols[name]; - ts.Debug.assert((symbol.flags & 33554432 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); if (symbol.flags & meaning) { return symbol; } - if (symbol.flags & 16777216 /* Import */) { + if (symbol.flags & 33554432 /* Import */) { var target = resolveImport(symbol); if (target === unknownSymbol || target.flags & meaning) { return symbol; @@ -9323,6 +9033,18 @@ var ts; } } } + function isDefinedBefore(node1, node2) { + var file1 = ts.getSourceFileOfNode(node1); + var file2 = ts.getSourceFileOfNode(node2); + if (file1 === file2) { + return node1.pos <= node2.pos; + } + if (!compilerOptions.out) { + return true; + } + var sourceFiles = program.getSourceFiles(); + return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); + } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { var result; var lastLocation; @@ -9335,32 +9057,32 @@ var ts; } } switch (location.kind) { - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 181 /* ModuleDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & ts.SymbolFlags.ModuleMember)) { + case 188 /* ModuleDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 35653619 /* ModuleMember */)) { break loop; } break; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 120 /* Property */: - if (location.parent.kind === 177 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { + case 124 /* Property */: + if (location.parent.kind === 184 /* ClassDeclaration */ && !(location.flags & 128 /* Static */)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (getSymbol(ctor.locals, name, meaning & ts.SymbolFlags.Value)) { + if (getSymbol(ctor.locals, name, meaning & 107455 /* Value */)) { propertyWithInvalidInitializer = location; } } } break; - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & ts.SymbolFlags.Type)) { + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 3152352 /* Type */)) { if (lastLocation && lastLocation.flags & 128 /* Static */) { error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters); return undefined; @@ -9368,18 +9090,18 @@ var ts; break loop; } break; - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: if (name === "arguments") { result = argumentsSymbol; break loop; } break; - case 144 /* FunctionExpression */: + case 149 /* FunctionExpression */: if (name === "arguments") { result = argumentsSymbol; break loop; @@ -9390,7 +9112,7 @@ var ts; break loop; } break; - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: var id = location.variable; if (name === id.text) { result = location.symbol; @@ -9417,31 +9139,21 @@ var ts; return undefined; } if (result.flags & 2 /* BlockScopedVariable */) { - var declaration = ts.forEach(result.declarations, function (d) { return d.flags & ts.NodeFlags.BlockScoped ? d : undefined; }); - ts.Debug.assert(declaration, "Block-scoped variable declaration is undefined"); - var declarationSourceFile = ts.getSourceFileOfNode(declaration); - var referenceSourceFile = ts.getSourceFileOfNode(errorLocation); - if (declarationSourceFile === referenceSourceFile) { - if (declaration.pos > errorLocation.pos) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.identifierToString(declaration.name)); - } - } - else if (compilerOptions.out) { - var sourceFiles = program.getSourceFiles(); - if (sourceFiles.indexOf(referenceSourceFile) < sourceFiles.indexOf(declarationSourceFile)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.identifierToString(declaration.name)); - } + var declaration = ts.forEach(result.declarations, function (d) { return d.flags & 6144 /* BlockScoped */ ? d : undefined; }); + ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); + if (!isDefinedBefore(declaration, errorLocation)) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.identifierToString(declaration.name)); } } } return result; } function resolveImport(symbol) { - ts.Debug.assert((symbol.flags & 16777216 /* Import */) !== 0, "Should only get Imports here."); + ts.Debug.assert((symbol.flags & 33554432 /* Import */) !== 0, "Should only get Imports here."); var links = getSymbolLinks(symbol); if (!links.target) { links.target = resolvingSymbol; - var node = getDeclarationOfKind(symbol, 183 /* ImportDeclaration */); + var node = getDeclarationOfKind(symbol, 190 /* ImportDeclaration */); var target = node.externalModuleName ? resolveExternalModuleName(node, node.externalModuleName) : getSymbolOfPartOfRightHandSideOfImport(node.entityName, node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; @@ -9457,33 +9169,33 @@ var ts; } function getSymbolOfPartOfRightHandSideOfImport(entityName, importDeclaration) { if (!importDeclaration) { - importDeclaration = ts.getAncestor(entityName, 183 /* ImportDeclaration */); - ts.Debug.assert(importDeclaration); + importDeclaration = ts.getAncestor(entityName, 190 /* ImportDeclaration */); + ts.Debug.assert(importDeclaration !== undefined); } - if (entityName.kind === 59 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 63 /* Identifier */ && isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 59 /* Identifier */ || entityName.parent.kind === 117 /* QualifiedName */) { - return resolveEntityName(importDeclaration, entityName, ts.SymbolFlags.Namespace); + if (entityName.kind === 63 /* Identifier */ || entityName.parent.kind === 121 /* QualifiedName */) { + return resolveEntityName(importDeclaration, entityName, 1536 /* Namespace */); } else { - ts.Debug.assert(entityName.parent.kind === 183 /* ImportDeclaration */); - return resolveEntityName(importDeclaration, entityName, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace); + ts.Debug.assert(entityName.parent.kind === 190 /* ImportDeclaration */); + return resolveEntityName(importDeclaration, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */); } } function getFullyQualifiedName(symbol) { return symbol.parent ? getFullyQualifiedName(symbol.parent) + "." + symbolToString(symbol) : symbolToString(symbol); } function resolveEntityName(location, name, meaning) { - if (name.kind === 59 /* Identifier */) { + if (name.kind === 63 /* Identifier */) { var symbol = resolveName(location, name.text, meaning, ts.Diagnostics.Cannot_find_name_0, name); if (!symbol) { return; } } - else if (name.kind === 117 /* QualifiedName */) { - var namespace = resolveEntityName(location, name.left, ts.SymbolFlags.Namespace); - if (!namespace || namespace === unknownSymbol || name.right.kind === 116 /* Missing */) + else if (name.kind === 121 /* QualifiedName */) { + var namespace = resolveEntityName(location, name.left, 1536 /* Namespace */); + if (!namespace || namespace === unknownSymbol || name.right.kind === 120 /* Missing */) return; var symbol = getSymbol(namespace.exports, name.right.text, meaning); if (!symbol) { @@ -9494,7 +9206,7 @@ var ts; else { return; } - ts.Debug.assert((symbol.flags & 33554432 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); + ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return symbol.flags & meaning ? symbol : resolveImport(symbol); } function isExternalModuleNameRelative(moduleName) { @@ -9507,7 +9219,7 @@ var ts; return; var isRelative = isExternalModuleNameRelative(moduleName); if (!isRelative) { - var symbol = getSymbol(globals, '"' + moduleName + '"', 256 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); if (symbol) { return getResolvedExportSymbol(symbol); } @@ -9534,10 +9246,10 @@ var ts; function getResolvedExportSymbol(moduleSymbol) { var symbol = getExportAssignmentSymbol(moduleSymbol); if (symbol) { - if (symbol.flags & (ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace)) { + if (symbol.flags & (107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */)) { return symbol; } - if (symbol.flags & 16777216 /* Import */) { + if (symbol.flags & 33554432 /* Import */) { return resolveImport(symbol); } } @@ -9561,7 +9273,7 @@ var ts; error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } if (node.exportName.text) { - var meaning = ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace; + var meaning = 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */; var exportSymbol = resolveName(node, node.exportName.text, meaning, ts.Diagnostics.Cannot_find_name_0, node.exportName); } } @@ -9572,9 +9284,9 @@ var ts; var seenExportedMember = false; var result = []; ts.forEach(symbol.declarations, function (declaration) { - var block = (declaration.kind === 186 /* SourceFile */ ? declaration : declaration.body); + var block = (declaration.kind === 193 /* SourceFile */ ? declaration : declaration.body); ts.forEach(block.statements, function (node) { - if (node.kind === 184 /* ExportAssignment */) { + if (node.kind === 191 /* ExportAssignment */) { result.push(node); } else { @@ -9598,17 +9310,17 @@ var ts; return getMergedSymbol(symbol.parent); } function getExportSymbolOfValueSymbolIfExported(symbol) { - return symbol && (symbol.flags & 2097152 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; + return symbol && (symbol.flags & 4194304 /* ExportValue */) !== 0 ? getMergedSymbol(symbol.exportSymbol) : symbol; } function symbolIsValue(symbol) { - if (symbol.flags & 33554432 /* Instantiated */) { + if (symbol.flags & 67108864 /* Instantiated */) { return symbolIsValue(getSymbolLinks(symbol).target); } - if (symbol.flags & ts.SymbolFlags.Value) { + if (symbol.flags & 107455 /* Value */) { return true; } - if (symbol.flags & 16777216 /* Import */) { - return (resolveImport(symbol).flags & ts.SymbolFlags.Value) !== 0; + if (symbol.flags & 33554432 /* Import */) { + return (resolveImport(symbol).flags & 107455 /* Value */) !== 0; } return false; } @@ -9616,7 +9328,7 @@ var ts; var members = node.members; for (var i = 0; i < members.length; i++) { var member = members[i]; - if (member.kind === 122 /* Constructor */ && member.body) { + if (member.kind === 126 /* Constructor */ && member.body) { return member; } } @@ -9670,7 +9382,7 @@ var ts; return setObjectTypeMembers(createObjectType(32768 /* Anonymous */, symbol), members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } function isOptionalProperty(propertySymbol) { - return propertySymbol.valueDeclaration && propertySymbol.valueDeclaration.flags & 4 /* QuestionMark */ && propertySymbol.valueDeclaration.kind !== 119 /* Parameter */; + return propertySymbol.valueDeclaration && propertySymbol.valueDeclaration.flags & 4 /* QuestionMark */ && propertySymbol.valueDeclaration.kind !== 123 /* Parameter */; } function forEachSymbolTableInScope(enclosingDeclaration, callback) { var result; @@ -9681,17 +9393,17 @@ var ts; } } switch (location.kind) { - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (!ts.isExternalModule(location)) { break; } - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } break; - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: if (result = callback(getSymbolOfNode(location).members)) { return result; } @@ -9701,7 +9413,7 @@ var ts; return callback(globals); } function getQualifiedLeftMeaning(rightMeaning) { - return rightMeaning === ts.SymbolFlags.Value ? ts.SymbolFlags.Value : ts.SymbolFlags.Namespace; + return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1536 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { function getAccessibleSymbolChainFromSymbolTable(symbols) { @@ -9721,8 +9433,8 @@ var ts; return [symbol]; } return ts.forEachValue(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 16777216 /* Import */) { - if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 183 /* ImportDeclaration */ && declaration.externalModuleName; })) { + if (symbolFromSymbolTable.flags & 33554432 /* Import */) { + if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, function (declaration) { return declaration.kind === 190 /* ImportDeclaration */ && declaration.externalModuleName; })) { var resolvedImportedSymbol = resolveImport(symbolFromSymbolTable); if (isAccessible(symbolFromSymbolTable, resolveImport(symbolFromSymbolTable))) { return [symbolFromSymbolTable]; @@ -9749,7 +9461,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 16777216 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 33554432 /* Import */) ? resolveImport(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -9759,7 +9471,7 @@ var ts; return qualify; } function isSymbolAccessible(symbol, enclosingDeclaration, meaning) { - if (symbol && enclosingDeclaration && !(symbol.flags & 524288 /* TypeParameter */)) { + if (symbol && enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { var initialSymbol = symbol; var meaningToLook = meaning; while (symbol) { @@ -9770,7 +9482,7 @@ var ts; return { accessibility: 1 /* NotAccessible */, errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning), - errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, ts.SymbolFlags.Namespace) : undefined + errorModuleName: symbol !== initialSymbol ? symbolToString(symbol, enclosingDeclaration, 1536 /* Namespace */) : undefined }; } return { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasAccessibleDeclarations.aliasesToMakeVisible }; @@ -9804,7 +9516,7 @@ var ts; } } function hasExternalModuleSymbol(declaration) { - return (declaration.kind === 181 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 186 /* SourceFile */ && ts.isExternalModule(declaration)); + return (declaration.kind === 188 /* ModuleDeclaration */ && declaration.name.kind === 7 /* StringLiteral */) || (declaration.kind === 193 /* SourceFile */ && ts.isExternalModule(declaration)); } function hasVisibleDeclarations(symbol) { var aliasesToMakeVisible; @@ -9814,7 +9526,7 @@ var ts; return { aliasesToMakeVisible: aliasesToMakeVisible }; function getIsDeclarationVisible(declaration) { if (!isDeclarationVisible(declaration)) { - if (declaration.kind === 183 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { + if (declaration.kind === 190 /* ImportDeclaration */ && !(declaration.flags & 1 /* Export */) && isDeclarationVisible(declaration.parent)) { getNodeLinks(declaration).isVisible = true; if (aliasesToMakeVisible) { if (!ts.contains(aliasesToMakeVisible, declaration)) { @@ -9833,7 +9545,7 @@ var ts; } function isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName) { var firstIdentifier = getFirstIdentifier(entityName); - var symbolOfNameSpace = resolveName(entityName.parent, firstIdentifier.text, ts.SymbolFlags.Namespace, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); + var symbolOfNameSpace = resolveName(entityName.parent, firstIdentifier.text, 1536 /* Namespace */, ts.Diagnostics.Cannot_find_name_0, firstIdentifier); var hasNamespaceDeclarationsVisibile = hasVisibleDeclarations(symbolOfNameSpace); return hasNamespaceDeclarationsVisibile ? { accessibility: 0 /* Accessible */, aliasesToMakeVisible: hasNamespaceDeclarationsVisibile.aliasesToMakeVisible } : { accessibility: 1 /* NotAccessible */, errorSymbolName: ts.identifierToString(firstIdentifier) }; } @@ -9872,12 +9584,12 @@ var ts; return result; } function getTypeAliasForTypeLiteral(type) { - if (type.symbol && type.symbol.flags & 1024 /* TypeLiteral */) { + if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { var node = type.symbol.declarations[0].parent; - while (node.kind === 134 /* ParenType */) { + while (node.kind === 138 /* ParenType */) { node = node.parent; } - if (node.kind === 179 /* TypeAliasDeclaration */) { + if (node.kind === 186 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -9900,14 +9612,14 @@ var ts; function appendParentTypeArgumentsAndSymbolName(symbol) { if (parentSymbol) { if (flags & 1 /* WriteTypeParametersOrArguments */) { - if (symbol.flags & 33554432 /* Instantiated */) { + if (symbol.flags & 67108864 /* Instantiated */) { buildDisplayForTypeArgumentsAndDelimiters(getTypeParametersOfClassOrInterface(parentSymbol), symbol.mapper, writer, enclosingDeclaration); } else { buildTypeParameterDisplayFromSymbol(parentSymbol, writer, enclosingDeclaration); } } - writePunctuation(writer, 15 /* DotToken */); + writePunctuation(writer, 19 /* DotToken */); } parentSymbol = symbol; appendSymbolNameOnly(symbol, writer); @@ -9928,14 +9640,14 @@ var ts; if (!parentSymbol && ts.forEach(symbol.declarations, function (declaration) { return hasExternalModuleSymbol(declaration); })) { return; } - if (symbol.flags & 1024 /* TypeLiteral */ || symbol.flags & 2048 /* ObjectLiteral */) { + if (symbol.flags & 2048 /* TypeLiteral */ || symbol.flags & 4096 /* ObjectLiteral */) { return; } appendParentTypeArgumentsAndSymbolName(symbol); } } } - if (enclosingDeclaration && !(symbol.flags & 524288 /* TypeParameter */)) { + if (enclosingDeclaration && !(symbol.flags & 1048576 /* TypeParameter */)) { walkSymbol(symbol, meaning); return; } @@ -9945,14 +9657,14 @@ var ts; var globalFlagsToPass = globalFlags & 16 /* WriteOwnNameForAnyLike */; return writeType(type, globalFlags); function writeType(type, flags) { - if (type.flags & ts.TypeFlags.Intrinsic) { + if (type.flags & 127 /* Intrinsic */) { writer.writeKeyword(!(globalFlags & 16 /* WriteOwnNameForAnyLike */) && (type.flags & 1 /* Any */) ? "any" : type.intrinsicName); } else if (type.flags & 4096 /* Reference */) { writeTypeReference(type, flags); } else if (type.flags & (1024 /* Class */ | 2048 /* Interface */ | 128 /* Enum */ | 512 /* TypeParameter */)) { - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Type); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 3152352 /* Type */); } else if (type.flags & 8192 /* Tuple */) { writeTupleType(type); @@ -9967,11 +9679,11 @@ var ts; writer.writeStringLiteral(type.text); } else { - writePunctuation(writer, 9 /* OpenBraceToken */); + writePunctuation(writer, 13 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 16 /* DotDotDotToken */); + writePunctuation(writer, 20 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 10 /* CloseBraceToken */); + writePunctuation(writer, 14 /* CloseBraceToken */); } } function writeTypeList(types, union) { @@ -9980,7 +9692,7 @@ var ts; if (union) { writeSpace(writer); } - writePunctuation(writer, union ? 39 /* BarToken */ : 18 /* CommaToken */); + writePunctuation(writer, union ? 43 /* BarToken */ : 22 /* CommaToken */); writeSpace(writer); } writeType(types[i], union ? 64 /* InElementType */ : 0 /* None */); @@ -9989,32 +9701,32 @@ var ts; function writeTypeReference(type, flags) { if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(type.typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 13 /* OpenBracketToken */); - writePunctuation(writer, 14 /* CloseBracketToken */); + writePunctuation(writer, 17 /* OpenBracketToken */); + writePunctuation(writer, 18 /* CloseBracketToken */); } else { - buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Type); - writePunctuation(writer, 19 /* LessThanToken */); + buildSymbolDisplay(type.target.symbol, writer, enclosingDeclaration, 3152352 /* Type */); + writePunctuation(writer, 23 /* LessThanToken */); writeTypeList(type.typeArguments, false); - writePunctuation(writer, 20 /* GreaterThanToken */); + writePunctuation(writer, 24 /* GreaterThanToken */); } } function writeTupleType(type) { - writePunctuation(writer, 13 /* OpenBracketToken */); + writePunctuation(writer, 17 /* OpenBracketToken */); writeTypeList(type.elementTypes, false); - writePunctuation(writer, 14 /* CloseBracketToken */); + writePunctuation(writer, 18 /* CloseBracketToken */); } function writeUnionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 11 /* OpenParenToken */); + writePunctuation(writer, 15 /* OpenParenToken */); } writeTypeList(type.types, true); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 12 /* CloseParenToken */); + writePunctuation(writer, 16 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { - if (type.symbol && type.symbol.flags & (32 /* Class */ | 128 /* Enum */ | 256 /* ValueModule */)) { + if (type.symbol && type.symbol.flags & (32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { writeTypeofSymbol(type); } else if (shouldWriteTypeOfFunctionSymbol()) { @@ -10023,10 +9735,10 @@ var ts; else if (typeStack && ts.contains(typeStack, type)) { var typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { - buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, ts.SymbolFlags.Type); + buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 3152352 /* Type */); } else { - writeKeyword(writer, 105 /* AnyKeyword */); + writeKeyword(writer, 109 /* AnyKeyword */); } } else { @@ -10039,8 +9751,8 @@ var ts; } function shouldWriteTypeOfFunctionSymbol() { if (type.symbol) { - var isStaticMethodSymbol = !!(type.symbol.flags & 4096 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); - var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 186 /* SourceFile */ || declaration.parent.kind === 182 /* ModuleBlock */; })); + var isStaticMethodSymbol = !!(type.symbol.flags & 8192 /* Method */ && ts.forEach(type.symbol.declarations, function (declaration) { return declaration.flags & 128 /* Static */; })); + var isNonLocalFunctionSymbol = !!(type.symbol.flags & 16 /* Function */) && (type.symbol.parent || ts.forEach(type.symbol.declarations, function (declaration) { return declaration.parent.kind === 193 /* SourceFile */ || declaration.parent.kind === 189 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2 /* UseTypeOfFunction */) || (typeStack && ts.contains(typeStack, type)); } @@ -10048,111 +9760,111 @@ var ts; } } function writeTypeofSymbol(type) { - writeKeyword(writer, 91 /* TypeOfKeyword */); + writeKeyword(writer, 95 /* TypeOfKeyword */); writeSpace(writer); - buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, ts.SymbolFlags.Value); + buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */); } function writeLiteralType(type, flags) { var resolved = resolveObjectOrUnionTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexType && !resolved.numberIndexType) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 9 /* OpenBraceToken */); - writePunctuation(writer, 10 /* CloseBraceToken */); + writePunctuation(writer, 13 /* OpenBraceToken */); + writePunctuation(writer, 14 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 11 /* OpenParenToken */); + writePunctuation(writer, 15 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 12 /* CloseParenToken */); + writePunctuation(writer, 16 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 11 /* OpenParenToken */); + writePunctuation(writer, 15 /* OpenParenToken */); } - writeKeyword(writer, 82 /* NewKeyword */); + writeKeyword(writer, 86 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, typeStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 12 /* CloseParenToken */); + writePunctuation(writer, 16 /* CloseParenToken */); } return; } } - writePunctuation(writer, 9 /* OpenBraceToken */); + writePunctuation(writer, 13 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); for (var i = 0; i < resolved.callSignatures.length; i++) { buildSignatureDisplay(resolved.callSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.constructSignatures.length; i++) { - writeKeyword(writer, 82 /* NewKeyword */); + writeKeyword(writer, 86 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[i], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } if (resolved.stringIndexType) { - writePunctuation(writer, 13 /* OpenBracketToken */); + writePunctuation(writer, 17 /* OpenBracketToken */); writer.writeParameter("x"); - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 114 /* StringKeyword */); - writePunctuation(writer, 14 /* CloseBracketToken */); - writePunctuation(writer, 46 /* ColonToken */); + writeKeyword(writer, 118 /* StringKeyword */); + writePunctuation(writer, 18 /* CloseBracketToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeType(resolved.stringIndexType, 0 /* None */); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } if (resolved.numberIndexType) { - writePunctuation(writer, 13 /* OpenBracketToken */); + writePunctuation(writer, 17 /* OpenBracketToken */); writer.writeParameter("x"); - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); - writeKeyword(writer, 112 /* NumberKeyword */); - writePunctuation(writer, 14 /* CloseBracketToken */); - writePunctuation(writer, 46 /* ColonToken */); + writeKeyword(writer, 116 /* NumberKeyword */); + writePunctuation(writer, 18 /* CloseBracketToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeType(resolved.numberIndexType, 0 /* None */); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } for (var i = 0; i < resolved.properties.length; i++) { var p = resolved.properties[i]; var t = getTypeOfSymbol(p); - if (p.flags & (16 /* Function */ | 4096 /* Method */) && !getPropertiesOfObjectType(t).length) { + if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); for (var j = 0; j < signatures.length; j++) { buildSymbolDisplay(p, writer); if (isOptionalProperty(p)) { - writePunctuation(writer, 45 /* QuestionToken */); + writePunctuation(writer, 49 /* QuestionToken */); } buildSignatureDisplay(signatures[j], writer, enclosingDeclaration, globalFlagsToPass, typeStack); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } } else { buildSymbolDisplay(p, writer); if (isOptionalProperty(p)) { - writePunctuation(writer, 45 /* QuestionToken */); + writePunctuation(writer, 49 /* QuestionToken */); } - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 17 /* SemicolonToken */); + writePunctuation(writer, 21 /* SemicolonToken */); writer.writeLine(); } } writer.decreaseIndent(); - writePunctuation(writer, 10 /* CloseBraceToken */); + writePunctuation(writer, 14 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaraiton, flags) { @@ -10166,67 +9878,67 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 73 /* ExtendsKeyword */); + writeKeyword(writer, 77 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, typeStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, typeStack) { if (getDeclarationFlagsFromSymbol(p) & 8 /* Rest */) { - writePunctuation(writer, 16 /* DotDotDotToken */); + writePunctuation(writer, 20 /* DotDotDotToken */); } appendSymbolNameOnly(p, writer); if (p.valueDeclaration.flags & 4 /* QuestionMark */ || p.valueDeclaration.initializer) { - writePunctuation(writer, 45 /* QuestionToken */); + writePunctuation(writer, 49 /* QuestionToken */); } - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); writeSpace(writer); buildTypeDisplay(getTypeOfSymbol(p), writer, enclosingDeclaration, flags, typeStack); } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, typeStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 19 /* LessThanToken */); + writePunctuation(writer, 23 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 18 /* CommaToken */); + writePunctuation(writer, 22 /* CommaToken */); writeSpace(writer); } buildTypeParameterDisplay(typeParameters[i], writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, 20 /* GreaterThanToken */); + writePunctuation(writer, 24 /* GreaterThanToken */); } } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration, flags, typeStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 19 /* LessThanToken */); + writePunctuation(writer, 23 /* LessThanToken */); for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 18 /* CommaToken */); + writePunctuation(writer, 22 /* CommaToken */); writeSpace(writer); } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, 0 /* None */); } - writePunctuation(writer, 20 /* GreaterThanToken */); + writePunctuation(writer, 24 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(parameters, writer, enclosingDeclaration, flags, typeStack) { - writePunctuation(writer, 11 /* OpenParenToken */); + writePunctuation(writer, 15 /* OpenParenToken */); for (var i = 0; i < parameters.length; i++) { if (i > 0) { - writePunctuation(writer, 18 /* CommaToken */); + writePunctuation(writer, 22 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, typeStack); } - writePunctuation(writer, 12 /* CloseParenToken */); + writePunctuation(writer, 16 /* CloseParenToken */); } function buildReturnTypeDisplay(signature, writer, enclosingDeclaration, flags, typeStack) { if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 27 /* EqualsGreaterThanToken */); + writePunctuation(writer, 31 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 46 /* ColonToken */); + writePunctuation(writer, 50 /* ColonToken */); } writeSpace(writer); buildTypeDisplay(getReturnTypeOfSignature(signature), writer, enclosingDeclaration, flags, typeStack); @@ -10259,12 +9971,12 @@ var ts; function isDeclarationVisible(node) { function getContainingExternalModule(node) { for (; node; node = node.parent) { - if (node.kind === 181 /* ModuleDeclaration */) { + if (node.kind === 188 /* ModuleDeclaration */) { if (node.name.kind === 7 /* StringLiteral */) { return node; } } - else if (node.kind === 186 /* SourceFile */) { + else if (node.kind === 193 /* SourceFile */) { return ts.isExternalModule(node) ? node : undefined; } } @@ -10280,7 +9992,7 @@ var ts; if (isSymbolUsedInExportAssignment(symbolOfNode)) { return true; } - if (symbolOfNode.flags & 16777216 /* Import */) { + if (symbolOfNode.flags & 33554432 /* Import */) { return isSymbolUsedInExportAssignment(resolveImport(symbolOfNode)); } } @@ -10288,7 +10000,7 @@ var ts; if (exportAssignmentSymbol === symbol) { return true; } - if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 16777216 /* Import */)) { + if (exportAssignmentSymbol && !!(exportAssignmentSymbol.flags & 33554432 /* Import */)) { resolvedExportSymbol = resolvedExportSymbol || resolveImport(exportAssignmentSymbol); if (resolvedExportSymbol === symbol) { return true; @@ -10306,35 +10018,35 @@ var ts; } function determineIfDeclarationIsVisible() { switch (node.kind) { - case 174 /* VariableDeclaration */: - case 181 /* ModuleDeclaration */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 175 /* FunctionDeclaration */: - case 180 /* EnumDeclaration */: - case 183 /* ImportDeclaration */: - var parent = node.kind === 174 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (!(node.flags & 1 /* Export */) && !(node.kind !== 183 /* ImportDeclaration */ && parent.kind !== 186 /* SourceFile */ && ts.isInAmbientContext(parent))) { + case 181 /* VariableDeclaration */: + case 188 /* ModuleDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 182 /* FunctionDeclaration */: + case 187 /* EnumDeclaration */: + case 190 /* ImportDeclaration */: + var parent = node.kind === 181 /* VariableDeclaration */ ? node.parent.parent : node.parent; + if (!(node.flags & 1 /* Export */) && !(node.kind !== 190 /* ImportDeclaration */ && parent.kind !== 193 /* SourceFile */ && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent) || isUsedInExportAssignment(node); } return isDeclarationVisible(parent); - case 120 /* Property */: - case 121 /* Method */: + case 124 /* Property */: + case 125 /* Method */: if (node.flags & (32 /* Private */ | 64 /* Protected */)) { return false; } - case 122 /* Constructor */: - case 126 /* ConstructSignature */: - case 125 /* CallSignature */: - case 127 /* IndexSignature */: - case 119 /* Parameter */: - case 182 /* ModuleBlock */: + case 126 /* Constructor */: + case 130 /* ConstructSignature */: + case 129 /* CallSignature */: + case 131 /* IndexSignature */: + case 123 /* Parameter */: + case 189 /* ModuleBlock */: return isDeclarationVisible(node.parent); - case 186 /* SourceFile */: + case 193 /* SourceFile */: return true; default: - ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + ts.SyntaxKind[node.kind]); + ts.Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } } if (node) { @@ -10350,16 +10062,16 @@ var ts; return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType; } function getTypeOfVariableDeclaration(declaration) { - if (declaration.parent.kind === 159 /* ForInStatement */) { + if (declaration.parent.kind === 166 /* ForInStatement */) { return anyType; } if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 119 /* Parameter */) { + if (declaration.kind === 123 /* Parameter */) { var func = declaration.parent; - if (func.kind === 124 /* SetAccessor */) { - var getter = getDeclarationOfKind(declaration.parent.symbol, 123 /* GetAccessor */); + if (func.kind === 128 /* SetAccessor */) { + var getter = getDeclarationOfKind(declaration.parent.symbol, 127 /* GetAccessor */); if (getter) { return getReturnTypeOfSignature(getSignatureFromDeclaration(getter)); } @@ -10371,7 +10083,7 @@ var ts; } if (declaration.initializer) { var type = checkAndMarkExpression(declaration.initializer); - if (declaration.kind !== 137 /* PropertyAssignment */) { + if (declaration.kind !== 141 /* PropertyAssignment */) { var unwidenedType = type; type = getWidenedType(type); if (type !== unwidenedType) { @@ -10390,14 +10102,14 @@ var ts; if (getInnermostTypeOfNestedArrayTypes(type) !== anyType) { return; } - if (isPrivateWithinAmbient(declaration) || (declaration.kind === 119 /* Parameter */ && isPrivateWithinAmbient(declaration.parent))) { + if (isPrivateWithinAmbient(declaration) || (declaration.kind === 123 /* Parameter */ && isPrivateWithinAmbient(declaration.parent))) { return; } switch (declaration.kind) { - case 120 /* Property */: + case 124 /* Property */: var diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 119 /* Parameter */: + case 123 /* Parameter */: var diagnostic = declaration.flags & 8 /* Rest */ ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; default: @@ -10409,11 +10121,11 @@ var ts; function getTypeOfVariableOrParameterOrProperty(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (symbol.flags & 268435456 /* Prototype */) { + if (symbol.flags & 536870912 /* Prototype */) { return links.type = getTypeOfPrototypeProperty(symbol); } var declaration = symbol.valueDeclaration; - if (declaration.kind === 171 /* CatchBlock */) { + if (declaration.kind === 178 /* CatchBlock */) { return links.type = anyType; } links.type = resolvingType; @@ -10436,7 +10148,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 123 /* GetAccessor */) { + if (accessor.kind === 127 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -10455,8 +10167,8 @@ var ts; links = links || getSymbolLinks(symbol); if (!links.type) { links.type = resolvingType; - var getter = getDeclarationOfKind(symbol, 123 /* GetAccessor */); - var setter = getDeclarationOfKind(symbol, 124 /* SetAccessor */); + var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); + var setter = getDeclarationOfKind(symbol, 128 /* SetAccessor */); var type; var getterReturnType = getAnnotatedAccessorType(getter); if (getterReturnType) { @@ -10486,7 +10198,7 @@ var ts; else if (links.type === resolvingType) { links.type = anyType; if (compilerOptions.noImplicitAny) { - var getter = getDeclarationOfKind(symbol, 123 /* GetAccessor */); + var getter = getDeclarationOfKind(symbol, 127 /* GetAccessor */); error(getter, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -10520,22 +10232,22 @@ var ts; return links.type; } function getTypeOfSymbol(symbol) { - if (symbol.flags & 33554432 /* Instantiated */) { + if (symbol.flags & 67108864 /* Instantiated */) { return getTypeOfInstantiatedSymbol(symbol); } - if (symbol.flags & (ts.SymbolFlags.Variable | 4 /* Property */)) { + if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) { return getTypeOfVariableOrParameterOrProperty(symbol); } - if (symbol.flags & (16 /* Function */ | 4096 /* Method */ | 32 /* Class */ | 128 /* Enum */ | 256 /* ValueModule */)) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) { return getTypeOfFuncClassEnumModule(symbol); } if (symbol.flags & 8 /* EnumMember */) { return getTypeOfEnumMember(symbol); } - if (symbol.flags & ts.SymbolFlags.Accessor) { + if (symbol.flags & 98304 /* Accessor */) { return getTypeOfAccessors(symbol); } - if (symbol.flags & 16777216 /* Import */) { + if (symbol.flags & 33554432 /* Import */) { return getTypeOfImport(symbol); } return unknownType; @@ -10553,7 +10265,7 @@ var ts; function getTypeParametersOfClassOrInterface(symbol) { var result; ts.forEach(symbol.declarations, function (node) { - if (node.kind === 178 /* InterfaceDeclaration */ || node.kind === 177 /* ClassDeclaration */) { + if (node.kind === 185 /* InterfaceDeclaration */ || node.kind === 184 /* ClassDeclaration */) { var declaration = node; if (declaration.typeParameters && declaration.typeParameters.length) { ts.forEach(declaration.typeParameters, function (node) { @@ -10584,7 +10296,7 @@ var ts; type.typeArguments = type.typeParameters; } type.baseTypes = []; - var declaration = getDeclarationOfKind(symbol, 177 /* ClassDeclaration */); + var declaration = getDeclarationOfKind(symbol, 184 /* ClassDeclaration */); if (declaration.baseType) { var baseType = getTypeFromTypeReferenceNode(declaration.baseType); if (baseType !== unknownType) { @@ -10624,7 +10336,7 @@ var ts; } type.baseTypes = []; ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 178 /* InterfaceDeclaration */ && declaration.baseTypes) { + if (declaration.kind === 185 /* InterfaceDeclaration */ && declaration.baseTypes) { ts.forEach(declaration.baseTypes, function (node) { var baseType = getTypeFromTypeReferenceNode(node); if (baseType !== unknownType) { @@ -10655,7 +10367,7 @@ var ts; var links = getSymbolLinks(symbol); if (!links.declaredType) { links.declaredType = resolvingType; - var declaration = getDeclarationOfKind(symbol, 179 /* TypeAliasDeclaration */); + var declaration = getDeclarationOfKind(symbol, 186 /* TypeAliasDeclaration */); var type = getTypeFromTypeNode(declaration.type); if (links.declaredType === resolvingType) { links.declaredType = type; @@ -10663,7 +10375,7 @@ var ts; } else if (links.declaredType === resolvingType) { links.declaredType = unknownType; - var declaration = getDeclarationOfKind(symbol, 179 /* TypeAliasDeclaration */); + var declaration = getDeclarationOfKind(symbol, 186 /* TypeAliasDeclaration */); error(declaration.name, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol)); } return links.declaredType; @@ -10682,7 +10394,7 @@ var ts; if (!links.declaredType) { var type = createType(512 /* TypeParameter */); type.symbol = symbol; - if (!getDeclarationOfKind(symbol, 118 /* TypeParameter */).constraint) { + if (!getDeclarationOfKind(symbol, 122 /* TypeParameter */).constraint) { type.constraint = noConstraintType; } links.declaredType = type; @@ -10697,23 +10409,23 @@ var ts; return links.declaredType; } function getDeclaredTypeOfSymbol(symbol) { - ts.Debug.assert((symbol.flags & 33554432 /* Instantiated */) === 0); + ts.Debug.assert((symbol.flags & 67108864 /* Instantiated */) === 0); if (symbol.flags & 32 /* Class */) { return getDeclaredTypeOfClass(symbol); } if (symbol.flags & 64 /* Interface */) { return getDeclaredTypeOfInterface(symbol); } - if (symbol.flags & 1048576 /* TypeAlias */) { + if (symbol.flags & 2097152 /* TypeAlias */) { return getDeclaredTypeOfTypeAlias(symbol); } - if (symbol.flags & 128 /* Enum */) { + if (symbol.flags & 384 /* Enum */) { return getDeclaredTypeOfEnum(symbol); } - if (symbol.flags & 524288 /* TypeParameter */) { + if (symbol.flags & 1048576 /* TypeParameter */) { return getDeclaredTypeOfTypeParameter(symbol); } - if (symbol.flags & 16777216 /* Import */) { + if (symbol.flags & 33554432 /* Import */) { return getDeclaredTypeOfImport(symbol); } return unknownType; @@ -10815,7 +10527,7 @@ var ts; function createTupleTypeMemberSymbols(memberTypes) { var members = {}; for (var i = 0; i < memberTypes.length; i++) { - var symbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, "" + i); + var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */, "" + i); symbol.type = memberTypes[i]; members[i] = symbol; } @@ -10832,7 +10544,7 @@ var ts; return false; } for (var i = 0; i < s.length; i++) { - if (!compareSignatures(s[i], t[i], false, isTypeIdenticalTo)) { + if (!compareSignatures(s[i], t[i], false, compareTypes)) { return false; } } @@ -10879,7 +10591,7 @@ var ts; } function resolveAnonymousTypeMembers(type) { var symbol = type.symbol; - if (symbol.flags & 1024 /* TypeLiteral */) { + if (symbol.flags & 2048 /* TypeLiteral */) { var members = symbol.members; var callSignatures = getSignaturesOfSymbol(members["__call"]); var constructSignatures = getSignaturesOfSymbol(members["__new"]); @@ -10890,10 +10602,10 @@ var ts; var members = emptySymbols; var callSignatures = emptyArray; var constructSignatures = emptyArray; - if (symbol.flags & ts.SymbolFlags.HasExports) { + if (symbol.flags & 1952 /* HasExports */) { members = symbol.exports; } - if (symbol.flags & (16 /* Function */ | 4096 /* Method */)) { + if (symbol.flags & (16 /* Function */ | 8192 /* Method */)) { callSignatures = getSignaturesOfSymbol(symbol); } if (symbol.flags & 32 /* Class */) { @@ -10908,7 +10620,7 @@ var ts; } } var stringIndexType = undefined; - var numberIndexType = (symbol.flags & 128 /* Enum */) ? stringType : undefined; + var numberIndexType = (symbol.flags & 384 /* Enum */) ? stringType : undefined; } setObjectTypeMembers(type, members, callSignatures, constructSignatures, stringIndexType, numberIndexType); } @@ -10933,13 +10645,13 @@ var ts; return type; } function getPropertiesOfObjectType(type) { - if (type.flags & ts.TypeFlags.ObjectType) { + if (type.flags & 48128 /* ObjectType */) { return resolveObjectOrUnionTypeMembers(type).properties; } return emptyArray; } function getPropertyOfObjectType(type, name) { - if (type.flags & ts.TypeFlags.ObjectType) { + if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (ts.hasProperty(resolved.members, name)) { var symbol = resolved.members[name]; @@ -10974,10 +10686,10 @@ var ts; type = emptyObjectType; } } - if (type.flags & ts.TypeFlags.StringLike) { + if (type.flags & 258 /* StringLike */) { type = globalStringType; } - else if (type.flags & ts.TypeFlags.NumberLike) { + else if (type.flags & 132 /* NumberLike */) { type = globalNumberType; } else if (type.flags & 8 /* Boolean */) { @@ -11012,7 +10724,7 @@ var ts; } propTypes.push(getTypeOfSymbol(prop)); } - var result = createSymbol(4 /* Property */ | 134217728 /* Transient */ | 536870912 /* UnionProperty */, name); + var result = createSymbol(4 /* Property */ | 268435456 /* Transient */ | 1073741824 /* UnionProperty */, name); result.unionType = unionType; result.declarations = declarations; result.type = getUnionType(propTypes); @@ -11033,9 +10745,9 @@ var ts; if (type.flags & 16384 /* Union */) { return getPropertyOfUnionType(type, name); } - if (!(type.flags & ts.TypeFlags.ObjectType)) { + if (!(type.flags & 48128 /* ObjectType */)) { type = getApparentType(type); - if (!(type.flags & ts.TypeFlags.ObjectType)) { + if (!(type.flags & 48128 /* ObjectType */)) { return undefined; } } @@ -11054,7 +10766,7 @@ var ts; return getPropertyOfObjectType(globalObjectType, name); } function getSignaturesOfObjectOrUnionType(type, kind) { - if (type.flags & (ts.TypeFlags.ObjectType | 16384 /* Union */)) { + if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { var resolved = resolveObjectOrUnionTypeMembers(type); return kind === 0 /* Call */ ? resolved.callSignatures : resolved.constructSignatures; } @@ -11064,7 +10776,7 @@ var ts; return getSignaturesOfObjectOrUnionType(getApparentType(type), kind); } function getIndexTypeOfObjectOrUnionType(type, kind) { - if (type.flags & (ts.TypeFlags.ObjectType | 16384 /* Union */)) { + if (type.flags & (48128 /* ObjectType */ | 16384 /* Union */)) { var resolved = resolveObjectOrUnionTypeMembers(type); return kind === 0 /* String */ ? resolved.stringIndexType : resolved.numberIndexType; } @@ -11085,7 +10797,7 @@ var ts; function getSignatureFromDeclaration(declaration) { var links = getNodeLinks(declaration); if (!links.resolvedSignature) { - var classType = declaration.kind === 122 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; + var classType = declaration.kind === 126 /* Constructor */ ? getDeclaredTypeOfClass(declaration.parent.symbol) : undefined; var typeParameters = classType ? classType.typeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : undefined; var parameters = []; var hasStringLiterals = false; @@ -11113,8 +10825,8 @@ var ts; returnType = getTypeFromTypeNode(declaration.type); } else { - if (declaration.kind === 123 /* GetAccessor */) { - var setter = getDeclarationOfKind(declaration.symbol, 124 /* SetAccessor */); + if (declaration.kind === 127 /* GetAccessor */) { + var setter = getDeclarationOfKind(declaration.symbol, 128 /* SetAccessor */); returnType = getAnnotatedAccessorType(setter); } if (!returnType && !declaration.body) { @@ -11132,16 +10844,16 @@ var ts; for (var i = 0, len = symbol.declarations.length; i < len; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 175 /* FunctionDeclaration */: - case 121 /* Method */: - case 122 /* Constructor */: - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 182 /* FunctionDeclaration */: + case 125 /* Method */: + case 126 /* Constructor */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -11210,7 +10922,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 122 /* Constructor */ || signature.declaration.kind === 126 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 126 /* Constructor */ || signature.declaration.kind === 130 /* ConstructSignature */; var type = createObjectType(32768 /* Anonymous */ | 65536 /* FromSignature */); type.members = emptySymbols; type.properties = emptyArray; @@ -11224,7 +10936,7 @@ var ts; return symbol.members["__index"]; } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 112 /* NumberKeyword */ : 114 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 116 /* NumberKeyword */ : 118 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { var len = indexSymbol.declarations.length; @@ -11251,7 +10963,7 @@ var ts; type.constraint = targetConstraint ? instantiateType(targetConstraint, type.mapper) : noConstraintType; } else { - type.constraint = getTypeFromTypeNode(getDeclarationOfKind(type.symbol, 118 /* TypeParameter */).constraint); + type.constraint = getTypeFromTypeNode(getDeclarationOfKind(type.symbol, 122 /* TypeParameter */).constraint); } } return type.constraint === noConstraintType ? undefined : type.constraint; @@ -11291,17 +11003,17 @@ var ts; while (!ts.forEach(typeParameterSymbol.declarations, function (d) { return d.parent === currentNode.parent; })) { currentNode = currentNode.parent; } - links.isIllegalTypeReferenceInConstraint = currentNode.kind === 118 /* TypeParameter */; + links.isIllegalTypeReferenceInConstraint = currentNode.kind === 122 /* TypeParameter */; return links.isIllegalTypeReferenceInConstraint; } function checkTypeParameterHasIllegalReferencesInConstraint(typeParameter) { var typeParameterSymbol; function check(n) { - if (n.kind === 128 /* TypeReference */ && n.typeName.kind === 59 /* Identifier */) { + if (n.kind === 132 /* TypeReference */ && n.typeName.kind === 63 /* Identifier */) { var links = getNodeLinks(n); if (links.isIllegalTypeReferenceInConstraint === undefined) { - var symbol = resolveName(typeParameter, n.typeName.text, ts.SymbolFlags.Type, undefined, undefined); - if (symbol && (symbol.flags & 524288 /* TypeParameter */)) { + var symbol = resolveName(typeParameter, n.typeName.text, 3152352 /* Type */, undefined, undefined); + if (symbol && (symbol.flags & 1048576 /* TypeParameter */)) { links.isIllegalTypeReferenceInConstraint = ts.forEach(symbol.declarations, function (d) { return d.parent == typeParameter.parent; }); } } @@ -11319,10 +11031,10 @@ var ts; function getTypeFromTypeReferenceNode(node) { var links = getNodeLinks(node); if (!links.resolvedType) { - var symbol = resolveEntityName(node, node.typeName, ts.SymbolFlags.Type); + var symbol = resolveEntityName(node, node.typeName, 3152352 /* Type */); if (symbol) { var type; - if ((symbol.flags & 524288 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { + if ((symbol.flags & 1048576 /* TypeParameter */) && isTypeParameterReferenceIllegalInConstraint(node, symbol)) { type = unknownType; } else { @@ -11362,9 +11074,9 @@ var ts; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; switch (declaration.kind) { - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: return declaration; } } @@ -11373,7 +11085,7 @@ var ts; return emptyObjectType; } var type = getDeclaredTypeOfSymbol(symbol); - if (!(type.flags & ts.TypeFlags.ObjectType)) { + if (!(type.flags & 48128 /* ObjectType */)) { error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name); return emptyObjectType; } @@ -11384,7 +11096,7 @@ var ts; return type; } function getGlobalSymbol(name) { - return resolveName(undefined, name, ts.SymbolFlags.Type, ts.Diagnostics.Cannot_find_global_type_0, name); + return resolveName(undefined, name, 3152352 /* Type */, ts.Diagnostics.Cannot_find_global_type_0, name); } function getGlobalType(name) { return getTypeOfGlobalSymbol(getGlobalSymbol(name), 0); @@ -11527,34 +11239,34 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 105 /* AnyKeyword */: + case 109 /* AnyKeyword */: return anyType; - case 114 /* StringKeyword */: + case 118 /* StringKeyword */: return stringType; - case 112 /* NumberKeyword */: + case 116 /* NumberKeyword */: return numberType; - case 106 /* BooleanKeyword */: + case 110 /* BooleanKeyword */: return booleanType; - case 93 /* VoidKeyword */: + case 97 /* VoidKeyword */: return voidType; case 7 /* StringLiteral */: return getTypeFromStringLiteral(node); - case 128 /* TypeReference */: + case 132 /* TypeReference */: return getTypeFromTypeReferenceNode(node); - case 129 /* TypeQuery */: + case 133 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 131 /* ArrayType */: + case 135 /* ArrayType */: return getTypeFromArrayTypeNode(node); - case 132 /* TupleType */: + case 136 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 133 /* UnionType */: + case 137 /* UnionType */: return getTypeFromUnionTypeNode(node); - case 134 /* ParenType */: + case 138 /* ParenType */: return getTypeFromTypeNode(node.type); - case 130 /* TypeLiteral */: + case 134 /* TypeLiteral */: return getTypeFromTypeLiteralNode(node); - case 59 /* Identifier */: - case 117 /* QualifiedName */: + case 63 /* Identifier */: + case 121 /* QualifiedName */: var symbol = getSymbolInfo(node); return symbol && getDeclaredTypeOfSymbol(symbol); default: @@ -11579,10 +11291,8 @@ var ts; } function createTypeMapper(sources, targets) { switch (sources.length) { - case 1: - return createUnaryTypeMapper(sources[0], targets[0]); - case 2: - return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); + case 1: return createUnaryTypeMapper(sources[0], targets[0]); + case 2: return createBinaryTypeMapper(sources[0], targets[0], sources[1], targets[1]); } return function (t) { for (var i = 0; i < sources.length; i++) { @@ -11600,10 +11310,8 @@ var ts; } function createTypeEraser(sources) { switch (sources.length) { - case 1: - return createUnaryTypeEraser(sources[0]); - case 2: - return createBinaryTypeEraser(sources[0], sources[1]); + case 1: return createUnaryTypeEraser(sources[0]); + case 2: return createBinaryTypeEraser(sources[0], sources[1]); } return function (t) { for (var i = 0; i < sources.length; i++) { @@ -11652,12 +11360,12 @@ var ts; return result; } function instantiateSymbol(symbol, mapper) { - if (symbol.flags & 33554432 /* Instantiated */) { + if (symbol.flags & 67108864 /* Instantiated */) { var links = getSymbolLinks(symbol); symbol = links.target; mapper = combineTypeMappers(links.mapper, mapper); } - var result = createSymbol(33554432 /* Instantiated */ | 134217728 /* Transient */ | symbol.flags, symbol.name); + var result = createSymbol(67108864 /* Instantiated */ | 268435456 /* Transient */ | symbol.flags, symbol.name); result.declarations = symbol.declarations; result.parent = symbol.parent; result.target = symbol; @@ -11687,7 +11395,7 @@ var ts; return mapper(type); } if (type.flags & 32768 /* Anonymous */) { - return type.symbol && type.symbol.flags & (16 /* Function */ | 4096 /* Method */ | 1024 /* TypeLiteral */ | 2048 /* ObjectLiteral */) ? instantiateAnonymousType(type, mapper) : type; + return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) ? instantiateAnonymousType(type, mapper) : type; } if (type.flags & 4096 /* Reference */) { return createTypeReference(type.target, instantiateList(type.typeArguments, mapper, instantiateType)); @@ -11703,22 +11411,22 @@ var ts; } function isContextSensitiveExpression(node) { switch (node.kind) { - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: return !node.typeParameters && !ts.forEach(node.parameters, function (p) { return p.type; }); - case 136 /* ObjectLiteral */: - return ts.forEach(node.properties, function (p) { return p.kind === 137 /* PropertyAssignment */ && isContextSensitiveExpression(p.initializer); }); - case 135 /* ArrayLiteral */: + case 140 /* ObjectLiteral */: + return ts.forEach(node.properties, function (p) { return p.kind === 141 /* PropertyAssignment */ && isContextSensitiveExpression(p.initializer); }); + case 139 /* ArrayLiteral */: return ts.forEach(node.elements, function (e) { return isContextSensitiveExpression(e); }); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return isContextSensitiveExpression(node.whenTrue) || isContextSensitiveExpression(node.whenFalse); - case 148 /* BinaryExpression */: - return node.operator === 44 /* BarBarToken */ && (isContextSensitiveExpression(node.left) || isContextSensitiveExpression(node.right)); + case 153 /* BinaryExpression */: + return node.operator === 48 /* BarBarToken */ && (isContextSensitiveExpression(node.left) || isContextSensitiveExpression(node.right)); } return false; } function getTypeWithoutConstructors(type) { - if (type.flags & ts.TypeFlags.ObjectType) { + if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.constructSignatures.length) { var result = createObjectType(32768 /* Anonymous */, type.symbol); @@ -11737,78 +11445,26 @@ var ts; function isTypeIdenticalTo(source, target) { return checkTypeRelatedTo(source, target, identityRelation, undefined); } + function compareTypes(source, target) { + return checkTypeRelatedTo(source, target, identityRelation, undefined) ? -1 /* True */ : 0 /* False */; + } function isTypeSubtypeOf(source, target) { return checkTypeSubtypeOf(source, target, undefined); } - function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { - return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); - } function isTypeAssignableTo(source, target) { return checkTypeAssignableTo(source, target, undefined); } + function checkTypeSubtypeOf(source, target, errorNode, headMessage, containingMessageChain) { + return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain); + } function checkTypeAssignableTo(source, target, errorNode, headMessage) { return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage); } - function isTypeRelatedTo(source, target, relation) { - return checkTypeRelatedTo(source, target, relation, undefined); - } function isSignatureAssignableTo(source, target) { var sourceType = getOrCreateTypeFromSignature(source); var targetType = getOrCreateTypeFromSignature(target); return checkTypeRelatedTo(sourceType, targetType, assignableRelation, undefined); } - function isPropertyIdenticalTo(sourceProp, targetProp) { - return isPropertyIdenticalToRecursive(sourceProp, targetProp, false, function (s, t, _reportErrors) { return isTypeIdenticalTo(s, t); }); - } - function checkInheritedPropertiesAreIdentical(type, typeNode) { - if (!type.baseTypes.length || type.baseTypes.length === 1) { - return true; - } - var seen = {}; - ts.forEach(type.declaredProperties, function (p) { - seen[p.name] = { prop: p, containingType: type }; - }); - var ok = true; - for (var i = 0, len = type.baseTypes.length; i < len; ++i) { - var base = type.baseTypes[i]; - var properties = getPropertiesOfObjectType(base); - for (var j = 0, proplen = properties.length; j < proplen; ++j) { - var prop = properties[j]; - if (!ts.hasProperty(seen, prop.name)) { - seen[prop.name] = { prop: prop, containingType: base }; - } - else { - var existing = seen[prop.name]; - var isInheritedProperty = existing.containingType !== type; - if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { - ok = false; - var typeName1 = typeToString(existing.containingType); - var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2); - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); - addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, program.getCompilerHost().getNewLine())); - } - } - } - } - return ok; - } - function isPropertyIdenticalToRecursive(sourceProp, targetProp, reportErrors, relate) { - if (sourceProp === targetProp) { - return true; - } - var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); - var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); - if (sourcePropAccessibility !== targetPropAccessibility) { - return false; - } - if (sourcePropAccessibility) { - return getTargetSymbol(sourceProp) === getTargetSymbol(targetProp) && relate(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - } - else { - return isOptionalProperty(sourceProp) === isOptionalProperty(targetProp) && relate(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); - } - } function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain) { var errorInfo; var sourceStack; @@ -11817,7 +11473,7 @@ var ts; var depth = 0; var overflow = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); - var result = isRelatedToWithCustomErrors(source, target, errorNode !== undefined, headMessage); + var result = isRelatedTo(source, target, errorNode !== undefined, headMessage); if (overflow) { error(errorNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target)); } @@ -11827,109 +11483,114 @@ var ts; } addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, program.getCompilerHost().getNewLine())); } - return result; + return result !== 0 /* False */; function reportError(message, arg0, arg1, arg2) { errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2); } - function isRelatedTo(source, target, reportErrors) { - return isRelatedToWithCustomErrors(source, target, reportErrors, undefined); - } - function isRelatedToWithCustomErrors(source, target, reportErrors, headMessage) { + function isRelatedTo(source, target, reportErrors, headMessage) { + var result; if (relation === identityRelation) { if (source === target) - return true; + return -1 /* True */; } else { if (source === target) - return true; + return -1 /* True */; if (target.flags & 1 /* Any */) - return true; + return -1 /* True */; if (source === undefinedType) - return true; + return -1 /* True */; if (source === nullType && target !== undefinedType) - return true; + return -1 /* True */; if (source.flags & 128 /* Enum */ && target === numberType) - return true; + return -1 /* True */; if (source.flags & 256 /* StringLiteral */ && target === stringType) - return true; + return -1 /* True */; if (relation === assignableRelation) { if (source.flags & 1 /* Any */) - return true; + return -1 /* True */; if (source === numberType && target.flags & 128 /* Enum */) - return true; + return -1 /* True */; } } if (source.flags & 16384 /* Union */) { - if (unionTypeRelatedToType(source, target, reportErrors)) { - return true; + if (result = unionTypeRelatedToType(source, target, reportErrors)) { + return result; } } else if (target.flags & 16384 /* Union */) { - if (typeRelatedToUnionType(source, target, reportErrors)) { - return true; + if (result = typeRelatedToUnionType(source, target, reportErrors)) { + return result; } } else if (source.flags & 512 /* TypeParameter */ && target.flags & 512 /* TypeParameter */) { - if (typeParameterRelatedTo(source, target, reportErrors)) { - return true; + if (result = typeParameterRelatedTo(source, target, reportErrors)) { + return result; } } else { var saveErrorInfo = errorInfo; if (source.flags & 4096 /* Reference */ && target.flags & 4096 /* Reference */ && source.target === target.target) { - if (typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { - return true; + if (result = typesRelatedTo(source.typeArguments, target.typeArguments, reportErrors)) { + return result; } } var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo; var sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); - if (sourceOrApparentType.flags & ts.TypeFlags.ObjectType && target.flags & ts.TypeFlags.ObjectType && objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors)) { + if (sourceOrApparentType.flags & 48128 /* ObjectType */ && target.flags & 48128 /* ObjectType */ && (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { errorInfo = saveErrorInfo; - return true; + return result; } } if (reportErrors) { headMessage = headMessage || ts.Diagnostics.Type_0_is_not_assignable_to_type_1; - ts.Debug.assert(headMessage); reportError(headMessage, typeToString(source), typeToString(target)); } - return false; + return 0 /* False */; } function typeRelatedToUnionType(source, target, reportErrors) { var targetTypes = target.types; for (var i = 0, len = targetTypes.length; i < len; i++) { - if (isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1)) { - return true; + var related = isRelatedTo(source, targetTypes[i], reportErrors && i === len - 1); + if (related) { + return related; } } - return false; + return 0 /* False */; } function unionTypeRelatedToType(source, target, reportErrors) { + var result = -1 /* True */; var sourceTypes = source.types; for (var i = 0, len = sourceTypes.length; i < len; i++) { - if (!isRelatedTo(sourceTypes[i], target, reportErrors)) { - return false; + var related = isRelatedTo(sourceTypes[i], target, reportErrors); + if (!related) { + return 0 /* False */; } + result &= related; } - return true; + return result; } function typesRelatedTo(sources, targets, reportErrors) { + var result = -1 /* True */; for (var i = 0, len = sources.length; i < len; i++) { - if (!isRelatedTo(sources[i], targets[i], reportErrors)) - return false; + var related = isRelatedTo(sources[i], targets[i], reportErrors); + if (!related) { + return 0 /* False */; + } + result &= related; } - return true; + return result; } function typeParameterRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { if (source.symbol.name !== target.symbol.name) { - return false; + return 0 /* False */; } if (source.constraint === target.constraint) { - return true; + return -1 /* True */; } if (source.constraint === noConstraintType || target.constraint === noConstraintType) { - return false; + return 0 /* False */; } return isRelatedTo(source.constraint, target.constraint, reportErrors); } @@ -11937,29 +11598,32 @@ var ts; while (true) { var constraint = getConstraintOfTypeParameter(source); if (constraint === target) - return true; + return -1 /* True */; if (!(constraint && constraint.flags & 512 /* TypeParameter */)) break; source = constraint; } - return false; + return 0 /* False */; } } function objectTypeRelatedTo(source, target, reportErrors) { - if (overflow) - return false; - var result; + if (overflow) { + return 0 /* False */; + } var id = source.id + "," + target.id; - if ((result = relation[id]) !== undefined) - return result; + var related = relation[id]; + if (related !== undefined) { + return related; + } if (depth > 0) { for (var i = 0; i < depth; i++) { - if (source === sourceStack[i] && target === targetStack[i]) - return true; + if (source === sourceStack[i] && target === targetStack[i]) { + return 1 /* Maybe */; + } } if (depth === 100) { overflow = true; - return false; + return 0 /* False */; } } else { @@ -11975,10 +11639,27 @@ var ts; expandingFlags |= 1; if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack)) expandingFlags |= 2; - result = expandingFlags === 3 || propertiesRelatedTo(source, target, reportErrors) && signaturesRelatedTo(source, target, 0 /* Call */, reportErrors) && signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors) && stringIndexTypesRelatedTo(source, target, reportErrors) && numberIndexTypesRelatedTo(source, target, reportErrors); + if (expandingFlags === 3) { + var result = -1 /* True */; + } + else { + var result = propertiesRelatedTo(source, target, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0 /* Call */, reportErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); + if (result) { + result &= stringIndexTypesRelatedTo(source, target, reportErrors); + if (result) { + result &= numberIndexTypesRelatedTo(source, target, reportErrors); + } + } + } + } + } expandingFlags = saveExpandingFlags; depth--; - if (depth === 0) { + if (result !== 1 /* Maybe */) { relation[id] = result; } return result; @@ -12000,8 +11681,9 @@ var ts; } function propertiesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { - return propertiesIdenticalTo(source, target, reportErrors); + return propertiesIdenticalTo(source, target); } + var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); for (var i = 0; i < properties.length; i++) { var targetProp = properties[i]; @@ -12012,10 +11694,10 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); } - return false; + return 0 /* False */; } } - else if (!(targetProp.flags & 268435456 /* Prototype */)) { + else if (!(targetProp.flags & 536870912 /* Prototype */)) { var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp); var targetFlags = getDeclarationFlagsFromSymbol(targetProp); if (sourceFlags & 32 /* Private */ || targetFlags & 32 /* Private */) { @@ -12028,7 +11710,7 @@ var ts; reportError(ts.Diagnostics.Property_0_is_private_in_type_1_but_not_in_type_2, symbolToString(targetProp), typeToString(sourceFlags & 32 /* Private */ ? source : target), typeToString(sourceFlags & 32 /* Private */ ? target : source)); } } - return false; + return 0 /* False */; } } else if (targetFlags & 64 /* Protected */) { @@ -12039,55 +11721,65 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2, symbolToString(targetProp), typeToString(sourceClass || source), typeToString(targetClass)); } - return false; + return 0 /* False */; } } else if (sourceFlags & 64 /* Protected */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return false; + return 0 /* False */; } - if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) { + var related = isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors); + if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp)); } - return false; + return 0 /* False */; } + result &= related; if (isOptionalProperty(sourceProp) && !isOptionalProperty(targetProp)) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target)); } - return false; + return 0 /* False */; } } } } - return true; + return result; } - function propertiesIdenticalTo(source, target, reportErrors) { + function propertiesIdenticalTo(source, target) { var sourceProperties = getPropertiesOfObjectType(source); var targetProperties = getPropertiesOfObjectType(target); if (sourceProperties.length !== targetProperties.length) { - return false; + return 0 /* False */; } + var result = -1 /* True */; for (var i = 0, len = sourceProperties.length; i < len; ++i) { var sourceProp = sourceProperties[i]; var targetProp = getPropertyOfObjectType(target, sourceProp.name); - if (!targetProp || !isPropertyIdenticalToRecursive(sourceProp, targetProp, reportErrors, isRelatedTo)) { - return false; + if (!targetProp) { + return 0 /* False */; } + var related = compareProperties(sourceProp, targetProp, isRelatedTo); + if (!related) { + return 0 /* False */; + } + result &= related; } - return true; + return result; } function signaturesRelatedTo(source, target, kind, reportErrors) { if (relation === identityRelation) { - return signaturesIdenticalTo(source, target, kind, reportErrors); + return signaturesIdenticalTo(source, target, kind); + } + if (target === anyFunctionType || source === anyFunctionType) { + return -1 /* True */; } - if (target === anyFunctionType || source === anyFunctionType) - return true; var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); + var result = -1 /* True */; var saveErrorInfo = errorInfo; outer: for (var i = 0; i < targetSignatures.length; i++) { var t = targetSignatures[i]; @@ -12096,24 +11788,26 @@ var ts; for (var j = 0; j < sourceSignatures.length; j++) { var s = sourceSignatures[j]; if (!s.hasStringLiterals || source.flags & 65536 /* FromSignature */) { - if (signatureRelatedTo(s, t, localErrors)) { + var related = signatureRelatedTo(s, t, localErrors); + if (related) { + result &= related; errorInfo = saveErrorInfo; continue outer; } localErrors = false; } } - return false; + return 0 /* False */; } } - return true; + return result; } function signatureRelatedTo(source, target, reportErrors) { if (source === target) { - return true; + return -1 /* True */; } if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { - return false; + return 0 /* False */; } var sourceMax = source.parameters.length; var targetMax = target.parameters.length; @@ -12136,42 +11830,49 @@ var ts; } source = getErasedSignature(source); target = getErasedSignature(target); + var result = -1 /* True */; for (var i = 0; i < checkCount; i++) { var s = i < sourceMax ? getTypeOfSymbol(source.parameters[i]) : getRestTypeOfSignature(source); var t = i < targetMax ? getTypeOfSymbol(target.parameters[i]) : getRestTypeOfSignature(target); var saveErrorInfo = errorInfo; - if (!isRelatedTo(s, t, reportErrors)) { - if (!isRelatedTo(t, s, false)) { + var related = isRelatedTo(s, t, reportErrors); + if (!related) { + related = isRelatedTo(t, s, false); + if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, source.parameters[i < sourceMax ? i : sourceMax].name, target.parameters[i < targetMax ? i : targetMax].name); } - return false; + return 0 /* False */; } errorInfo = saveErrorInfo; } + result &= related; } var t = getReturnTypeOfSignature(target); if (t === voidType) - return true; + return result; var s = getReturnTypeOfSignature(source); - return isRelatedTo(s, t, reportErrors); + return result & isRelatedTo(s, t, reportErrors); } - function signaturesIdenticalTo(source, target, kind, reportErrors) { + function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); var targetSignatures = getSignaturesOfType(target, kind); if (sourceSignatures.length !== targetSignatures.length) { - return false; + return 0 /* False */; } + var result = -1 /* True */; for (var i = 0, len = sourceSignatures.length; i < len; ++i) { - if (!compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo)) { - return false; + var related = compareSignatures(sourceSignatures[i], targetSignatures[i], true, isRelatedTo); + if (!related) { + return 0 /* False */; } + result &= related; } - return true; + return result; } function stringIndexTypesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { - return indexTypesIdenticalTo(0 /* String */, source, target, reportErrors); + return indexTypesIdenticalTo(0 /* String */, source, target); } var targetType = getIndexTypeOfType(target, 0 /* String */); if (targetType) { @@ -12180,20 +11881,22 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); } - return false; + return 0 /* False */; } - if (!isRelatedTo(sourceType, targetType, reportErrors)) { + var related = isRelatedTo(sourceType, targetType, reportErrors); + if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Index_signatures_are_incompatible); } - return false; + return 0 /* False */; } + return related; } - return true; + return -1 /* True */; } function numberIndexTypesRelatedTo(source, target, reportErrors) { if (relation === identityRelation) { - return indexTypesIdenticalTo(1 /* Number */, source, target, reportErrors); + return indexTypesIdenticalTo(1 /* Number */, source, target); } var targetType = getIndexTypeOfType(target, 1 /* Number */); if (targetType) { @@ -12203,59 +11906,98 @@ var ts; if (reportErrors) { reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source)); } - return false; + return 0 /* False */; } if (sourceStringType && sourceNumberType) { - var compatible = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); + var related = isRelatedTo(sourceStringType, targetType, false) || isRelatedTo(sourceNumberType, targetType, reportErrors); } else { - var compatible = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); + var related = isRelatedTo(sourceStringType || sourceNumberType, targetType, reportErrors); } - if (!compatible) { + if (!related) { if (reportErrors) { reportError(ts.Diagnostics.Index_signatures_are_incompatible); } - return false; + return 0 /* False */; } + return related; } - return true; + return -1 /* True */; } - function indexTypesIdenticalTo(indexKind, source, target, reportErrors) { + function indexTypesIdenticalTo(indexKind, source, target) { var targetType = getIndexTypeOfType(target, indexKind); var sourceType = getIndexTypeOfType(source, indexKind); - return (!sourceType && !targetType) || (sourceType && targetType && isRelatedTo(sourceType, targetType, reportErrors)); + if (!sourceType && !targetType) { + return -1 /* True */; + } + if (sourceType && targetType) { + return isRelatedTo(sourceType, targetType); + } + return 0 /* False */; } } + function isPropertyIdenticalTo(sourceProp, targetProp) { + return compareProperties(sourceProp, targetProp, compareTypes) !== 0 /* False */; + } + function compareProperties(sourceProp, targetProp, compareTypes) { + if (sourceProp === targetProp) { + return -1 /* True */; + } + var sourcePropAccessibility = getDeclarationFlagsFromSymbol(sourceProp) & (32 /* Private */ | 64 /* Protected */); + var targetPropAccessibility = getDeclarationFlagsFromSymbol(targetProp) & (32 /* Private */ | 64 /* Protected */); + if (sourcePropAccessibility !== targetPropAccessibility) { + return 0 /* False */; + } + if (sourcePropAccessibility) { + if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) { + return 0 /* False */; + } + } + else { + if (isOptionalProperty(sourceProp) !== isOptionalProperty(targetProp)) { + return 0 /* False */; + } + } + return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); + } function compareSignatures(source, target, compareReturnTypes, compareTypes) { if (source === target) { - return true; + return -1 /* True */; } if (source.parameters.length !== target.parameters.length || source.minArgumentCount !== target.minArgumentCount || source.hasRestParameter !== target.hasRestParameter) { - return false; + return 0 /* False */; } + var result = -1 /* True */; if (source.typeParameters && target.typeParameters) { if (source.typeParameters.length !== target.typeParameters.length) { - return false; + return 0 /* False */; } for (var i = 0, len = source.typeParameters.length; i < len; ++i) { - if (!compareTypes(source.typeParameters[i], target.typeParameters[i])) { - return false; + var related = compareTypes(source.typeParameters[i], target.typeParameters[i]); + if (!related) { + return 0 /* False */; } + result &= related; } } else if (source.typeParameters || source.typeParameters) { - return false; + return 0 /* False */; } source = getErasedSignature(source); target = getErasedSignature(target); for (var i = 0, len = source.parameters.length; i < len; i++) { var s = source.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(source) : getTypeOfSymbol(source.parameters[i]); var t = target.hasRestParameter && i === len - 1 ? getRestTypeOfSignature(target) : getTypeOfSymbol(target.parameters[i]); - if (!compareTypes(s, t)) { - return false; + var related = compareTypes(s, t); + if (!related) { + return 0 /* False */; } + result &= related; } - return !compareReturnTypes || compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + if (compareReturnTypes) { + result &= compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target)); + } + return result; } function isSupertypeOfEach(candidate, types) { for (var i = 0, len = types.length; i < len; i++) { @@ -12294,7 +12036,7 @@ var ts; checkTypeSubtypeOf(bestSupertypeDownfallType, bestSupertype, errorLocation, ts.Diagnostics.Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0, errorMessageChainHead); } function isTypeOfObjectLiteral(type) { - return (type.flags & 32768 /* Anonymous */) && type.symbol && (type.symbol.flags & 2048 /* ObjectLiteral */) ? true : false; + return (type.flags & 32768 /* Anonymous */) && type.symbol && (type.symbol.flags & 4096 /* ObjectLiteral */) ? true : false; } function isArrayType(type) { return type.flags & 4096 /* Reference */ && type.target === globalArrayType; @@ -12342,7 +12084,7 @@ var ts; var members = {}; var index = 0; ts.forEach(properties, function (p) { - var symbol = createSymbol(4 /* Property */ | 134217728 /* Transient */ | p.flags, p.name); + var symbol = createSymbol(4 /* Property */ | 268435456 /* Transient */ | p.flags, p.name); symbol.declarations = p.declarations; symbol.parent = p.parent; symbol.type = widenedTypes[index++]; @@ -12477,7 +12219,7 @@ var ts; inferFromTypes(sourceTypes[i], target); } } - else if (source.flags & ts.TypeFlags.ObjectType && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (4096 /* Method */ | 1024 /* TypeLiteral */))) { + else if (source.flags & 48128 /* ObjectType */ && (target.flags & (4096 /* Reference */ | 8192 /* Tuple */) || (target.flags & 32768 /* Anonymous */) && target.symbol && target.symbol.flags & (8192 /* Method */ | 2048 /* TypeLiteral */))) { if (!isInProcess(source, target) && isWithinDepthLimit(source, sourceStack) && isWithinDepthLimit(target, targetStack)) { if (depth === 0) { sourceStack = []; @@ -12561,17 +12303,17 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = resolveName(node, node.text, ts.SymbolFlags.Value | 2097152 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol; + links.resolvedSymbol = resolveName(node, node.text, 107455 /* Value */ | 4194304 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node) || unknownSymbol; } return links.resolvedSymbol; } function isInTypeQuery(node) { while (node) { switch (node.kind) { - case 129 /* TypeQuery */: + case 133 /* TypeQuery */: return true; - case 59 /* Identifier */: - case 117 /* QualifiedName */: + case 63 /* Identifier */: + case 121 /* QualifiedName */: node = node.parent; continue; default: @@ -12602,12 +12344,12 @@ var ts; } return links.assignmentChecks[symbol.id] = isAssignedIn(node); function isAssignedInBinaryExpression(node) { - if (node.operator >= ts.SyntaxKind.FirstAssignment && node.operator <= ts.SyntaxKind.LastAssignment) { + if (node.operator >= 51 /* FirstAssignment */ && node.operator <= 62 /* LastAssignment */) { var n = node.left; - while (n.kind === 143 /* ParenExpression */) { + while (n.kind === 148 /* ParenExpression */) { n = n.expression; } - if (n.kind === 59 /* Identifier */ && getResolvedSymbol(n) === symbol) { + if (n.kind === 63 /* Identifier */ && getResolvedSymbol(n) === symbol) { return true; } } @@ -12621,40 +12363,40 @@ var ts; } function isAssignedIn(node) { switch (node.kind) { - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return isAssignedInBinaryExpression(node); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: return isAssignedInVariableDeclaration(node); - case 135 /* ArrayLiteral */: - case 136 /* ObjectLiteral */: - case 138 /* PropertyAccess */: - case 139 /* IndexedAccess */: - case 140 /* CallExpression */: - case 141 /* NewExpression */: - case 142 /* TypeAssertion */: - case 143 /* ParenExpression */: - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: - case 149 /* ConditionalExpression */: - case 151 /* Block */: - case 152 /* VariableStatement */: - case 154 /* ExpressionStatement */: - case 155 /* IfStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 162 /* ReturnStatement */: - case 163 /* WithStatement */: - case 164 /* SwitchStatement */: - case 165 /* CaseClause */: - case 166 /* DefaultClause */: - case 167 /* LabeledStatement */: - case 168 /* ThrowStatement */: - case 169 /* TryStatement */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: + case 139 /* ArrayLiteral */: + case 140 /* ObjectLiteral */: + case 142 /* PropertyAccess */: + case 143 /* IndexedAccess */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: + case 147 /* TypeAssertion */: + case 148 /* ParenExpression */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: + case 154 /* ConditionalExpression */: + case 158 /* Block */: + case 159 /* VariableStatement */: + case 161 /* ExpressionStatement */: + case 162 /* IfStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 169 /* ReturnStatement */: + case 170 /* WithStatement */: + case 171 /* SwitchStatement */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: + case 174 /* LabeledStatement */: + case 175 /* ThrowStatement */: + case 176 /* TryStatement */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: return ts.forEachChild(node, isAssignedIn); } return false; @@ -12662,31 +12404,31 @@ var ts; } function getNarrowedTypeOfSymbol(symbol, node) { var type = getTypeOfSymbol(symbol); - if (symbol.flags & ts.SymbolFlags.Variable && type.flags & ts.TypeFlags.Structured) { + if (symbol.flags & 3 /* Variable */ && type.flags & 65025 /* Structured */) { while (true) { var child = node; node = node.parent; - if (!node || node.kind === 176 /* FunctionBlock */ || node.kind === 182 /* ModuleBlock */) { + if (!node || node.kind === 183 /* FunctionBlock */ || node.kind === 189 /* ModuleBlock */) { break; } var narrowedType = type; switch (node.kind) { - case 155 /* IfStatement */: + case 162 /* IfStatement */: if (child !== node.expression) { narrowedType = narrowType(type, node.expression, child === node.thenStatement); } break; - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: if (child !== node.condition) { narrowedType = narrowType(type, node.condition, child === node.whenTrue); } break; - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: if (child === node.right) { - if (node.operator === 43 /* AmpersandAmpersandToken */) { + if (node.operator === 47 /* AmpersandAmpersandToken */) { narrowedType = narrowType(type, node.left, true); } - else if (node.operator === 44 /* BarBarToken */) { + else if (node.operator === 48 /* BarBarToken */) { narrowedType = narrowType(type, node.left, false); } } @@ -12704,12 +12446,12 @@ var ts; function narrowTypeByEquality(type, expr, assumeTrue) { var left = expr.left; var right = expr.right; - if (left.kind !== 146 /* PrefixOperator */ || left.operator !== 91 /* TypeOfKeyword */ || left.operand.kind !== 59 /* Identifier */ || right.kind !== 7 /* StringLiteral */ || getResolvedSymbol(left.operand) !== symbol) { + if (left.kind !== 151 /* PrefixOperator */ || left.operator !== 95 /* TypeOfKeyword */ || left.operand.kind !== 63 /* Identifier */ || right.kind !== 7 /* StringLiteral */ || getResolvedSymbol(left.operand) !== symbol) { return type; } var t = right.text; var checkType = t === "string" ? stringType : t === "number" ? numberType : t === "boolean" ? booleanType : emptyObjectType; - if (expr.operator === 26 /* ExclamationEqualsEqualsToken */) { + if (expr.operator === 30 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue) { @@ -12742,7 +12484,7 @@ var ts; } } function narrowTypeByInstanceof(type, expr, assumeTrue) { - if (!assumeTrue || expr.left.kind !== 59 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { + if (!assumeTrue || expr.left.kind !== 63 /* Identifier */ || getResolvedSymbol(expr.left) !== symbol) { return type; } var rightType = checkExpression(expr.right); @@ -12758,25 +12500,25 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return narrowType(type, expr.expression, assumeTrue); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: var operator = expr.operator; - if (operator === 25 /* EqualsEqualsEqualsToken */ || operator === 26 /* ExclamationEqualsEqualsToken */) { + if (operator === 29 /* EqualsEqualsEqualsToken */ || operator === 30 /* ExclamationEqualsEqualsToken */) { return narrowTypeByEquality(type, expr, assumeTrue); } - else if (operator === 43 /* AmpersandAmpersandToken */) { + else if (operator === 47 /* AmpersandAmpersandToken */) { return narrowTypeByAnd(type, expr, assumeTrue); } - else if (operator === 44 /* BarBarToken */) { + else if (operator === 48 /* BarBarToken */) { return narrowTypeByOr(type, expr, assumeTrue); } - else if (operator === 81 /* InstanceOfKeyword */) { + else if (operator === 85 /* InstanceOfKeyword */) { return narrowTypeByInstanceof(type, expr, assumeTrue); } break; - case 146 /* PrefixOperator */: - if (expr.operator === 41 /* ExclamationToken */) { + case 151 /* PrefixOperator */: + if (expr.operator === 45 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -12786,8 +12528,8 @@ var ts; } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); - if (symbol.flags & 16777216 /* Import */) { - getSymbolLinks(symbol).referenced = !isInTypeQuery(node); + if (symbol.flags & 33554432 /* Import */) { + getSymbolLinks(symbol).referenced = !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol)); } checkCollisionWithCapturedSuperVariable(node, node); checkCollisionWithCapturedThisVariable(node, node); @@ -12795,9 +12537,9 @@ var ts; return getNarrowedTypeOfSymbol(getExportSymbolOfValueSymbolIfExported(symbol), node); } function captureLexicalThis(node, container) { - var classNode = container.parent && container.parent.kind === 177 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 184 /* ClassDeclaration */ ? container.parent : undefined; getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 120 /* Property */ || container.kind === 122 /* Constructor */) { + if (container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */) { getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } else { @@ -12807,23 +12549,23 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 145 /* ArrowFunction */) { + if (container.kind === 150 /* ArrowFunction */) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = true; } switch (container.kind) { - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_body); break; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 122 /* Constructor */: + case 126 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; - case 120 /* Property */: + case 124 /* Property */: if (container.flags & 128 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } @@ -12832,7 +12574,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node, container); } - var classNode = container.parent && container.parent.kind === 177 /* ClassDeclaration */ ? container.parent : undefined; + var classNode = container.parent && container.parent.kind === 184 /* ClassDeclaration */ ? container.parent : undefined; if (classNode) { var symbol = getSymbolOfNode(classNode); return container.flags & 128 /* Static */ ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol); @@ -12845,29 +12587,29 @@ var ts; if (!node) return node; switch (node.kind) { - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 120 /* Property */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 124 /* Property */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return node; } } } function isInConstructorArgumentInitializer(node, constructorDecl) { for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 119 /* Parameter */) { + if (n.kind === 123 /* Parameter */) { return true; } } return false; } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 140 /* CallExpression */ && node.parent.func === node; - var enclosingClass = ts.getAncestor(node, 177 /* ClassDeclaration */); + var isCallExpression = node.parent.kind === 144 /* CallExpression */ && node.parent.func === node; + var enclosingClass = ts.getAncestor(node, 184 /* ClassDeclaration */); var baseClass; if (enclosingClass && enclosingClass.baseType) { var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClass)); @@ -12881,20 +12623,20 @@ var ts; if (container) { var canUseSuperExpression = false; if (isCallExpression) { - canUseSuperExpression = container.kind === 122 /* Constructor */; + canUseSuperExpression = container.kind === 126 /* Constructor */; } else { var needToCaptureLexicalThis = false; - while (container && container.kind === 145 /* ArrowFunction */) { + while (container && container.kind === 150 /* ArrowFunction */) { container = getSuperContainer(container); needToCaptureLexicalThis = true; } - if (container && container.parent && container.parent.kind === 177 /* ClassDeclaration */) { + if (container && container.parent && container.parent.kind === 184 /* ClassDeclaration */) { if (container.flags & 128 /* Static */) { - canUseSuperExpression = container.kind === 121 /* Method */ || container.kind === 123 /* GetAccessor */ || container.kind === 124 /* SetAccessor */; + canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */; } else { - canUseSuperExpression = container.kind === 121 /* Method */ || container.kind === 123 /* GetAccessor */ || container.kind === 124 /* SetAccessor */ || container.kind === 120 /* Property */ || container.kind === 122 /* Constructor */; + canUseSuperExpression = container.kind === 125 /* Method */ || container.kind === 127 /* GetAccessor */ || container.kind === 128 /* SetAccessor */ || container.kind === 124 /* Property */ || container.kind === 126 /* Constructor */; } } } @@ -12908,7 +12650,7 @@ var ts; getNodeLinks(node).flags |= 16 /* SuperInstance */; returnType = baseClass; } - if (container.kind === 122 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 126 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); returnType = unknownType; } @@ -12928,7 +12670,7 @@ var ts; } function getContextuallyTypedParameterType(parameter) { var func = parameter.parent; - if (func.kind === 144 /* FunctionExpression */ || func.kind === 145 /* ArrowFunction */) { + if (func.kind === 149 /* FunctionExpression */ || func.kind === 150 /* ArrowFunction */) { if (isContextSensitiveExpression(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { @@ -12952,7 +12694,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 119 /* Parameter */) { + if (declaration.kind === 123 /* Parameter */) { return getContextuallyTypedParameterType(declaration); } } @@ -12961,7 +12703,7 @@ var ts; function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); if (func) { - if (func.type || func.kind === 122 /* Constructor */ || func.kind === 123 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 124 /* SetAccessor */))) { + if (func.type || func.kind === 126 /* Constructor */ || func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(func)); } var signature = getContextualSignature(func); @@ -12983,12 +12725,12 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operator; - if (operator >= ts.SyntaxKind.FirstAssignment && operator <= ts.SyntaxKind.LastAssignment) { + if (operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); } } - else if (operator === 44 /* BarBarToken */) { + else if (operator === 48 /* BarBarToken */) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = checkExpression(binaryExpression.left); @@ -13067,25 +12809,25 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 174 /* VariableDeclaration */: - case 119 /* Parameter */: - case 120 /* Property */: + case 181 /* VariableDeclaration */: + case 123 /* Parameter */: + case 124 /* Property */: return getContextualTypeForInitializerExpression(node); - case 145 /* ArrowFunction */: - case 162 /* ReturnStatement */: + case 150 /* ArrowFunction */: + case 169 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return getContextualTypeForArgument(node); - case 142 /* TypeAssertion */: + case 147 /* TypeAssertion */: return getTypeFromTypeNode(parent.type); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 137 /* PropertyAssignment */: + case 141 /* PropertyAssignment */: return getContextualTypeForPropertyExpression(node); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return getContextualTypeForElementExpression(node); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); } return undefined; @@ -13115,7 +12857,7 @@ var ts; if (!result) { result = signature; } - else if (!compareSignatures(result, signature, true, isTypeIdenticalTo)) { + else if (!compareSignatures(result, signature, true, compareTypes)) { return undefined; } } @@ -13149,7 +12891,7 @@ var ts; var member = members[id]; if (member.flags & 4 /* Property */) { var type = checkExpression(member.declarations[0].initializer, contextualMapper); - var prop = createSymbol(4 /* Property */ | 134217728 /* Transient */ | member.flags, member.name); + var prop = createSymbol(4 /* Property */ | 268435456 /* Transient */ | member.flags, member.name); prop.declarations = member.declarations; prop.parent = member.parent; if (member.valueDeclaration) @@ -13159,11 +12901,11 @@ var ts; member = prop; } else { - var getAccessor = getDeclarationOfKind(member, 123 /* GetAccessor */); + var getAccessor = getDeclarationOfKind(member, 127 /* GetAccessor */); if (getAccessor) { checkAccessorDeclaration(getAccessor); } - var setAccessor = getDeclarationOfKind(member, 124 /* SetAccessor */); + var setAccessor = getDeclarationOfKind(member, 128 /* SetAccessor */); if (setAccessor) { checkAccessorDeclaration(setAccessor); } @@ -13193,17 +12935,17 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 120 /* Property */; + return s.valueDeclaration ? s.valueDeclaration.kind : 124 /* Property */; } function getDeclarationFlagsFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 268435456 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; + return s.valueDeclaration ? s.valueDeclaration.flags : s.flags & 536870912 /* Prototype */ ? 16 /* Public */ | 128 /* Static */ : 0; } function checkClassPropertyAccess(node, type, prop) { var flags = getDeclarationFlagsFromSymbol(prop); if (!(flags & (32 /* Private */ | 64 /* Protected */))) { return; } - var enclosingClassDeclaration = ts.getAncestor(node, 177 /* ClassDeclaration */); + var enclosingClassDeclaration = ts.getAncestor(node, 184 /* ClassDeclaration */); var enclosingClass = enclosingClassDeclaration ? getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingClassDeclaration)) : undefined; var declaringClass = getDeclaredTypeOfSymbol(prop.parent); if (flags & 32 /* Private */) { @@ -13212,7 +12954,7 @@ var ts; } return; } - if (node.left.kind === 85 /* SuperKeyword */) { + if (node.left.kind === 89 /* SuperKeyword */) { return; } if (!enclosingClass || !hasBaseType(enclosingClass, declaringClass)) { @@ -13244,7 +12986,7 @@ var ts; } getNodeLinks(node).resolvedSymbol = prop; if (prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 85 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 121 /* Method */) { + if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { error(node.right, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); } else { @@ -13260,7 +13002,7 @@ var ts; if (type !== unknownType && type !== anyType) { var prop = getPropertyOfType(getWidenedType(type), propertyName); if (prop && prop.parent && prop.parent.flags & 32 /* Class */) { - if (node.left.kind === 85 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 121 /* Method */) { + if (node.left.kind === 89 /* SuperKeyword */ && getDeclarationKindFromSymbol(prop) !== 125 /* Method */) { return false; } else { @@ -13277,15 +13019,19 @@ var ts; var indexType = checkExpression(node.index); if (objectType === unknownType) return unknownType; + if (isConstEnumObjectType(objectType) && node.index.kind !== 7 /* StringLiteral */) { + error(node.index, ts.Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + } if (node.index.kind === 7 /* StringLiteral */ || node.index.kind === 6 /* NumericLiteral */) { var name = node.index.text; var prop = getPropertyOfType(objectType, name); if (prop) { + getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } } - if (indexType.flags & (1 /* Any */ | ts.TypeFlags.StringLike | ts.TypeFlags.NumberLike)) { - if (indexType.flags & (1 /* Any */ | ts.TypeFlags.NumberLike)) { + if (indexType.flags & (1 /* Any */ | 258 /* StringLike */ | 132 /* NumberLike */)) { + if (indexType.flags & (1 /* Any */ | 132 /* NumberLike */)) { var numberIndexType = getIndexTypeOfType(objectType, 1 /* Number */); if (numberIndexType) { return numberIndexType; @@ -13329,7 +13075,7 @@ var ts; return callIsIncomplete || hasEnoughArguments; } function getSingleCallSignature(type) { - if (type.flags & ts.TypeFlags.ObjectType) { + if (type.flags & 48128 /* ObjectType */) { var resolved = resolveObjectOrUnionTypeMembers(type); if (resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0 && resolved.properties.length === 0 && !resolved.stringIndexType && !resolved.numberIndexType) { return resolved.callSignatures[0]; @@ -13349,7 +13095,7 @@ var ts; var context = createInferenceContext(typeParameters, false); var mapper = createInferenceMapper(context); for (var i = 0; i < args.length; i++) { - if (args[i].kind === 150 /* OmittedExpression */) { + if (args[i].kind === 157 /* OmittedExpression */) { continue; } if (!excludeArgument || excludeArgument[i] === undefined) { @@ -13359,7 +13105,7 @@ var ts; } if (excludeArgument) { for (var i = 0; i < args.length; i++) { - if (args[i].kind === 150 /* OmittedExpression */) { + if (args[i].kind === 157 /* OmittedExpression */) { continue; } if (excludeArgument[i] === false) { @@ -13397,7 +13143,7 @@ var ts; if (node.arguments) { for (var i = 0; i < node.arguments.length; i++) { var arg = node.arguments[i]; - if (arg.kind === 150 /* OmittedExpression */) { + if (arg.kind === 157 /* OmittedExpression */) { continue; } var paramType = getTypeAtPosition(signature, i); @@ -13532,33 +13278,31 @@ var ts; ts.Debug.assert(!result.length); for (var i = 0; i < signatures.length; i++) { var signature = signatures[i]; - if (true) { - var symbol = signature.declaration && getSymbolOfNode(signature.declaration); - var parent = signature.declaration && signature.declaration.parent; - if (!lastSymbol || symbol === lastSymbol) { - if (lastParent && parent === lastParent) { - pos++; - } - else { - lastParent = parent; - pos = cutoffPos; - } + var symbol = signature.declaration && getSymbolOfNode(signature.declaration); + var parent = signature.declaration && signature.declaration.parent; + if (!lastSymbol || symbol === lastSymbol) { + if (lastParent && parent === lastParent) { + pos++; } else { - pos = cutoffPos = result.length; lastParent = parent; + pos = cutoffPos; } - lastSymbol = symbol; - for (var j = result.length; j > pos; j--) { - result[j] = result[j - 1]; - } - result[pos] = signature; } + else { + pos = cutoffPos = result.length; + lastParent = parent; + } + lastSymbol = symbol; + for (var j = result.length; j > pos; j--) { + result[j] = result[j - 1]; + } + result[pos] = signature; } } } function resolveCallExpression(node, candidatesOutArray) { - if (node.func.kind === 85 /* SuperKeyword */) { + if (node.func.kind === 89 /* SuperKeyword */) { var superType = checkSuperExpression(node.func); if (superType !== unknownType) { return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */), candidatesOutArray); @@ -13620,18 +13364,18 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedSignature || candidatesOutArray) { links.resolvedSignature = anySignature; - links.resolvedSignature = node.kind === 140 /* CallExpression */ ? resolveCallExpression(node, candidatesOutArray) : resolveNewExpression(node, candidatesOutArray); + links.resolvedSignature = node.kind === 144 /* CallExpression */ ? resolveCallExpression(node, candidatesOutArray) : resolveNewExpression(node, candidatesOutArray); } return links.resolvedSignature; } function checkCallExpression(node) { var signature = getResolvedSignature(node); - if (node.func.kind === 85 /* SuperKeyword */) { + if (node.func.kind === 89 /* SuperKeyword */) { return voidType; } - if (node.kind === 141 /* NewExpression */) { + if (node.kind === 145 /* NewExpression */) { var declaration = signature.declaration; - if (declaration && (declaration.kind !== 122 /* Constructor */ && declaration.kind !== 126 /* ConstructSignature */)) { + if (declaration && (declaration.kind !== 126 /* Constructor */ && declaration.kind !== 130 /* ConstructSignature */)) { if (compilerOptions.noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } @@ -13640,6 +13384,11 @@ var ts; } return getReturnTypeOfSignature(signature); } + function checkTaggedTemplateExpression(node) { + checkExpression(node.tag); + checkExpression(node.template); + return anyType; + } function checkTypeAssertion(node) { var exprType = checkExpression(node.operand); var targetType = getTypeFromTypeNode(node.type); @@ -13669,7 +13418,7 @@ var ts; } function getReturnTypeFromBody(func, contextualMapper) { var contextualSignature = getContextualSignature(func); - if (func.body.kind !== 176 /* FunctionBlock */) { + if (func.body.kind !== 183 /* FunctionBlock */) { var unwidenedType = checkAndMarkExpression(func.body, contextualMapper); var widenedType = getWidenedType(unwidenedType); if (fullTypeCheck && compilerOptions.noImplicitAny && !contextualSignature && widenedType !== unwidenedType && getInnermostTypeOfNestedArrayTypes(widenedType) === anyType) { @@ -13717,7 +13466,7 @@ var ts; }); } function bodyContainsSingleThrowStatement(body) { - return (body.statements.length === 1) && (body.statements[0].kind === 168 /* ThrowStatement */); + return (body.statements.length === 1) && (body.statements[0].kind === 175 /* ThrowStatement */); } function checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(func, returnType) { if (!fullTypeCheck) { @@ -13726,7 +13475,7 @@ var ts; if (returnType === voidType || returnType === anyType) { return; } - if (!func.body || func.body.kind !== 176 /* FunctionBlock */) { + if (!func.body || func.body.kind !== 183 /* FunctionBlock */) { return; } var bodyBlock = func.body; @@ -13770,7 +13519,7 @@ var ts; if (node.type) { checkIfNonVoidFunctionHasReturnExpressionsOrSingleThrowStatment(node, getTypeFromTypeNode(node.type)); } - if (node.body.kind === 176 /* FunctionBlock */) { + if (node.body.kind === 183 /* FunctionBlock */) { checkSourceElement(node.body); } else { @@ -13782,7 +13531,7 @@ var ts; } } function checkArithmeticOperandType(operand, type, diagnostic) { - if (!(type.flags & (1 /* Any */ | ts.TypeFlags.NumberLike))) { + if (!(type.flags & (1 /* Any */ | 132 /* NumberLike */))) { error(operand, diagnostic); return false; } @@ -13795,15 +13544,15 @@ var ts; } function isReferenceOrErrorExpression(n) { switch (n.kind) { - case 59 /* Identifier */: + case 63 /* Identifier */: var symbol = findSymbol(n); - return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & ts.SymbolFlags.Variable) !== 0; - case 138 /* PropertyAccess */: + return !symbol || symbol === unknownSymbol || symbol === argumentsSymbol || (symbol.flags & 3 /* Variable */) !== 0; + case 142 /* PropertyAccess */: var symbol = findSymbol(n); return !symbol || symbol === unknownSymbol || (symbol.flags & ~8 /* EnumMember */) !== 0; - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return true; - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return isReferenceOrErrorExpression(n.expression); default: return false; @@ -13811,20 +13560,20 @@ var ts; } function isConstVariableReference(n) { switch (n.kind) { - case 59 /* Identifier */: - case 138 /* PropertyAccess */: + case 63 /* Identifier */: + case 142 /* PropertyAccess */: var symbol = findSymbol(n); - return symbol && (symbol.flags & ts.SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; - case 139 /* IndexedAccess */: + return symbol && (symbol.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(symbol) & 4096 /* Const */) !== 0; + case 143 /* IndexedAccess */: var index = n.index; var symbol = findSymbol(n.object); if (symbol && index.kind === 7 /* StringLiteral */) { var name = index.text; var prop = getPropertyOfType(getTypeOfSymbol(symbol), name); - return prop && (prop.flags & ts.SymbolFlags.Variable) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; + return prop && (prop.flags & 3 /* Variable */) !== 0 && (getDeclarationFlagsFromSymbol(prop) & 4096 /* Const */) !== 0; } return false; - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return isConstVariableReference(n.expression); default: return false; @@ -13843,19 +13592,19 @@ var ts; function checkPrefixExpression(node) { var operandType = checkExpression(node.operand); switch (node.operator) { - case 28 /* PlusToken */: - case 29 /* MinusToken */: - case 42 /* TildeToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: + case 46 /* TildeToken */: return numberType; - case 41 /* ExclamationToken */: - case 68 /* DeleteKeyword */: + case 45 /* ExclamationToken */: + case 72 /* DeleteKeyword */: return booleanType; - case 91 /* TypeOfKeyword */: + case 95 /* TypeOfKeyword */: return stringType; - case 93 /* VoidKeyword */: + case 97 /* VoidKeyword */: return undefinedType; - case 33 /* PlusPlusToken */: - case 34 /* MinusMinusToken */: + case 37 /* PlusPlusToken */: + case 38 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, operandType, ts.Diagnostics.An_arithmetic_operand_must_be_of_type_any_number_or_an_enum_type); if (ok) { checkReferenceExpression(node.operand, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer, ts.Diagnostics.The_operand_of_an_increment_or_decrement_operator_cannot_be_a_constant); @@ -13876,7 +13625,13 @@ var ts; if (type.flags & 16384 /* Union */) { return !ts.forEach(type.types, function (t) { return !isStructuredType(t); }); } - return (type.flags & ts.TypeFlags.Structured) !== 0; + return (type.flags & 65025 /* Structured */) !== 0; + } + function isConstEnumObjectType(type) { + return type.flags & (48128 /* ObjectType */ | 32768 /* Anonymous */) && type.symbol && isConstEnumSymbol(type.symbol); + } + function isConstEnumSymbol(symbol) { + return (symbol.flags & 128 /* ConstEnum */) !== 0; } function checkInstanceOfExpression(node, leftType, rightType) { if (leftType !== unknownType && !isStructuredType(leftType)) { @@ -13901,26 +13656,26 @@ var ts; var leftType = checkExpression(node.left, contextualMapper); var rightType = checkExpression(node.right, contextualMapper); switch (operator) { - case 30 /* AsteriskToken */: - case 50 /* AsteriskEqualsToken */: - case 31 /* SlashToken */: - case 51 /* SlashEqualsToken */: - case 32 /* PercentToken */: - case 52 /* PercentEqualsToken */: - case 29 /* MinusToken */: - case 49 /* MinusEqualsToken */: - case 35 /* LessThanLessThanToken */: - case 53 /* LessThanLessThanEqualsToken */: - case 36 /* GreaterThanGreaterThanToken */: - case 54 /* GreaterThanGreaterThanEqualsToken */: - case 37 /* GreaterThanGreaterThanGreaterThanToken */: - case 55 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 39 /* BarToken */: - case 57 /* BarEqualsToken */: - case 40 /* CaretToken */: - case 58 /* CaretEqualsToken */: - case 38 /* AmpersandToken */: - case 56 /* AmpersandEqualsToken */: + case 34 /* AsteriskToken */: + case 54 /* AsteriskEqualsToken */: + case 35 /* SlashToken */: + case 55 /* SlashEqualsToken */: + case 36 /* PercentToken */: + case 56 /* PercentEqualsToken */: + case 33 /* MinusToken */: + case 53 /* MinusEqualsToken */: + case 39 /* LessThanLessThanToken */: + case 57 /* LessThanLessThanEqualsToken */: + case 40 /* GreaterThanGreaterThanToken */: + case 58 /* GreaterThanGreaterThanEqualsToken */: + case 41 /* GreaterThanGreaterThanGreaterThanToken */: + case 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 43 /* BarToken */: + case 61 /* BarEqualsToken */: + case 44 /* CaretToken */: + case 62 /* CaretEqualsToken */: + case 42 /* AmpersandToken */: + case 60 /* AmpersandEqualsToken */: if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) @@ -13937,17 +13692,17 @@ var ts; } } return numberType; - case 28 /* PlusToken */: - case 48 /* PlusEqualsToken */: + case 32 /* PlusToken */: + case 52 /* PlusEqualsToken */: if (leftType.flags & (32 /* Undefined */ | 64 /* Null */)) leftType = rightType; if (rightType.flags & (32 /* Undefined */ | 64 /* Null */)) rightType = leftType; var resultType; - if (leftType.flags & ts.TypeFlags.NumberLike && rightType.flags & ts.TypeFlags.NumberLike) { + if (leftType.flags & 132 /* NumberLike */ && rightType.flags & 132 /* NumberLike */) { resultType = numberType; } - else if (leftType.flags & ts.TypeFlags.StringLike || rightType.flags & ts.TypeFlags.StringLike) { + else if (leftType.flags & 258 /* StringLike */ || rightType.flags & 258 /* StringLike */) { resultType = stringType; } else if (leftType.flags & 1 /* Any */ || leftType === unknownType || rightType.flags & 1 /* Any */ || rightType === unknownType) { @@ -13957,53 +13712,53 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 48 /* PlusEqualsToken */) { + if (operator === 52 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 23 /* EqualsEqualsToken */: - case 24 /* ExclamationEqualsToken */: - case 25 /* EqualsEqualsEqualsToken */: - case 26 /* ExclamationEqualsEqualsToken */: - case 19 /* LessThanToken */: - case 20 /* GreaterThanToken */: - case 21 /* LessThanEqualsToken */: - case 22 /* GreaterThanEqualsToken */: + case 27 /* EqualsEqualsToken */: + case 28 /* ExclamationEqualsToken */: + case 29 /* EqualsEqualsEqualsToken */: + case 30 /* ExclamationEqualsEqualsToken */: + case 23 /* LessThanToken */: + case 24 /* GreaterThanToken */: + case 25 /* LessThanEqualsToken */: + case 26 /* GreaterThanEqualsToken */: if (!isTypeAssignableTo(leftType, rightType) && !isTypeAssignableTo(rightType, leftType)) { reportOperatorError(); } return booleanType; - case 81 /* InstanceOfKeyword */: + case 85 /* InstanceOfKeyword */: return checkInstanceOfExpression(node, leftType, rightType); - case 80 /* InKeyword */: + case 84 /* InKeyword */: return checkInExpression(node, leftType, rightType); - case 43 /* AmpersandAmpersandToken */: + case 47 /* AmpersandAmpersandToken */: return rightType; - case 44 /* BarBarToken */: + case 48 /* BarBarToken */: return getUnionType([leftType, rightType]); - case 47 /* EqualsToken */: + case 51 /* EqualsToken */: checkAssignmentOperator(rightType); return rightType; - case 18 /* CommaToken */: + case 22 /* CommaToken */: return rightType; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 39 /* BarToken */: - case 57 /* BarEqualsToken */: - return 44 /* BarBarToken */; - case 40 /* CaretToken */: - case 58 /* CaretEqualsToken */: - return 26 /* ExclamationEqualsEqualsToken */; - case 38 /* AmpersandToken */: - case 56 /* AmpersandEqualsToken */: - return 43 /* AmpersandAmpersandToken */; + case 43 /* BarToken */: + case 61 /* BarEqualsToken */: + return 48 /* BarBarToken */; + case 44 /* CaretToken */: + case 62 /* CaretEqualsToken */: + return 30 /* ExclamationEqualsEqualsToken */; + case 42 /* AmpersandToken */: + case 60 /* AmpersandEqualsToken */: + return 47 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (fullTypeCheck && operator >= ts.SyntaxKind.FirstAssignment && operator <= ts.SyntaxKind.LastAssignment) { + if (fullTypeCheck && operator >= 51 /* FirstAssignment */ && operator <= 62 /* LastAssignment */) { var ok = checkReferenceExpression(node.left, ts.Diagnostics.Invalid_left_hand_side_of_assignment_expression, ts.Diagnostics.Left_hand_side_of_assignment_expression_cannot_be_a_constant); if (ok) { checkTypeAssignableTo(valueType, leftType, node.left, undefined); @@ -14020,6 +13775,12 @@ var ts; var type2 = checkExpression(node.whenFalse, contextualMapper); return getUnionType([type1, type2]); } + function checkTemplateExpression(node) { + ts.forEach(node.templateSpans, function (templateSpan) { + checkExpression(templateSpan.expression); + }); + return stringType; + } function checkExpressionWithContextualType(node, contextualType, contextualMapper) { var saveContextualType = node.contextualType; node.contextualType = contextualType; @@ -14046,56 +13807,67 @@ var ts; } } } + if (isConstEnumObjectType(type)) { + var ok = (node.parent.kind === 142 /* PropertyAccess */ && node.parent.left === node) || (node.parent.kind === 143 /* IndexedAccess */ && node.parent.object === node) || ((node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + if (!ok) { + error(node, ts.Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); + } + } return type; } function checkExpressionNode(node, contextualMapper) { switch (node.kind) { - case 59 /* Identifier */: + case 63 /* Identifier */: return checkIdentifier(node); - case 87 /* ThisKeyword */: + case 91 /* ThisKeyword */: return checkThisExpression(node); - case 85 /* SuperKeyword */: + case 89 /* SuperKeyword */: return checkSuperExpression(node); - case 83 /* NullKeyword */: + case 87 /* NullKeyword */: return nullType; - case 89 /* TrueKeyword */: - case 74 /* FalseKeyword */: + case 93 /* TrueKeyword */: + case 78 /* FalseKeyword */: return booleanType; case 6 /* NumericLiteral */: return numberType; + case 155 /* TemplateExpression */: + return checkTemplateExpression(node); case 7 /* StringLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: return stringType; case 8 /* RegularExpressionLiteral */: return globalRegExpType; - case 117 /* QualifiedName */: + case 121 /* QualifiedName */: return checkPropertyAccess(node); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return checkArrayLiteral(node, contextualMapper); - case 136 /* ObjectLiteral */: + case 140 /* ObjectLiteral */: return checkObjectLiteral(node, contextualMapper); - case 138 /* PropertyAccess */: + case 142 /* PropertyAccess */: return checkPropertyAccess(node); - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return checkIndexedAccess(node); - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return checkCallExpression(node); - case 142 /* TypeAssertion */: + case 146 /* TaggedTemplateExpression */: + return checkTaggedTemplateExpression(node); + case 147 /* TypeAssertion */: return checkTypeAssertion(node); - case 143 /* ParenExpression */: + case 148 /* ParenExpression */: return checkExpression(node.expression); - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: return checkFunctionExpression(node, contextualMapper); - case 146 /* PrefixOperator */: + case 151 /* PrefixOperator */: return checkPrefixExpression(node); - case 147 /* PostfixOperator */: + case 152 /* PostfixOperator */: return checkPostfixExpression(node); - case 148 /* BinaryExpression */: + case 153 /* BinaryExpression */: return checkBinaryExpression(node, contextualMapper); - case 149 /* ConditionalExpression */: + case 154 /* ConditionalExpression */: return checkConditionalExpression(node, contextualMapper); - case 150 /* OmittedExpression */: + case 157 /* OmittedExpression */: return undefinedType; } return unknownType; @@ -14111,7 +13883,7 @@ var ts; checkVariableDeclaration(parameterDeclaration); if (fullTypeCheck) { checkCollisionWithIndexVariableInGeneratedCode(parameterDeclaration, parameterDeclaration.name); - if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 122 /* Constructor */ && parameterDeclaration.parent.body)) { + if (parameterDeclaration.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */) && !(parameterDeclaration.parent.kind === 126 /* Constructor */ && parameterDeclaration.parent.body)) { error(parameterDeclaration, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } if (parameterDeclaration.flags & 8 /* Rest */) { @@ -14126,10 +13898,10 @@ var ts; } } function checkReferencesInInitializer(n) { - if (n.kind === 59 /* Identifier */) { + if (n.kind === 63 /* Identifier */) { var referencedSymbol = getNodeLinks(n).resolvedSymbol; - if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, ts.SymbolFlags.Value) === referencedSymbol) { - if (referencedSymbol.valueDeclaration.kind === 119 /* Parameter */) { + if (referencedSymbol && referencedSymbol !== unknownSymbol && getSymbol(parameterDeclaration.parent.locals, referencedSymbol.name, 107455 /* Value */) === referencedSymbol) { + if (referencedSymbol.valueDeclaration.kind === 123 /* Parameter */) { if (referencedSymbol.valueDeclaration === parameterDeclaration) { error(n, ts.Diagnostics.Parameter_0_cannot_be_referenced_in_its_initializer, ts.identifierToString(parameterDeclaration.name)); return; @@ -14163,10 +13935,10 @@ var ts; checkCollisionWithArgumentsInGeneratedCode(node); if (compilerOptions.noImplicitAny && !node.type) { switch (node.kind) { - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 125 /* CallSignature */: + case 129 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } @@ -14175,7 +13947,7 @@ var ts; checkSpecializedSignatureDeclaration(node); } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 178 /* InterfaceDeclaration */) { + if (node.kind === 185 /* InterfaceDeclaration */) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -14189,7 +13961,7 @@ var ts; var declaration = indexSymbol.declarations[i]; if (declaration.parameters.length == 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 114 /* StringKeyword */: + case 118 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -14197,7 +13969,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 112 /* NumberKeyword */: + case 116 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -14231,39 +14003,37 @@ var ts; return; } function isSuperCallExpression(n) { - return n.kind === 140 /* CallExpression */ && n.func.kind === 85 /* SuperKeyword */; + return n.kind === 144 /* CallExpression */ && n.func.kind === 89 /* SuperKeyword */; } function containsSuperCall(n) { if (isSuperCallExpression(n)) { return true; } switch (n.kind) { - case 144 /* FunctionExpression */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: - case 136 /* ObjectLiteral */: - return false; - default: - return ts.forEachChild(n, containsSuperCall); + case 149 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: + case 140 /* ObjectLiteral */: return false; + default: return ts.forEachChild(n, containsSuperCall); } } function markThisReferencesAsErrors(n) { - if (n.kind === 87 /* ThisKeyword */) { + if (n.kind === 91 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 144 /* FunctionExpression */ && n.kind !== 175 /* FunctionDeclaration */) { + else if (n.kind !== 149 /* FunctionExpression */ && n.kind !== 182 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 120 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; + return n.kind === 124 /* Property */ && !(n.flags & 128 /* Static */) && !!n.initializer; } if (node.parent.baseType) { if (containsSuperCall(node.body)) { var superCallShouldBeFirst = ts.forEach(node.parent.members, isInstancePropertyWithInitializer) || ts.forEach(node.parameters, function (p) { return p.flags & (16 /* Public */ | 32 /* Private */ | 64 /* Protected */); }); if (superCallShouldBeFirst) { var statements = node.body.statements; - if (!statements.length || statements[0].kind !== 154 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { + if (!statements.length || statements[0].kind !== 161 /* ExpressionStatement */ || !isSuperCallExpression(statements[0].expression)) { error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_or_has_parameter_properties); } else { @@ -14278,15 +14048,15 @@ var ts; } function checkAccessorDeclaration(node) { if (fullTypeCheck) { - if (node.kind === 123 /* GetAccessor */) { + if (node.kind === 127 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && node.body && !(bodyContainsAReturnStatement(node.body) || bodyContainsSingleThrowStatement(node.body))) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value_or_consist_of_a_single_throw_statement); } } - var otherKind = node.kind === 123 /* GetAccessor */ ? 124 /* SetAccessor */ : 123 /* GetAccessor */; + var otherKind = node.kind === 127 /* GetAccessor */ ? 128 /* SetAccessor */ : 127 /* GetAccessor */; var otherAccessor = getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { - if (((node.flags & ts.NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & ts.NodeFlags.AccessibilityModifier))) { + if (((node.flags & 112 /* AccessibilityModifier */) !== (otherAccessor.flags & 112 /* AccessibilityModifier */))) { error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); } var thisType = getAnnotatedAccessorType(node); @@ -14352,9 +14122,9 @@ var ts; } var symbol = getSymbolOfNode(signatureDeclarationNode); var signaturesToCheck; - if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 178 /* InterfaceDeclaration */) { - ts.Debug.assert(signatureDeclarationNode.kind === 125 /* CallSignature */ || signatureDeclarationNode.kind === 126 /* ConstructSignature */); - var signatureKind = signatureDeclarationNode.kind === 125 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; + if (!signatureDeclarationNode.name && signatureDeclarationNode.parent && signatureDeclarationNode.parent.kind === 185 /* InterfaceDeclaration */) { + ts.Debug.assert(signatureDeclarationNode.kind === 129 /* CallSignature */ || signatureDeclarationNode.kind === 130 /* ConstructSignature */); + var signatureKind = signatureDeclarationNode.kind === 129 /* CallSignature */ ? 0 /* Call */ : 1 /* Construct */; var containingSymbol = getSymbolOfNode(signatureDeclarationNode.parent); var containingType = getDeclaredTypeOfSymbol(containingSymbol); signaturesToCheck = getSignaturesOfType(containingType, signatureKind); @@ -14372,7 +14142,7 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = n.flags; - if (n.parent.kind !== 178 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { + if (n.parent.kind !== 185 /* InterfaceDeclaration */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { flags |= 1 /* Export */; } @@ -14414,9 +14184,9 @@ var ts; var lastSeenNonAmbientDeclaration; var previousDeclaration; var declarations = symbol.declarations; - var isConstructor = (symbol.flags & 8192 /* Constructor */) !== 0; + var isConstructor = (symbol.flags & 16384 /* Constructor */) !== 0; function reportImplementationExpectedError(node) { - if (node.name && node.name.kind === 116 /* Missing */) { + if (node.name && node.name.kind === 120 /* Missing */) { return; } var seen = false; @@ -14432,7 +14202,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - ts.Debug.assert(node.kind === 121 /* Method */); + ts.Debug.assert(node.kind === 125 /* Method */); ts.Debug.assert((node.flags & 128 /* Static */) !== (subsequentNode.flags & 128 /* Static */)); var diagnostic = node.flags & 128 /* Static */ ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; error(errorNode, diagnostic); @@ -14452,17 +14222,17 @@ var ts; error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration); } } - var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & ts.SymbolFlags.Module; + var isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & 1536 /* Module */; var duplicateFunctionDeclaration = false; var multipleConstructorImplementation = false; for (var i = 0; i < declarations.length; i++) { var node = declarations[i]; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 178 /* InterfaceDeclaration */ || node.parent.kind === 130 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 185 /* InterfaceDeclaration */ || node.parent.kind === 134 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 175 /* FunctionDeclaration */ || node.kind === 121 /* Method */ || node.kind === 122 /* Constructor */) { + if (node.kind === 182 /* FunctionDeclaration */ || node.kind === 125 /* Method */ || node.kind === 126 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -14528,7 +14298,7 @@ var ts; var symbol = node.localSymbol; if (!symbol) { symbol = getSymbolOfNode(node); - if (!(symbol.flags & ts.SymbolFlags.Export)) { + if (!(symbol.flags & 29360128 /* Export */)) { return; } } @@ -14556,14 +14326,14 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 178 /* InterfaceDeclaration */: - return 4194304 /* ExportType */; - case 181 /* ModuleDeclaration */: - return d.name.kind === 7 /* StringLiteral */ || ts.isInstantiated(d) ? 8388608 /* ExportNamespace */ | 2097152 /* ExportValue */ : 8388608 /* ExportNamespace */; - case 177 /* ClassDeclaration */: - case 180 /* EnumDeclaration */: - return 4194304 /* ExportType */ | 2097152 /* ExportValue */; - case 183 /* ImportDeclaration */: + case 185 /* InterfaceDeclaration */: + return 8388608 /* ExportType */; + case 188 /* ModuleDeclaration */: + return d.name.kind === 7 /* StringLiteral */ || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 16777216 /* ExportNamespace */ | 4194304 /* ExportValue */ : 16777216 /* ExportNamespace */; + case 184 /* ClassDeclaration */: + case 187 /* EnumDeclaration */: + return 8388608 /* ExportType */ | 4194304 /* ExportValue */; + case 190 /* ImportDeclaration */: var result = 0; var target = resolveImport(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { @@ -14571,7 +14341,7 @@ var ts; }); return result; default: - return 2097152 /* ExportValue */; + return 4194304 /* ExportValue */; } } } @@ -14621,7 +14391,7 @@ var ts; if (!(name && name.text === "_i")) { return; } - if (node.kind === 119 /* Parameter */) { + if (node.kind === 123 /* Parameter */) { if (node.parent.body && ts.hasRestParameters(node.parent) && !ts.isInAmbientContext(node)) { error(node, ts.Diagnostics.Duplicate_identifier_i_Compiler_uses_i_to_initialize_rest_parameter); } @@ -14638,11 +14408,11 @@ var ts; return; } switch (current.kind) { - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 121 /* Method */: - case 145 /* ArrowFunction */: - case 122 /* Constructor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 125 /* Method */: + case 150 /* ArrowFunction */: + case 126 /* Constructor */: if (ts.hasRestParameters(current)) { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_i_that_compiler_uses_to_initialize_rest_parameter); return; @@ -14656,13 +14426,13 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 120 /* Property */ || node.kind === 121 /* Method */ || node.kind === 123 /* GetAccessor */ || node.kind === 124 /* SetAccessor */) { + if (node.kind === 124 /* Property */ || node.kind === 125 /* Method */ || node.kind === 127 /* GetAccessor */ || node.kind === 128 /* SetAccessor */) { return false; } if (ts.isInAmbientContext(node)) { return false; } - if (node.kind === 119 /* Parameter */ && !node.parent.body) { + if (node.kind === 123 /* Parameter */ && !node.parent.body) { return false; } return true; @@ -14677,7 +14447,7 @@ var ts; var current = node; while (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration = node.kind !== 59 /* Identifier */; + var isDeclaration = node.kind !== 63 /* Identifier */; if (isDeclaration) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } @@ -14693,12 +14463,12 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "_super")) { return; } - var enclosingClass = ts.getAncestor(node, 177 /* ClassDeclaration */); + var enclosingClass = ts.getAncestor(node, 184 /* ClassDeclaration */); if (!enclosingClass || ts.isInAmbientContext(enclosingClass)) { return; } if (enclosingClass.baseType) { - var isDeclaration = node.kind !== 59 /* Identifier */; + var isDeclaration = node.kind !== 63 /* Identifier */; if (isDeclaration) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -14711,19 +14481,19 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 181 /* ModuleDeclaration */ && !ts.isInstantiated(node)) { + if (node.kind === 188 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return; } - var parent = node.kind === 174 /* VariableDeclaration */ ? node.parent.parent : node.parent; - if (parent.kind === 186 /* SourceFile */ && ts.isExternalModule(parent)) { + var parent = node.kind === 181 /* VariableDeclaration */ ? node.parent.parent : node.parent; + if (parent.kind === 193 /* SourceFile */ && ts.isExternalModule(parent)) { error(name, ts.Diagnostics.Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_an_external_module, name.text, name.text); } } function checkCollisionWithConstDeclarations(node) { - if (node.initializer && (node.flags & ts.NodeFlags.BlockScoped) === 0) { + if (node.initializer && (node.flags & 6144 /* BlockScoped */) === 0) { var symbol = getSymbolOfNode(node); if (symbol.flags & 1 /* FunctionScopedVariable */) { - var localDeclarationSymbol = resolveName(node, node.name.text, ts.SymbolFlags.Variable, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.text, 3 /* Variable */, undefined, undefined); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationFlagsFromSymbol(localDeclarationSymbol) & 4096 /* Const */) { error(node, ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0, symbolToString(localDeclarationSymbol)); @@ -14820,18 +14590,18 @@ var ts; if (node.expression && !(getNodeLinks(node.expression).flags & 1 /* TypeChecked */)) { var func = ts.getContainingFunction(node); if (func) { - if (func.kind === 124 /* SetAccessor */) { + if (func.kind === 128 /* SetAccessor */) { if (node.expression) { error(node.expression, ts.Diagnostics.Setters_cannot_return_a_value); } } else { var returnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func)); - var checkAssignability = func.type || (func.kind === 123 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 124 /* SetAccessor */))); + var checkAssignability = func.type || (func.kind === 127 /* GetAccessor */ && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(func.symbol, 128 /* SetAccessor */))); if (checkAssignability) { checkTypeAssignableTo(checkExpression(node.expression), returnType, node.expression, undefined); } - else if (func.kind == 122 /* Constructor */) { + else if (func.kind == 126 /* Constructor */) { if (!isTypeAssignableTo(checkExpression(node.expression), returnType)) { error(node.expression, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } @@ -14960,7 +14730,7 @@ var ts; checkTypeAssignableTo(type, baseType, node.name, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1); var staticBaseType = getTypeOfSymbol(baseType.symbol); checkTypeAssignableTo(staticType, getTypeWithoutConstructors(staticBaseType), node.name, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1); - if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, ts.SymbolFlags.Value)) { + if (baseType.symbol !== resolveEntityName(node, node.baseType.typeName, 107455 /* Value */)) { error(node.baseType, ts.Diagnostics.Type_name_0_in_extends_clause_does_not_reference_constructor_function_for_0, typeToString(baseType)); } checkKindsOfPropertyMemberOverrides(type, baseType); @@ -14991,13 +14761,13 @@ var ts; } } function getTargetSymbol(s) { - return s.flags & 33554432 /* Instantiated */ ? getSymbolLinks(s).target : s; + return s.flags & 67108864 /* Instantiated */ ? getSymbolLinks(s).target : s; } function checkKindsOfPropertyMemberOverrides(type, baseType) { var baseProperties = getPropertiesOfObjectType(baseType); for (var i = 0, len = baseProperties.length; i < len; ++i) { var base = getTargetSymbol(baseProperties[i]); - if (base.flags & 268435456 /* Prototype */) { + if (base.flags & 536870912 /* Prototype */) { continue; } var derived = getTargetSymbol(getPropertyOfObjectType(type, base.name)); @@ -15010,26 +14780,26 @@ var ts; if ((baseDeclarationFlags & 128 /* Static */) !== (derivedDeclarationFlags & 128 /* Static */)) { continue; } - if ((base.flags & derived.flags & 4096 /* Method */) || ((base.flags & ts.SymbolFlags.PropertyOrAccessor) && (derived.flags & ts.SymbolFlags.PropertyOrAccessor))) { + if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { continue; } var errorMessage; - if (base.flags & 4096 /* Method */) { - if (derived.flags & ts.SymbolFlags.Accessor) { + if (base.flags & 8192 /* Method */) { + if (derived.flags & 98304 /* Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - ts.Debug.assert(derived.flags & 4 /* Property */); + ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & 4 /* Property */) { - ts.Debug.assert(derived.flags & 4096 /* Method */); + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert(base.flags & ts.SymbolFlags.Accessor); - ts.Debug.assert(derived.flags & 4096 /* Method */); + ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); + ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); @@ -15037,7 +14807,7 @@ var ts; } } function isAccessor(kind) { - return kind === 123 /* GetAccessor */ || kind === 124 /* SetAccessor */; + return kind === 127 /* GetAccessor */ || kind === 128 /* SetAccessor */; } function areTypeParametersIdentical(list1, list2) { if (!list1 && !list2) { @@ -15064,13 +14834,46 @@ var ts; } return true; } + function checkInheritedPropertiesAreIdentical(type, typeNode) { + if (!type.baseTypes.length || type.baseTypes.length === 1) { + return true; + } + var seen = {}; + ts.forEach(type.declaredProperties, function (p) { + seen[p.name] = { prop: p, containingType: type }; + }); + var ok = true; + for (var i = 0, len = type.baseTypes.length; i < len; ++i) { + var base = type.baseTypes[i]; + var properties = getPropertiesOfObjectType(base); + for (var j = 0, proplen = properties.length; j < proplen; ++j) { + var prop = properties[j]; + if (!ts.hasProperty(seen, prop.name)) { + seen[prop.name] = { prop: prop, containingType: base }; + } + else { + var existing = seen[prop.name]; + var isInheritedProperty = existing.containingType !== type; + if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { + ok = false; + var typeName1 = typeToString(existing.containingType); + var typeName2 = typeToString(base); + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); + addDiagnostic(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, program.getCompilerHost().getNewLine())); + } + } + } + } + return ok; + } function checkInterfaceDeclaration(node) { checkTypeParameters(node.typeParameters); if (fullTypeCheck) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - var firstInterfaceDecl = getDeclarationOfKind(symbol, 178 /* InterfaceDeclaration */); + var firstInterfaceDecl = getDeclarationOfKind(symbol, 185 /* InterfaceDeclaration */); if (symbol.declarations.length > 1) { if (node !== firstInterfaceDecl && !areTypeParametersIdentical(firstInterfaceDecl.typeParameters, node.typeParameters)) { error(node.name, ts.Diagnostics.All_declarations_of_an_interface_must_have_identical_type_parameters); @@ -15093,23 +14896,9 @@ var ts; } } function checkTypeAliasDeclaration(node) { + checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); } - function getConstantValueForExpression(node) { - var isNegative = false; - if (node.kind === 146 /* PrefixOperator */) { - var unaryExpression = node; - if (unaryExpression.operator === 29 /* MinusToken */ || unaryExpression.operator === 28 /* PlusToken */) { - node = unaryExpression.operand; - isNegative = unaryExpression.operator === 29 /* MinusToken */; - } - } - if (node.kind === 6 /* NumericLiteral */) { - var literalText = node.text; - return isNegative ? -literalText : +literalText; - } - return undefined; - } function computeEnumMemberValues(node) { var nodeLinks = getNodeLinks(node); if (!(nodeLinks.flags & 128 /* EnumValuesComputed */)) { @@ -15117,18 +14906,32 @@ var ts; var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = ts.isInAmbientContext(node); + var enumIsConst = ts.isConstEnumDeclaration(node); ts.forEach(node.members, function (member) { if (isNumericName(member.name.text)) { error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name); } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForExpression(initializer); - if (autoValue === undefined && !ambient) { - checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); + if (autoValue === undefined) { + if (enumIsConst) { + error(initializer, ts.Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, undefined); + } + } + else if (enumIsConst) { + if (isNaN(autoValue)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(autoValue)) { + error(initializer, ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } } } - else if (ambient) { + else if (ambient && !enumIsConst) { autoValue = undefined; } if (autoValue !== undefined) { @@ -15137,6 +14940,99 @@ var ts; }); nodeLinks.flags |= 128 /* EnumValuesComputed */; } + function getConstantValueForEnumMemberInitializer(initializer, enumIsConst) { + return evalConstant(initializer); + function evalConstant(e) { + switch (e.kind) { + case 151 /* PrefixOperator */: + var value = evalConstant(e.operand); + if (value === undefined) { + return undefined; + } + switch (e.operator) { + case 32 /* PlusToken */: return value; + case 33 /* MinusToken */: return -value; + case 46 /* TildeToken */: return enumIsConst ? ~value : undefined; + } + return undefined; + case 153 /* BinaryExpression */: + if (!enumIsConst) { + return undefined; + } + var left = evalConstant(e.left); + if (left === undefined) { + return undefined; + } + var right = evalConstant(e.right); + if (right === undefined) { + return undefined; + } + switch (e.operator) { + case 43 /* BarToken */: return left | right; + case 42 /* AmpersandToken */: return left & right; + case 40 /* GreaterThanGreaterThanToken */: return left >> right; + case 41 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 39 /* LessThanLessThanToken */: return left << right; + case 44 /* CaretToken */: return left ^ right; + case 34 /* AsteriskToken */: return left * right; + case 35 /* SlashToken */: return left / right; + case 32 /* PlusToken */: return left + right; + case 33 /* MinusToken */: return left - right; + case 36 /* PercentToken */: return left % right; + } + return undefined; + case 6 /* NumericLiteral */: + return +e.text; + case 148 /* ParenExpression */: + return enumIsConst ? evalConstant(e.expression) : undefined; + case 63 /* Identifier */: + case 143 /* IndexedAccess */: + case 142 /* PropertyAccess */: + if (!enumIsConst) { + return undefined; + } + var member = initializer.parent; + var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); + var enumType; + var propertyName; + if (e.kind === 63 /* Identifier */) { + enumType = currentType; + propertyName = e.text; + } + else { + if (e.kind === 143 /* IndexedAccess */) { + if (e.index.kind !== 7 /* StringLiteral */) { + return undefined; + } + var enumType = getTypeOfNode(e.object); + propertyName = e.index.text; + } + else { + var enumType = getTypeOfNode(e.left); + propertyName = e.right.text; + } + if (enumType !== currentType) { + return undefined; + } + } + if (propertyName === undefined) { + return undefined; + } + var property = getPropertyOfObjectType(enumType, propertyName); + if (!property || !(property.flags & 8 /* EnumMember */)) { + return undefined; + } + var propertyDecl = property.valueDeclaration; + if (member === propertyDecl) { + return undefined; + } + if (!isDefinedBefore(propertyDecl, member)) { + return undefined; + } + return getNodeLinks(propertyDecl).enumMemberValue; + } + } + } } function checkEnumDeclaration(node) { if (!fullTypeCheck) { @@ -15150,9 +15046,17 @@ var ts; var enumSymbol = getSymbolOfNode(node); var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { + if (enumSymbol.declarations.length > 1) { + var enumIsConst = ts.isConstEnumDeclaration(node); + ts.forEach(enumSymbol.declarations, function (decl) { + if (ts.isConstEnumDeclaration(decl) !== enumIsConst) { + error(decl.name, ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const); + } + }); + } var seenEnumMissingInitialInitializer = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 180 /* EnumDeclaration */) { + if (declaration.kind !== 187 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -15175,7 +15079,7 @@ var ts; var declarations = symbol.declarations; for (var i = 0; i < declarations.length; i++) { var declaration = declarations[i]; - if ((declaration.kind === 177 /* ClassDeclaration */ || (declaration.kind === 175 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { + if ((declaration.kind === 184 /* ClassDeclaration */ || (declaration.kind === 182 /* FunctionDeclaration */ && declaration.body)) && !ts.isInAmbientContext(declaration)) { return declaration; } } @@ -15187,7 +15091,7 @@ var ts; checkCollisionWithRequireExportsInGeneratedCode(node, node.name); checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); - if (symbol.flags & 256 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { + if (symbol.flags & 512 /* ValueModule */ && symbol.declarations.length > 1 && !ts.isInAmbientContext(node)) { var classOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol); if (classOrFunc) { if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(classOrFunc)) { @@ -15210,7 +15114,7 @@ var ts; checkSourceElement(node.body); } function getFirstIdentifier(node) { - while (node.kind === 117 /* QualifiedName */) { + while (node.kind === 121 /* QualifiedName */) { node = node.left; } return node; @@ -15223,25 +15127,25 @@ var ts; if (node.entityName) { target = resolveImport(symbol); if (target !== unknownSymbol) { - if (target.flags & ts.SymbolFlags.Value) { + if (target.flags & 107455 /* Value */) { var moduleName = getFirstIdentifier(node.entityName); - if (resolveEntityName(node, moduleName, ts.SymbolFlags.Value | ts.SymbolFlags.Namespace).flags & ts.SymbolFlags.Namespace) { + if (resolveEntityName(node, moduleName, 107455 /* Value */ | 1536 /* Namespace */).flags & 1536 /* Namespace */) { checkExpression(node.entityName); } else { error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.identifierToString(moduleName)); } } - if (target.flags & ts.SymbolFlags.Type) { + if (target.flags & 3152352 /* Type */) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0); } } } else { - if (node.parent.kind === 186 /* SourceFile */) { + if (node.parent.kind === 193 /* SourceFile */) { target = resolveImport(symbol); } - else if (node.parent.kind === 182 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { + else if (node.parent.kind === 189 /* ModuleBlock */ && node.parent.parent.name.kind === 7 /* StringLiteral */) { if (isExternalModuleNameRelative(node.externalModuleName.text)) { error(node, ts.Diagnostics.Import_declaration_in_an_ambient_external_module_declaration_cannot_reference_external_module_through_relative_external_module_name); target = unknownSymbol; @@ -15255,7 +15159,7 @@ var ts; } } if (target !== unknownSymbol) { - var excludedMeanings = (symbol.flags & ts.SymbolFlags.Value ? ts.SymbolFlags.Value : 0) | (symbol.flags & ts.SymbolFlags.Type ? ts.SymbolFlags.Type : 0) | (symbol.flags & ts.SymbolFlags.Namespace ? ts.SymbolFlags.Namespace : 0); + var excludedMeanings = (symbol.flags & 107455 /* Value */ ? 107455 /* Value */ : 0) | (symbol.flags & 3152352 /* Type */ ? 3152352 /* Type */ : 0) | (symbol.flags & 1536 /* Namespace */ ? 1536 /* Namespace */ : 0); if (target.flags & excludedMeanings) { error(node, ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0, symbolToString(symbol)); } @@ -15263,7 +15167,7 @@ var ts; } function checkExportAssignment(node) { var container = node.parent; - if (container.kind !== 186 /* SourceFile */) { + if (container.kind !== 193 /* SourceFile */) { container = container.parent; } checkTypeOfExportAssignmentSymbol(getSymbolOfNode(container)); @@ -15272,150 +15176,151 @@ var ts; if (!node) return; switch (node.kind) { - case 118 /* TypeParameter */: + case 122 /* TypeParameter */: return checkTypeParameter(node); - case 119 /* Parameter */: + case 123 /* Parameter */: return checkParameter(node); - case 120 /* Property */: + case 124 /* Property */: return checkPropertyDeclaration(node); - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: return checkSignatureDeclaration(node); - case 121 /* Method */: + case 125 /* Method */: return checkMethodDeclaration(node); - case 122 /* Constructor */: + case 126 /* Constructor */: return checkConstructorDeclaration(node); - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return checkAccessorDeclaration(node); - case 128 /* TypeReference */: + case 132 /* TypeReference */: return checkTypeReference(node); - case 129 /* TypeQuery */: + case 133 /* TypeQuery */: return checkTypeQuery(node); - case 130 /* TypeLiteral */: + case 134 /* TypeLiteral */: return checkTypeLiteral(node); - case 131 /* ArrayType */: + case 135 /* ArrayType */: return checkArrayType(node); - case 132 /* TupleType */: + case 136 /* TupleType */: return checkTupleType(node); - case 133 /* UnionType */: + case 137 /* UnionType */: return checkUnionType(node); - case 134 /* ParenType */: + case 138 /* ParenType */: return checkSourceElement(node.type); - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 151 /* Block */: + case 158 /* Block */: return checkBlock(node); - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: return checkBody(node); - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return checkVariableStatement(node); - case 154 /* ExpressionStatement */: + case 161 /* ExpressionStatement */: return checkExpressionStatement(node); - case 155 /* IfStatement */: + case 162 /* IfStatement */: return checkIfStatement(node); - case 156 /* DoStatement */: + case 163 /* DoStatement */: return checkDoStatement(node); - case 157 /* WhileStatement */: + case 164 /* WhileStatement */: return checkWhileStatement(node); - case 158 /* ForStatement */: + case 165 /* ForStatement */: return checkForStatement(node); - case 159 /* ForInStatement */: + case 166 /* ForInStatement */: return checkForInStatement(node); - case 160 /* ContinueStatement */: - case 161 /* BreakStatement */: + case 167 /* ContinueStatement */: + case 168 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return checkReturnStatement(node); - case 163 /* WithStatement */: + case 170 /* WithStatement */: return checkWithStatement(node); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return checkSwitchStatement(node); - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return checkLabeledStatement(node); - case 168 /* ThrowStatement */: + case 175 /* ThrowStatement */: return checkThrowStatement(node); - case 169 /* TryStatement */: + case 176 /* TryStatement */: return checkTryStatement(node); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: return ts.Debug.fail("Checker encountered variable declaration"); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return checkClassDeclaration(node); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 179 /* TypeAliasDeclaration */: + case 186 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return checkImportDeclaration(node); - case 184 /* ExportAssignment */: + case 191 /* ExportAssignment */: return checkExportAssignment(node); } } function checkFunctionExpressionBodies(node) { switch (node.kind) { - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: ts.forEach(node.parameters, checkFunctionExpressionBodies); checkFunctionExpressionBody(node); break; - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 175 /* FunctionDeclaration */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 182 /* FunctionDeclaration */: ts.forEach(node.parameters, checkFunctionExpressionBodies); break; - case 163 /* WithStatement */: + case 170 /* WithStatement */: checkFunctionExpressionBodies(node.expression); break; - case 119 /* Parameter */: - case 120 /* Property */: - case 135 /* ArrayLiteral */: - case 136 /* ObjectLiteral */: - case 137 /* PropertyAssignment */: - case 138 /* PropertyAccess */: - case 139 /* IndexedAccess */: - case 140 /* CallExpression */: - case 141 /* NewExpression */: - case 142 /* TypeAssertion */: - case 143 /* ParenExpression */: - case 146 /* PrefixOperator */: - case 147 /* PostfixOperator */: - case 148 /* BinaryExpression */: - case 149 /* ConditionalExpression */: - case 151 /* Block */: - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: - case 152 /* VariableStatement */: - case 154 /* ExpressionStatement */: - case 155 /* IfStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 160 /* ContinueStatement */: - case 161 /* BreakStatement */: - case 162 /* ReturnStatement */: - case 164 /* SwitchStatement */: - case 165 /* CaseClause */: - case 166 /* DefaultClause */: - case 167 /* LabeledStatement */: - case 168 /* ThrowStatement */: - case 169 /* TryStatement */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: - case 174 /* VariableDeclaration */: - case 177 /* ClassDeclaration */: - case 180 /* EnumDeclaration */: - case 185 /* EnumMember */: - case 186 /* SourceFile */: + case 123 /* Parameter */: + case 124 /* Property */: + case 139 /* ArrayLiteral */: + case 140 /* ObjectLiteral */: + case 141 /* PropertyAssignment */: + case 142 /* PropertyAccess */: + case 143 /* IndexedAccess */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: + case 146 /* TaggedTemplateExpression */: + case 147 /* TypeAssertion */: + case 148 /* ParenExpression */: + case 151 /* PrefixOperator */: + case 152 /* PostfixOperator */: + case 153 /* BinaryExpression */: + case 154 /* ConditionalExpression */: + case 158 /* Block */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: + case 159 /* VariableStatement */: + case 161 /* ExpressionStatement */: + case 162 /* IfStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 167 /* ContinueStatement */: + case 168 /* BreakStatement */: + case 169 /* ReturnStatement */: + case 171 /* SwitchStatement */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: + case 174 /* LabeledStatement */: + case 175 /* ThrowStatement */: + case 176 /* TryStatement */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: + case 181 /* VariableDeclaration */: + case 184 /* ClassDeclaration */: + case 187 /* EnumDeclaration */: + case 192 /* EnumMember */: + case 193 /* SourceFile */: ts.forEachChild(node, checkFunctionExpressionBodies); break; } @@ -15432,7 +15337,7 @@ var ts; checkBody(node); if (ts.isExternalModule(node)) { var symbol = getExportAssignmentSymbol(node.symbol); - if (symbol && symbol.flags & 16777216 /* Import */) { + if (symbol && symbol.flags & 33554432 /* Import */) { getSymbolLinks(symbol).referenced = true; } } @@ -15486,7 +15391,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 163 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 170 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -15522,27 +15427,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (!ts.isExternalModule(location)) break; - case 181 /* ModuleDeclaration */: - copySymbols(getSymbolOfNode(location).exports, meaning & ts.SymbolFlags.ModuleMember); + case 188 /* ModuleDeclaration */: + copySymbols(getSymbolOfNode(location).exports, meaning & 35653619 /* ModuleMember */); break; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: if (!(memberFlags & 128 /* Static */)) { - copySymbols(getSymbolOfNode(location).members, meaning & ts.SymbolFlags.Type); + copySymbols(getSymbolOfNode(location).members, meaning & 3152352 /* Type */); } break; - case 144 /* FunctionExpression */: + case 149 /* FunctionExpression */: if (location.name) { copySymbol(location.symbol, meaning); } break; - case 171 /* CatchBlock */: + case 178 /* CatchBlock */: if (location.variable.text) { copySymbol(location.symbol, meaning); } @@ -15555,100 +15460,102 @@ var ts; return ts.mapToArray(symbols); } function isTypeDeclarationName(name) { - return name.kind == 59 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; + return name.kind == 63 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 118 /* TypeParameter */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 180 /* EnumDeclaration */: + case 122 /* TypeParameter */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 187 /* EnumDeclaration */: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 117 /* QualifiedName */) + while (node.parent && node.parent.kind === 121 /* QualifiedName */) node = node.parent; - return node.parent && node.parent.kind === 128 /* TypeReference */; + return node.parent && node.parent.kind === 132 /* TypeReference */; } function isTypeNode(node) { - if (ts.SyntaxKind.FirstTypeNode <= node.kind && node.kind <= ts.SyntaxKind.LastTypeNode) { + if (132 /* FirstTypeNode */ <= node.kind && node.kind <= 138 /* LastTypeNode */) { return true; } switch (node.kind) { - case 105 /* AnyKeyword */: - case 112 /* NumberKeyword */: - case 114 /* StringKeyword */: - case 106 /* BooleanKeyword */: + case 109 /* AnyKeyword */: + case 116 /* NumberKeyword */: + case 118 /* StringKeyword */: + case 110 /* BooleanKeyword */: return true; - case 93 /* VoidKeyword */: - return node.parent.kind !== 146 /* PrefixOperator */; + case 97 /* VoidKeyword */: + return node.parent.kind !== 151 /* PrefixOperator */; case 7 /* StringLiteral */: - return node.parent.kind === 119 /* Parameter */; - case 59 /* Identifier */: - if (node.parent.kind === 117 /* QualifiedName */) { + return node.parent.kind === 123 /* Parameter */; + case 63 /* Identifier */: + if (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; } - case 117 /* QualifiedName */: - ts.Debug.assert(node.kind === 59 /* Identifier */ || node.kind === 117 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); + case 121 /* QualifiedName */: + ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */, "'node' was expected to be a qualified name or identifier in 'isTypeNode'."); var parent = node.parent; - if (parent.kind === 129 /* TypeQuery */) { + if (parent.kind === 133 /* TypeQuery */) { return false; } - if (ts.SyntaxKind.FirstTypeNode <= parent.kind && parent.kind <= ts.SyntaxKind.LastTypeNode) { + if (132 /* FirstTypeNode */ <= parent.kind && parent.kind <= 138 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 118 /* TypeParameter */: + case 122 /* TypeParameter */: return node === parent.constraint; - case 120 /* Property */: - case 119 /* Parameter */: - case 174 /* VariableDeclaration */: + case 124 /* Property */: + case 123 /* Parameter */: + case 181 /* VariableDeclaration */: return node === parent.type; - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 122 /* Constructor */: - case 121 /* Method */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 126 /* Constructor */: + case 125 /* Method */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: return node === parent.type; - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: return node === parent.type; - case 142 /* TypeAssertion */: + case 147 /* TypeAssertion */: return node === parent.type; - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return parent.typeArguments && parent.typeArguments.indexOf(node) >= 0; + case 146 /* TaggedTemplateExpression */: + return false; } } return false; } function isInRightSideOfImportOrExportAssignment(node) { - while (node.parent.kind === 117 /* QualifiedName */) { + while (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; } - if (node.parent.kind === 183 /* ImportDeclaration */) { + if (node.parent.kind === 190 /* ImportDeclaration */) { return node.parent.entityName === node; } - if (node.parent.kind === 184 /* ExportAssignment */) { + if (node.parent.kind === 191 /* ExportAssignment */) { return node.parent.exportName === node; } return false; } function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 117 /* QualifiedName */ || node.parent.kind === 138 /* PropertyAccess */) && node.parent.right === node; + return (node.parent.kind === 121 /* QualifiedName */ || node.parent.kind === 142 /* PropertyAccess */) && node.parent.right === node; } function getSymbolOfEntityName(entityName) { if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (entityName.parent.kind === 184 /* ExportAssignment */) { - return resolveEntityName(entityName.parent.parent, entityName, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace | 16777216 /* Import */); + if (entityName.parent.kind === 191 /* ExportAssignment */) { + return resolveEntityName(entityName.parent.parent, entityName, 107455 /* Value */ | 3152352 /* Type */ | 1536 /* Namespace */ | 33554432 /* Import */); } if (isInRightSideOfImportOrExportAssignment(entityName)) { return getSymbolOfPartOfRightHandSideOfImport(entityName); @@ -15657,11 +15564,11 @@ var ts; entityName = entityName.parent; } if (ts.isExpression(entityName)) { - if (entityName.kind === 59 /* Identifier */) { - var meaning = ts.SymbolFlags.Value | 16777216 /* Import */; + if (entityName.kind === 63 /* Identifier */) { + var meaning = 107455 /* Value */ | 33554432 /* Import */; return resolveEntityName(entityName, entityName, meaning); } - else if (entityName.kind === 117 /* QualifiedName */ || entityName.kind === 138 /* PropertyAccess */) { + else if (entityName.kind === 121 /* QualifiedName */ || entityName.kind === 142 /* PropertyAccess */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccess(entityName); @@ -15673,8 +15580,8 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = entityName.parent.kind === 128 /* TypeReference */ ? ts.SymbolFlags.Type : ts.SymbolFlags.Namespace; - meaning |= 16777216 /* Import */; + var meaning = entityName.parent.kind === 132 /* TypeReference */ ? 3152352 /* Type */ : 1536 /* Namespace */; + meaning |= 33554432 /* Import */; return resolveEntityName(entityName, entityName, meaning); } return undefined; @@ -15686,32 +15593,32 @@ var ts; if (ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { return getSymbolOfNode(node.parent); } - if (node.kind === 59 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { - return node.parent.kind === 184 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node); + if (node.kind === 63 /* Identifier */ && isInRightSideOfImportOrExportAssignment(node)) { + return node.parent.kind === 191 /* ExportAssignment */ ? getSymbolOfEntityName(node) : getSymbolOfPartOfRightHandSideOfImport(node); } switch (node.kind) { - case 59 /* Identifier */: - case 138 /* PropertyAccess */: - case 117 /* QualifiedName */: + case 63 /* Identifier */: + case 142 /* PropertyAccess */: + case 121 /* QualifiedName */: return getSymbolOfEntityName(node); - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: var type = checkExpression(node); return type.symbol; - case 107 /* ConstructorKeyword */: + case 111 /* ConstructorKeyword */: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 122 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 126 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; case 7 /* StringLiteral */: - if (node.parent.kind === 183 /* ImportDeclaration */ && node.parent.externalModuleName === node) { + if (node.parent.kind === 190 /* ImportDeclaration */ && node.parent.externalModuleName === node) { var importSymbol = getSymbolOfNode(node.parent); var moduleType = getTypeOfSymbol(importSymbol); return moduleType ? moduleType.symbol : undefined; } case 6 /* NumericLiteral */: - if (node.parent.kind == 139 /* IndexedAccess */ && node.parent.index === node) { + if (node.parent.kind == 143 /* IndexedAccess */ && node.parent.index === node) { var objectType = checkExpression(node.parent.object); if (objectType === unknownType) return undefined; @@ -15776,7 +15683,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (symbol.flags & 536870912 /* UnionProperty */) { + if (symbol.flags & 1073741824 /* UnionProperty */) { var symbols = []; var name = symbol.name; ts.forEach(getSymbolLinks(symbol).unionType.types, function (t) { @@ -15784,7 +15691,7 @@ var ts; }); return symbols; } - else if (symbol.flags & 134217728 /* Transient */) { + else if (symbol.flags & 268435456 /* Transient */) { var target = getSymbolLinks(symbol).target; if (target) { return [target]; @@ -15793,7 +15700,7 @@ var ts; return [symbol]; } function isExternalModuleSymbol(symbol) { - return symbol.flags & 256 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 186 /* SourceFile */; + return symbol.flags & 512 /* ValueModule */ && symbol.declarations.length === 1 && symbol.declarations[0].kind === 193 /* SourceFile */; } function isNodeDescendentOf(node, ancestor) { while (node) { @@ -15805,7 +15712,7 @@ var ts; } function isUniqueLocalName(name, container) { for (var node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && ts.hasProperty(node.locals, name) && node.locals[name].flags & (ts.SymbolFlags.Value | 2097152 /* ExportValue */)) { + if (node.locals && ts.hasProperty(node.locals, name) && node.locals[name].flags & (107455 /* Value */ | 4194304 /* ExportValue */)) { return false; } } @@ -15826,7 +15733,7 @@ var ts; function getLocalNameForSymbol(symbol, location) { var node = location; while (node) { - if ((node.kind === 181 /* ModuleDeclaration */ || node.kind === 180 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { + if ((node.kind === 188 /* ModuleDeclaration */ || node.kind === 187 /* EnumDeclaration */) && getSymbolOfNode(node) === symbol) { return getLocalNameOfContainer(node); } node = node.parent; @@ -15837,7 +15744,7 @@ var ts; var symbol = getNodeLinks(node).resolvedSymbol; if (symbol) { var exportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); - if (symbol !== exportSymbol && !(exportSymbol.flags & ts.SymbolFlags.ExportHasLocal)) { + if (symbol !== exportSymbol && !(exportSymbol.flags & 944 /* ExportHasLocal */)) { symbol = exportSymbol; } if (symbol.parent) { @@ -15847,15 +15754,14 @@ var ts; } function getExportAssignmentName(node) { var symbol = getExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbolIsValue(symbol) ? symbolToString(symbol) : undefined; + return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol) : undefined; } - function isTopLevelValueImportedViaEntityName(node) { - if (node.parent.kind !== 186 /* SourceFile */ || !node.entityName) { + function isTopLevelValueImportWithEntityName(node) { + if (node.parent.kind !== 193 /* SourceFile */ || !node.entityName) { return false; } var symbol = getSymbolOfNode(node); - var target = resolveImport(symbol); - return target !== unknownSymbol && ((target.flags & ts.SymbolFlags.Value) !== 0); + return isImportResolvedToValue(getSymbolOfNode(node)); } function hasSemanticErrors() { return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0; @@ -15863,16 +15769,20 @@ var ts; function hasEarlyErrors(sourceFile) { return ts.forEach(getDiagnostics(sourceFile), function (d) { return d.isEarly; }); } + function isImportResolvedToValue(symbol) { + var target = resolveImport(symbol); + return target !== unknownSymbol && target.flags & 107455 /* Value */ && !isConstEnumOrConstEnumOnlyModule(target); + } + function isConstEnumOrConstEnumOnlyModule(s) { + return isConstEnumSymbol(s) || s.constEnumOnlyModule; + } function isReferencedImportDeclaration(node) { var symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { return true; } if (node.flags & 1 /* Export */) { - var target = resolveImport(symbol); - if (target !== unknownSymbol && target.flags & ts.SymbolFlags.Value) { - return true; - } + return isImportResolvedToValue(symbol); } return false; } @@ -15896,7 +15806,7 @@ var ts; if (symbol && (symbol.flags & 8 /* EnumMember */)) { var declaration = symbol.valueDeclaration; var constantValue; - if (declaration.kind === 185 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { + if (declaration.kind === 192 /* EnumMember */ && (constantValue = getNodeLinks(declaration).enumMemberValue) !== undefined) { return constantValue; } } @@ -15904,7 +15814,7 @@ var ts; } function writeTypeAtLocation(location, enclosingDeclaration, flags, writer) { var symbol = getSymbolOfNode(location); - var type = symbol && !(symbol.flags & 1024 /* TypeLiteral */) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); + var type = symbol && !(symbol.flags & 2048 /* TypeLiteral */) ? getTypeOfSymbol(symbol) : getTypeFromTypeNode(location); getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } function writeReturnTypeOfSignatureDeclaration(signatureDeclaration, enclosingDeclaration, flags, writer) { @@ -15920,7 +15830,7 @@ var ts; isReferencedImportDeclaration: isReferencedImportDeclaration, getNodeCheckFlags: getNodeCheckFlags, getEnumMemberValue: getEnumMemberValue, - isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName, + isTopLevelValueImportWithEntityName: isTopLevelValueImportWithEntityName, hasSemanticErrors: hasSemanticErrors, hasEarlyErrors: hasEarlyErrors, isDeclarationVisible: isDeclarationVisible, @@ -15977,7 +15887,6 @@ var TypeScript; Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", Trailing_comma_not_allowed: "Trailing comma not allowed.", - AsteriskSlash_expected: "'*/' expected.", public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", Unexpected_token: "Unexpected token.", Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", @@ -16059,6 +15968,7 @@ var TypeScript; return_statement_must_be_contained_within_a_function_body: "'return' statement must be contained within a function body.", Expression_expected: "Expression expected.", Type_expected: "Type expected.", + Template_literal_cannot_be_used_as_an_element_name: "Template literal cannot be used as an element name.", Duplicate_identifier_0: "Duplicate identifier '{0}'.", The_name_0_does_not_exist_in_the_current_scope: "The name '{0}' does not exist in the current scope.", The_name_0_does_not_refer_to_a_value: "The name '{0}' does not refer to a value.", @@ -16514,6 +16424,7 @@ var TypeScript; "'return' statement must be contained within a function body.": { "code": 1108, "category": 1 /* Error */ }, "Expression expected.": { "code": 1109, "category": 1 /* Error */ }, "Type expected.": { "code": 1110, "category": 1 /* Error */ }, + "Template literal cannot be used as an element name.": { "code": 1111, "category": 1 /* Error */ }, "Duplicate identifier '{0}'.": { "code": 2000, "category": 1 /* Error */ }, "The name '{0}' does not exist in the current scope.": { "code": 2001, "category": 1 /* Error */ }, "The name '{0}' does not refer to a value.": { "code": 2002, "category": 1 /* Error */ }, @@ -16871,7 +16782,7 @@ var TypeScript; if (array1 === array2) { return true; } - if (array1 === null || array2 === null) { + if (!array1 || !array2) { return false; } if (array1.length !== array2.length) { @@ -16920,7 +16831,7 @@ var TypeScript; return v; } } - return null; + return undefined; }; ArrayUtilities.firstOrDefault = function (array, func) { for (var i = 0, n = array.length; i < n; i++) { @@ -16929,7 +16840,7 @@ var TypeScript; return value; } } - return null; + return undefined; }; ArrayUtilities.first = function (array, func) { for (var i = 0, n = array.length; i < n; i++) { @@ -17043,13 +16954,12 @@ var TypeScript; return this.currentAssertionLevel >= level; }; Debug.assert = function (expression, message, verboseDebugInfo) { - if (message === void 0) { message = ""; } - if (verboseDebugInfo === void 0) { verboseDebugInfo = null; } if (!expression) { var verboseDebugString = ""; if (verboseDebugInfo) { verboseDebugString = "\r\nVerbose Debug Information:" + verboseDebugInfo(); } + message = message || ""; throw new Error("Debug Failure. False expression: " + message + verboseDebugString); } }; @@ -17103,12 +17013,10 @@ var TypeScript; var Diagnostic = (function (_super) { __extends(Diagnostic, _super); function Diagnostic(fileName, lineMap, start, length, diagnosticKey, _arguments, additionalLocations) { - if (_arguments === void 0) { _arguments = null; } - if (additionalLocations === void 0) { additionalLocations = null; } _super.call(this, fileName, lineMap, start, length); this._diagnosticKey = diagnosticKey; - this._arguments = (_arguments && _arguments.length > 0) ? _arguments : null; - this._additionalLocations = (additionalLocations && additionalLocations.length > 0) ? additionalLocations : null; + this._arguments = (_arguments && _arguments.length > 0) ? _arguments : undefined; + this._additionalLocations = (additionalLocations && additionalLocations.length > 0) ? additionalLocations : undefined; } Diagnostic.prototype.toJSON = function (key) { var result = {}; @@ -17260,7 +17168,7 @@ var TypeScript; function LineMap(_computeLineStarts, length) { this._computeLineStarts = _computeLineStarts; this.length = length; - this._lineStarts = null; + this._lineStarts = undefined; } LineMap.prototype.toJSON = function (key) { return { lineStarts: this.lineStarts(), length: this.length }; @@ -17269,7 +17177,7 @@ var TypeScript; return this.length === other.length && TypeScript.ArrayUtilities.sequenceEquals(this.lineStarts(), other.lineStarts(), function (v1, v2) { return v1 === v2; }); }; LineMap.prototype.lineStarts = function () { - if (this._lineStarts === null) { + if (!this._lineStarts) { this._lineStarts = this._computeLineStarts(); } return this._lineStarts; @@ -17456,6 +17364,7 @@ var TypeScript; CharacterCodes[CharacterCodes["asterisk"] = 42] = "asterisk"; CharacterCodes[CharacterCodes["at"] = 64] = "at"; CharacterCodes[CharacterCodes["backslash"] = 92] = "backslash"; + CharacterCodes[CharacterCodes["backtick"] = 96] = "backtick"; CharacterCodes[CharacterCodes["bar"] = 124] = "bar"; CharacterCodes[CharacterCodes["caret"] = 94] = "caret"; CharacterCodes[CharacterCodes["closeBrace"] = 125] = "closeBrace"; @@ -17495,7 +17404,7 @@ var TypeScript; var StringScriptSnapshot = (function () { function StringScriptSnapshot(text) { this.text = text; - this._lineStartPositions = null; + this._lineStartPositions = undefined; } StringScriptSnapshot.prototype.getText = function (start, end) { return this.text.substring(start, end); @@ -17545,13 +17454,14 @@ var TypeScript; var SimpleStringText = (function () { function SimpleStringText(value) { this.value = value; - this._lineMap = null; + this._lineMap = undefined; } SimpleStringText.prototype.length = function () { return this.value.length; }; SimpleStringText.prototype.substr = function (start, length) { - return this.value.substr(start, length); + var val = this.value; + return start === 0 && length == val.length ? val : val.substr(start, length); }; SimpleStringText.prototype.charCodeAt = function (index) { return this.value.charCodeAt(index); @@ -17567,7 +17477,7 @@ var TypeScript; var SimpleScriptSnapshotText = (function () { function SimpleScriptSnapshotText(scriptSnapshot) { this.scriptSnapshot = scriptSnapshot; - this._lineMap = null; + this._lineMap = undefined; } SimpleScriptSnapshotText.prototype.charCodeAt = function (index) { return this.scriptSnapshot.getText(index, index + 1).charCodeAt(0); @@ -17580,7 +17490,7 @@ var TypeScript; }; SimpleScriptSnapshotText.prototype.lineMap = function () { var _this = this; - if (this._lineMap === null) { + if (!this._lineMap) { this._lineMap = new TypeScript.LineMap(function () { return _this.scriptSnapshot.getLineStartPositions(); }, this.length()); } return this._lineMap; @@ -17714,7 +17624,7 @@ var TypeScript; if (overlapStart < overlapEnd) { return TextSpan.fromBounds(overlapStart, overlapEnd); } - return null; + return undefined; }; TextSpan.prototype.intersectsWithTextSpan = function (span) { return span._start <= this.end() && span.end() >= this._start; @@ -17732,7 +17642,7 @@ var TypeScript; if (intersectStart <= intersectEnd) { return TextSpan.fromBounds(intersectStart, intersectEnd); } - return null; + return undefined; }; TextSpan.fromBounds = function (start, end) { TypeScript.Debug.assert(start >= 0); @@ -17885,252 +17795,217 @@ var TypeScript; (function (SyntaxKind) { SyntaxKind[SyntaxKind["None"] = 0] = "None"; SyntaxKind[SyntaxKind["List"] = 1] = "List"; - SyntaxKind[SyntaxKind["SeparatedList"] = 2] = "SeparatedList"; - SyntaxKind[SyntaxKind["TriviaList"] = 3] = "TriviaList"; - SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 4] = "WhitespaceTrivia"; - SyntaxKind[SyntaxKind["NewLineTrivia"] = 5] = "NewLineTrivia"; - SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 6] = "MultiLineCommentTrivia"; - SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 7] = "SingleLineCommentTrivia"; - SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 8] = "SkippedTokenTrivia"; - SyntaxKind[SyntaxKind["ErrorToken"] = 9] = "ErrorToken"; - SyntaxKind[SyntaxKind["EndOfFileToken"] = 10] = "EndOfFileToken"; - SyntaxKind[SyntaxKind["IdentifierName"] = 11] = "IdentifierName"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NumericLiteral"] = 13] = "NumericLiteral"; - SyntaxKind[SyntaxKind["StringLiteral"] = 14] = "StringLiteral"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 15] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 16] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 17] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 18] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 19] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 20] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 21] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 22] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 23] = "ElseKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 24] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 25] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 26] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 27] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 28] = "IfKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 29] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 30] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 31] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 32] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 33] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 34] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 35] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 36] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 37] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 38] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 39] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 40] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 41] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 42] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 43] = "WithKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 44] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 45] = "ConstKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 46] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 47] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 48] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 49] = "ImportKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 50] = "SuperKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 51] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 52] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 53] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 54] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 55] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 56] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 57] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 58] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 59] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 60] = "AnyKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 61] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 62] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 63] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 64] = "GetKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 65] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 66] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 67] = "NumberKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 68] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 69] = "StringKeyword"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 70] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 71] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 72] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 73] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 74] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 75] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 76] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 77] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 78] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 79] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 80] = "LessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 81] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 82] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 83] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 84] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 85] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 86] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 87] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 88] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 89] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 90] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 91] = "AsteriskToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 92] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 93] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 94] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 95] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 96] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 97] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 98] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 99] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 100] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 101] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 102] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 103] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 104] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 105] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 106] = "ColonToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 107] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 108] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 109] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 110] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 111] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 112] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 113] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 114] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 115] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 116] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 117] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 118] = "SlashToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 119] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["SourceUnit"] = 120] = "SourceUnit"; - SyntaxKind[SyntaxKind["QualifiedName"] = 121] = "QualifiedName"; - SyntaxKind[SyntaxKind["ObjectType"] = 122] = "ObjectType"; - SyntaxKind[SyntaxKind["FunctionType"] = 123] = "FunctionType"; - SyntaxKind[SyntaxKind["ArrayType"] = 124] = "ArrayType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 125] = "ConstructorType"; - SyntaxKind[SyntaxKind["GenericType"] = 126] = "GenericType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 127] = "TypeQuery"; - SyntaxKind[SyntaxKind["TupleType"] = 128] = "TupleType"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 129] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 130] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 131] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 132] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 133] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 134] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 135] = "ExportAssignment"; - SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 136] = "MemberFunctionDeclaration"; - SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 137] = "MemberVariableDeclaration"; - SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 138] = "ConstructorDeclaration"; - SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 139] = "IndexMemberDeclaration"; - SyntaxKind[SyntaxKind["GetAccessor"] = 140] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 141] = "SetAccessor"; - SyntaxKind[SyntaxKind["PropertySignature"] = 142] = "PropertySignature"; - SyntaxKind[SyntaxKind["CallSignature"] = 143] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 144] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 145] = "IndexSignature"; - SyntaxKind[SyntaxKind["MethodSignature"] = 146] = "MethodSignature"; - SyntaxKind[SyntaxKind["Block"] = 147] = "Block"; - SyntaxKind[SyntaxKind["IfStatement"] = 148] = "IfStatement"; - SyntaxKind[SyntaxKind["VariableStatement"] = 149] = "VariableStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 150] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 151] = "ReturnStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 152] = "SwitchStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 153] = "BreakStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 154] = "ContinueStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 155] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 156] = "ForInStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 157] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 158] = "ThrowStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 159] = "WhileStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 160] = "TryStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 161] = "LabeledStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 162] = "DoStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 163] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 164] = "WithStatement"; - SyntaxKind[SyntaxKind["PlusExpression"] = 165] = "PlusExpression"; - SyntaxKind[SyntaxKind["NegateExpression"] = 166] = "NegateExpression"; - SyntaxKind[SyntaxKind["BitwiseNotExpression"] = 167] = "BitwiseNotExpression"; - SyntaxKind[SyntaxKind["LogicalNotExpression"] = 168] = "LogicalNotExpression"; - SyntaxKind[SyntaxKind["PreIncrementExpression"] = 169] = "PreIncrementExpression"; - SyntaxKind[SyntaxKind["PreDecrementExpression"] = 170] = "PreDecrementExpression"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 171] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 172] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 173] = "VoidExpression"; - SyntaxKind[SyntaxKind["CommaExpression"] = 174] = "CommaExpression"; - SyntaxKind[SyntaxKind["AssignmentExpression"] = 175] = "AssignmentExpression"; - SyntaxKind[SyntaxKind["AddAssignmentExpression"] = 176] = "AddAssignmentExpression"; - SyntaxKind[SyntaxKind["SubtractAssignmentExpression"] = 177] = "SubtractAssignmentExpression"; - SyntaxKind[SyntaxKind["MultiplyAssignmentExpression"] = 178] = "MultiplyAssignmentExpression"; - SyntaxKind[SyntaxKind["DivideAssignmentExpression"] = 179] = "DivideAssignmentExpression"; - SyntaxKind[SyntaxKind["ModuloAssignmentExpression"] = 180] = "ModuloAssignmentExpression"; - SyntaxKind[SyntaxKind["AndAssignmentExpression"] = 181] = "AndAssignmentExpression"; - SyntaxKind[SyntaxKind["ExclusiveOrAssignmentExpression"] = 182] = "ExclusiveOrAssignmentExpression"; - SyntaxKind[SyntaxKind["OrAssignmentExpression"] = 183] = "OrAssignmentExpression"; - SyntaxKind[SyntaxKind["LeftShiftAssignmentExpression"] = 184] = "LeftShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftAssignmentExpression"] = 185] = "SignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftAssignmentExpression"] = 186] = "UnsignedRightShiftAssignmentExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 187] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["LogicalOrExpression"] = 188] = "LogicalOrExpression"; - SyntaxKind[SyntaxKind["LogicalAndExpression"] = 189] = "LogicalAndExpression"; - SyntaxKind[SyntaxKind["BitwiseOrExpression"] = 190] = "BitwiseOrExpression"; - SyntaxKind[SyntaxKind["BitwiseExclusiveOrExpression"] = 191] = "BitwiseExclusiveOrExpression"; - SyntaxKind[SyntaxKind["BitwiseAndExpression"] = 192] = "BitwiseAndExpression"; - SyntaxKind[SyntaxKind["EqualsWithTypeConversionExpression"] = 193] = "EqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["NotEqualsWithTypeConversionExpression"] = 194] = "NotEqualsWithTypeConversionExpression"; - SyntaxKind[SyntaxKind["EqualsExpression"] = 195] = "EqualsExpression"; - SyntaxKind[SyntaxKind["NotEqualsExpression"] = 196] = "NotEqualsExpression"; - SyntaxKind[SyntaxKind["LessThanExpression"] = 197] = "LessThanExpression"; - SyntaxKind[SyntaxKind["GreaterThanExpression"] = 198] = "GreaterThanExpression"; - SyntaxKind[SyntaxKind["LessThanOrEqualExpression"] = 199] = "LessThanOrEqualExpression"; - SyntaxKind[SyntaxKind["GreaterThanOrEqualExpression"] = 200] = "GreaterThanOrEqualExpression"; - SyntaxKind[SyntaxKind["InstanceOfExpression"] = 201] = "InstanceOfExpression"; - SyntaxKind[SyntaxKind["InExpression"] = 202] = "InExpression"; - SyntaxKind[SyntaxKind["LeftShiftExpression"] = 203] = "LeftShiftExpression"; - SyntaxKind[SyntaxKind["SignedRightShiftExpression"] = 204] = "SignedRightShiftExpression"; - SyntaxKind[SyntaxKind["UnsignedRightShiftExpression"] = 205] = "UnsignedRightShiftExpression"; - SyntaxKind[SyntaxKind["MultiplyExpression"] = 206] = "MultiplyExpression"; - SyntaxKind[SyntaxKind["DivideExpression"] = 207] = "DivideExpression"; - SyntaxKind[SyntaxKind["ModuloExpression"] = 208] = "ModuloExpression"; - SyntaxKind[SyntaxKind["AddExpression"] = 209] = "AddExpression"; - SyntaxKind[SyntaxKind["SubtractExpression"] = 210] = "SubtractExpression"; - SyntaxKind[SyntaxKind["PostIncrementExpression"] = 211] = "PostIncrementExpression"; - SyntaxKind[SyntaxKind["PostDecrementExpression"] = 212] = "PostDecrementExpression"; - SyntaxKind[SyntaxKind["MemberAccessExpression"] = 213] = "MemberAccessExpression"; - SyntaxKind[SyntaxKind["InvocationExpression"] = 214] = "InvocationExpression"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 215] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 216] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 217] = "ObjectCreationExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 218] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 219] = "ParenthesizedArrowFunctionExpression"; - SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 220] = "SimpleArrowFunctionExpression"; - SyntaxKind[SyntaxKind["CastExpression"] = 221] = "CastExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 222] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 223] = "FunctionExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 224] = "OmittedExpression"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarator"] = 226] = "VariableDeclarator"; - SyntaxKind[SyntaxKind["ArgumentList"] = 227] = "ArgumentList"; - SyntaxKind[SyntaxKind["ParameterList"] = 228] = "ParameterList"; - SyntaxKind[SyntaxKind["TypeArgumentList"] = 229] = "TypeArgumentList"; - SyntaxKind[SyntaxKind["TypeParameterList"] = 230] = "TypeParameterList"; - SyntaxKind[SyntaxKind["ExtendsHeritageClause"] = 231] = "ExtendsHeritageClause"; - SyntaxKind[SyntaxKind["ImplementsHeritageClause"] = 232] = "ImplementsHeritageClause"; - SyntaxKind[SyntaxKind["EqualsValueClause"] = 233] = "EqualsValueClause"; - SyntaxKind[SyntaxKind["CaseSwitchClause"] = 234] = "CaseSwitchClause"; - SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 235] = "DefaultSwitchClause"; - SyntaxKind[SyntaxKind["ElseClause"] = 236] = "ElseClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 237] = "CatchClause"; - SyntaxKind[SyntaxKind["FinallyClause"] = 238] = "FinallyClause"; - SyntaxKind[SyntaxKind["TypeParameter"] = 239] = "TypeParameter"; - SyntaxKind[SyntaxKind["Constraint"] = 240] = "Constraint"; - SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 241] = "SimplePropertyAssignment"; - SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 242] = "FunctionPropertyAssignment"; - SyntaxKind[SyntaxKind["Parameter"] = 243] = "Parameter"; - SyntaxKind[SyntaxKind["EnumElement"] = 244] = "EnumElement"; - SyntaxKind[SyntaxKind["TypeAnnotation"] = 245] = "TypeAnnotation"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 246] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 247] = "ModuleNameModuleReference"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 2] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 3] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 4] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 5] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 6] = "SkippedTokenTrivia"; + SyntaxKind[SyntaxKind["ErrorToken"] = 7] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 8] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["IdentifierName"] = 9] = "IdentifierName"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 12] = "StringLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateToken"] = 13] = "NoSubstitutionTemplateToken"; + SyntaxKind[SyntaxKind["TemplateStartToken"] = 14] = "TemplateStartToken"; + SyntaxKind[SyntaxKind["TemplateMiddleToken"] = 15] = "TemplateMiddleToken"; + SyntaxKind[SyntaxKind["TemplateEndToken"] = 16] = "TemplateEndToken"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 17] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 18] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 19] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 20] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 21] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 22] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 23] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 24] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 25] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 26] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 27] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 28] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 29] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 30] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 31] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 32] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 33] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 34] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 35] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 36] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 37] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 38] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 39] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 40] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 41] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 42] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 43] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 44] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 45] = "WithKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 46] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 47] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 48] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 49] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 50] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 51] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 52] = "SuperKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 53] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 54] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 55] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 56] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 57] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 58] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 59] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 60] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 61] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 62] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 63] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 64] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 65] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 66] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 67] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 68] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 69] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 70] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 71] = "StringKeyword"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 72] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 73] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 74] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 75] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 76] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 77] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 78] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 79] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 80] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 81] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 82] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 83] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 84] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 85] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 86] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 87] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 88] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 89] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 90] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 91] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 92] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 93] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 94] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 95] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 96] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 97] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 98] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 99] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 100] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 101] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 102] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 103] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 104] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 105] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 106] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 107] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 108] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 109] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 110] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 111] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 112] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 113] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 114] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 115] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 116] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 117] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 118] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 119] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 120] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 121] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["SourceUnit"] = 122] = "SourceUnit"; + SyntaxKind[SyntaxKind["QualifiedName"] = 123] = "QualifiedName"; + SyntaxKind[SyntaxKind["ObjectType"] = 124] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 125] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 126] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 127] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 128] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 129] = "TypeQuery"; + SyntaxKind[SyntaxKind["TupleType"] = 130] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 131] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 132] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 133] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 134] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 135] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 136] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 137] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 138] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 139] = "ExportAssignment"; + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 140] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 141] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 142] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 143] = "IndexMemberDeclaration"; + SyntaxKind[SyntaxKind["GetAccessor"] = 144] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 145] = "SetAccessor"; + SyntaxKind[SyntaxKind["PropertySignature"] = 146] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 150] = "MethodSignature"; + SyntaxKind[SyntaxKind["Block"] = 151] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 152] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 153] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 154] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 155] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 156] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 157] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 158] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 159] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 160] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 161] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 162] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 163] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 164] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 165] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 166] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 167] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 168] = "WithStatement"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 169] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 173] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 174] = "BinaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 175] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 176] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 177] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 178] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 179] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 180] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 181] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 182] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 183] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 184] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 185] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 186] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 188] = "TemplateExpression"; + SyntaxKind[SyntaxKind["TemplateAccessExpression"] = 189] = "TemplateAccessExpression"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 190] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 191] = "VariableDeclarator"; + SyntaxKind[SyntaxKind["ArgumentList"] = 192] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 193] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 194] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 195] = "TypeParameterList"; + SyntaxKind[SyntaxKind["HeritageClause"] = 196] = "HeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 197] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 198] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 199] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 200] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 201] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 202] = "FinallyClause"; + SyntaxKind[SyntaxKind["TemplateClause"] = 203] = "TemplateClause"; + SyntaxKind[SyntaxKind["TypeParameter"] = 204] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 205] = "Constraint"; + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 206] = "SimplePropertyAssignment"; + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 207] = "FunctionPropertyAssignment"; + SyntaxKind[SyntaxKind["Parameter"] = 208] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 209] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 210] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 211] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 212] = "ModuleNameModuleReference"; SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; @@ -18159,111 +18034,111 @@ var TypeScript; var SyntaxFacts; (function (SyntaxFacts) { var textToKeywordKind = { - "any": 60 /* AnyKeyword */, - "boolean": 61 /* BooleanKeyword */, - "break": 15 /* BreakKeyword */, - "case": 16 /* CaseKeyword */, - "catch": 17 /* CatchKeyword */, - "class": 44 /* ClassKeyword */, - "continue": 18 /* ContinueKeyword */, - "const": 45 /* ConstKeyword */, - "constructor": 62 /* ConstructorKeyword */, - "debugger": 19 /* DebuggerKeyword */, - "declare": 63 /* DeclareKeyword */, - "default": 20 /* DefaultKeyword */, - "delete": 21 /* DeleteKeyword */, - "do": 22 /* DoKeyword */, - "else": 23 /* ElseKeyword */, - "enum": 46 /* EnumKeyword */, - "export": 47 /* ExportKeyword */, - "extends": 48 /* ExtendsKeyword */, - "false": 24 /* FalseKeyword */, - "finally": 25 /* FinallyKeyword */, - "for": 26 /* ForKeyword */, - "function": 27 /* FunctionKeyword */, - "get": 64 /* GetKeyword */, - "if": 28 /* IfKeyword */, - "implements": 51 /* ImplementsKeyword */, - "import": 49 /* ImportKeyword */, - "in": 29 /* InKeyword */, - "instanceof": 30 /* InstanceOfKeyword */, - "interface": 52 /* InterfaceKeyword */, - "let": 53 /* LetKeyword */, - "module": 65 /* ModuleKeyword */, - "new": 31 /* NewKeyword */, - "null": 32 /* NullKeyword */, - "number": 67 /* NumberKeyword */, - "package": 54 /* PackageKeyword */, - "private": 55 /* PrivateKeyword */, - "protected": 56 /* ProtectedKeyword */, - "public": 57 /* PublicKeyword */, - "require": 66 /* RequireKeyword */, - "return": 33 /* ReturnKeyword */, - "set": 68 /* SetKeyword */, - "static": 58 /* StaticKeyword */, - "string": 69 /* StringKeyword */, - "super": 50 /* SuperKeyword */, - "switch": 34 /* SwitchKeyword */, - "this": 35 /* ThisKeyword */, - "throw": 36 /* ThrowKeyword */, - "true": 37 /* TrueKeyword */, - "try": 38 /* TryKeyword */, - "typeof": 39 /* TypeOfKeyword */, - "var": 40 /* VarKeyword */, - "void": 41 /* VoidKeyword */, - "while": 42 /* WhileKeyword */, - "with": 43 /* WithKeyword */, - "yield": 59 /* YieldKeyword */, - "{": 70 /* OpenBraceToken */, - "}": 71 /* CloseBraceToken */, - "(": 72 /* OpenParenToken */, - ")": 73 /* CloseParenToken */, - "[": 74 /* OpenBracketToken */, - "]": 75 /* CloseBracketToken */, - ".": 76 /* DotToken */, - "...": 77 /* DotDotDotToken */, - ";": 78 /* SemicolonToken */, - ",": 79 /* CommaToken */, - "<": 80 /* LessThanToken */, - ">": 81 /* GreaterThanToken */, - "<=": 82 /* LessThanEqualsToken */, - ">=": 83 /* GreaterThanEqualsToken */, - "==": 84 /* EqualsEqualsToken */, - "=>": 85 /* EqualsGreaterThanToken */, - "!=": 86 /* ExclamationEqualsToken */, - "===": 87 /* EqualsEqualsEqualsToken */, - "!==": 88 /* ExclamationEqualsEqualsToken */, - "+": 89 /* PlusToken */, - "-": 90 /* MinusToken */, - "*": 91 /* AsteriskToken */, - "%": 92 /* PercentToken */, - "++": 93 /* PlusPlusToken */, - "--": 94 /* MinusMinusToken */, - "<<": 95 /* LessThanLessThanToken */, - ">>": 96 /* GreaterThanGreaterThanToken */, - ">>>": 97 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 98 /* AmpersandToken */, - "|": 99 /* BarToken */, - "^": 100 /* CaretToken */, - "!": 101 /* ExclamationToken */, - "~": 102 /* TildeToken */, - "&&": 103 /* AmpersandAmpersandToken */, - "||": 104 /* BarBarToken */, - "?": 105 /* QuestionToken */, - ":": 106 /* ColonToken */, - "=": 107 /* EqualsToken */, - "+=": 108 /* PlusEqualsToken */, - "-=": 109 /* MinusEqualsToken */, - "*=": 110 /* AsteriskEqualsToken */, - "%=": 111 /* PercentEqualsToken */, - "<<=": 112 /* LessThanLessThanEqualsToken */, - ">>=": 113 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 115 /* AmpersandEqualsToken */, - "|=": 116 /* BarEqualsToken */, - "^=": 117 /* CaretEqualsToken */, - "/": 118 /* SlashToken */, - "/=": 119 /* SlashEqualsToken */ + "any": 62 /* AnyKeyword */, + "boolean": 63 /* BooleanKeyword */, + "break": 17 /* BreakKeyword */, + "case": 18 /* CaseKeyword */, + "catch": 19 /* CatchKeyword */, + "class": 46 /* ClassKeyword */, + "continue": 20 /* ContinueKeyword */, + "const": 47 /* ConstKeyword */, + "constructor": 64 /* ConstructorKeyword */, + "debugger": 21 /* DebuggerKeyword */, + "declare": 65 /* DeclareKeyword */, + "default": 22 /* DefaultKeyword */, + "delete": 23 /* DeleteKeyword */, + "do": 24 /* DoKeyword */, + "else": 25 /* ElseKeyword */, + "enum": 48 /* EnumKeyword */, + "export": 49 /* ExportKeyword */, + "extends": 50 /* ExtendsKeyword */, + "false": 26 /* FalseKeyword */, + "finally": 27 /* FinallyKeyword */, + "for": 28 /* ForKeyword */, + "function": 29 /* FunctionKeyword */, + "get": 66 /* GetKeyword */, + "if": 30 /* IfKeyword */, + "implements": 53 /* ImplementsKeyword */, + "import": 51 /* ImportKeyword */, + "in": 31 /* InKeyword */, + "instanceof": 32 /* InstanceOfKeyword */, + "interface": 54 /* InterfaceKeyword */, + "let": 55 /* LetKeyword */, + "module": 67 /* ModuleKeyword */, + "new": 33 /* NewKeyword */, + "null": 34 /* NullKeyword */, + "number": 69 /* NumberKeyword */, + "package": 56 /* PackageKeyword */, + "private": 57 /* PrivateKeyword */, + "protected": 58 /* ProtectedKeyword */, + "public": 59 /* PublicKeyword */, + "require": 68 /* RequireKeyword */, + "return": 35 /* ReturnKeyword */, + "set": 70 /* SetKeyword */, + "static": 60 /* StaticKeyword */, + "string": 71 /* StringKeyword */, + "super": 52 /* SuperKeyword */, + "switch": 36 /* SwitchKeyword */, + "this": 37 /* ThisKeyword */, + "throw": 38 /* ThrowKeyword */, + "true": 39 /* TrueKeyword */, + "try": 40 /* TryKeyword */, + "typeof": 41 /* TypeOfKeyword */, + "var": 42 /* VarKeyword */, + "void": 43 /* VoidKeyword */, + "while": 44 /* WhileKeyword */, + "with": 45 /* WithKeyword */, + "yield": 61 /* YieldKeyword */, + "{": 72 /* OpenBraceToken */, + "}": 73 /* CloseBraceToken */, + "(": 74 /* OpenParenToken */, + ")": 75 /* CloseParenToken */, + "[": 76 /* OpenBracketToken */, + "]": 77 /* CloseBracketToken */, + ".": 78 /* DotToken */, + "...": 79 /* DotDotDotToken */, + ";": 80 /* SemicolonToken */, + ",": 81 /* CommaToken */, + "<": 82 /* LessThanToken */, + ">": 83 /* GreaterThanToken */, + "<=": 84 /* LessThanEqualsToken */, + ">=": 85 /* GreaterThanEqualsToken */, + "==": 86 /* EqualsEqualsToken */, + "=>": 87 /* EqualsGreaterThanToken */, + "!=": 88 /* ExclamationEqualsToken */, + "===": 89 /* EqualsEqualsEqualsToken */, + "!==": 90 /* ExclamationEqualsEqualsToken */, + "+": 91 /* PlusToken */, + "-": 92 /* MinusToken */, + "*": 93 /* AsteriskToken */, + "%": 94 /* PercentToken */, + "++": 95 /* PlusPlusToken */, + "--": 96 /* MinusMinusToken */, + "<<": 97 /* LessThanLessThanToken */, + ">>": 98 /* GreaterThanGreaterThanToken */, + ">>>": 99 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 100 /* AmpersandToken */, + "|": 101 /* BarToken */, + "^": 102 /* CaretToken */, + "!": 103 /* ExclamationToken */, + "~": 104 /* TildeToken */, + "&&": 105 /* AmpersandAmpersandToken */, + "||": 106 /* BarBarToken */, + "?": 107 /* QuestionToken */, + ":": 108 /* ColonToken */, + "=": 109 /* EqualsToken */, + "+=": 110 /* PlusEqualsToken */, + "-=": 111 /* MinusEqualsToken */, + "*=": 112 /* AsteriskEqualsToken */, + "%=": 113 /* PercentEqualsToken */, + "<<=": 114 /* LessThanLessThanEqualsToken */, + ">>=": 115 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 117 /* AmpersandEqualsToken */, + "|=": 118 /* BarEqualsToken */, + "^=": 119 /* CaretEqualsToken */, + "/": 120 /* SlashToken */, + "/=": 121 /* SlashEqualsToken */ }; var kindToText = new Array(); for (var name in textToKeywordKind) { @@ -18271,7 +18146,7 @@ var TypeScript; kindToText[textToKeywordKind[name]] = name; } } - kindToText[62 /* ConstructorKeyword */] = "constructor"; + kindToText[64 /* ConstructorKeyword */] = "constructor"; function getTokenKind(text) { if (textToKeywordKind.hasOwnProperty(text)) { return textToKeywordKind[text]; @@ -18281,7 +18156,7 @@ var TypeScript; SyntaxFacts.getTokenKind = getTokenKind; function getText(kind) { var result = kindToText[kind]; - return result !== undefined ? result : null; + return result; } SyntaxFacts.getText = getText; function isAnyKeyword(kind) { @@ -18293,215 +18168,77 @@ var TypeScript; } SyntaxFacts.isAnyPunctuation = isAnyPunctuation; function isPrefixUnaryExpressionOperatorToken(tokenKind) { - return getPrefixUnaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + switch (tokenKind) { + case 91 /* PlusToken */: + case 92 /* MinusToken */: + case 104 /* TildeToken */: + case 103 /* ExclamationToken */: + case 95 /* PlusPlusToken */: + case 96 /* MinusMinusToken */: + return true; + default: + return false; + } } SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; function isBinaryExpressionOperatorToken(tokenKind) { - return getBinaryExpressionFromOperatorToken(tokenKind) !== 0 /* None */; + switch (tokenKind) { + case 93 /* AsteriskToken */: + case 120 /* SlashToken */: + case 94 /* PercentToken */: + case 91 /* PlusToken */: + case 92 /* MinusToken */: + case 97 /* LessThanLessThanToken */: + case 98 /* GreaterThanGreaterThanToken */: + case 99 /* GreaterThanGreaterThanGreaterThanToken */: + case 82 /* LessThanToken */: + case 83 /* GreaterThanToken */: + case 84 /* LessThanEqualsToken */: + case 85 /* GreaterThanEqualsToken */: + case 32 /* InstanceOfKeyword */: + case 31 /* InKeyword */: + case 86 /* EqualsEqualsToken */: + case 88 /* ExclamationEqualsToken */: + case 89 /* EqualsEqualsEqualsToken */: + case 90 /* ExclamationEqualsEqualsToken */: + case 100 /* AmpersandToken */: + case 102 /* CaretToken */: + case 101 /* BarToken */: + case 105 /* AmpersandAmpersandToken */: + case 106 /* BarBarToken */: + case 118 /* BarEqualsToken */: + case 117 /* AmpersandEqualsToken */: + case 119 /* CaretEqualsToken */: + case 114 /* LessThanLessThanEqualsToken */: + case 115 /* GreaterThanGreaterThanEqualsToken */: + case 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 110 /* PlusEqualsToken */: + case 111 /* MinusEqualsToken */: + case 112 /* AsteriskEqualsToken */: + case 121 /* SlashEqualsToken */: + case 113 /* PercentEqualsToken */: + case 109 /* EqualsToken */: + case 81 /* CommaToken */: + return true; + default: + return false; + } } SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; - function getPrefixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 89 /* PlusToken */: - return 165 /* PlusExpression */; - case 90 /* MinusToken */: - return 166 /* NegateExpression */; - case 102 /* TildeToken */: - return 167 /* BitwiseNotExpression */; - case 101 /* ExclamationToken */: - return 168 /* LogicalNotExpression */; - case 93 /* PlusPlusToken */: - return 169 /* PreIncrementExpression */; - case 94 /* MinusMinusToken */: - return 170 /* PreDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken = getPrefixUnaryExpressionFromOperatorToken; - function getPostfixUnaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 93 /* PlusPlusToken */: - return 211 /* PostIncrementExpression */; - case 94 /* MinusMinusToken */: - return 212 /* PostDecrementExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken = getPostfixUnaryExpressionFromOperatorToken; - function getBinaryExpressionFromOperatorToken(tokenKind) { - switch (tokenKind) { - case 91 /* AsteriskToken */: - return 206 /* MultiplyExpression */; - case 118 /* SlashToken */: - return 207 /* DivideExpression */; - case 92 /* PercentToken */: - return 208 /* ModuloExpression */; - case 89 /* PlusToken */: - return 209 /* AddExpression */; - case 90 /* MinusToken */: - return 210 /* SubtractExpression */; - case 95 /* LessThanLessThanToken */: - return 203 /* LeftShiftExpression */; - case 96 /* GreaterThanGreaterThanToken */: - return 204 /* SignedRightShiftExpression */; - case 97 /* GreaterThanGreaterThanGreaterThanToken */: - return 205 /* UnsignedRightShiftExpression */; - case 80 /* LessThanToken */: - return 197 /* LessThanExpression */; - case 81 /* GreaterThanToken */: - return 198 /* GreaterThanExpression */; - case 82 /* LessThanEqualsToken */: - return 199 /* LessThanOrEqualExpression */; - case 83 /* GreaterThanEqualsToken */: - return 200 /* GreaterThanOrEqualExpression */; - case 30 /* InstanceOfKeyword */: - return 201 /* InstanceOfExpression */; - case 29 /* InKeyword */: - return 202 /* InExpression */; - case 84 /* EqualsEqualsToken */: - return 193 /* EqualsWithTypeConversionExpression */; - case 86 /* ExclamationEqualsToken */: - return 194 /* NotEqualsWithTypeConversionExpression */; - case 87 /* EqualsEqualsEqualsToken */: - return 195 /* EqualsExpression */; - case 88 /* ExclamationEqualsEqualsToken */: - return 196 /* NotEqualsExpression */; - case 98 /* AmpersandToken */: - return 192 /* BitwiseAndExpression */; - case 100 /* CaretToken */: - return 191 /* BitwiseExclusiveOrExpression */; - case 99 /* BarToken */: - return 190 /* BitwiseOrExpression */; - case 103 /* AmpersandAmpersandToken */: - return 189 /* LogicalAndExpression */; - case 104 /* BarBarToken */: - return 188 /* LogicalOrExpression */; - case 116 /* BarEqualsToken */: - return 183 /* OrAssignmentExpression */; - case 115 /* AmpersandEqualsToken */: - return 181 /* AndAssignmentExpression */; - case 117 /* CaretEqualsToken */: - return 182 /* ExclusiveOrAssignmentExpression */; - case 112 /* LessThanLessThanEqualsToken */: - return 184 /* LeftShiftAssignmentExpression */; - case 113 /* GreaterThanGreaterThanEqualsToken */: - return 185 /* SignedRightShiftAssignmentExpression */; - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - return 186 /* UnsignedRightShiftAssignmentExpression */; - case 108 /* PlusEqualsToken */: - return 176 /* AddAssignmentExpression */; - case 109 /* MinusEqualsToken */: - return 177 /* SubtractAssignmentExpression */; - case 110 /* AsteriskEqualsToken */: - return 178 /* MultiplyAssignmentExpression */; - case 119 /* SlashEqualsToken */: - return 179 /* DivideAssignmentExpression */; - case 111 /* PercentEqualsToken */: - return 180 /* ModuloAssignmentExpression */; - case 107 /* EqualsToken */: - return 175 /* AssignmentExpression */; - case 79 /* CommaToken */: - return 174 /* CommaExpression */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getBinaryExpressionFromOperatorToken = getBinaryExpressionFromOperatorToken; - function getOperatorTokenFromBinaryExpression(tokenKind) { - switch (tokenKind) { - case 206 /* MultiplyExpression */: - return 91 /* AsteriskToken */; - case 207 /* DivideExpression */: - return 118 /* SlashToken */; - case 208 /* ModuloExpression */: - return 92 /* PercentToken */; - case 209 /* AddExpression */: - return 89 /* PlusToken */; - case 210 /* SubtractExpression */: - return 90 /* MinusToken */; - case 203 /* LeftShiftExpression */: - return 95 /* LessThanLessThanToken */; - case 204 /* SignedRightShiftExpression */: - return 96 /* GreaterThanGreaterThanToken */; - case 205 /* UnsignedRightShiftExpression */: - return 97 /* GreaterThanGreaterThanGreaterThanToken */; - case 197 /* LessThanExpression */: - return 80 /* LessThanToken */; - case 198 /* GreaterThanExpression */: - return 81 /* GreaterThanToken */; - case 199 /* LessThanOrEqualExpression */: - return 82 /* LessThanEqualsToken */; - case 200 /* GreaterThanOrEqualExpression */: - return 83 /* GreaterThanEqualsToken */; - case 201 /* InstanceOfExpression */: - return 30 /* InstanceOfKeyword */; - case 202 /* InExpression */: - return 29 /* InKeyword */; - case 193 /* EqualsWithTypeConversionExpression */: - return 84 /* EqualsEqualsToken */; - case 194 /* NotEqualsWithTypeConversionExpression */: - return 86 /* ExclamationEqualsToken */; - case 195 /* EqualsExpression */: - return 87 /* EqualsEqualsEqualsToken */; - case 196 /* NotEqualsExpression */: - return 88 /* ExclamationEqualsEqualsToken */; - case 192 /* BitwiseAndExpression */: - return 98 /* AmpersandToken */; - case 191 /* BitwiseExclusiveOrExpression */: - return 100 /* CaretToken */; - case 190 /* BitwiseOrExpression */: - return 99 /* BarToken */; - case 189 /* LogicalAndExpression */: - return 103 /* AmpersandAmpersandToken */; - case 188 /* LogicalOrExpression */: - return 104 /* BarBarToken */; - case 183 /* OrAssignmentExpression */: - return 116 /* BarEqualsToken */; - case 181 /* AndAssignmentExpression */: - return 115 /* AmpersandEqualsToken */; - case 182 /* ExclusiveOrAssignmentExpression */: - return 117 /* CaretEqualsToken */; - case 184 /* LeftShiftAssignmentExpression */: - return 112 /* LessThanLessThanEqualsToken */; - case 185 /* SignedRightShiftAssignmentExpression */: - return 113 /* GreaterThanGreaterThanEqualsToken */; - case 186 /* UnsignedRightShiftAssignmentExpression */: - return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; - case 176 /* AddAssignmentExpression */: - return 108 /* PlusEqualsToken */; - case 177 /* SubtractAssignmentExpression */: - return 109 /* MinusEqualsToken */; - case 178 /* MultiplyAssignmentExpression */: - return 110 /* AsteriskEqualsToken */; - case 179 /* DivideAssignmentExpression */: - return 119 /* SlashEqualsToken */; - case 180 /* ModuloAssignmentExpression */: - return 111 /* PercentEqualsToken */; - case 175 /* AssignmentExpression */: - return 107 /* EqualsToken */; - case 174 /* CommaExpression */: - return 79 /* CommaToken */; - default: - return 0 /* None */; - } - } - SyntaxFacts.getOperatorTokenFromBinaryExpression = getOperatorTokenFromBinaryExpression; function isAssignmentOperatorToken(tokenKind) { switch (tokenKind) { - case 116 /* BarEqualsToken */: - case 115 /* AmpersandEqualsToken */: - case 117 /* CaretEqualsToken */: - case 112 /* LessThanLessThanEqualsToken */: - case 113 /* GreaterThanGreaterThanEqualsToken */: - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 108 /* PlusEqualsToken */: - case 109 /* MinusEqualsToken */: - case 110 /* AsteriskEqualsToken */: - case 119 /* SlashEqualsToken */: - case 111 /* PercentEqualsToken */: - case 107 /* EqualsToken */: + case 118 /* BarEqualsToken */: + case 117 /* AmpersandEqualsToken */: + case 119 /* CaretEqualsToken */: + case 114 /* LessThanLessThanEqualsToken */: + case 115 /* GreaterThanGreaterThanEqualsToken */: + case 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 110 /* PlusEqualsToken */: + case 111 /* MinusEqualsToken */: + case 112 /* AsteriskEqualsToken */: + case 121 /* SlashEqualsToken */: + case 113 /* PercentEqualsToken */: + case 109 /* EqualsToken */: return true; default: return false; @@ -18510,19 +18247,19 @@ var TypeScript; SyntaxFacts.isAssignmentOperatorToken = isAssignmentOperatorToken; function isType(kind) { switch (kind) { - case 124 /* ArrayType */: - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - case 123 /* FunctionType */: - case 122 /* ObjectType */: - case 125 /* ConstructorType */: - case 127 /* TypeQuery */: - case 126 /* GenericType */: - case 121 /* QualifiedName */: - case 11 /* IdentifierName */: + case 126 /* ArrayType */: + case 62 /* AnyKeyword */: + case 69 /* NumberKeyword */: + case 63 /* BooleanKeyword */: + case 71 /* StringKeyword */: + case 43 /* VoidKeyword */: + case 125 /* FunctionType */: + case 124 /* ObjectType */: + case 127 /* ConstructorType */: + case 129 /* TypeQuery */: + case 128 /* GenericType */: + case 123 /* QualifiedName */: + case 9 /* IdentifierName */: return true; } return false; @@ -18614,12 +18351,15 @@ var TypeScript; } function isContextualToken(token) { switch (token.kind()) { - case 12 /* RegularExpressionLiteral */: - case 96 /* GreaterThanGreaterThanToken */: - case 97 /* GreaterThanGreaterThanGreaterThanToken */: - case 83 /* GreaterThanEqualsToken */: - case 113 /* GreaterThanGreaterThanEqualsToken */: - case 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 10 /* RegularExpressionLiteral */: + case 98 /* GreaterThanGreaterThanToken */: + case 99 /* GreaterThanGreaterThanGreaterThanToken */: + case 85 /* GreaterThanEqualsToken */: + case 115 /* GreaterThanGreaterThanEqualsToken */: + case 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + return true; + case 15 /* TemplateMiddleToken */: + case 16 /* TemplateEndToken */: return true; default: return token.isKeywordConvertedToIdentifier(); @@ -18628,7 +18368,7 @@ var TypeScript; Scanner.isContextualToken = isContextualToken; var lastTokenInfo = { leadingTriviaWidth: -1, width: -1 }; var lastTokenInfoTokenID = -1; - var triviaScanner = createScannerInternal(ts.ScriptTarget.Latest, TypeScript.SimpleText.fromString(""), function () { + var triviaScanner = createScannerInternal(2 /* Latest */, TypeScript.SimpleText.fromString(""), function () { }); function fillSizeInfo(token, text) { if (lastTokenInfoTokenID !== TypeScript.syntaxID(token)) { @@ -18675,6 +18415,15 @@ var TypeScript; FixedWidthTokenWithNoTrivia.prototype.setFullStart = function (fullStart) { this._packedData = fixedWidthTokenPackData(fullStart, this.kind()); }; + FixedWidthTokenWithNoTrivia.prototype.childCount = function () { + return 0; + }; + FixedWidthTokenWithNoTrivia.prototype.childAt = function (index) { + throw TypeScript.Errors.invalidOperation(); + }; + FixedWidthTokenWithNoTrivia.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; FixedWidthTokenWithNoTrivia.prototype.isIncrementallyUnusable = function () { return false; }; @@ -18706,7 +18455,7 @@ var TypeScript; return this._packedData & 127 /* KindMask */; }; FixedWidthTokenWithNoTrivia.prototype.fullWidth = function () { - return this.fullText().length; + return fixedWidthTokenLength(this._packedData & 127 /* KindMask */); }; FixedWidthTokenWithNoTrivia.prototype.fullStart = function () { return fixedWidthTokenUnpackFullStart(this._packedData); @@ -18739,6 +18488,15 @@ var TypeScript; LargeScannerToken.prototype.setFullStart = function (fullStart) { this._packedFullStartAndInfo = largeTokenPackFullStartAndInfo(fullStart, largeTokenUnpackTriviaInfo(this._packedFullStartAndInfo)); }; + LargeScannerToken.prototype.childCount = function () { + return 0; + }; + LargeScannerToken.prototype.childAt = function (index) { + throw TypeScript.Errors.invalidOperation(); + }; + LargeScannerToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; LargeScannerToken.prototype.syntaxTreeText = function (text) { var result = text || TypeScript.syntaxTree(this).text; TypeScript.Debug.assert(result); @@ -19026,7 +18784,7 @@ var TypeScript; } break; } - return createTrivia(4 /* WhitespaceTrivia */, absoluteStartIndex); + return createTrivia(2 /* WhitespaceTrivia */, absoluteStartIndex); } function createTrivia(kind, absoluteStartIndex) { var fullWidth = index - absoluteStartIndex; @@ -19035,7 +18793,7 @@ var TypeScript; function scanSingleLineCommentTrivia() { var absoluteStartIndex = index; skipSingleLineCommentTrivia(); - return createTrivia(7 /* SingleLineCommentTrivia */, absoluteStartIndex); + return createTrivia(5 /* SingleLineCommentTrivia */, absoluteStartIndex); } function skipSingleLineCommentTrivia() { index += 2; @@ -19049,13 +18807,13 @@ var TypeScript; function scanMultiLineCommentTrivia() { var absoluteStartIndex = index; skipMultiLineCommentTrivia(); - return createTrivia(6 /* MultiLineCommentTrivia */, absoluteStartIndex); + return createTrivia(4 /* MultiLineCommentTrivia */, absoluteStartIndex); } function skipMultiLineCommentTrivia() { index += 2; while (true) { if (index === end) { - reportDiagnostic(end, 0, TypeScript.DiagnosticCode.AsteriskSlash_expected, null); + reportDiagnostic(end, 0, TypeScript.DiagnosticCode._0_expected, ["*/"]); return; } if ((index + 1) < end && str.charCodeAt(index) === 42 /* asterisk */ && str.charCodeAt(index + 1) === 47 /* slash */) { @@ -19068,7 +18826,7 @@ var TypeScript; function scanLineTerminatorSequenceTrivia(ch) { var absoluteStartIndex = index; skipLineTerminatorSequence(ch); - return createTrivia(5 /* NewLineTrivia */, absoluteStartIndex); + return createTrivia(3 /* NewLineTrivia */, absoluteStartIndex); } function skipLineTerminatorSequence(ch) { index++; @@ -19078,37 +18836,24 @@ var TypeScript; } function scanSyntaxKind(allowContextualToken) { if (index >= end) { - return 10 /* EndOfFileToken */; + return 8 /* EndOfFileToken */; } var character = str.charCodeAt(index); index++; switch (character) { - case 33 /* exclamation */: - return scanExclamationToken(); - case 34 /* doubleQuote */: - return scanStringLiteral(character); - case 37 /* percent */: - return scanPercentToken(); - case 38 /* ampersand */: - return scanAmpersandToken(); - case 39 /* singleQuote */: - return scanStringLiteral(character); - case 40 /* openParen */: - return 72 /* OpenParenToken */; - case 41 /* closeParen */: - return 73 /* CloseParenToken */; - case 42 /* asterisk */: - return scanAsteriskToken(); - case 43 /* plus */: - return scanPlusToken(); - case 44 /* comma */: - return 79 /* CommaToken */; - case 45 /* minus */: - return scanMinusToken(); - case 46 /* dot */: - return scanDotToken(); - case 47 /* slash */: - return scanSlashToken(allowContextualToken); + case 33 /* exclamation */: return scanExclamationToken(); + case 34 /* doubleQuote */: return scanStringLiteral(character); + case 37 /* percent */: return scanPercentToken(); + case 38 /* ampersand */: return scanAmpersandToken(); + case 39 /* singleQuote */: return scanStringLiteral(character); + case 40 /* openParen */: return 74 /* OpenParenToken */; + case 41 /* closeParen */: return 75 /* CloseParenToken */; + case 42 /* asterisk */: return scanAsteriskToken(); + case 43 /* plus */: return scanPlusToken(); + case 44 /* comma */: return 81 /* CommaToken */; + case 45 /* minus */: return scanMinusToken(); + case 46 /* dot */: return scanDotToken(); + case 47 /* slash */: return scanSlashToken(allowContextualToken); case 48 /* _0 */: case 49 /* _1 */: case 50 /* _2 */: @@ -19120,32 +18865,20 @@ var TypeScript; case 56 /* _8 */: case 57 /* _9 */: return scanNumericLiteral(character); - case 58 /* colon */: - return 106 /* ColonToken */; - case 59 /* semicolon */: - return 78 /* SemicolonToken */; - case 60 /* lessThan */: - return scanLessThanToken(); - case 61 /* equals */: - return scanEqualsToken(); - case 62 /* greaterThan */: - return scanGreaterThanToken(allowContextualToken); - case 63 /* question */: - return 105 /* QuestionToken */; - case 91 /* openBracket */: - return 74 /* OpenBracketToken */; - case 93 /* closeBracket */: - return 75 /* CloseBracketToken */; - case 94 /* caret */: - return scanCaretToken(); - case 123 /* openBrace */: - return 70 /* OpenBraceToken */; - case 124 /* bar */: - return scanBarToken(); - case 125 /* closeBrace */: - return 71 /* CloseBraceToken */; - case 126 /* tilde */: - return 102 /* TildeToken */; + case 58 /* colon */: return 108 /* ColonToken */; + case 59 /* semicolon */: return 80 /* SemicolonToken */; + case 60 /* lessThan */: return scanLessThanToken(); + case 61 /* equals */: return scanEqualsToken(); + case 62 /* greaterThan */: return scanGreaterThanToken(allowContextualToken); + case 63 /* question */: return 107 /* QuestionToken */; + case 91 /* openBracket */: return 76 /* OpenBracketToken */; + case 93 /* closeBracket */: return 77 /* CloseBracketToken */; + case 94 /* caret */: return scanCaretToken(); + case 96 /* backtick */: return scanTemplateToken(character); + case 123 /* openBrace */: return 72 /* OpenBraceToken */; + case 124 /* bar */: return scanBarToken(); + case 125 /* closeBrace */: return scanCloseBraceToken(allowContextualToken, character); + case 126 /* tilde */: return 104 /* TildeToken */; } if (isIdentifierStartCharacter[character]) { var result = tryFastScanIdentifierOrKeyword(character); @@ -19161,7 +18894,7 @@ var TypeScript; var messageText = getErrorMessageText(text); reportDiagnostic(index, 1, TypeScript.DiagnosticCode.Unexpected_character_0, [messageText]); index++; - return 9 /* ErrorToken */; + return 7 /* ErrorToken */; } function isIdentifierStart(interpretedChar) { if (isIdentifierStartCharacter[interpretedChar]) { @@ -19194,7 +18927,7 @@ var TypeScript; return TypeScript.ScannerUtilities.identifierKind(str, startIndex - 1, index - startIndex + 1); } else { - return 11 /* IdentifierName */; + return 9 /* IdentifierName */; } } } @@ -19210,7 +18943,7 @@ var TypeScript; if (keywordKind >= TypeScript.SyntaxKind.FirstKeyword && keywordKind <= TypeScript.SyntaxKind.LastKeyword) { return keywordKind | 128 /* IsVariableWidthMask */; } - return 11 /* IdentifierName */; + return 9 /* IdentifierName */; } function scanNumericLiteral(ch) { if (isHexNumericLiteral(ch)) { @@ -19222,7 +18955,7 @@ var TypeScript; else { scanDecimalNumericLiteral(); } - return 13 /* NumericLiteral */; + return 11 /* NumericLiteral */; } function isOctalNumericLiteral(ch) { return ch === 48 /* _0 */ && TypeScript.CharacterInfo.isOctalDigit(str.charCodeAt(index)); @@ -19233,7 +18966,7 @@ var TypeScript; index++; } if (languageVersion >= 1 /* ES5 */) { - reportDiagnostic(start, index - start, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, null); + reportDiagnostic(start, index - start, TypeScript.DiagnosticCode.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher, undefined); } } function scanDecimalDigits() { @@ -19285,20 +19018,20 @@ var TypeScript; var ch0 = str.charCodeAt(index); if (ch0 === 61 /* equals */) { index++; - return 82 /* LessThanEqualsToken */; + return 84 /* LessThanEqualsToken */; } else if (ch0 === 60 /* lessThan */) { index++; if (str.charCodeAt(index) === 61 /* equals */) { index++; - return 112 /* LessThanLessThanEqualsToken */; + return 114 /* LessThanLessThanEqualsToken */; } else { - return 95 /* LessThanLessThanToken */; + return 97 /* LessThanLessThanToken */; } } else { - return 80 /* LessThanToken */; + return 82 /* LessThanToken */; } } function scanGreaterThanToken(allowContextualToken) { @@ -19312,108 +19045,130 @@ var TypeScript; var ch2 = str.charCodeAt(index); if (ch2 === 61 /* equals */) { index++; - return 114 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } else { - return 97 /* GreaterThanGreaterThanGreaterThanToken */; + return 99 /* GreaterThanGreaterThanGreaterThanToken */; } } else if (ch1 === 61 /* equals */) { index++; - return 113 /* GreaterThanGreaterThanEqualsToken */; + return 115 /* GreaterThanGreaterThanEqualsToken */; } else { - return 96 /* GreaterThanGreaterThanToken */; + return 98 /* GreaterThanGreaterThanToken */; } } else if (ch0 === 61 /* equals */) { index++; - return 83 /* GreaterThanEqualsToken */; + return 85 /* GreaterThanEqualsToken */; } } - return 81 /* GreaterThanToken */; + return 83 /* GreaterThanToken */; } function scanBarToken() { var ch = str.charCodeAt(index); if (ch === 61 /* equals */) { index++; - return 116 /* BarEqualsToken */; + return 118 /* BarEqualsToken */; } else if (ch === 124 /* bar */) { index++; - return 104 /* BarBarToken */; + return 106 /* BarBarToken */; } else { - return 99 /* BarToken */; + return 101 /* BarToken */; } } function scanCaretToken() { if (str.charCodeAt(index) === 61 /* equals */) { index++; - return 117 /* CaretEqualsToken */; + return 119 /* CaretEqualsToken */; } else { - return 100 /* CaretToken */; + return 102 /* CaretToken */; } } + function scanCloseBraceToken(allowContextualToken, startChar) { + return allowContextualToken ? scanTemplateToken(startChar) : 73 /* CloseBraceToken */; + } + function scanTemplateToken(startChar) { + var startedWithBacktick = startChar === 96 /* backtick */; + while (true) { + if (index === end) { + reportDiagnostic(end, 0, TypeScript.DiagnosticCode._0_expected, ["`"]); + break; + } + var ch = str.charCodeAt(index); + index++; + if (ch === 96 /* backtick */) { + break; + } + if (ch === 36 /* $ */ && index < end && str.charCodeAt(index) === 123 /* openBrace */) { + index++; + return startedWithBacktick ? 14 /* TemplateStartToken */ : 15 /* TemplateMiddleToken */; + } + } + return startedWithBacktick ? 13 /* NoSubstitutionTemplateToken */ : 16 /* TemplateEndToken */; + } function scanAmpersandToken() { var character = str.charCodeAt(index); if (character === 61 /* equals */) { index++; - return 115 /* AmpersandEqualsToken */; + return 117 /* AmpersandEqualsToken */; } else if (character === 38 /* ampersand */) { index++; - return 103 /* AmpersandAmpersandToken */; + return 105 /* AmpersandAmpersandToken */; } else { - return 98 /* AmpersandToken */; + return 100 /* AmpersandToken */; } } function scanPercentToken() { if (str.charCodeAt(index) === 61 /* equals */) { index++; - return 111 /* PercentEqualsToken */; + return 113 /* PercentEqualsToken */; } else { - return 92 /* PercentToken */; + return 94 /* PercentToken */; } } function scanMinusToken() { var character = str.charCodeAt(index); if (character === 61 /* equals */) { index++; - return 109 /* MinusEqualsToken */; + return 111 /* MinusEqualsToken */; } else if (character === 45 /* minus */) { index++; - return 94 /* MinusMinusToken */; + return 96 /* MinusMinusToken */; } else { - return 90 /* MinusToken */; + return 92 /* MinusToken */; } } function scanPlusToken() { var character = str.charCodeAt(index); if (character === 61 /* equals */) { index++; - return 108 /* PlusEqualsToken */; + return 110 /* PlusEqualsToken */; } else if (character === 43 /* plus */) { index++; - return 93 /* PlusPlusToken */; + return 95 /* PlusPlusToken */; } else { - return 89 /* PlusToken */; + return 91 /* PlusToken */; } } function scanAsteriskToken() { if (str.charCodeAt(index) === 61 /* equals */) { index++; - return 110 /* AsteriskEqualsToken */; + return 112 /* AsteriskEqualsToken */; } else { - return 91 /* AsteriskToken */; + return 93 /* AsteriskToken */; } } function scanEqualsToken() { @@ -19422,32 +19177,32 @@ var TypeScript; index++; if (str.charCodeAt(index) === 61 /* equals */) { index++; - return 87 /* EqualsEqualsEqualsToken */; + return 89 /* EqualsEqualsEqualsToken */; } else { - return 84 /* EqualsEqualsToken */; + return 86 /* EqualsEqualsToken */; } } else if (character === 62 /* greaterThan */) { index++; - return 85 /* EqualsGreaterThanToken */; + return 87 /* EqualsGreaterThanToken */; } else { - return 107 /* EqualsToken */; + return 109 /* EqualsToken */; } } function scanDotToken() { var nextChar = str.charCodeAt(index); if (TypeScript.CharacterInfo.isDecimalDigit(nextChar)) { scanDecimalNumericLiteralAfterDot(); - return 13 /* NumericLiteral */; + return 11 /* NumericLiteral */; } if (nextChar === 46 /* dot */ && str.charCodeAt(index + 1) === 46 /* dot */) { index += 2; - return 77 /* DotDotDotToken */; + return 79 /* DotDotDotToken */; } else { - return 76 /* DotToken */; + return 78 /* DotToken */; } } function scanSlashToken(allowContextualToken) { @@ -19459,10 +19214,10 @@ var TypeScript; } if (str.charCodeAt(index) === 61 /* equals */) { index++; - return 119 /* SlashEqualsToken */; + return 121 /* SlashEqualsToken */; } else { - return 118 /* SlashToken */; + return 120 /* SlashToken */; } } function tryScanRegularExpressionToken() { @@ -19503,21 +19258,21 @@ var TypeScript; while (isIdentifierPartCharacter[str.charCodeAt(index)]) { index++; } - return 12 /* RegularExpressionLiteral */; + return 10 /* RegularExpressionLiteral */; } function scanExclamationToken() { if (str.charCodeAt(index) === 61 /* equals */) { index++; if (str.charCodeAt(index) === 61 /* equals */) { index++; - return 88 /* ExclamationEqualsEqualsToken */; + return 90 /* ExclamationEqualsEqualsToken */; } else { - return 86 /* ExclamationEqualsToken */; + return 88 /* ExclamationEqualsToken */; } } else { - return 101 /* ExclamationToken */; + return 103 /* ExclamationToken */; } } function getErrorMessageText(text) { @@ -19560,14 +19315,14 @@ var TypeScript; break; } else if (isNaN(ch) || isNewLineCharacter(ch)) { - reportDiagnostic(Math.min(index, end), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, null); + reportDiagnostic(Math.min(index, end), 1, TypeScript.DiagnosticCode.Missing_close_quote_character, undefined); break; } else { index++; } } - return 14 /* StringLiteral */; + return 12 /* StringLiteral */; } function isUnicodeEscape(character) { return character === 92 /* backslash */ && str.charCodeAt(index + 1) === 117 /* u */; @@ -19607,7 +19362,7 @@ var TypeScript; var ch2 = str.charCodeAt(index); if (!TypeScript.CharacterInfo.isHexDigit(ch2)) { if (report) { - reportDiagnostic(start, index - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, null); + reportDiagnostic(start, index - start, TypeScript.DiagnosticCode.Unrecognized_escape_sequence, undefined); } break; } @@ -19647,22 +19402,22 @@ var TypeScript; var _tokenDiagnostics = []; var rewindPointPool = []; var rewindPointPoolCount = 0; - var lastDiagnostic = null; + var lastDiagnostic = undefined; var reportDiagnostic = function (position, fullWidth, diagnosticKey, args) { lastDiagnostic = new TypeScript.Diagnostic(fileName, text.lineMap(), position, fullWidth, diagnosticKey, args); }; - var slidingWindow = new TypeScript.SlidingWindow(fetchNextItem, TypeScript.ArrayUtilities.createArray(1024, null), null); + var slidingWindow = new TypeScript.SlidingWindow(fetchNextItem, TypeScript.ArrayUtilities.createArray(1024, undefined), undefined); var scanner = createScanner(languageVersion, text, reportDiagnostic); function release() { - slidingWindow = null; - scanner = null; + slidingWindow = undefined; + scanner = undefined; _tokenDiagnostics = []; rewindPointPool = []; - lastDiagnostic = null; - reportDiagnostic = null; + lastDiagnostic = undefined; + reportDiagnostic = undefined; } function currentNode() { - return null; + return undefined; } function consumeNode(node) { throw TypeScript.Errors.invalidOperation(); @@ -19679,7 +19434,7 @@ var TypeScript; } rewindPointPoolCount--; var result = rewindPointPool[rewindPointPoolCount]; - rewindPointPool[rewindPointPoolCount] = null; + rewindPointPool[rewindPointPoolCount] = undefined; return result; } function getRewindPoint() { @@ -19700,11 +19455,11 @@ var TypeScript; } function fetchNextItem(allowContextualToken) { var token = scanner.scan(allowContextualToken); - if (lastDiagnostic === null) { + if (lastDiagnostic === undefined) { return token; } _tokenDiagnostics.push(lastDiagnostic); - lastDiagnostic = null; + lastDiagnostic = undefined; return TypeScript.Syntax.realizeToken(token, text); } function peekToken(n) { @@ -19723,12 +19478,12 @@ var TypeScript; var diagnostic = _tokenDiagnostics[tokenDiagnosticsLength - 1]; if (diagnostic.start() >= position) { tokenDiagnosticsLength--; + _tokenDiagnostics.pop(); } else { break; } } - _tokenDiagnostics.length = tokenDiagnosticsLength; } function resetToPosition(absolutePosition) { TypeScript.Debug.assert(absolutePosition <= text.length(), "Trying to set the position outside the bounds of the text!"); @@ -19762,227 +19517,371 @@ var TypeScript; }; } Scanner.createParserSource = createParserSource; + function fixedWidthTokenLength(kind) { + switch (kind) { + case 17 /* BreakKeyword */: return 5; + case 18 /* CaseKeyword */: return 4; + case 19 /* CatchKeyword */: return 5; + case 20 /* ContinueKeyword */: return 8; + case 21 /* DebuggerKeyword */: return 8; + case 22 /* DefaultKeyword */: return 7; + case 23 /* DeleteKeyword */: return 6; + case 24 /* DoKeyword */: return 2; + case 25 /* ElseKeyword */: return 4; + case 26 /* FalseKeyword */: return 5; + case 27 /* FinallyKeyword */: return 7; + case 28 /* ForKeyword */: return 3; + case 29 /* FunctionKeyword */: return 8; + case 30 /* IfKeyword */: return 2; + case 31 /* InKeyword */: return 2; + case 32 /* InstanceOfKeyword */: return 10; + case 33 /* NewKeyword */: return 3; + case 34 /* NullKeyword */: return 4; + case 35 /* ReturnKeyword */: return 6; + case 36 /* SwitchKeyword */: return 6; + case 37 /* ThisKeyword */: return 4; + case 38 /* ThrowKeyword */: return 5; + case 39 /* TrueKeyword */: return 4; + case 40 /* TryKeyword */: return 3; + case 41 /* TypeOfKeyword */: return 6; + case 42 /* VarKeyword */: return 3; + case 43 /* VoidKeyword */: return 4; + case 44 /* WhileKeyword */: return 5; + case 45 /* WithKeyword */: return 4; + case 46 /* ClassKeyword */: return 5; + case 47 /* ConstKeyword */: return 5; + case 48 /* EnumKeyword */: return 4; + case 49 /* ExportKeyword */: return 6; + case 50 /* ExtendsKeyword */: return 7; + case 51 /* ImportKeyword */: return 6; + case 52 /* SuperKeyword */: return 5; + case 53 /* ImplementsKeyword */: return 10; + case 54 /* InterfaceKeyword */: return 9; + case 55 /* LetKeyword */: return 3; + case 56 /* PackageKeyword */: return 7; + case 57 /* PrivateKeyword */: return 7; + case 58 /* ProtectedKeyword */: return 9; + case 59 /* PublicKeyword */: return 6; + case 60 /* StaticKeyword */: return 6; + case 61 /* YieldKeyword */: return 5; + case 62 /* AnyKeyword */: return 3; + case 63 /* BooleanKeyword */: return 7; + case 64 /* ConstructorKeyword */: return 11; + case 65 /* DeclareKeyword */: return 7; + case 66 /* GetKeyword */: return 3; + case 67 /* ModuleKeyword */: return 6; + case 68 /* RequireKeyword */: return 7; + case 69 /* NumberKeyword */: return 6; + case 70 /* SetKeyword */: return 3; + case 71 /* StringKeyword */: return 6; + case 72 /* OpenBraceToken */: return 1; + case 73 /* CloseBraceToken */: return 1; + case 74 /* OpenParenToken */: return 1; + case 75 /* CloseParenToken */: return 1; + case 76 /* OpenBracketToken */: return 1; + case 77 /* CloseBracketToken */: return 1; + case 78 /* DotToken */: return 1; + case 79 /* DotDotDotToken */: return 3; + case 80 /* SemicolonToken */: return 1; + case 81 /* CommaToken */: return 1; + case 82 /* LessThanToken */: return 1; + case 83 /* GreaterThanToken */: return 1; + case 84 /* LessThanEqualsToken */: return 2; + case 85 /* GreaterThanEqualsToken */: return 2; + case 86 /* EqualsEqualsToken */: return 2; + case 87 /* EqualsGreaterThanToken */: return 2; + case 88 /* ExclamationEqualsToken */: return 2; + case 89 /* EqualsEqualsEqualsToken */: return 3; + case 90 /* ExclamationEqualsEqualsToken */: return 3; + case 91 /* PlusToken */: return 1; + case 92 /* MinusToken */: return 1; + case 93 /* AsteriskToken */: return 1; + case 94 /* PercentToken */: return 1; + case 95 /* PlusPlusToken */: return 2; + case 96 /* MinusMinusToken */: return 2; + case 97 /* LessThanLessThanToken */: return 2; + case 98 /* GreaterThanGreaterThanToken */: return 2; + case 99 /* GreaterThanGreaterThanGreaterThanToken */: return 3; + case 100 /* AmpersandToken */: return 1; + case 101 /* BarToken */: return 1; + case 102 /* CaretToken */: return 1; + case 103 /* ExclamationToken */: return 1; + case 104 /* TildeToken */: return 1; + case 105 /* AmpersandAmpersandToken */: return 2; + case 106 /* BarBarToken */: return 2; + case 107 /* QuestionToken */: return 1; + case 108 /* ColonToken */: return 1; + case 109 /* EqualsToken */: return 1; + case 110 /* PlusEqualsToken */: return 2; + case 111 /* MinusEqualsToken */: return 2; + case 112 /* AsteriskEqualsToken */: return 2; + case 113 /* PercentEqualsToken */: return 2; + case 114 /* LessThanLessThanEqualsToken */: return 3; + case 115 /* GreaterThanGreaterThanEqualsToken */: return 3; + case 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 4; + case 117 /* AmpersandEqualsToken */: return 2; + case 118 /* BarEqualsToken */: return 2; + case 119 /* CaretEqualsToken */: return 2; + case 120 /* SlashToken */: return 1; + case 121 /* SlashEqualsToken */: return 2; + default: throw new Error(); + } + } })(Scanner = TypeScript.Scanner || (TypeScript.Scanner = {})); })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { - var ScannerUtilities = (function () { - function ScannerUtilities() { + var ScannerUtilities; + (function (ScannerUtilities) { + function fixedWidthTokenLength(kind) { + switch (kind) { + case 17 /* BreakKeyword */: return 5; + case 18 /* CaseKeyword */: return 4; + case 19 /* CatchKeyword */: return 5; + case 20 /* ContinueKeyword */: return 8; + case 21 /* DebuggerKeyword */: return 8; + case 22 /* DefaultKeyword */: return 7; + case 23 /* DeleteKeyword */: return 6; + case 24 /* DoKeyword */: return 2; + case 25 /* ElseKeyword */: return 4; + case 26 /* FalseKeyword */: return 5; + case 27 /* FinallyKeyword */: return 7; + case 28 /* ForKeyword */: return 3; + case 29 /* FunctionKeyword */: return 8; + case 30 /* IfKeyword */: return 2; + case 31 /* InKeyword */: return 2; + case 32 /* InstanceOfKeyword */: return 10; + case 33 /* NewKeyword */: return 3; + case 34 /* NullKeyword */: return 4; + case 35 /* ReturnKeyword */: return 6; + case 36 /* SwitchKeyword */: return 6; + case 37 /* ThisKeyword */: return 4; + case 38 /* ThrowKeyword */: return 5; + case 39 /* TrueKeyword */: return 4; + case 40 /* TryKeyword */: return 3; + case 41 /* TypeOfKeyword */: return 6; + case 42 /* VarKeyword */: return 3; + case 43 /* VoidKeyword */: return 4; + case 44 /* WhileKeyword */: return 5; + case 45 /* WithKeyword */: return 4; + case 46 /* ClassKeyword */: return 5; + case 47 /* ConstKeyword */: return 5; + case 48 /* EnumKeyword */: return 4; + case 49 /* ExportKeyword */: return 6; + case 50 /* ExtendsKeyword */: return 7; + case 51 /* ImportKeyword */: return 6; + case 52 /* SuperKeyword */: return 5; + case 53 /* ImplementsKeyword */: return 10; + case 54 /* InterfaceKeyword */: return 9; + case 55 /* LetKeyword */: return 3; + case 56 /* PackageKeyword */: return 7; + case 57 /* PrivateKeyword */: return 7; + case 58 /* ProtectedKeyword */: return 9; + case 59 /* PublicKeyword */: return 6; + case 60 /* StaticKeyword */: return 6; + case 61 /* YieldKeyword */: return 5; + case 62 /* AnyKeyword */: return 3; + case 63 /* BooleanKeyword */: return 7; + case 64 /* ConstructorKeyword */: return 11; + case 65 /* DeclareKeyword */: return 7; + case 66 /* GetKeyword */: return 3; + case 67 /* ModuleKeyword */: return 6; + case 68 /* RequireKeyword */: return 7; + case 69 /* NumberKeyword */: return 6; + case 70 /* SetKeyword */: return 3; + case 71 /* StringKeyword */: return 6; + case 72 /* OpenBraceToken */: return 1; + case 73 /* CloseBraceToken */: return 1; + case 74 /* OpenParenToken */: return 1; + case 75 /* CloseParenToken */: return 1; + case 76 /* OpenBracketToken */: return 1; + case 77 /* CloseBracketToken */: return 1; + case 78 /* DotToken */: return 1; + case 79 /* DotDotDotToken */: return 3; + case 80 /* SemicolonToken */: return 1; + case 81 /* CommaToken */: return 1; + case 82 /* LessThanToken */: return 1; + case 83 /* GreaterThanToken */: return 1; + case 84 /* LessThanEqualsToken */: return 2; + case 85 /* GreaterThanEqualsToken */: return 2; + case 86 /* EqualsEqualsToken */: return 2; + case 87 /* EqualsGreaterThanToken */: return 2; + case 88 /* ExclamationEqualsToken */: return 2; + case 89 /* EqualsEqualsEqualsToken */: return 3; + case 90 /* ExclamationEqualsEqualsToken */: return 3; + case 91 /* PlusToken */: return 1; + case 92 /* MinusToken */: return 1; + case 93 /* AsteriskToken */: return 1; + case 94 /* PercentToken */: return 1; + case 95 /* PlusPlusToken */: return 2; + case 96 /* MinusMinusToken */: return 2; + case 97 /* LessThanLessThanToken */: return 2; + case 98 /* GreaterThanGreaterThanToken */: return 2; + case 99 /* GreaterThanGreaterThanGreaterThanToken */: return 3; + case 100 /* AmpersandToken */: return 1; + case 101 /* BarToken */: return 1; + case 102 /* CaretToken */: return 1; + case 103 /* ExclamationToken */: return 1; + case 104 /* TildeToken */: return 1; + case 105 /* AmpersandAmpersandToken */: return 2; + case 106 /* BarBarToken */: return 2; + case 107 /* QuestionToken */: return 1; + case 108 /* ColonToken */: return 1; + case 109 /* EqualsToken */: return 1; + case 110 /* PlusEqualsToken */: return 2; + case 111 /* MinusEqualsToken */: return 2; + case 112 /* AsteriskEqualsToken */: return 2; + case 113 /* PercentEqualsToken */: return 2; + case 114 /* LessThanLessThanEqualsToken */: return 3; + case 115 /* GreaterThanGreaterThanEqualsToken */: return 3; + case 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 4; + case 117 /* AmpersandEqualsToken */: return 2; + case 118 /* BarEqualsToken */: return 2; + case 119 /* CaretEqualsToken */: return 2; + case 120 /* SlashToken */: return 1; + case 121 /* SlashEqualsToken */: return 2; + default: throw new Error(); + } } - ScannerUtilities.identifierKind = function (str, start, length) { + ScannerUtilities.fixedWidthTokenLength = fixedWidthTokenLength; + function identifierKind(str, start, length) { switch (length) { case 2: switch (str.charCodeAt(start)) { - case 100 /* d */: - return (str.charCodeAt(start + 1) === 111 /* o */) ? 22 /* DoKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: return (str.charCodeAt(start + 1) === 111 /* o */) ? 24 /* DoKeyword */ : 9 /* IdentifierName */; case 105 /* i */: switch (str.charCodeAt(start + 1)) { - case 102 /* f */: - return 28 /* IfKeyword */; - case 110 /* n */: - return 29 /* InKeyword */; - default: - return 11 /* IdentifierName */; + case 102 /* f */: return 30 /* IfKeyword */; + case 110 /* n */: return 31 /* InKeyword */; + default: return 9 /* IdentifierName */; } - default: - return 11 /* IdentifierName */; + default: return 9 /* IdentifierName */; } case 3: switch (str.charCodeAt(start)) { - case 97 /* a */: - return (str.charCodeAt(start + 1) === 110 /* n */ && str.charCodeAt(start + 2) === 121 /* y */) ? 60 /* AnyKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 114 /* r */) ? 26 /* ForKeyword */ : 11 /* IdentifierName */; - case 103 /* g */: - return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 116 /* t */) ? 64 /* GetKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 116 /* t */) ? 53 /* LetKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 119 /* w */) ? 31 /* NewKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 116 /* t */) ? 68 /* SetKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (str.charCodeAt(start + 1) === 114 /* r */ && str.charCodeAt(start + 2) === 121 /* y */) ? 38 /* TryKeyword */ : 11 /* IdentifierName */; - case 118 /* v */: - return (str.charCodeAt(start + 1) === 97 /* a */ && str.charCodeAt(start + 2) === 114 /* r */) ? 40 /* VarKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 97 /* a */: return (str.charCodeAt(start + 1) === 110 /* n */ && str.charCodeAt(start + 2) === 121 /* y */) ? 62 /* AnyKeyword */ : 9 /* IdentifierName */; + case 102 /* f */: return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 114 /* r */) ? 28 /* ForKeyword */ : 9 /* IdentifierName */; + case 103 /* g */: return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 116 /* t */) ? 66 /* GetKeyword */ : 9 /* IdentifierName */; + case 108 /* l */: return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 116 /* t */) ? 55 /* LetKeyword */ : 9 /* IdentifierName */; + case 110 /* n */: return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 119 /* w */) ? 33 /* NewKeyword */ : 9 /* IdentifierName */; + case 115 /* s */: return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 116 /* t */) ? 70 /* SetKeyword */ : 9 /* IdentifierName */; + case 116 /* t */: return (str.charCodeAt(start + 1) === 114 /* r */ && str.charCodeAt(start + 2) === 121 /* y */) ? 40 /* TryKeyword */ : 9 /* IdentifierName */; + case 118 /* v */: return (str.charCodeAt(start + 1) === 97 /* a */ && str.charCodeAt(start + 2) === 114 /* r */) ? 42 /* VarKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } case 4: switch (str.charCodeAt(start)) { - case 99 /* c */: - return (str.charCodeAt(start + 1) === 97 /* a */ && str.charCodeAt(start + 2) === 115 /* s */ && str.charCodeAt(start + 3) === 101 /* e */) ? 16 /* CaseKeyword */ : 11 /* IdentifierName */; + case 99 /* c */: return (str.charCodeAt(start + 1) === 97 /* a */ && str.charCodeAt(start + 2) === 115 /* s */ && str.charCodeAt(start + 3) === 101 /* e */) ? 18 /* CaseKeyword */ : 9 /* IdentifierName */; case 101 /* e */: switch (str.charCodeAt(start + 1)) { - case 108 /* l */: - return (str.charCodeAt(start + 2) === 115 /* s */ && str.charCodeAt(start + 3) === 101 /* e */) ? 23 /* ElseKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (str.charCodeAt(start + 2) === 117 /* u */ && str.charCodeAt(start + 3) === 109 /* m */) ? 46 /* EnumKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 108 /* l */: return (str.charCodeAt(start + 2) === 115 /* s */ && str.charCodeAt(start + 3) === 101 /* e */) ? 25 /* ElseKeyword */ : 9 /* IdentifierName */; + case 110 /* n */: return (str.charCodeAt(start + 2) === 117 /* u */ && str.charCodeAt(start + 3) === 109 /* m */) ? 48 /* EnumKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - case 110 /* n */: - return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 108 /* l */ && str.charCodeAt(start + 3) === 108 /* l */) ? 32 /* NullKeyword */ : 11 /* IdentifierName */; + case 110 /* n */: return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 108 /* l */ && str.charCodeAt(start + 3) === 108 /* l */) ? 34 /* NullKeyword */ : 9 /* IdentifierName */; case 116 /* t */: switch (str.charCodeAt(start + 1)) { - case 104 /* h */: - return (str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 115 /* s */) ? 35 /* ThisKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (str.charCodeAt(start + 2) === 117 /* u */ && str.charCodeAt(start + 3) === 101 /* e */) ? 37 /* TrueKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 104 /* h */: return (str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 115 /* s */) ? 37 /* ThisKeyword */ : 9 /* IdentifierName */; + case 114 /* r */: return (str.charCodeAt(start + 2) === 117 /* u */ && str.charCodeAt(start + 3) === 101 /* e */) ? 39 /* TrueKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - case 118 /* v */: - return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 100 /* d */) ? 41 /* VoidKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (str.charCodeAt(start + 1) === 105 /* i */ && str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 104 /* h */) ? 43 /* WithKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 118 /* v */: return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 100 /* d */) ? 43 /* VoidKeyword */ : 9 /* IdentifierName */; + case 119 /* w */: return (str.charCodeAt(start + 1) === 105 /* i */ && str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 104 /* h */) ? 45 /* WithKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } case 5: switch (str.charCodeAt(start)) { - case 98 /* b */: - return (str.charCodeAt(start + 1) === 114 /* r */ && str.charCodeAt(start + 2) === 101 /* e */ && str.charCodeAt(start + 3) === 97 /* a */ && str.charCodeAt(start + 4) === 107 /* k */) ? 15 /* BreakKeyword */ : 11 /* IdentifierName */; + case 98 /* b */: return (str.charCodeAt(start + 1) === 114 /* r */ && str.charCodeAt(start + 2) === 101 /* e */ && str.charCodeAt(start + 3) === 97 /* a */ && str.charCodeAt(start + 4) === 107 /* k */) ? 17 /* BreakKeyword */ : 9 /* IdentifierName */; case 99 /* c */: switch (str.charCodeAt(start + 1)) { - case 97 /* a */: - return (str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 99 /* c */ && str.charCodeAt(start + 4) === 104 /* h */) ? 17 /* CatchKeyword */ : 11 /* IdentifierName */; - case 108 /* l */: - return (str.charCodeAt(start + 2) === 97 /* a */ && str.charCodeAt(start + 3) === 115 /* s */ && str.charCodeAt(start + 4) === 115 /* s */) ? 44 /* ClassKeyword */ : 11 /* IdentifierName */; - case 111 /* o */: - return (str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 115 /* s */ && str.charCodeAt(start + 4) === 116 /* t */) ? 45 /* ConstKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 97 /* a */: return (str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 99 /* c */ && str.charCodeAt(start + 4) === 104 /* h */) ? 19 /* CatchKeyword */ : 9 /* IdentifierName */; + case 108 /* l */: return (str.charCodeAt(start + 2) === 97 /* a */ && str.charCodeAt(start + 3) === 115 /* s */ && str.charCodeAt(start + 4) === 115 /* s */) ? 46 /* ClassKeyword */ : 9 /* IdentifierName */; + case 111 /* o */: return (str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 115 /* s */ && str.charCodeAt(start + 4) === 116 /* t */) ? 47 /* ConstKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - case 102 /* f */: - return (str.charCodeAt(start + 1) === 97 /* a */ && str.charCodeAt(start + 2) === 108 /* l */ && str.charCodeAt(start + 3) === 115 /* s */ && str.charCodeAt(start + 4) === 101 /* e */) ? 24 /* FalseKeyword */ : 11 /* IdentifierName */; - case 115 /* s */: - return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 114 /* r */) ? 50 /* SuperKeyword */ : 11 /* IdentifierName */; - case 116 /* t */: - return (str.charCodeAt(start + 1) === 104 /* h */ && str.charCodeAt(start + 2) === 114 /* r */ && str.charCodeAt(start + 3) === 111 /* o */ && str.charCodeAt(start + 4) === 119 /* w */) ? 36 /* ThrowKeyword */ : 11 /* IdentifierName */; - case 119 /* w */: - return (str.charCodeAt(start + 1) === 104 /* h */ && str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 101 /* e */) ? 42 /* WhileKeyword */ : 11 /* IdentifierName */; - case 121 /* y */: - return (str.charCodeAt(start + 1) === 105 /* i */ && str.charCodeAt(start + 2) === 101 /* e */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 100 /* d */) ? 59 /* YieldKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 102 /* f */: return (str.charCodeAt(start + 1) === 97 /* a */ && str.charCodeAt(start + 2) === 108 /* l */ && str.charCodeAt(start + 3) === 115 /* s */ && str.charCodeAt(start + 4) === 101 /* e */) ? 26 /* FalseKeyword */ : 9 /* IdentifierName */; + case 115 /* s */: return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 114 /* r */) ? 52 /* SuperKeyword */ : 9 /* IdentifierName */; + case 116 /* t */: return (str.charCodeAt(start + 1) === 104 /* h */ && str.charCodeAt(start + 2) === 114 /* r */ && str.charCodeAt(start + 3) === 111 /* o */ && str.charCodeAt(start + 4) === 119 /* w */) ? 38 /* ThrowKeyword */ : 9 /* IdentifierName */; + case 119 /* w */: return (str.charCodeAt(start + 1) === 104 /* h */ && str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 101 /* e */) ? 44 /* WhileKeyword */ : 9 /* IdentifierName */; + case 121 /* y */: return (str.charCodeAt(start + 1) === 105 /* i */ && str.charCodeAt(start + 2) === 101 /* e */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 100 /* d */) ? 61 /* YieldKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } case 6: switch (str.charCodeAt(start)) { - case 100 /* d */: - return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 108 /* l */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 116 /* t */ && str.charCodeAt(start + 5) === 101 /* e */) ? 21 /* DeleteKeyword */ : 11 /* IdentifierName */; - case 101 /* e */: - return (str.charCodeAt(start + 1) === 120 /* x */ && str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 111 /* o */ && str.charCodeAt(start + 4) === 114 /* r */ && str.charCodeAt(start + 5) === 116 /* t */) ? 47 /* ExportKeyword */ : 11 /* IdentifierName */; - case 105 /* i */: - return (str.charCodeAt(start + 1) === 109 /* m */ && str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 111 /* o */ && str.charCodeAt(start + 4) === 114 /* r */ && str.charCodeAt(start + 5) === 116 /* t */) ? 49 /* ImportKeyword */ : 11 /* IdentifierName */; - case 109 /* m */: - return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 100 /* d */ && str.charCodeAt(start + 3) === 117 /* u */ && str.charCodeAt(start + 4) === 108 /* l */ && str.charCodeAt(start + 5) === 101 /* e */) ? 65 /* ModuleKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 109 /* m */ && str.charCodeAt(start + 3) === 98 /* b */ && str.charCodeAt(start + 4) === 101 /* e */ && str.charCodeAt(start + 5) === 114 /* r */) ? 67 /* NumberKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 98 /* b */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 105 /* i */ && str.charCodeAt(start + 5) === 99 /* c */) ? 57 /* PublicKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 117 /* u */ && str.charCodeAt(start + 4) === 114 /* r */ && str.charCodeAt(start + 5) === 110 /* n */) ? 33 /* ReturnKeyword */ : 11 /* IdentifierName */; + case 100 /* d */: return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 108 /* l */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 116 /* t */ && str.charCodeAt(start + 5) === 101 /* e */) ? 23 /* DeleteKeyword */ : 9 /* IdentifierName */; + case 101 /* e */: return (str.charCodeAt(start + 1) === 120 /* x */ && str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 111 /* o */ && str.charCodeAt(start + 4) === 114 /* r */ && str.charCodeAt(start + 5) === 116 /* t */) ? 49 /* ExportKeyword */ : 9 /* IdentifierName */; + case 105 /* i */: return (str.charCodeAt(start + 1) === 109 /* m */ && str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 111 /* o */ && str.charCodeAt(start + 4) === 114 /* r */ && str.charCodeAt(start + 5) === 116 /* t */) ? 51 /* ImportKeyword */ : 9 /* IdentifierName */; + case 109 /* m */: return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 100 /* d */ && str.charCodeAt(start + 3) === 117 /* u */ && str.charCodeAt(start + 4) === 108 /* l */ && str.charCodeAt(start + 5) === 101 /* e */) ? 67 /* ModuleKeyword */ : 9 /* IdentifierName */; + case 110 /* n */: return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 109 /* m */ && str.charCodeAt(start + 3) === 98 /* b */ && str.charCodeAt(start + 4) === 101 /* e */ && str.charCodeAt(start + 5) === 114 /* r */) ? 69 /* NumberKeyword */ : 9 /* IdentifierName */; + case 112 /* p */: return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 98 /* b */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 105 /* i */ && str.charCodeAt(start + 5) === 99 /* c */) ? 59 /* PublicKeyword */ : 9 /* IdentifierName */; + case 114 /* r */: return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 117 /* u */ && str.charCodeAt(start + 4) === 114 /* r */ && str.charCodeAt(start + 5) === 110 /* n */) ? 35 /* ReturnKeyword */ : 9 /* IdentifierName */; case 115 /* s */: switch (str.charCodeAt(start + 1)) { case 116 /* t */: switch (str.charCodeAt(start + 2)) { - case 97 /* a */: - return (str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 105 /* i */ && str.charCodeAt(start + 5) === 99 /* c */) ? 58 /* StaticKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (str.charCodeAt(start + 3) === 105 /* i */ && str.charCodeAt(start + 4) === 110 /* n */ && str.charCodeAt(start + 5) === 103 /* g */) ? 69 /* StringKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 97 /* a */: return (str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 105 /* i */ && str.charCodeAt(start + 5) === 99 /* c */) ? 60 /* StaticKeyword */ : 9 /* IdentifierName */; + case 114 /* r */: return (str.charCodeAt(start + 3) === 105 /* i */ && str.charCodeAt(start + 4) === 110 /* n */ && str.charCodeAt(start + 5) === 103 /* g */) ? 71 /* StringKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - case 119 /* w */: - return (str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 99 /* c */ && str.charCodeAt(start + 5) === 104 /* h */) ? 34 /* SwitchKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 119 /* w */: return (str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 99 /* c */ && str.charCodeAt(start + 5) === 104 /* h */) ? 36 /* SwitchKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - case 116 /* t */: - return (str.charCodeAt(start + 1) === 121 /* y */ && str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 111 /* o */ && str.charCodeAt(start + 5) === 102 /* f */) ? 39 /* TypeOfKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 116 /* t */: return (str.charCodeAt(start + 1) === 121 /* y */ && str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 111 /* o */ && str.charCodeAt(start + 5) === 102 /* f */) ? 41 /* TypeOfKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } case 7: switch (str.charCodeAt(start)) { - case 98 /* b */: - return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 111 /* o */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 101 /* e */ && str.charCodeAt(start + 5) === 97 /* a */ && str.charCodeAt(start + 6) === 110 /* n */) ? 61 /* BooleanKeyword */ : 11 /* IdentifierName */; + case 98 /* b */: return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 111 /* o */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 101 /* e */ && str.charCodeAt(start + 5) === 97 /* a */ && str.charCodeAt(start + 6) === 110 /* n */) ? 63 /* BooleanKeyword */ : 9 /* IdentifierName */; case 100 /* d */: switch (str.charCodeAt(start + 1)) { case 101 /* e */: switch (str.charCodeAt(start + 2)) { - case 99 /* c */: - return (str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 97 /* a */ && str.charCodeAt(start + 5) === 114 /* r */ && str.charCodeAt(start + 6) === 101 /* e */) ? 63 /* DeclareKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (str.charCodeAt(start + 3) === 97 /* a */ && str.charCodeAt(start + 4) === 117 /* u */ && str.charCodeAt(start + 5) === 108 /* l */ && str.charCodeAt(start + 6) === 116 /* t */) ? 20 /* DefaultKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 99 /* c */: return (str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 97 /* a */ && str.charCodeAt(start + 5) === 114 /* r */ && str.charCodeAt(start + 6) === 101 /* e */) ? 65 /* DeclareKeyword */ : 9 /* IdentifierName */; + case 102 /* f */: return (str.charCodeAt(start + 3) === 97 /* a */ && str.charCodeAt(start + 4) === 117 /* u */ && str.charCodeAt(start + 5) === 108 /* l */ && str.charCodeAt(start + 6) === 116 /* t */) ? 22 /* DefaultKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - default: - return 11 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - case 101 /* e */: - return (str.charCodeAt(start + 1) === 120 /* x */ && str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 110 /* n */ && str.charCodeAt(start + 5) === 100 /* d */ && str.charCodeAt(start + 6) === 115 /* s */) ? 48 /* ExtendsKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (str.charCodeAt(start + 1) === 105 /* i */ && str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 97 /* a */ && str.charCodeAt(start + 4) === 108 /* l */ && str.charCodeAt(start + 5) === 108 /* l */ && str.charCodeAt(start + 6) === 121 /* y */) ? 25 /* FinallyKeyword */ : 11 /* IdentifierName */; + case 101 /* e */: return (str.charCodeAt(start + 1) === 120 /* x */ && str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 110 /* n */ && str.charCodeAt(start + 5) === 100 /* d */ && str.charCodeAt(start + 6) === 115 /* s */) ? 50 /* ExtendsKeyword */ : 9 /* IdentifierName */; + case 102 /* f */: return (str.charCodeAt(start + 1) === 105 /* i */ && str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 97 /* a */ && str.charCodeAt(start + 4) === 108 /* l */ && str.charCodeAt(start + 5) === 108 /* l */ && str.charCodeAt(start + 6) === 121 /* y */) ? 27 /* FinallyKeyword */ : 9 /* IdentifierName */; case 112 /* p */: switch (str.charCodeAt(start + 1)) { - case 97 /* a */: - return (str.charCodeAt(start + 2) === 99 /* c */ && str.charCodeAt(start + 3) === 107 /* k */ && str.charCodeAt(start + 4) === 97 /* a */ && str.charCodeAt(start + 5) === 103 /* g */ && str.charCodeAt(start + 6) === 101 /* e */) ? 54 /* PackageKeyword */ : 11 /* IdentifierName */; - case 114 /* r */: - return (str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 118 /* v */ && str.charCodeAt(start + 4) === 97 /* a */ && str.charCodeAt(start + 5) === 116 /* t */ && str.charCodeAt(start + 6) === 101 /* e */) ? 55 /* PrivateKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 97 /* a */: return (str.charCodeAt(start + 2) === 99 /* c */ && str.charCodeAt(start + 3) === 107 /* k */ && str.charCodeAt(start + 4) === 97 /* a */ && str.charCodeAt(start + 5) === 103 /* g */ && str.charCodeAt(start + 6) === 101 /* e */) ? 56 /* PackageKeyword */ : 9 /* IdentifierName */; + case 114 /* r */: return (str.charCodeAt(start + 2) === 105 /* i */ && str.charCodeAt(start + 3) === 118 /* v */ && str.charCodeAt(start + 4) === 97 /* a */ && str.charCodeAt(start + 5) === 116 /* t */ && str.charCodeAt(start + 6) === 101 /* e */) ? 57 /* PrivateKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - case 114 /* r */: - return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 113 /* q */ && str.charCodeAt(start + 3) === 117 /* u */ && str.charCodeAt(start + 4) === 105 /* i */ && str.charCodeAt(start + 5) === 114 /* r */ && str.charCodeAt(start + 6) === 101 /* e */) ? 66 /* RequireKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 114 /* r */: return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 113 /* q */ && str.charCodeAt(start + 3) === 117 /* u */ && str.charCodeAt(start + 4) === 105 /* i */ && str.charCodeAt(start + 5) === 114 /* r */ && str.charCodeAt(start + 6) === 101 /* e */) ? 68 /* RequireKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } case 8: switch (str.charCodeAt(start)) { - case 99 /* c */: - return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 105 /* i */ && str.charCodeAt(start + 5) === 110 /* n */ && str.charCodeAt(start + 6) === 117 /* u */ && str.charCodeAt(start + 7) === 101 /* e */) ? 18 /* ContinueKeyword */ : 11 /* IdentifierName */; - case 100 /* d */: - return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 98 /* b */ && str.charCodeAt(start + 3) === 117 /* u */ && str.charCodeAt(start + 4) === 103 /* g */ && str.charCodeAt(start + 5) === 103 /* g */ && str.charCodeAt(start + 6) === 101 /* e */ && str.charCodeAt(start + 7) === 114 /* r */) ? 19 /* DebuggerKeyword */ : 11 /* IdentifierName */; - case 102 /* f */: - return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 99 /* c */ && str.charCodeAt(start + 4) === 116 /* t */ && str.charCodeAt(start + 5) === 105 /* i */ && str.charCodeAt(start + 6) === 111 /* o */ && str.charCodeAt(start + 7) === 110 /* n */) ? 27 /* FunctionKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 99 /* c */: return (str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 105 /* i */ && str.charCodeAt(start + 5) === 110 /* n */ && str.charCodeAt(start + 6) === 117 /* u */ && str.charCodeAt(start + 7) === 101 /* e */) ? 20 /* ContinueKeyword */ : 9 /* IdentifierName */; + case 100 /* d */: return (str.charCodeAt(start + 1) === 101 /* e */ && str.charCodeAt(start + 2) === 98 /* b */ && str.charCodeAt(start + 3) === 117 /* u */ && str.charCodeAt(start + 4) === 103 /* g */ && str.charCodeAt(start + 5) === 103 /* g */ && str.charCodeAt(start + 6) === 101 /* e */ && str.charCodeAt(start + 7) === 114 /* r */) ? 21 /* DebuggerKeyword */ : 9 /* IdentifierName */; + case 102 /* f */: return (str.charCodeAt(start + 1) === 117 /* u */ && str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 99 /* c */ && str.charCodeAt(start + 4) === 116 /* t */ && str.charCodeAt(start + 5) === 105 /* i */ && str.charCodeAt(start + 6) === 111 /* o */ && str.charCodeAt(start + 7) === 110 /* n */) ? 29 /* FunctionKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } case 9: switch (str.charCodeAt(start)) { - case 105 /* i */: - return (str.charCodeAt(start + 1) === 110 /* n */ && str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 114 /* r */ && str.charCodeAt(start + 5) === 102 /* f */ && str.charCodeAt(start + 6) === 97 /* a */ && str.charCodeAt(start + 7) === 99 /* c */ && str.charCodeAt(start + 8) === 101 /* e */) ? 52 /* InterfaceKeyword */ : 11 /* IdentifierName */; - case 112 /* p */: - return (str.charCodeAt(start + 1) === 114 /* r */ && str.charCodeAt(start + 2) === 111 /* o */ && str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 101 /* e */ && str.charCodeAt(start + 5) === 99 /* c */ && str.charCodeAt(start + 6) === 116 /* t */ && str.charCodeAt(start + 7) === 101 /* e */ && str.charCodeAt(start + 8) === 100 /* d */) ? 56 /* ProtectedKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 105 /* i */: return (str.charCodeAt(start + 1) === 110 /* n */ && str.charCodeAt(start + 2) === 116 /* t */ && str.charCodeAt(start + 3) === 101 /* e */ && str.charCodeAt(start + 4) === 114 /* r */ && str.charCodeAt(start + 5) === 102 /* f */ && str.charCodeAt(start + 6) === 97 /* a */ && str.charCodeAt(start + 7) === 99 /* c */ && str.charCodeAt(start + 8) === 101 /* e */) ? 54 /* InterfaceKeyword */ : 9 /* IdentifierName */; + case 112 /* p */: return (str.charCodeAt(start + 1) === 114 /* r */ && str.charCodeAt(start + 2) === 111 /* o */ && str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 101 /* e */ && str.charCodeAt(start + 5) === 99 /* c */ && str.charCodeAt(start + 6) === 116 /* t */ && str.charCodeAt(start + 7) === 101 /* e */ && str.charCodeAt(start + 8) === 100 /* d */) ? 58 /* ProtectedKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } case 10: switch (str.charCodeAt(start)) { case 105 /* i */: switch (str.charCodeAt(start + 1)) { - case 109 /* m */: - return (str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 101 /* e */ && str.charCodeAt(start + 5) === 109 /* m */ && str.charCodeAt(start + 6) === 101 /* e */ && str.charCodeAt(start + 7) === 110 /* n */ && str.charCodeAt(start + 8) === 116 /* t */ && str.charCodeAt(start + 9) === 115 /* s */) ? 51 /* ImplementsKeyword */ : 11 /* IdentifierName */; - case 110 /* n */: - return (str.charCodeAt(start + 2) === 115 /* s */ && str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 97 /* a */ && str.charCodeAt(start + 5) === 110 /* n */ && str.charCodeAt(start + 6) === 99 /* c */ && str.charCodeAt(start + 7) === 101 /* e */ && str.charCodeAt(start + 8) === 111 /* o */ && str.charCodeAt(start + 9) === 102 /* f */) ? 30 /* InstanceOfKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 109 /* m */: return (str.charCodeAt(start + 2) === 112 /* p */ && str.charCodeAt(start + 3) === 108 /* l */ && str.charCodeAt(start + 4) === 101 /* e */ && str.charCodeAt(start + 5) === 109 /* m */ && str.charCodeAt(start + 6) === 101 /* e */ && str.charCodeAt(start + 7) === 110 /* n */ && str.charCodeAt(start + 8) === 116 /* t */ && str.charCodeAt(start + 9) === 115 /* s */) ? 53 /* ImplementsKeyword */ : 9 /* IdentifierName */; + case 110 /* n */: return (str.charCodeAt(start + 2) === 115 /* s */ && str.charCodeAt(start + 3) === 116 /* t */ && str.charCodeAt(start + 4) === 97 /* a */ && str.charCodeAt(start + 5) === 110 /* n */ && str.charCodeAt(start + 6) === 99 /* c */ && str.charCodeAt(start + 7) === 101 /* e */ && str.charCodeAt(start + 8) === 111 /* o */ && str.charCodeAt(start + 9) === 102 /* f */) ? 32 /* InstanceOfKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - default: - return 11 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - case 11: - return (str.charCodeAt(start) === 99 /* c */ && str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 115 /* s */ && str.charCodeAt(start + 4) === 116 /* t */ && str.charCodeAt(start + 5) === 114 /* r */ && str.charCodeAt(start + 6) === 117 /* u */ && str.charCodeAt(start + 7) === 99 /* c */ && str.charCodeAt(start + 8) === 116 /* t */ && str.charCodeAt(start + 9) === 111 /* o */ && str.charCodeAt(start + 10) === 114 /* r */) ? 62 /* ConstructorKeyword */ : 11 /* IdentifierName */; - default: - return 11 /* IdentifierName */; + case 11: return (str.charCodeAt(start) === 99 /* c */ && str.charCodeAt(start + 1) === 111 /* o */ && str.charCodeAt(start + 2) === 110 /* n */ && str.charCodeAt(start + 3) === 115 /* s */ && str.charCodeAt(start + 4) === 116 /* t */ && str.charCodeAt(start + 5) === 114 /* r */ && str.charCodeAt(start + 6) === 117 /* u */ && str.charCodeAt(start + 7) === 99 /* c */ && str.charCodeAt(start + 8) === 116 /* t */ && str.charCodeAt(start + 9) === 111 /* o */ && str.charCodeAt(start + 10) === 114 /* r */) ? 64 /* ConstructorKeyword */ : 9 /* IdentifierName */; + default: return 9 /* IdentifierName */; } - }; - return ScannerUtilities; - })(); - TypeScript.ScannerUtilities = ScannerUtilities; + } + ScannerUtilities.identifierKind = identifierKind; + })(ScannerUtilities = TypeScript.ScannerUtilities || (TypeScript.ScannerUtilities = {})); })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { @@ -20063,7 +19962,7 @@ var TypeScript; }; SlidingWindow.prototype.peekItemN = function (n) { while (this.currentRelativeItemIndex + n >= this.windowCount) { - if (!this.addMoreItemsToWindow(null)) { + if (!this.addMoreItemsToWindow(undefined)) { return this.defaultValue; } } @@ -20084,22 +19983,12 @@ var TypeScript; var Syntax; (function (Syntax) { Syntax._nextSyntaxID = 1; - function childIndex(parent, child) { - for (var i = 0, n = TypeScript.childCount(parent); i < n; i++) { - var current = TypeScript.childAt(parent, i); - if (current === child) { - return i; - } - } - throw TypeScript.Errors.invalidOperation(); - } - Syntax.childIndex = childIndex; function nodeHasSkippedOrMissingTokens(node) { for (var i = 0; i < TypeScript.childCount(node); i++) { var child = TypeScript.childAt(node, i); if (TypeScript.isToken(child)) { var token = child; - if (token.hasSkippedToken() || (TypeScript.width(token) === 0 && token.kind() !== 10 /* EndOfFileToken */)) { + if (token.hasSkippedToken() || (TypeScript.width(token) === 0 && token.kind() !== 8 /* EndOfFileToken */)) { return true; } } @@ -20108,7 +19997,7 @@ var TypeScript; } Syntax.nodeHasSkippedOrMissingTokens = nodeHasSkippedOrMissingTokens; function isUnterminatedStringLiteral(token) { - if (token && token.kind() === 14 /* StringLiteral */) { + if (token && token.kind() === 12 /* StringLiteral */) { var text = token.text(); return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); } @@ -20116,7 +20005,7 @@ var TypeScript; } Syntax.isUnterminatedStringLiteral = isUnterminatedStringLiteral; function isUnterminatedMultilineCommentTrivia(trivia) { - if (trivia && trivia.kind() === 6 /* MultiLineCommentTrivia */) { + if (trivia && trivia.kind() === 4 /* MultiLineCommentTrivia */) { var text = trivia.fullText(); return text.length < 4 || text.substring(text.length - 2) !== "*/"; } @@ -20130,7 +20019,7 @@ var TypeScript; return true; } else if (position === end) { - return trivia.kind() === 7 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); + return trivia.kind() === 5 /* SingleLineCommentTrivia */ || isUnterminatedMultilineCommentTrivia(trivia); } } return false; @@ -20139,9 +20028,9 @@ var TypeScript; function isEntirelyInsideComment(sourceUnit, position) { var positionedToken = TypeScript.findToken(sourceUnit, position); var fullStart = positionedToken.fullStart(); - var triviaList = null; - var lastTriviaBeforeToken = null; - if (positionedToken.kind() === 10 /* EndOfFileToken */) { + var triviaList = undefined; + var lastTriviaBeforeToken = undefined; + if (positionedToken.kind() === 8 /* EndOfFileToken */) { if (positionedToken.hasLeadingTrivia()) { triviaList = positionedToken.leadingTrivia(); } @@ -20183,45 +20072,17 @@ var TypeScript; function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit, position) { var positionedToken = TypeScript.findToken(sourceUnit, position); if (positionedToken) { - if (positionedToken.kind() === 10 /* EndOfFileToken */) { + if (positionedToken.kind() === 8 /* EndOfFileToken */) { positionedToken = TypeScript.previousToken(positionedToken); return positionedToken && positionedToken.trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken); } else if (position > TypeScript.start(positionedToken)) { - return (position < TypeScript.end(positionedToken) && (positionedToken.kind() === 14 /* StringLiteral */ || positionedToken.kind() === 12 /* RegularExpressionLiteral */)) || (position <= TypeScript.end(positionedToken) && isUnterminatedStringLiteral(positionedToken)); + return (position < TypeScript.end(positionedToken) && (positionedToken.kind() === 12 /* StringLiteral */ || positionedToken.kind() === 10 /* RegularExpressionLiteral */)) || (position <= TypeScript.end(positionedToken) && isUnterminatedStringLiteral(positionedToken)); } } return false; } Syntax.isEntirelyInStringOrRegularExpressionLiteral = isEntirelyInStringOrRegularExpressionLiteral; - function findSkippedTokenOnLeftInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; - var fullEnd; - if (lookInLeadingTriviaList) { - triviaList = positionedToken.leadingTrivia(); - fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); - } - else { - triviaList = positionedToken.trailingTrivia(); - fullEnd = TypeScript.fullEnd(positionedToken); - } - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - if (trivia.isSkippedToken() && position >= fullEnd) { - return trivia.skippedToken(); - } - fullEnd -= triviaWidth; - } - } - return null; - } - function findSkippedTokenOnLeft(positionedToken, position) { - var positionInLeadingTriviaList = (position < TypeScript.start(positionedToken)); - return findSkippedTokenOnLeftInTriviaList(positionedToken, position, positionInLeadingTriviaList); - } - Syntax.findSkippedTokenOnLeft = findSkippedTokenOnLeft; function getAncestorOfKind(positionedToken, kind) { while (positionedToken && positionedToken.parent) { if (positionedToken.parent.kind() === kind) { @@ -20229,21 +20090,24 @@ var TypeScript; } positionedToken = positionedToken.parent; } - return null; + return undefined; } Syntax.getAncestorOfKind = getAncestorOfKind; function hasAncestorOfKind(positionedToken, kind) { - return getAncestorOfKind(positionedToken, kind) !== null; + return !!getAncestorOfKind(positionedToken, kind); } Syntax.hasAncestorOfKind = hasAncestorOfKind; function isIntegerLiteral(expression) { if (expression) { switch (expression.kind()) { - case 165 /* PlusExpression */: - case 166 /* NegateExpression */: - expression = expression.operand; - return TypeScript.isToken(expression) && TypeScript.IntegerUtilities.isInteger(expression.text()); - case 13 /* NumericLiteral */: + case 169 /* PrefixUnaryExpression */: + var prefixExpr = expression; + if (prefixExpr.operatorToken.kind() == 91 /* PlusToken */ || prefixExpr.operatorToken.kind() === 92 /* MinusToken */) { + expression = prefixExpr.operand; + return TypeScript.isToken(expression) && TypeScript.IntegerUtilities.isInteger(expression.text()); + } + return false; + case 11 /* NumericLiteral */: var text = expression.text(); return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); } @@ -20253,38 +20117,30 @@ var TypeScript; Syntax.isIntegerLiteral = isIntegerLiteral; function containingNode(element) { var current = element.parent; - while (current !== null && !TypeScript.isNode(current)) { + while (current && !TypeScript.isNode(current)) { current = current.parent; } return current; } Syntax.containingNode = containingNode; - function findTokenOnLeft(element, position, includeSkippedTokens) { - if (includeSkippedTokens === void 0) { includeSkippedTokens = false; } - var positionedToken = TypeScript.findToken(element, position, false); + function findTokenOnLeft(sourceUnit, position) { + var positionedToken = TypeScript.findToken(sourceUnit, position); var _start = TypeScript.start(positionedToken); - if (includeSkippedTokens) { - positionedToken = findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } if (position > _start) { return positionedToken; } if (positionedToken.fullStart() === 0) { - return null; + return undefined; } - return TypeScript.previousToken(positionedToken, includeSkippedTokens); + return TypeScript.previousToken(positionedToken); } Syntax.findTokenOnLeft = findTokenOnLeft; - function findCompleteTokenOnLeft(element, position, includeSkippedTokens) { - if (includeSkippedTokens === void 0) { includeSkippedTokens = false; } - var positionedToken = TypeScript.findToken(element, position, false); - if (includeSkippedTokens) { - positionedToken = findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } + function findCompleteTokenOnLeft(sourceUnit, position) { + var positionedToken = TypeScript.findToken(sourceUnit, position); if (TypeScript.width(positionedToken) > 0 && position >= TypeScript.end(positionedToken)) { return positionedToken; } - return TypeScript.previousToken(positionedToken, includeSkippedTokens); + return TypeScript.previousToken(positionedToken); } Syntax.findCompleteTokenOnLeft = findCompleteTokenOnLeft; function firstTokenInLineContainingPosition(syntaxTree, position) { @@ -20300,7 +20156,7 @@ var TypeScript; Syntax.firstTokenInLineContainingPosition = firstTokenInLineContainingPosition; function isFirstTokenInLine(token, lineMap) { var _previousToken = TypeScript.previousToken(token); - if (_previousToken === null) { + if (_previousToken === undefined) { return true; } return lineMap.getLineNumberFromPosition(TypeScript.end(_previousToken)) !== lineMap.getLineNumberFromPosition(TypeScript.start(token)); @@ -20309,97 +20165,50 @@ var TypeScript; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { - function isShared(element) { - var kind = element.kind(); - return (kind === 1 /* List */ || kind === 2 /* SeparatedList */) && element.length === 0; - } - TypeScript.isShared = isShared; - function childCount(element) { - var kind = element.kind(); - if (kind === 1 /* List */) { - return element.length; - } - else if (kind === 2 /* SeparatedList */) { - return element.length + element.separators.length; - } - else if (kind >= TypeScript.SyntaxKind.FirstToken && kind <= TypeScript.SyntaxKind.LastToken) { - return 0; - } - else { - return TypeScript.nodeMetadata[kind].length; - } - } - TypeScript.childCount = childCount; - function childAt(element, index) { - var kind = element.kind(); - if (kind === 1 /* List */) { - return element[index]; - } - else if (kind === 2 /* SeparatedList */) { - return (index % 2 === 0) ? element[index / 2] : element.separators[(index - 1) / 2]; - } - else { - return element[TypeScript.nodeMetadata[element.kind()][index]]; - } - } - TypeScript.childAt = childAt; function syntaxTree(element) { if (element) { - TypeScript.Debug.assert(!isShared(element)); while (element) { - if (element.kind() === 120 /* SourceUnit */) { + if (element.kind() === 122 /* SourceUnit */) { return element.syntaxTree; } element = element.parent; } } - return null; + return undefined; } TypeScript.syntaxTree = syntaxTree; function parsedInStrictMode(node) { - var info = node.data; + var info = node.__data; if (info === undefined) { return false; } return (info & 4 /* NodeParsedInStrictModeMask */) !== 0; } TypeScript.parsedInStrictMode = parsedInStrictMode; - function previousToken(token, includeSkippedTokens) { - if (includeSkippedTokens === void 0) { includeSkippedTokens = false; } - if (includeSkippedTokens) { - var triviaList = token.leadingTrivia(); - if (triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = TypeScript.start(token); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return trivia.skippedToken(); - } - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - } + function previousToken(token) { var start = token.fullStart(); if (start === 0) { - return null; + return undefined; } - return findToken(syntaxTree(token).sourceUnit(), start - 1, includeSkippedTokens); + return findToken(syntaxTree(token).sourceUnit(), start - 1); } TypeScript.previousToken = previousToken; - function findToken(element, position, includeSkippedTokens) { - if (includeSkippedTokens === void 0) { includeSkippedTokens = false; } - var endOfFileToken = tryGetEndOfFileAt(element, position); - if (endOfFileToken !== null) { - return endOfFileToken; - } - if (position < 0 || position >= fullWidth(element)) { + function findToken(sourceUnit, position) { + if (position < 0) { throw TypeScript.Errors.argumentOutOfRange("position"); } - var positionedToken = findTokenWorker(element, position); - if (includeSkippedTokens) { - return findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + var token = findTokenWorker(sourceUnit, 0, position); + if (token) { + TypeScript.Debug.assert(token.fullWidth() > 0); + return token; } - return positionedToken; + if (position === fullWidth(sourceUnit)) { + return sourceUnit.endOfFileToken; + } + if (position > fullWidth(sourceUnit)) { + throw TypeScript.Errors.argumentOutOfRange("position"); + } + throw TypeScript.Errors.invalidOperation(); } TypeScript.findToken = findToken; function findSkippedTokenInPositionedToken(positionedToken, position) { @@ -20416,7 +20225,7 @@ var TypeScript; } TypeScript.findSkippedTokenInTrailingTriviaList = findSkippedTokenInTrailingTriviaList; function findSkippedTokenInTriviaList(positionedToken, position, lookInLeadingTriviaList) { - var triviaList = null; + var triviaList = undefined; var fullStart; if (lookInLeadingTriviaList) { triviaList = positionedToken.leadingTrivia(); @@ -20436,61 +20245,41 @@ var TypeScript; fullStart += triviaWidth; } } - return null; + return undefined; } - function findTokenWorker(element, position) { + function findTokenWorker(element, elementPosition, position) { if (isToken(element)) { - TypeScript.Debug.assert(fullWidth(element) > 0); return element; } - if (isShared(element)) { - throw TypeScript.Errors.invalidOperation(); - } - for (var i = 0, n = childCount(element); i < n; i++) { - var child = childAt(element, i); - if (child !== null) { + for (var i = 0, n = TypeScript.childCount(element); i < n; i++) { + var child = TypeScript.childAt(element, i); + if (child) { var childFullWidth = fullWidth(child); - if (childFullWidth > 0) { - var childFullStart = fullStart(child); - if (position >= childFullStart) { - var childFullEnd = childFullStart + childFullWidth; - if (position < childFullEnd) { - return findTokenWorker(child, position); - } - } + var elementEndPosition = elementPosition + childFullWidth; + if (position < elementEndPosition) { + return findTokenWorker(child, elementPosition, position); } + elementPosition = elementEndPosition; } } - throw TypeScript.Errors.invalidOperation(); + return undefined; } function tryGetEndOfFileAt(element, position) { - if (element.kind() === 120 /* SourceUnit */ && position === fullWidth(element)) { + if (element.kind() === 122 /* SourceUnit */ && position === fullWidth(element)) { var sourceUnit = element; return sourceUnit.endOfFileToken; } - return null; + return undefined; } - function nextToken(token, text, includeSkippedTokens) { - if (includeSkippedTokens === void 0) { includeSkippedTokens = false; } - if (token.kind() === 10 /* EndOfFileToken */) { - return null; + function nextToken(token, text) { + if (token.kind() === 8 /* EndOfFileToken */) { + return undefined; } - if (includeSkippedTokens) { - var triviaList = token.trailingTrivia(text); - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return trivia.skippedToken(); - } - } - } - } - return findToken(syntaxTree(token).sourceUnit(), fullEnd(token), includeSkippedTokens); + return findToken(syntaxTree(token).sourceUnit(), fullEnd(token)); } TypeScript.nextToken = nextToken; function isNode(element) { - if (element !== null) { + if (element) { var kind = element.kind(); return kind >= TypeScript.SyntaxKind.FirstNode && kind <= TypeScript.SyntaxKind.LastNode; } @@ -20501,24 +20290,17 @@ var TypeScript; return kind >= TypeScript.SyntaxKind.FirstToken && kind <= TypeScript.SyntaxKind.LastToken; } function isToken(element) { - if (element !== null) { + if (element) { return isTokenKind(element.kind()); } return false; } TypeScript.isToken = isToken; function isList(element) { - return element !== null && element.kind() === 1 /* List */; + return element instanceof Array; } TypeScript.isList = isList; - function isSeparatedList(element) { - return element !== null && element.kind() === 2 /* SeparatedList */; - } - TypeScript.isSeparatedList = isSeparatedList; function syntaxID(element) { - if (isShared(element)) { - throw TypeScript.Errors.invalidOperation("Should not use shared syntax element as a key."); - } var obj = element; if (obj._syntaxID === undefined) { obj._syntaxID = TypeScript.Syntax._nextSyntaxID++; @@ -20532,8 +20314,8 @@ var TypeScript; elements.push(element.fullText(text)); } else { - for (var i = 0, n = childCount(element); i < n; i++) { - collectTextElements(childAt(element, i), elements, text); + for (var i = 0, n = TypeScript.childCount(element); i < n; i++) { + collectTextElements(TypeScript.childAt(element, i), elements, text); } } } @@ -20561,65 +20343,38 @@ var TypeScript; if (element) { var kind = element.kind(); if (isTokenKind(kind)) { - return fullWidth(element) > 0 || element.kind() === 10 /* EndOfFileToken */ ? element : null; + return element.fullWidth() > 0 || kind === 8 /* EndOfFileToken */ ? element : undefined; } - if (kind === 1 /* List */) { - var array = element; - for (var i = 0, n = array.length; i < n; i++) { - var token = firstToken(array[i]); - if (token) { - return token; - } - } - } - else if (kind === 2 /* SeparatedList */) { - var array = element; - var separators = array.separators; - for (var i = 0, n = array.length + separators.length; i < n; i++) { - var token = firstToken(i % 2 === 0 ? array[i / 2] : separators[(i - 1) / 2]); - if (token) { - return token; - } - } - } - else { - var metadata = TypeScript.nodeMetadata[kind]; - for (var i = 0, n = metadata.length; i < n; i++) { - var child = element[metadata[i]]; - var token = firstToken(child); - if (token) { - return token; - } - } - if (element.kind() === 120 /* SourceUnit */) { - return element.endOfFileToken; + for (var i = 0, n = TypeScript.childCount(element); i < n; i++) { + var token = firstToken(TypeScript.childAt(element, i)); + if (token) { + return token; } } } - return null; + return undefined; } TypeScript.firstToken = firstToken; function lastToken(element) { if (isToken(element)) { - return fullWidth(element) > 0 || element.kind() === 10 /* EndOfFileToken */ ? element : null; + return fullWidth(element) > 0 || element.kind() === 8 /* EndOfFileToken */ ? element : undefined; } - if (element.kind() === 120 /* SourceUnit */) { + if (element.kind() === 122 /* SourceUnit */) { return element.endOfFileToken; } - for (var i = childCount(element) - 1; i >= 0; i--) { - var child = childAt(element, i); - if (child !== null) { + for (var i = TypeScript.childCount(element) - 1; i >= 0; i--) { + var child = TypeScript.childAt(element, i); + if (child) { var token = lastToken(child); if (token) { return token; } } } - return null; + return undefined; } TypeScript.lastToken = lastToken; function fullStart(element) { - TypeScript.Debug.assert(!isShared(element)); var token = isToken(element) ? element : firstToken(element); return token ? token.fullStart() : -1; } @@ -20628,9 +20383,6 @@ var TypeScript; if (isToken(element)) { return element.fullWidth(); } - if (isShared(element)) { - return 0; - } var info = data(element); return info >>> 3 /* NodeFullWidthShift */; } @@ -20639,31 +20391,27 @@ var TypeScript; if (isToken(element)) { return element.isIncrementallyUnusable(); } - if (isShared(element)) { - return false; - } return (data(element) & 2 /* NodeIncrementallyUnusableMask */) !== 0; } TypeScript.isIncrementallyUnusable = isIncrementallyUnusable; function data(element) { - TypeScript.Debug.assert(isNode(element) || isList(element) || isSeparatedList(element)); var dataElement = element; - var info = dataElement.data; + var info = dataElement.__data; if (info === undefined) { info = 0; } if ((info & 1 /* NodeDataComputed */) === 0) { info |= computeData(element); - dataElement.data = info; + dataElement.__data = info; } return info; } function computeData(element) { - var slotCount = childCount(element); + var slotCount = TypeScript.childCount(element); var fullWidth = 0; - var isIncrementallyUnusable = slotCount === 0; + var isIncrementallyUnusable = slotCount === 0 && !isList(element); for (var i = 0, n = slotCount; i < n; i++) { - var child = childAt(element, i); + var child = TypeScript.childAt(element, i); if (child) { fullWidth += TypeScript.fullWidth(child); isIncrementallyUnusable = isIncrementallyUnusable || TypeScript.isIncrementallyUnusable(child); @@ -20696,7 +20444,7 @@ var TypeScript; if (token1 === token2) { return false; } - if (token1 === null || token2 === null) { + if (!token1 || !token2) { return true; } var lineMap = text.lineMap(); @@ -20709,10 +20457,10 @@ var TypeScript; var SyntaxFacts; (function (SyntaxFacts) { function isDirectivePrologueElement(node) { - if (node.kind() === 150 /* ExpressionStatement */) { + if (node.kind() === 154 /* ExpressionStatement */) { var expressionStatement = node; var expression = expressionStatement.expression; - if (expression.kind() === 14 /* StringLiteral */) { + if (expression.kind() === 12 /* StringLiteral */) { return true; } } @@ -20728,14 +20476,14 @@ var TypeScript; SyntaxFacts.isUseStrictDirective = isUseStrictDirective; function isIdentifierNameOrAnyKeyword(token) { var tokenKind = token.kind(); - return tokenKind === 11 /* IdentifierName */ || SyntaxFacts.isAnyKeyword(tokenKind); + return tokenKind === 9 /* IdentifierName */ || SyntaxFacts.isAnyKeyword(tokenKind); } SyntaxFacts.isIdentifierNameOrAnyKeyword = isIdentifierNameOrAnyKeyword; function isAccessibilityModifier(kind) { switch (kind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 56 /* ProtectedKeyword */: + case 59 /* PublicKeyword */: + case 57 /* PrivateKeyword */: + case 58 /* ProtectedKeyword */: return true; } return false; @@ -20744,126 +20492,94 @@ var TypeScript; })(SyntaxFacts = TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); })(TypeScript || (TypeScript = {})); var TypeScript; +(function (TypeScript) { + function separatorCount(list) { + return list.length >> 1; + } + TypeScript.separatorCount = separatorCount; + function nonSeparatorCount(list) { + return (list.length + 1) >> 1; + } + TypeScript.nonSeparatorCount = nonSeparatorCount; + function separatorAt(list, index) { + return list[(index << 1) + 1]; + } + TypeScript.separatorAt = separatorAt; + function nonSeparatorAt(list, index) { + return list[index << 1]; + } + TypeScript.nonSeparatorAt = nonSeparatorAt; +})(TypeScript || (TypeScript = {})); +var TypeScript; (function (TypeScript) { var Syntax; (function (Syntax) { - var _emptyList = []; - var _emptySeparatedList = []; - var _emptySeparators = []; - _emptySeparatedList.separators = _emptySeparators; - function assertEmptyLists() { - } - Array.prototype.kind = function () { - return this.separators === undefined ? 1 /* List */ : 2 /* SeparatedList */; - }; - Array.prototype.separatorCount = function () { - assertEmptyLists(); - return this.separators.length; - }; - Array.prototype.separatorAt = function (index) { - assertEmptyLists(); - return this.separators[index]; - }; - function emptyList() { - return _emptyList; - } - Syntax.emptyList = emptyList; - function emptySeparatedList() { - return _emptySeparatedList; - } - Syntax.emptySeparatedList = emptySeparatedList; - function list(nodes) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return emptyList(); + function addArrayFunction(name, func) { + if (Object.defineProperty) { + Object.defineProperty(Array.prototype, name, { value: func, writable: true }); } + else { + Array.prototype[name] = func; + } + } + addArrayFunction("kind", function () { + return 1 /* List */; + }); + function list(nodes) { for (var i = 0, n = nodes.length; i < n; i++) { nodes[i].parent = nodes; } return nodes; } Syntax.list = list; - function separatedList(nodes, separators) { - if (nodes === undefined || nodes === null || nodes.length === 0) { - return emptySeparatedList(); + function separatedList(nodesAndTokens) { + for (var i = 0, n = nodesAndTokens.length; i < n; i++) { + nodesAndTokens[i].parent = nodesAndTokens; } - for (var i = 0, n = nodes.length; i < n; i++) { - nodes[i].parent = nodes; - } - for (var i = 0, n = separators.length; i < n; i++) { - separators[i].parent = nodes; - } - nodes.separators = separators.length === 0 ? _emptySeparators : separators; - return nodes; + return nodesAndTokens; } Syntax.separatedList = separatedList; - function nonSeparatorIndexOf(list, ast) { - for (var i = 0, n = list.length; i < n; i++) { - if (list[i] === ast) { - return i; - } - } - return -1; - } - Syntax.nonSeparatorIndexOf = nonSeparatorIndexOf; })(Syntax = TypeScript.Syntax || (TypeScript.Syntax = {})); })(TypeScript || (TypeScript = {})); var TypeScript; -(function (TypeScript) { - var SyntaxNode = (function () { - function SyntaxNode(data) { - if (data) { - this.data = data; - } - } - SyntaxNode.prototype.kind = function () { - return this.__kind; - }; - return SyntaxNode; - })(); - TypeScript.SyntaxNode = SyntaxNode; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - TypeScript.nodeMetadata = [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], ["moduleElements", "endOfFileToken"], ["left", "dotToken", "right"], ["openBraceToken", "typeMembers", "closeBraceToken"], ["typeParameterList", "parameterList", "equalsGreaterThanToken", "type"], ["type", "openBracketToken", "closeBracketToken"], ["newKeyword", "typeParameterList", "parameterList", "equalsGreaterThanToken", "type"], ["name", "typeArgumentList"], ["typeOfKeyword", "name"], ["openBracketToken", "types", "closeBracketToken"], ["modifiers", "interfaceKeyword", "identifier", "typeParameterList", "heritageClauses", "body"], ["modifiers", "functionKeyword", "identifier", "callSignature", "block", "semicolonToken"], ["modifiers", "moduleKeyword", "name", "stringLiteral", "openBraceToken", "moduleElements", "closeBraceToken"], ["modifiers", "classKeyword", "identifier", "typeParameterList", "heritageClauses", "openBraceToken", "classElements", "closeBraceToken"], ["modifiers", "enumKeyword", "identifier", "openBraceToken", "enumElements", "closeBraceToken"], ["modifiers", "importKeyword", "identifier", "equalsToken", "moduleReference", "semicolonToken"], ["exportKeyword", "equalsToken", "identifier", "semicolonToken"], ["modifiers", "propertyName", "callSignature", "block", "semicolonToken"], ["modifiers", "variableDeclarator", "semicolonToken"], ["modifiers", "constructorKeyword", "callSignature", "block", "semicolonToken"], ["modifiers", "indexSignature", "semicolonToken"], ["modifiers", "getKeyword", "propertyName", "callSignature", "block"], ["modifiers", "setKeyword", "propertyName", "callSignature", "block"], ["propertyName", "questionToken", "typeAnnotation"], ["typeParameterList", "parameterList", "typeAnnotation"], ["newKeyword", "callSignature"], ["openBracketToken", "parameters", "closeBracketToken", "typeAnnotation"], ["propertyName", "questionToken", "callSignature"], ["openBraceToken", "statements", "closeBraceToken"], ["ifKeyword", "openParenToken", "condition", "closeParenToken", "statement", "elseClause"], ["modifiers", "variableDeclaration", "semicolonToken"], ["expression", "semicolonToken"], ["returnKeyword", "expression", "semicolonToken"], ["switchKeyword", "openParenToken", "expression", "closeParenToken", "openBraceToken", "switchClauses", "closeBraceToken"], ["breakKeyword", "identifier", "semicolonToken"], ["continueKeyword", "identifier", "semicolonToken"], ["forKeyword", "openParenToken", "variableDeclaration", "initializer", "firstSemicolonToken", "condition", "secondSemicolonToken", "incrementor", "closeParenToken", "statement"], ["forKeyword", "openParenToken", "variableDeclaration", "left", "inKeyword", "expression", "closeParenToken", "statement"], ["semicolonToken"], ["throwKeyword", "expression", "semicolonToken"], ["whileKeyword", "openParenToken", "condition", "closeParenToken", "statement"], ["tryKeyword", "block", "catchClause", "finallyClause"], ["identifier", "colonToken", "statement"], ["doKeyword", "statement", "whileKeyword", "openParenToken", "condition", "closeParenToken", "semicolonToken"], ["debuggerKeyword", "semicolonToken"], ["withKeyword", "openParenToken", "condition", "closeParenToken", "statement"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["operatorToken", "operand"], ["deleteKeyword", "expression"], ["typeOfKeyword", "expression"], ["voidKeyword", "expression"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["condition", "questionToken", "whenTrue", "colonToken", "whenFalse"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["left", "operatorToken", "right"], ["operand", "operatorToken"], ["operand", "operatorToken"], ["expression", "dotToken", "name"], ["expression", "argumentList"], ["openBracketToken", "expressions", "closeBracketToken"], ["openBraceToken", "propertyAssignments", "closeBraceToken"], ["newKeyword", "expression", "argumentList"], ["openParenToken", "expression", "closeParenToken"], ["callSignature", "equalsGreaterThanToken", "block", "expression"], ["parameter", "equalsGreaterThanToken", "block", "expression"], ["lessThanToken", "type", "greaterThanToken", "expression"], ["expression", "openBracketToken", "argumentExpression", "closeBracketToken"], ["functionKeyword", "identifier", "callSignature", "block"], [], ["varKeyword", "variableDeclarators"], ["propertyName", "typeAnnotation", "equalsValueClause"], ["typeArgumentList", "openParenToken", "arguments", "closeParenToken"], ["openParenToken", "parameters", "closeParenToken"], ["lessThanToken", "typeArguments", "greaterThanToken"], ["lessThanToken", "typeParameters", "greaterThanToken"], ["extendsOrImplementsKeyword", "typeNames"], ["extendsOrImplementsKeyword", "typeNames"], ["equalsToken", "value"], ["caseKeyword", "expression", "colonToken", "statements"], ["defaultKeyword", "colonToken", "statements"], ["elseKeyword", "statement"], ["catchKeyword", "openParenToken", "identifier", "typeAnnotation", "closeParenToken", "block"], ["finallyKeyword", "block"], ["identifier", "constraint"], ["extendsKeyword", "typeOrExpression"], ["propertyName", "colonToken", "expression"], ["propertyName", "callSignature", "block"], ["dotDotDotToken", "modifiers", "identifier", "questionToken", "typeAnnotation", "equalsValueClause"], ["propertyName", "equalsValueClause"], ["colonToken", "type"], ["requireKeyword", "openParenToken", "stringLiteral", "closeParenToken"], ["moduleName"],]; -})(TypeScript || (TypeScript = {})); -var TypeScript; (function (TypeScript) { function tokenValue(token) { if (token.fullWidth() === 0) { - return null; + return undefined; } var kind = token.kind(); var text = token.text(); - if (kind === 11 /* IdentifierName */) { + if (kind === 9 /* IdentifierName */) { return massageEscapes(text); } switch (kind) { - case 37 /* TrueKeyword */: + case 39 /* TrueKeyword */: return true; - case 24 /* FalseKeyword */: + case 26 /* FalseKeyword */: return false; - case 32 /* NullKeyword */: - return null; + case 34 /* NullKeyword */: + return undefined; } if (TypeScript.SyntaxFacts.isAnyKeyword(kind) || TypeScript.SyntaxFacts.isAnyPunctuation(kind)) { return TypeScript.SyntaxFacts.getText(kind); } - if (kind === 13 /* NumericLiteral */) { + if (kind === 11 /* NumericLiteral */) { return TypeScript.IntegerUtilities.isHexInteger(text) ? parseInt(text, 16) : parseFloat(text); } - else if (kind === 14 /* StringLiteral */) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - return massageEscapes(text.substr(1, text.length - 2)); - } - else { - return massageEscapes(text.substr(1)); - } + else if (kind === 12 /* StringLiteral */) { + return (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) ? massageEscapes(text.substr(1, text.length - "''".length)) : massageEscapes(text.substr(1)); } - else if (kind === 12 /* RegularExpressionLiteral */) { + else if (kind === 13 /* NoSubstitutionTemplateToken */ || kind === 16 /* TemplateEndToken */) { + return (text.length > 1 && text.charCodeAt(text.length - 1) === 96 /* backtick */) ? massageTemplate(text.substr(1, text.length - "``".length)) : massageTemplate(text.substr(1)); + } + else if (kind === 14 /* TemplateStartToken */ || kind === 15 /* TemplateMiddleToken */) { + return massageTemplate(text.substr(1, text.length - "`${".length)); + } + else if (kind === 10 /* RegularExpressionLiteral */) { return regularExpressionValue(text); } - else if (kind === 10 /* EndOfFileToken */ || kind === 9 /* ErrorToken */) { - return null; + else if (kind === 8 /* EndOfFileToken */ || kind === 7 /* ErrorToken */) { + return undefined; } else { throw TypeScript.Errors.invalidOperation(); @@ -20872,9 +20588,13 @@ var TypeScript; TypeScript.tokenValue = tokenValue; function tokenValueText(token) { var value = tokenValue(token); - return value === null ? "" : massageDisallowedIdentifiers(value.toString()); + return value === undefined ? "" : massageDisallowedIdentifiers(value.toString()); } TypeScript.tokenValueText = tokenValueText; + function massageTemplate(text) { + text = text.replace("\r\n", "\n").replace("\r", "\n"); + return massageEscapes(text); + } function massageEscapes(text) { return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; } @@ -20887,7 +20607,7 @@ var TypeScript; return new RegExp(body, flags); } catch (e) { - return null; + return undefined; } } function massageDisallowedIdentifiers(text) { @@ -20952,12 +20672,12 @@ var TypeScript; } characterArray.push(ch); if (i && !(i % 1024)) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); + result = result.concat(String.fromCharCode.apply(undefined, characterArray)); characterArray.length = 0; } } if (characterArray.length) { - result = result.concat(String.fromCharCode.apply(null, characterArray)); + result = result.concat(String.fromCharCode.apply(undefined, characterArray)); } return result; } @@ -21006,6 +20726,15 @@ var TypeScript; EmptyToken.prototype.kind = function () { return this._kind; }; + EmptyToken.prototype.childCount = function () { + return 0; + }; + EmptyToken.prototype.childAt = function (index) { + throw TypeScript.Errors.invalidOperation(); + }; + EmptyToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; EmptyToken.prototype.clone = function () { return new EmptyToken(this.kind()); }; @@ -21020,15 +20749,15 @@ var TypeScript; }; EmptyToken.prototype.position = function () { var previousElement = this.previousNonZeroWidthElement(); - return previousElement === null ? 0 : TypeScript.fullStart(previousElement) + TypeScript.fullWidth(previousElement); + return !previousElement ? 0 : TypeScript.fullStart(previousElement) + TypeScript.fullWidth(previousElement); }; EmptyToken.prototype.previousNonZeroWidthElement = function () { var current = this; while (true) { var parent = current.parent; - if (parent === null) { - TypeScript.Debug.assert(current.kind() === 120 /* SourceUnit */, "We had a node without a parent that was not the root node!"); - return null; + if (parent === undefined) { + TypeScript.Debug.assert(current.kind() === 122 /* SourceUnit */, "We had a node without a parent that was not the root node!"); + return undefined; } for (var i = 0, n = TypeScript.childCount(parent); i < n; i++) { if (TypeScript.childAt(parent, i) === current) { @@ -21104,6 +20833,15 @@ var TypeScript; RealizedToken.prototype.kind = function () { return this._kind; }; + RealizedToken.prototype.childCount = function () { + return 0; + }; + RealizedToken.prototype.childAt = function (index) { + throw TypeScript.Errors.invalidOperation(); + }; + RealizedToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; RealizedToken.prototype.clone = function () { return new RealizedToken(this._fullStart, this.kind(), this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text, this._trailingTrivia); }; @@ -21159,11 +20897,20 @@ var TypeScript; this.underlyingToken = underlyingToken; } ConvertedKeywordToken.prototype.kind = function () { - return 11 /* IdentifierName */; + return 9 /* IdentifierName */; }; ConvertedKeywordToken.prototype.setFullStart = function (fullStart) { this.underlyingToken.setFullStart(fullStart); }; + ConvertedKeywordToken.prototype.childCount = function () { + return 0; + }; + ConvertedKeywordToken.prototype.childAt = function (index) { + throw TypeScript.Errors.invalidOperation(); + }; + ConvertedKeywordToken.prototype.accept = function (visitor) { + return visitor.visitToken(this); + }; ConvertedKeywordToken.prototype.fullStart = function () { return this.underlyingToken.fullStart(); }; @@ -21252,23 +20999,23 @@ var TypeScript; throw TypeScript.Errors.abstract(); }; AbstractTrivia.prototype.isWhitespace = function () { - return this.kind() === 4 /* WhitespaceTrivia */; + return this.kind() === 2 /* WhitespaceTrivia */; }; AbstractTrivia.prototype.isComment = function () { - return this.kind() === 7 /* SingleLineCommentTrivia */ || this.kind() === 6 /* MultiLineCommentTrivia */; + return this.kind() === 5 /* SingleLineCommentTrivia */ || this.kind() === 4 /* MultiLineCommentTrivia */; }; AbstractTrivia.prototype.isNewLine = function () { - return this.kind() === 5 /* NewLineTrivia */; + return this.kind() === 3 /* NewLineTrivia */; }; AbstractTrivia.prototype.isSkippedToken = function () { - return this.kind() === 8 /* SkippedTokenTrivia */; + return this.kind() === 6 /* SkippedTokenTrivia */; }; return AbstractTrivia; })(); var SkippedTokenTrivia = (function (_super) { __extends(SkippedTokenTrivia, _super); function SkippedTokenTrivia(_skippedToken, _fullText) { - _super.call(this, 8 /* SkippedTokenTrivia */); + _super.call(this, 6 /* SkippedTokenTrivia */); this._skippedToken = _skippedToken; this._fullText = _fullText; _skippedToken.parent = this; @@ -21358,9 +21105,6 @@ var TypeScript; var EmptyTriviaList = (function () { function EmptyTriviaList() { } - EmptyTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; EmptyTriviaList.prototype.isShared = function () { return true; }; @@ -21399,16 +21143,13 @@ var TypeScript; ; Syntax.emptyTriviaList = new EmptyTriviaList(); function isComment(trivia) { - return trivia.kind() === 6 /* MultiLineCommentTrivia */ || trivia.kind() === 7 /* SingleLineCommentTrivia */; + return trivia.kind() === 4 /* MultiLineCommentTrivia */ || trivia.kind() === 5 /* SingleLineCommentTrivia */; } var SingletonSyntaxTriviaList = (function () { function SingletonSyntaxTriviaList(item) { this.item = item.clone(); this.item.parent = this; } - SingletonSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; SingletonSyntaxTriviaList.prototype.isShared = function () { return false; }; @@ -21434,10 +21175,10 @@ var TypeScript; return isComment(this.item); }; SingletonSyntaxTriviaList.prototype.hasNewLine = function () { - return this.item.kind() === 5 /* NewLineTrivia */; + return this.item.kind() === 3 /* NewLineTrivia */; }; SingletonSyntaxTriviaList.prototype.hasSkippedToken = function () { - return this.item.kind() === 8 /* SkippedTokenTrivia */; + return this.item.kind() === 6 /* SkippedTokenTrivia */; }; SingletonSyntaxTriviaList.prototype.toArray = function () { return [this.item]; @@ -21456,9 +21197,6 @@ var TypeScript; return cloned; }); } - NormalSyntaxTriviaList.prototype.kind = function () { - return 3 /* TriviaList */; - }; NormalSyntaxTriviaList.prototype.isShared = function () { return false; }; @@ -21494,7 +21232,7 @@ var TypeScript; }; NormalSyntaxTriviaList.prototype.hasNewLine = function () { for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 5 /* NewLineTrivia */) { + if (this.trivia[i].kind() === 3 /* NewLineTrivia */) { return true; } } @@ -21502,7 +21240,7 @@ var TypeScript; }; NormalSyntaxTriviaList.prototype.hasSkippedToken = function () { for (var i = 0; i < this.trivia.length; i++) { - if (this.trivia[i].kind() === 8 /* SkippedTokenTrivia */) { + if (this.trivia[i].kind() === 6 /* SkippedTokenTrivia */) { return true; } } @@ -21517,7 +21255,7 @@ var TypeScript; return NormalSyntaxTriviaList; })(); function triviaList(trivia) { - if (trivia === undefined || trivia === null || trivia.length === 0) { + if (!trivia || trivia.length === 0) { return Syntax.emptyTriviaList; } if (trivia.length === 1) { @@ -21535,22 +21273,22 @@ var TypeScript; } SyntaxUtilities.isAnyFunctionExpressionOrDeclaration = function (ast) { switch (ast.kind()) { - case 220 /* SimpleArrowFunctionExpression */: - case 219 /* ParenthesizedArrowFunctionExpression */: - case 223 /* FunctionExpression */: - case 130 /* FunctionDeclaration */: - case 136 /* MemberFunctionDeclaration */: - case 242 /* FunctionPropertyAssignment */: - case 138 /* ConstructorDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: + case 183 /* SimpleArrowFunctionExpression */: + case 182 /* ParenthesizedArrowFunctionExpression */: + case 186 /* FunctionExpression */: + case 134 /* FunctionDeclaration */: + case 140 /* MemberFunctionDeclaration */: + case 207 /* FunctionPropertyAssignment */: + case 142 /* ConstructorDeclaration */: + case 144 /* GetAccessor */: + case 145 /* SetAccessor */: return true; } return false; }; SyntaxUtilities.isLastTokenOnLine = function (token, text) { var _nextToken = TypeScript.nextToken(token, text); - if (_nextToken === null) { + if (_nextToken === undefined) { return true; } var lineMap = text.lineMap(); @@ -21561,100 +21299,24 @@ var TypeScript; SyntaxUtilities.isLeftHandSizeExpression = function (element) { if (element) { switch (element.kind()) { - case 213 /* MemberAccessExpression */: - case 222 /* ElementAccessExpression */: - case 217 /* ObjectCreationExpression */: - case 214 /* InvocationExpression */: - case 215 /* ArrayLiteralExpression */: - case 218 /* ParenthesizedExpression */: - case 216 /* ObjectLiteralExpression */: - case 223 /* FunctionExpression */: - case 11 /* IdentifierName */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 50 /* SuperKeyword */: - return true; - } - } - return false; - }; - SyntaxUtilities.isExpression = function (element) { - if (element) { - switch (element.kind()) { - case 11 /* IdentifierName */: - case 12 /* RegularExpressionLiteral */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 50 /* SuperKeyword */: - case 165 /* PlusExpression */: - case 166 /* NegateExpression */: - case 167 /* BitwiseNotExpression */: - case 168 /* LogicalNotExpression */: - case 169 /* PreIncrementExpression */: - case 170 /* PreDecrementExpression */: - case 171 /* DeleteExpression */: - case 172 /* TypeOfExpression */: - case 173 /* VoidExpression */: - case 174 /* CommaExpression */: - case 175 /* AssignmentExpression */: - case 176 /* AddAssignmentExpression */: - case 177 /* SubtractAssignmentExpression */: - case 178 /* MultiplyAssignmentExpression */: - case 179 /* DivideAssignmentExpression */: - case 180 /* ModuloAssignmentExpression */: - case 181 /* AndAssignmentExpression */: - case 182 /* ExclusiveOrAssignmentExpression */: - case 183 /* OrAssignmentExpression */: - case 184 /* LeftShiftAssignmentExpression */: - case 185 /* SignedRightShiftAssignmentExpression */: - case 186 /* UnsignedRightShiftAssignmentExpression */: - case 187 /* ConditionalExpression */: - case 188 /* LogicalOrExpression */: - case 189 /* LogicalAndExpression */: - case 190 /* BitwiseOrExpression */: - case 191 /* BitwiseExclusiveOrExpression */: - case 192 /* BitwiseAndExpression */: - case 193 /* EqualsWithTypeConversionExpression */: - case 194 /* NotEqualsWithTypeConversionExpression */: - case 195 /* EqualsExpression */: - case 196 /* NotEqualsExpression */: - case 197 /* LessThanExpression */: - case 198 /* GreaterThanExpression */: - case 199 /* LessThanOrEqualExpression */: - case 200 /* GreaterThanOrEqualExpression */: - case 201 /* InstanceOfExpression */: - case 202 /* InExpression */: - case 203 /* LeftShiftExpression */: - case 204 /* SignedRightShiftExpression */: - case 205 /* UnsignedRightShiftExpression */: - case 206 /* MultiplyExpression */: - case 207 /* DivideExpression */: - case 208 /* ModuloExpression */: - case 209 /* AddExpression */: - case 210 /* SubtractExpression */: - case 211 /* PostIncrementExpression */: - case 212 /* PostDecrementExpression */: - case 213 /* MemberAccessExpression */: - case 214 /* InvocationExpression */: - case 215 /* ArrayLiteralExpression */: - case 216 /* ObjectLiteralExpression */: - case 217 /* ObjectCreationExpression */: - case 218 /* ParenthesizedExpression */: - case 219 /* ParenthesizedArrowFunctionExpression */: - case 220 /* SimpleArrowFunctionExpression */: - case 221 /* CastExpression */: - case 222 /* ElementAccessExpression */: - case 223 /* FunctionExpression */: - case 224 /* OmittedExpression */: + case 176 /* MemberAccessExpression */: + case 185 /* ElementAccessExpression */: + case 189 /* TemplateAccessExpression */: + case 180 /* ObjectCreationExpression */: + case 177 /* InvocationExpression */: + case 178 /* ArrayLiteralExpression */: + case 181 /* ParenthesizedExpression */: + case 179 /* ObjectLiteralExpression */: + case 186 /* FunctionExpression */: + case 9 /* IdentifierName */: + case 10 /* RegularExpressionLiteral */: + case 11 /* NumericLiteral */: + case 12 /* StringLiteral */: + case 26 /* FalseKeyword */: + case 34 /* NullKeyword */: + case 37 /* ThisKeyword */: + case 39 /* TrueKeyword */: + case 52 /* SuperKeyword */: return true; } } @@ -21663,8 +21325,8 @@ var TypeScript; SyntaxUtilities.isSwitchClause = function (element) { if (element) { switch (element.kind()) { - case 234 /* CaseSwitchClause */: - case 235 /* DefaultSwitchClause */: + case 198 /* CaseSwitchClause */: + case 199 /* DefaultSwitchClause */: return true; } } @@ -21673,11 +21335,11 @@ var TypeScript; SyntaxUtilities.isTypeMember = function (element) { if (element) { switch (element.kind()) { - case 144 /* ConstructSignature */: - case 146 /* MethodSignature */: - case 145 /* IndexSignature */: - case 142 /* PropertySignature */: - case 143 /* CallSignature */: + case 148 /* ConstructSignature */: + case 150 /* MethodSignature */: + case 149 /* IndexSignature */: + case 146 /* PropertySignature */: + case 147 /* CallSignature */: return true; } } @@ -21686,13 +21348,13 @@ var TypeScript; SyntaxUtilities.isClassElement = function (element) { if (element) { switch (element.kind()) { - case 138 /* ConstructorDeclaration */: - case 139 /* IndexMemberDeclaration */: - case 136 /* MemberFunctionDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: - case 136 /* MemberFunctionDeclaration */: - case 137 /* MemberVariableDeclaration */: + case 142 /* ConstructorDeclaration */: + case 143 /* IndexMemberDeclaration */: + case 140 /* MemberFunctionDeclaration */: + case 144 /* GetAccessor */: + case 145 /* SetAccessor */: + case 140 /* MemberFunctionDeclaration */: + case 141 /* MemberVariableDeclaration */: return true; } } @@ -21701,31 +21363,31 @@ var TypeScript; SyntaxUtilities.isModuleElement = function (element) { if (element) { switch (element.kind()) { - case 134 /* ImportDeclaration */: - case 135 /* ExportAssignment */: - case 132 /* ClassDeclaration */: - case 129 /* InterfaceDeclaration */: - case 131 /* ModuleDeclaration */: - case 133 /* EnumDeclaration */: - case 130 /* FunctionDeclaration */: - case 149 /* VariableStatement */: - case 147 /* Block */: - case 148 /* IfStatement */: - case 150 /* ExpressionStatement */: - case 158 /* ThrowStatement */: - case 151 /* ReturnStatement */: - case 152 /* SwitchStatement */: - case 153 /* BreakStatement */: - case 154 /* ContinueStatement */: - case 156 /* ForInStatement */: - case 155 /* ForStatement */: - case 159 /* WhileStatement */: - case 164 /* WithStatement */: - case 157 /* EmptyStatement */: - case 160 /* TryStatement */: - case 161 /* LabeledStatement */: - case 162 /* DoStatement */: - case 163 /* DebuggerStatement */: + case 138 /* ImportDeclaration */: + case 139 /* ExportAssignment */: + case 136 /* ClassDeclaration */: + case 133 /* InterfaceDeclaration */: + case 135 /* ModuleDeclaration */: + case 137 /* EnumDeclaration */: + case 134 /* FunctionDeclaration */: + case 153 /* VariableStatement */: + case 151 /* Block */: + case 152 /* IfStatement */: + case 154 /* ExpressionStatement */: + case 162 /* ThrowStatement */: + case 155 /* ReturnStatement */: + case 156 /* SwitchStatement */: + case 157 /* BreakStatement */: + case 158 /* ContinueStatement */: + case 160 /* ForInStatement */: + case 159 /* ForStatement */: + case 163 /* WhileStatement */: + case 168 /* WithStatement */: + case 161 /* EmptyStatement */: + case 164 /* TryStatement */: + case 165 /* LabeledStatement */: + case 166 /* DoStatement */: + case 167 /* DebuggerStatement */: return true; } } @@ -21734,25 +21396,25 @@ var TypeScript; SyntaxUtilities.isStatement = function (element) { if (element) { switch (element.kind()) { - case 130 /* FunctionDeclaration */: - case 149 /* VariableStatement */: - case 147 /* Block */: - case 148 /* IfStatement */: - case 150 /* ExpressionStatement */: - case 158 /* ThrowStatement */: - case 151 /* ReturnStatement */: - case 152 /* SwitchStatement */: - case 153 /* BreakStatement */: - case 154 /* ContinueStatement */: - case 156 /* ForInStatement */: - case 155 /* ForStatement */: - case 159 /* WhileStatement */: - case 164 /* WithStatement */: - case 157 /* EmptyStatement */: - case 160 /* TryStatement */: - case 161 /* LabeledStatement */: - case 162 /* DoStatement */: - case 163 /* DebuggerStatement */: + case 134 /* FunctionDeclaration */: + case 153 /* VariableStatement */: + case 151 /* Block */: + case 152 /* IfStatement */: + case 154 /* ExpressionStatement */: + case 162 /* ThrowStatement */: + case 155 /* ReturnStatement */: + case 156 /* SwitchStatement */: + case 157 /* BreakStatement */: + case 158 /* ContinueStatement */: + case 160 /* ForInStatement */: + case 159 /* ForStatement */: + case 163 /* WhileStatement */: + case 168 /* WithStatement */: + case 161 /* EmptyStatement */: + case 164 /* TryStatement */: + case 165 /* LabeledStatement */: + case 166 /* DoStatement */: + case 167 /* DebuggerStatement */: return true; } } @@ -21761,11 +21423,11 @@ var TypeScript; SyntaxUtilities.isAngleBracket = function (positionedElement) { var element = positionedElement; var parent = positionedElement.parent; - if (parent !== null && (element.kind() === 80 /* LessThanToken */ || element.kind() === 81 /* GreaterThanToken */)) { + if (parent && (element.kind() === 82 /* LessThanToken */ || element.kind() === 83 /* GreaterThanToken */)) { switch (parent.kind()) { - case 229 /* TypeArgumentList */: - case 230 /* TypeParameterList */: - case 221 /* CastExpression */: + case 194 /* TypeArgumentList */: + case 195 /* TypeParameterList */: + case 184 /* CastExpression */: return true; } } @@ -21778,26 +21440,26 @@ var TypeScript; return token; } } - return null; + return undefined; }; SyntaxUtilities.containsToken = function (list, kind) { - return SyntaxUtilities.getToken(list, kind) !== null; + return !!SyntaxUtilities.getToken(list, kind); }; SyntaxUtilities.hasExportKeyword = function (moduleElement) { - return SyntaxUtilities.getExportKeyword(moduleElement) !== null; + return !!SyntaxUtilities.getExportKeyword(moduleElement); }; SyntaxUtilities.getExportKeyword = function (moduleElement) { switch (moduleElement.kind()) { - case 131 /* ModuleDeclaration */: - case 132 /* ClassDeclaration */: - case 130 /* FunctionDeclaration */: - case 149 /* VariableStatement */: - case 133 /* EnumDeclaration */: - case 129 /* InterfaceDeclaration */: - case 134 /* ImportDeclaration */: - return SyntaxUtilities.getToken(moduleElement.modifiers, 47 /* ExportKeyword */); + case 135 /* ModuleDeclaration */: + case 136 /* ClassDeclaration */: + case 134 /* FunctionDeclaration */: + case 153 /* VariableStatement */: + case 137 /* EnumDeclaration */: + case 133 /* InterfaceDeclaration */: + case 138 /* ImportDeclaration */: + return SyntaxUtilities.getToken(moduleElement.modifiers, 49 /* ExportKeyword */); default: - return null; + return undefined; } }; SyntaxUtilities.isAmbientDeclarationSyntax = function (positionNode) { @@ -21806,24 +21468,24 @@ var TypeScript; } var node = positionNode; switch (node.kind()) { - case 131 /* ModuleDeclaration */: - case 132 /* ClassDeclaration */: - case 130 /* FunctionDeclaration */: - case 149 /* VariableStatement */: - case 133 /* EnumDeclaration */: - if (SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + case 135 /* ModuleDeclaration */: + case 136 /* ClassDeclaration */: + case 134 /* FunctionDeclaration */: + case 153 /* VariableStatement */: + case 137 /* EnumDeclaration */: + if (SyntaxUtilities.containsToken(node.modifiers, 65 /* DeclareKeyword */)) { return true; } - case 134 /* ImportDeclaration */: - case 138 /* ConstructorDeclaration */: - case 136 /* MemberFunctionDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: - case 137 /* MemberVariableDeclaration */: + case 138 /* ImportDeclaration */: + case 142 /* ConstructorDeclaration */: + case 140 /* MemberFunctionDeclaration */: + case 144 /* GetAccessor */: + case 145 /* SetAccessor */: + case 141 /* MemberVariableDeclaration */: if (SyntaxUtilities.isClassElement(node) || SyntaxUtilities.isModuleElement(node)) { return SyntaxUtilities.isAmbientDeclarationSyntax(TypeScript.Syntax.containingNode(positionNode)); } - case 244 /* EnumElement */: + case 209 /* EnumElement */: return SyntaxUtilities.isAmbientDeclarationSyntax(TypeScript.Syntax.containingNode(TypeScript.Syntax.containingNode(positionNode))); default: return SyntaxUtilities.isAmbientDeclarationSyntax(TypeScript.Syntax.containingNode(positionNode)); @@ -21835,230 +21497,897 @@ var TypeScript; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { - function visitNodeOrToken(visitor, element) { - if (element === null) { - return null; + var childCountArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 4, 3, 5, 2, 2, 3, 3, 3, 6, 6, 7, 8, 6, 6, 4, 5, 3, 5, 3, 5, 5, 3, 3, 2, 4, 3, 3, 6, 3, 2, 3, 7, 3, 3, 10, 8, 1, 3, 5, 4, 3, 7, 2, 5, 2, 2, 2, 2, 5, 3, 2, 3, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 2, 2, 2, 3, 4, 3, 3, 3, 2, 2, 4, 3, 2, 6, 2, 2, 2, 2, 3, 3, 6, 2, 2, 4, 1]; + function childCount(element) { + if (TypeScript.isList(element)) { + return element.length; } - if (TypeScript.isToken(element)) { - return visitor.visitToken(element); + return childCountArray[element.kind()]; + } + TypeScript.childCount = childCount; + function sourceUnitChildAt(node, index) { + switch (index) { + case 0: return node.moduleElements; + case 1: return node.endOfFileToken; + } + } + function qualifiedNameChildAt(node, index) { + switch (index) { + case 0: return node.left; + case 1: return node.dotToken; + case 2: return node.right; + } + } + function objectTypeChildAt(node, index) { + switch (index) { + case 0: return node.openBraceToken; + case 1: return node.typeMembers; + case 2: return node.closeBraceToken; + } + } + function functionTypeChildAt(node, index) { + switch (index) { + case 0: return node.typeParameterList; + case 1: return node.parameterList; + case 2: return node.equalsGreaterThanToken; + case 3: return node.type; + } + } + function arrayTypeChildAt(node, index) { + switch (index) { + case 0: return node.type; + case 1: return node.openBracketToken; + case 2: return node.closeBracketToken; + } + } + function constructorTypeChildAt(node, index) { + switch (index) { + case 0: return node.newKeyword; + case 1: return node.typeParameterList; + case 2: return node.parameterList; + case 3: return node.equalsGreaterThanToken; + case 4: return node.type; + } + } + function genericTypeChildAt(node, index) { + switch (index) { + case 0: return node.name; + case 1: return node.typeArgumentList; + } + } + function typeQueryChildAt(node, index) { + switch (index) { + case 0: return node.typeOfKeyword; + case 1: return node.name; + } + } + function tupleTypeChildAt(node, index) { + switch (index) { + case 0: return node.openBracketToken; + case 1: return node.types; + case 2: return node.closeBracketToken; + } + } + function unionTypeChildAt(node, index) { + switch (index) { + case 0: return node.left; + case 1: return node.barToken; + case 2: return node.right; + } + } + function parenthesizedTypeChildAt(node, index) { + switch (index) { + case 0: return node.openParenToken; + case 1: return node.type; + case 2: return node.closeParenToken; + } + } + function interfaceDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.interfaceKeyword; + case 2: return node.identifier; + case 3: return node.typeParameterList; + case 4: return node.heritageClauses; + case 5: return node.body; + } + } + function functionDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.functionKeyword; + case 2: return node.identifier; + case 3: return node.callSignature; + case 4: return node.block; + case 5: return node.semicolonToken; + } + } + function moduleDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.moduleKeyword; + case 2: return node.name; + case 3: return node.stringLiteral; + case 4: return node.openBraceToken; + case 5: return node.moduleElements; + case 6: return node.closeBraceToken; + } + } + function classDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.classKeyword; + case 2: return node.identifier; + case 3: return node.typeParameterList; + case 4: return node.heritageClauses; + case 5: return node.openBraceToken; + case 6: return node.classElements; + case 7: return node.closeBraceToken; + } + } + function enumDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.enumKeyword; + case 2: return node.identifier; + case 3: return node.openBraceToken; + case 4: return node.enumElements; + case 5: return node.closeBraceToken; + } + } + function importDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.importKeyword; + case 2: return node.identifier; + case 3: return node.equalsToken; + case 4: return node.moduleReference; + case 5: return node.semicolonToken; + } + } + function exportAssignmentChildAt(node, index) { + switch (index) { + case 0: return node.exportKeyword; + case 1: return node.equalsToken; + case 2: return node.identifier; + case 3: return node.semicolonToken; + } + } + function memberFunctionDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.propertyName; + case 2: return node.callSignature; + case 3: return node.block; + case 4: return node.semicolonToken; + } + } + function memberVariableDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.variableDeclarator; + case 2: return node.semicolonToken; + } + } + function constructorDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.constructorKeyword; + case 2: return node.callSignature; + case 3: return node.block; + case 4: return node.semicolonToken; + } + } + function indexMemberDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.indexSignature; + case 2: return node.semicolonToken; + } + } + function getAccessorChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.getKeyword; + case 2: return node.propertyName; + case 3: return node.callSignature; + case 4: return node.block; + } + } + function setAccessorChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.setKeyword; + case 2: return node.propertyName; + case 3: return node.callSignature; + case 4: return node.block; + } + } + function propertySignatureChildAt(node, index) { + switch (index) { + case 0: return node.propertyName; + case 1: return node.questionToken; + case 2: return node.typeAnnotation; + } + } + function callSignatureChildAt(node, index) { + switch (index) { + case 0: return node.typeParameterList; + case 1: return node.parameterList; + case 2: return node.typeAnnotation; + } + } + function constructSignatureChildAt(node, index) { + switch (index) { + case 0: return node.newKeyword; + case 1: return node.callSignature; + } + } + function indexSignatureChildAt(node, index) { + switch (index) { + case 0: return node.openBracketToken; + case 1: return node.parameters; + case 2: return node.closeBracketToken; + case 3: return node.typeAnnotation; + } + } + function methodSignatureChildAt(node, index) { + switch (index) { + case 0: return node.propertyName; + case 1: return node.questionToken; + case 2: return node.callSignature; + } + } + function blockChildAt(node, index) { + switch (index) { + case 0: return node.openBraceToken; + case 1: return node.statements; + case 2: return node.closeBraceToken; + } + } + function ifStatementChildAt(node, index) { + switch (index) { + case 0: return node.ifKeyword; + case 1: return node.openParenToken; + case 2: return node.condition; + case 3: return node.closeParenToken; + case 4: return node.statement; + case 5: return node.elseClause; + } + } + function variableStatementChildAt(node, index) { + switch (index) { + case 0: return node.modifiers; + case 1: return node.variableDeclaration; + case 2: return node.semicolonToken; + } + } + function expressionStatementChildAt(node, index) { + switch (index) { + case 0: return node.expression; + case 1: return node.semicolonToken; + } + } + function returnStatementChildAt(node, index) { + switch (index) { + case 0: return node.returnKeyword; + case 1: return node.expression; + case 2: return node.semicolonToken; + } + } + function switchStatementChildAt(node, index) { + switch (index) { + case 0: return node.switchKeyword; + case 1: return node.openParenToken; + case 2: return node.expression; + case 3: return node.closeParenToken; + case 4: return node.openBraceToken; + case 5: return node.switchClauses; + case 6: return node.closeBraceToken; + } + } + function breakStatementChildAt(node, index) { + switch (index) { + case 0: return node.breakKeyword; + case 1: return node.identifier; + case 2: return node.semicolonToken; + } + } + function continueStatementChildAt(node, index) { + switch (index) { + case 0: return node.continueKeyword; + case 1: return node.identifier; + case 2: return node.semicolonToken; + } + } + function forStatementChildAt(node, index) { + switch (index) { + case 0: return node.forKeyword; + case 1: return node.openParenToken; + case 2: return node.variableDeclaration; + case 3: return node.initializer; + case 4: return node.firstSemicolonToken; + case 5: return node.condition; + case 6: return node.secondSemicolonToken; + case 7: return node.incrementor; + case 8: return node.closeParenToken; + case 9: return node.statement; + } + } + function forInStatementChildAt(node, index) { + switch (index) { + case 0: return node.forKeyword; + case 1: return node.openParenToken; + case 2: return node.variableDeclaration; + case 3: return node.left; + case 4: return node.inKeyword; + case 5: return node.expression; + case 6: return node.closeParenToken; + case 7: return node.statement; + } + } + function emptyStatementChildAt(node, index) { + switch (index) { + case 0: return node.semicolonToken; + } + } + function throwStatementChildAt(node, index) { + switch (index) { + case 0: return node.throwKeyword; + case 1: return node.expression; + case 2: return node.semicolonToken; + } + } + function whileStatementChildAt(node, index) { + switch (index) { + case 0: return node.whileKeyword; + case 1: return node.openParenToken; + case 2: return node.condition; + case 3: return node.closeParenToken; + case 4: return node.statement; + } + } + function tryStatementChildAt(node, index) { + switch (index) { + case 0: return node.tryKeyword; + case 1: return node.block; + case 2: return node.catchClause; + case 3: return node.finallyClause; + } + } + function labeledStatementChildAt(node, index) { + switch (index) { + case 0: return node.identifier; + case 1: return node.colonToken; + case 2: return node.statement; + } + } + function doStatementChildAt(node, index) { + switch (index) { + case 0: return node.doKeyword; + case 1: return node.statement; + case 2: return node.whileKeyword; + case 3: return node.openParenToken; + case 4: return node.condition; + case 5: return node.closeParenToken; + case 6: return node.semicolonToken; + } + } + function debuggerStatementChildAt(node, index) { + switch (index) { + case 0: return node.debuggerKeyword; + case 1: return node.semicolonToken; + } + } + function withStatementChildAt(node, index) { + switch (index) { + case 0: return node.withKeyword; + case 1: return node.openParenToken; + case 2: return node.condition; + case 3: return node.closeParenToken; + case 4: return node.statement; + } + } + function prefixUnaryExpressionChildAt(node, index) { + switch (index) { + case 0: return node.operatorToken; + case 1: return node.operand; + } + } + function deleteExpressionChildAt(node, index) { + switch (index) { + case 0: return node.deleteKeyword; + case 1: return node.expression; + } + } + function typeOfExpressionChildAt(node, index) { + switch (index) { + case 0: return node.typeOfKeyword; + case 1: return node.expression; + } + } + function voidExpressionChildAt(node, index) { + switch (index) { + case 0: return node.voidKeyword; + case 1: return node.expression; + } + } + function conditionalExpressionChildAt(node, index) { + switch (index) { + case 0: return node.condition; + case 1: return node.questionToken; + case 2: return node.whenTrue; + case 3: return node.colonToken; + case 4: return node.whenFalse; + } + } + function binaryExpressionChildAt(node, index) { + switch (index) { + case 0: return node.left; + case 1: return node.operatorToken; + case 2: return node.right; + } + } + function postfixUnaryExpressionChildAt(node, index) { + switch (index) { + case 0: return node.operand; + case 1: return node.operatorToken; + } + } + function memberAccessExpressionChildAt(node, index) { + switch (index) { + case 0: return node.expression; + case 1: return node.dotToken; + case 2: return node.name; + } + } + function invocationExpressionChildAt(node, index) { + switch (index) { + case 0: return node.expression; + case 1: return node.argumentList; + } + } + function arrayLiteralExpressionChildAt(node, index) { + switch (index) { + case 0: return node.openBracketToken; + case 1: return node.expressions; + case 2: return node.closeBracketToken; + } + } + function objectLiteralExpressionChildAt(node, index) { + switch (index) { + case 0: return node.openBraceToken; + case 1: return node.propertyAssignments; + case 2: return node.closeBraceToken; + } + } + function objectCreationExpressionChildAt(node, index) { + switch (index) { + case 0: return node.newKeyword; + case 1: return node.expression; + case 2: return node.argumentList; + } + } + function parenthesizedExpressionChildAt(node, index) { + switch (index) { + case 0: return node.openParenToken; + case 1: return node.expression; + case 2: return node.closeParenToken; + } + } + function parenthesizedArrowFunctionExpressionChildAt(node, index) { + switch (index) { + case 0: return node.callSignature; + case 1: return node.equalsGreaterThanToken; + case 2: return node.block; + case 3: return node.expression; + } + } + function simpleArrowFunctionExpressionChildAt(node, index) { + switch (index) { + case 0: return node.parameter; + case 1: return node.equalsGreaterThanToken; + case 2: return node.block; + case 3: return node.expression; + } + } + function castExpressionChildAt(node, index) { + switch (index) { + case 0: return node.lessThanToken; + case 1: return node.type; + case 2: return node.greaterThanToken; + case 3: return node.expression; + } + } + function elementAccessExpressionChildAt(node, index) { + switch (index) { + case 0: return node.expression; + case 1: return node.openBracketToken; + case 2: return node.argumentExpression; + case 3: return node.closeBracketToken; + } + } + function functionExpressionChildAt(node, index) { + switch (index) { + case 0: return node.functionKeyword; + case 1: return node.identifier; + case 2: return node.callSignature; + case 3: return node.block; + } + } + function omittedExpressionChildAt(node, index) { + throw TypeScript.Errors.invalidOperation(); + } + function templateExpressionChildAt(node, index) { + switch (index) { + case 0: return node.templateStartToken; + case 1: return node.templateClauses; + } + } + function templateAccessExpressionChildAt(node, index) { + switch (index) { + case 0: return node.expression; + case 1: return node.templateExpression; + } + } + function variableDeclarationChildAt(node, index) { + switch (index) { + case 0: return node.varKeyword; + case 1: return node.variableDeclarators; + } + } + function variableDeclaratorChildAt(node, index) { + switch (index) { + case 0: return node.propertyName; + case 1: return node.typeAnnotation; + case 2: return node.equalsValueClause; + } + } + function argumentListChildAt(node, index) { + switch (index) { + case 0: return node.typeArgumentList; + case 1: return node.openParenToken; + case 2: return node.arguments; + case 3: return node.closeParenToken; + } + } + function parameterListChildAt(node, index) { + switch (index) { + case 0: return node.openParenToken; + case 1: return node.parameters; + case 2: return node.closeParenToken; + } + } + function typeArgumentListChildAt(node, index) { + switch (index) { + case 0: return node.lessThanToken; + case 1: return node.typeArguments; + case 2: return node.greaterThanToken; + } + } + function typeParameterListChildAt(node, index) { + switch (index) { + case 0: return node.lessThanToken; + case 1: return node.typeParameters; + case 2: return node.greaterThanToken; + } + } + function heritageClauseChildAt(node, index) { + switch (index) { + case 0: return node.extendsOrImplementsKeyword; + case 1: return node.typeNames; + } + } + function equalsValueClauseChildAt(node, index) { + switch (index) { + case 0: return node.equalsToken; + case 1: return node.value; + } + } + function caseSwitchClauseChildAt(node, index) { + switch (index) { + case 0: return node.caseKeyword; + case 1: return node.expression; + case 2: return node.colonToken; + case 3: return node.statements; + } + } + function defaultSwitchClauseChildAt(node, index) { + switch (index) { + case 0: return node.defaultKeyword; + case 1: return node.colonToken; + case 2: return node.statements; + } + } + function elseClauseChildAt(node, index) { + switch (index) { + case 0: return node.elseKeyword; + case 1: return node.statement; + } + } + function catchClauseChildAt(node, index) { + switch (index) { + case 0: return node.catchKeyword; + case 1: return node.openParenToken; + case 2: return node.identifier; + case 3: return node.typeAnnotation; + case 4: return node.closeParenToken; + case 5: return node.block; + } + } + function finallyClauseChildAt(node, index) { + switch (index) { + case 0: return node.finallyKeyword; + case 1: return node.block; + } + } + function templateClauseChildAt(node, index) { + switch (index) { + case 0: return node.expression; + case 1: return node.templateMiddleOrEndToken; + } + } + function typeParameterChildAt(node, index) { + switch (index) { + case 0: return node.identifier; + case 1: return node.constraint; + } + } + function constraintChildAt(node, index) { + switch (index) { + case 0: return node.extendsKeyword; + case 1: return node.typeOrExpression; + } + } + function simplePropertyAssignmentChildAt(node, index) { + switch (index) { + case 0: return node.propertyName; + case 1: return node.colonToken; + case 2: return node.expression; + } + } + function functionPropertyAssignmentChildAt(node, index) { + switch (index) { + case 0: return node.propertyName; + case 1: return node.callSignature; + case 2: return node.block; + } + } + function parameterChildAt(node, index) { + switch (index) { + case 0: return node.dotDotDotToken; + case 1: return node.modifiers; + case 2: return node.identifier; + case 3: return node.questionToken; + case 4: return node.typeAnnotation; + case 5: return node.equalsValueClause; + } + } + function enumElementChildAt(node, index) { + switch (index) { + case 0: return node.propertyName; + case 1: return node.equalsValueClause; + } + } + function typeAnnotationChildAt(node, index) { + switch (index) { + case 0: return node.colonToken; + case 1: return node.type; + } + } + function externalModuleReferenceChildAt(node, index) { + switch (index) { + case 0: return node.requireKeyword; + case 1: return node.openParenToken; + case 2: return node.stringLiteral; + case 3: return node.closeParenToken; + } + } + function moduleNameModuleReferenceChildAt(node, index) { + switch (index) { + case 0: return node.moduleName; + } + } + function childAt(element, index) { + if (TypeScript.isList(element)) { + return element[index]; } switch (element.kind()) { - case 120 /* SourceUnit */: - return visitor.visitSourceUnit(element); - case 121 /* QualifiedName */: - return visitor.visitQualifiedName(element); - case 122 /* ObjectType */: - return visitor.visitObjectType(element); - case 123 /* FunctionType */: - return visitor.visitFunctionType(element); - case 124 /* ArrayType */: - return visitor.visitArrayType(element); - case 125 /* ConstructorType */: - return visitor.visitConstructorType(element); - case 126 /* GenericType */: - return visitor.visitGenericType(element); - case 127 /* TypeQuery */: - return visitor.visitTypeQuery(element); - case 128 /* TupleType */: - return visitor.visitTupleType(element); - case 129 /* InterfaceDeclaration */: - return visitor.visitInterfaceDeclaration(element); - case 130 /* FunctionDeclaration */: - return visitor.visitFunctionDeclaration(element); - case 131 /* ModuleDeclaration */: - return visitor.visitModuleDeclaration(element); - case 132 /* ClassDeclaration */: - return visitor.visitClassDeclaration(element); - case 133 /* EnumDeclaration */: - return visitor.visitEnumDeclaration(element); - case 134 /* ImportDeclaration */: - return visitor.visitImportDeclaration(element); - case 135 /* ExportAssignment */: - return visitor.visitExportAssignment(element); - case 136 /* MemberFunctionDeclaration */: - return visitor.visitMemberFunctionDeclaration(element); - case 137 /* MemberVariableDeclaration */: - return visitor.visitMemberVariableDeclaration(element); - case 138 /* ConstructorDeclaration */: - return visitor.visitConstructorDeclaration(element); - case 139 /* IndexMemberDeclaration */: - return visitor.visitIndexMemberDeclaration(element); - case 140 /* GetAccessor */: - return visitor.visitGetAccessor(element); - case 141 /* SetAccessor */: - return visitor.visitSetAccessor(element); - case 142 /* PropertySignature */: - return visitor.visitPropertySignature(element); - case 143 /* CallSignature */: - return visitor.visitCallSignature(element); - case 144 /* ConstructSignature */: - return visitor.visitConstructSignature(element); - case 145 /* IndexSignature */: - return visitor.visitIndexSignature(element); - case 146 /* MethodSignature */: - return visitor.visitMethodSignature(element); - case 147 /* Block */: - return visitor.visitBlock(element); - case 148 /* IfStatement */: - return visitor.visitIfStatement(element); - case 149 /* VariableStatement */: - return visitor.visitVariableStatement(element); - case 150 /* ExpressionStatement */: - return visitor.visitExpressionStatement(element); - case 151 /* ReturnStatement */: - return visitor.visitReturnStatement(element); - case 152 /* SwitchStatement */: - return visitor.visitSwitchStatement(element); - case 153 /* BreakStatement */: - return visitor.visitBreakStatement(element); - case 154 /* ContinueStatement */: - return visitor.visitContinueStatement(element); - case 155 /* ForStatement */: - return visitor.visitForStatement(element); - case 156 /* ForInStatement */: - return visitor.visitForInStatement(element); - case 157 /* EmptyStatement */: - return visitor.visitEmptyStatement(element); - case 158 /* ThrowStatement */: - return visitor.visitThrowStatement(element); - case 159 /* WhileStatement */: - return visitor.visitWhileStatement(element); - case 160 /* TryStatement */: - return visitor.visitTryStatement(element); - case 161 /* LabeledStatement */: - return visitor.visitLabeledStatement(element); - case 162 /* DoStatement */: - return visitor.visitDoStatement(element); - case 163 /* DebuggerStatement */: - return visitor.visitDebuggerStatement(element); - case 164 /* WithStatement */: - return visitor.visitWithStatement(element); - case 169 /* PreIncrementExpression */: - case 170 /* PreDecrementExpression */: - case 165 /* PlusExpression */: - case 166 /* NegateExpression */: - case 167 /* BitwiseNotExpression */: - case 168 /* LogicalNotExpression */: - return visitor.visitPrefixUnaryExpression(element); - case 171 /* DeleteExpression */: - return visitor.visitDeleteExpression(element); - case 172 /* TypeOfExpression */: - return visitor.visitTypeOfExpression(element); - case 173 /* VoidExpression */: - return visitor.visitVoidExpression(element); - case 187 /* ConditionalExpression */: - return visitor.visitConditionalExpression(element); - case 206 /* MultiplyExpression */: - case 207 /* DivideExpression */: - case 208 /* ModuloExpression */: - case 209 /* AddExpression */: - case 210 /* SubtractExpression */: - case 203 /* LeftShiftExpression */: - case 204 /* SignedRightShiftExpression */: - case 205 /* UnsignedRightShiftExpression */: - case 197 /* LessThanExpression */: - case 198 /* GreaterThanExpression */: - case 199 /* LessThanOrEqualExpression */: - case 200 /* GreaterThanOrEqualExpression */: - case 201 /* InstanceOfExpression */: - case 202 /* InExpression */: - case 193 /* EqualsWithTypeConversionExpression */: - case 194 /* NotEqualsWithTypeConversionExpression */: - case 195 /* EqualsExpression */: - case 196 /* NotEqualsExpression */: - case 192 /* BitwiseAndExpression */: - case 191 /* BitwiseExclusiveOrExpression */: - case 190 /* BitwiseOrExpression */: - case 189 /* LogicalAndExpression */: - case 188 /* LogicalOrExpression */: - case 183 /* OrAssignmentExpression */: - case 181 /* AndAssignmentExpression */: - case 182 /* ExclusiveOrAssignmentExpression */: - case 184 /* LeftShiftAssignmentExpression */: - case 185 /* SignedRightShiftAssignmentExpression */: - case 186 /* UnsignedRightShiftAssignmentExpression */: - case 176 /* AddAssignmentExpression */: - case 177 /* SubtractAssignmentExpression */: - case 178 /* MultiplyAssignmentExpression */: - case 179 /* DivideAssignmentExpression */: - case 180 /* ModuloAssignmentExpression */: - case 175 /* AssignmentExpression */: - case 174 /* CommaExpression */: - return visitor.visitBinaryExpression(element); - case 211 /* PostIncrementExpression */: - case 212 /* PostDecrementExpression */: - return visitor.visitPostfixUnaryExpression(element); - case 213 /* MemberAccessExpression */: - return visitor.visitMemberAccessExpression(element); - case 214 /* InvocationExpression */: - return visitor.visitInvocationExpression(element); - case 215 /* ArrayLiteralExpression */: - return visitor.visitArrayLiteralExpression(element); - case 216 /* ObjectLiteralExpression */: - return visitor.visitObjectLiteralExpression(element); - case 217 /* ObjectCreationExpression */: - return visitor.visitObjectCreationExpression(element); - case 218 /* ParenthesizedExpression */: - return visitor.visitParenthesizedExpression(element); - case 219 /* ParenthesizedArrowFunctionExpression */: - return visitor.visitParenthesizedArrowFunctionExpression(element); - case 220 /* SimpleArrowFunctionExpression */: - return visitor.visitSimpleArrowFunctionExpression(element); - case 221 /* CastExpression */: - return visitor.visitCastExpression(element); - case 222 /* ElementAccessExpression */: - return visitor.visitElementAccessExpression(element); - case 223 /* FunctionExpression */: - return visitor.visitFunctionExpression(element); - case 224 /* OmittedExpression */: - return visitor.visitOmittedExpression(element); - case 225 /* VariableDeclaration */: - return visitor.visitVariableDeclaration(element); - case 226 /* VariableDeclarator */: - return visitor.visitVariableDeclarator(element); - case 227 /* ArgumentList */: - return visitor.visitArgumentList(element); - case 228 /* ParameterList */: - return visitor.visitParameterList(element); - case 229 /* TypeArgumentList */: - return visitor.visitTypeArgumentList(element); - case 230 /* TypeParameterList */: - return visitor.visitTypeParameterList(element); - case 231 /* ExtendsHeritageClause */: - case 232 /* ImplementsHeritageClause */: - return visitor.visitHeritageClause(element); - case 233 /* EqualsValueClause */: - return visitor.visitEqualsValueClause(element); - case 234 /* CaseSwitchClause */: - return visitor.visitCaseSwitchClause(element); - case 235 /* DefaultSwitchClause */: - return visitor.visitDefaultSwitchClause(element); - case 236 /* ElseClause */: - return visitor.visitElseClause(element); - case 237 /* CatchClause */: - return visitor.visitCatchClause(element); - case 238 /* FinallyClause */: - return visitor.visitFinallyClause(element); - case 239 /* TypeParameter */: - return visitor.visitTypeParameter(element); - case 240 /* Constraint */: - return visitor.visitConstraint(element); - case 241 /* SimplePropertyAssignment */: - return visitor.visitSimplePropertyAssignment(element); - case 242 /* FunctionPropertyAssignment */: - return visitor.visitFunctionPropertyAssignment(element); - case 243 /* Parameter */: - return visitor.visitParameter(element); - case 244 /* EnumElement */: - return visitor.visitEnumElement(element); - case 245 /* TypeAnnotation */: - return visitor.visitTypeAnnotation(element); - case 246 /* ExternalModuleReference */: - return visitor.visitExternalModuleReference(element); - case 247 /* ModuleNameModuleReference */: - return visitor.visitModuleNameModuleReference(element); + case 122 /* SourceUnit */: return sourceUnitChildAt(element, index); + case 123 /* QualifiedName */: return qualifiedNameChildAt(element, index); + case 124 /* ObjectType */: return objectTypeChildAt(element, index); + case 125 /* FunctionType */: return functionTypeChildAt(element, index); + case 126 /* ArrayType */: return arrayTypeChildAt(element, index); + case 127 /* ConstructorType */: return constructorTypeChildAt(element, index); + case 128 /* GenericType */: return genericTypeChildAt(element, index); + case 129 /* TypeQuery */: return typeQueryChildAt(element, index); + case 130 /* TupleType */: return tupleTypeChildAt(element, index); + case 131 /* UnionType */: return unionTypeChildAt(element, index); + case 132 /* ParenthesizedType */: return parenthesizedTypeChildAt(element, index); + case 133 /* InterfaceDeclaration */: return interfaceDeclarationChildAt(element, index); + case 134 /* FunctionDeclaration */: return functionDeclarationChildAt(element, index); + case 135 /* ModuleDeclaration */: return moduleDeclarationChildAt(element, index); + case 136 /* ClassDeclaration */: return classDeclarationChildAt(element, index); + case 137 /* EnumDeclaration */: return enumDeclarationChildAt(element, index); + case 138 /* ImportDeclaration */: return importDeclarationChildAt(element, index); + case 139 /* ExportAssignment */: return exportAssignmentChildAt(element, index); + case 140 /* MemberFunctionDeclaration */: return memberFunctionDeclarationChildAt(element, index); + case 141 /* MemberVariableDeclaration */: return memberVariableDeclarationChildAt(element, index); + case 142 /* ConstructorDeclaration */: return constructorDeclarationChildAt(element, index); + case 143 /* IndexMemberDeclaration */: return indexMemberDeclarationChildAt(element, index); + case 144 /* GetAccessor */: return getAccessorChildAt(element, index); + case 145 /* SetAccessor */: return setAccessorChildAt(element, index); + case 146 /* PropertySignature */: return propertySignatureChildAt(element, index); + case 147 /* CallSignature */: return callSignatureChildAt(element, index); + case 148 /* ConstructSignature */: return constructSignatureChildAt(element, index); + case 149 /* IndexSignature */: return indexSignatureChildAt(element, index); + case 150 /* MethodSignature */: return methodSignatureChildAt(element, index); + case 151 /* Block */: return blockChildAt(element, index); + case 152 /* IfStatement */: return ifStatementChildAt(element, index); + case 153 /* VariableStatement */: return variableStatementChildAt(element, index); + case 154 /* ExpressionStatement */: return expressionStatementChildAt(element, index); + case 155 /* ReturnStatement */: return returnStatementChildAt(element, index); + case 156 /* SwitchStatement */: return switchStatementChildAt(element, index); + case 157 /* BreakStatement */: return breakStatementChildAt(element, index); + case 158 /* ContinueStatement */: return continueStatementChildAt(element, index); + case 159 /* ForStatement */: return forStatementChildAt(element, index); + case 160 /* ForInStatement */: return forInStatementChildAt(element, index); + case 161 /* EmptyStatement */: return emptyStatementChildAt(element, index); + case 162 /* ThrowStatement */: return throwStatementChildAt(element, index); + case 163 /* WhileStatement */: return whileStatementChildAt(element, index); + case 164 /* TryStatement */: return tryStatementChildAt(element, index); + case 165 /* LabeledStatement */: return labeledStatementChildAt(element, index); + case 166 /* DoStatement */: return doStatementChildAt(element, index); + case 167 /* DebuggerStatement */: return debuggerStatementChildAt(element, index); + case 168 /* WithStatement */: return withStatementChildAt(element, index); + case 169 /* PrefixUnaryExpression */: return prefixUnaryExpressionChildAt(element, index); + case 170 /* DeleteExpression */: return deleteExpressionChildAt(element, index); + case 171 /* TypeOfExpression */: return typeOfExpressionChildAt(element, index); + case 172 /* VoidExpression */: return voidExpressionChildAt(element, index); + case 173 /* ConditionalExpression */: return conditionalExpressionChildAt(element, index); + case 174 /* BinaryExpression */: return binaryExpressionChildAt(element, index); + case 175 /* PostfixUnaryExpression */: return postfixUnaryExpressionChildAt(element, index); + case 176 /* MemberAccessExpression */: return memberAccessExpressionChildAt(element, index); + case 177 /* InvocationExpression */: return invocationExpressionChildAt(element, index); + case 178 /* ArrayLiteralExpression */: return arrayLiteralExpressionChildAt(element, index); + case 179 /* ObjectLiteralExpression */: return objectLiteralExpressionChildAt(element, index); + case 180 /* ObjectCreationExpression */: return objectCreationExpressionChildAt(element, index); + case 181 /* ParenthesizedExpression */: return parenthesizedExpressionChildAt(element, index); + case 182 /* ParenthesizedArrowFunctionExpression */: return parenthesizedArrowFunctionExpressionChildAt(element, index); + case 183 /* SimpleArrowFunctionExpression */: return simpleArrowFunctionExpressionChildAt(element, index); + case 184 /* CastExpression */: return castExpressionChildAt(element, index); + case 185 /* ElementAccessExpression */: return elementAccessExpressionChildAt(element, index); + case 186 /* FunctionExpression */: return functionExpressionChildAt(element, index); + case 187 /* OmittedExpression */: return omittedExpressionChildAt(element, index); + case 188 /* TemplateExpression */: return templateExpressionChildAt(element, index); + case 189 /* TemplateAccessExpression */: return templateAccessExpressionChildAt(element, index); + case 190 /* VariableDeclaration */: return variableDeclarationChildAt(element, index); + case 191 /* VariableDeclarator */: return variableDeclaratorChildAt(element, index); + case 192 /* ArgumentList */: return argumentListChildAt(element, index); + case 193 /* ParameterList */: return parameterListChildAt(element, index); + case 194 /* TypeArgumentList */: return typeArgumentListChildAt(element, index); + case 195 /* TypeParameterList */: return typeParameterListChildAt(element, index); + case 196 /* HeritageClause */: return heritageClauseChildAt(element, index); + case 197 /* EqualsValueClause */: return equalsValueClauseChildAt(element, index); + case 198 /* CaseSwitchClause */: return caseSwitchClauseChildAt(element, index); + case 199 /* DefaultSwitchClause */: return defaultSwitchClauseChildAt(element, index); + case 200 /* ElseClause */: return elseClauseChildAt(element, index); + case 201 /* CatchClause */: return catchClauseChildAt(element, index); + case 202 /* FinallyClause */: return finallyClauseChildAt(element, index); + case 203 /* TemplateClause */: return templateClauseChildAt(element, index); + case 204 /* TypeParameter */: return typeParameterChildAt(element, index); + case 205 /* Constraint */: return constraintChildAt(element, index); + case 206 /* SimplePropertyAssignment */: return simplePropertyAssignmentChildAt(element, index); + case 207 /* FunctionPropertyAssignment */: return functionPropertyAssignmentChildAt(element, index); + case 208 /* Parameter */: return parameterChildAt(element, index); + case 209 /* EnumElement */: return enumElementChildAt(element, index); + case 210 /* TypeAnnotation */: return typeAnnotationChildAt(element, index); + case 211 /* ExternalModuleReference */: return externalModuleReferenceChildAt(element, index); + case 212 /* ModuleNameModuleReference */: return moduleNameModuleReferenceChildAt(element, index); + } + } + TypeScript.childAt = childAt; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + function visitNodeOrToken(visitor, element) { + if (element === undefined) { + return undefined; + } + switch (element.kind()) { + case 122 /* SourceUnit */: return visitor.visitSourceUnit(element); + case 123 /* QualifiedName */: return visitor.visitQualifiedName(element); + case 124 /* ObjectType */: return visitor.visitObjectType(element); + case 125 /* FunctionType */: return visitor.visitFunctionType(element); + case 126 /* ArrayType */: return visitor.visitArrayType(element); + case 127 /* ConstructorType */: return visitor.visitConstructorType(element); + case 128 /* GenericType */: return visitor.visitGenericType(element); + case 129 /* TypeQuery */: return visitor.visitTypeQuery(element); + case 130 /* TupleType */: return visitor.visitTupleType(element); + case 131 /* UnionType */: return visitor.visitUnionType(element); + case 132 /* ParenthesizedType */: return visitor.visitParenthesizedType(element); + case 133 /* InterfaceDeclaration */: return visitor.visitInterfaceDeclaration(element); + case 134 /* FunctionDeclaration */: return visitor.visitFunctionDeclaration(element); + case 135 /* ModuleDeclaration */: return visitor.visitModuleDeclaration(element); + case 136 /* ClassDeclaration */: return visitor.visitClassDeclaration(element); + case 137 /* EnumDeclaration */: return visitor.visitEnumDeclaration(element); + case 138 /* ImportDeclaration */: return visitor.visitImportDeclaration(element); + case 139 /* ExportAssignment */: return visitor.visitExportAssignment(element); + case 140 /* MemberFunctionDeclaration */: return visitor.visitMemberFunctionDeclaration(element); + case 141 /* MemberVariableDeclaration */: return visitor.visitMemberVariableDeclaration(element); + case 142 /* ConstructorDeclaration */: return visitor.visitConstructorDeclaration(element); + case 143 /* IndexMemberDeclaration */: return visitor.visitIndexMemberDeclaration(element); + case 144 /* GetAccessor */: return visitor.visitGetAccessor(element); + case 145 /* SetAccessor */: return visitor.visitSetAccessor(element); + case 146 /* PropertySignature */: return visitor.visitPropertySignature(element); + case 147 /* CallSignature */: return visitor.visitCallSignature(element); + case 148 /* ConstructSignature */: return visitor.visitConstructSignature(element); + case 149 /* IndexSignature */: return visitor.visitIndexSignature(element); + case 150 /* MethodSignature */: return visitor.visitMethodSignature(element); + case 151 /* Block */: return visitor.visitBlock(element); + case 152 /* IfStatement */: return visitor.visitIfStatement(element); + case 153 /* VariableStatement */: return visitor.visitVariableStatement(element); + case 154 /* ExpressionStatement */: return visitor.visitExpressionStatement(element); + case 155 /* ReturnStatement */: return visitor.visitReturnStatement(element); + case 156 /* SwitchStatement */: return visitor.visitSwitchStatement(element); + case 157 /* BreakStatement */: return visitor.visitBreakStatement(element); + case 158 /* ContinueStatement */: return visitor.visitContinueStatement(element); + case 159 /* ForStatement */: return visitor.visitForStatement(element); + case 160 /* ForInStatement */: return visitor.visitForInStatement(element); + case 161 /* EmptyStatement */: return visitor.visitEmptyStatement(element); + case 162 /* ThrowStatement */: return visitor.visitThrowStatement(element); + case 163 /* WhileStatement */: return visitor.visitWhileStatement(element); + case 164 /* TryStatement */: return visitor.visitTryStatement(element); + case 165 /* LabeledStatement */: return visitor.visitLabeledStatement(element); + case 166 /* DoStatement */: return visitor.visitDoStatement(element); + case 167 /* DebuggerStatement */: return visitor.visitDebuggerStatement(element); + case 168 /* WithStatement */: return visitor.visitWithStatement(element); + case 169 /* PrefixUnaryExpression */: return visitor.visitPrefixUnaryExpression(element); + case 170 /* DeleteExpression */: return visitor.visitDeleteExpression(element); + case 171 /* TypeOfExpression */: return visitor.visitTypeOfExpression(element); + case 172 /* VoidExpression */: return visitor.visitVoidExpression(element); + case 173 /* ConditionalExpression */: return visitor.visitConditionalExpression(element); + case 174 /* BinaryExpression */: return visitor.visitBinaryExpression(element); + case 175 /* PostfixUnaryExpression */: return visitor.visitPostfixUnaryExpression(element); + case 176 /* MemberAccessExpression */: return visitor.visitMemberAccessExpression(element); + case 177 /* InvocationExpression */: return visitor.visitInvocationExpression(element); + case 178 /* ArrayLiteralExpression */: return visitor.visitArrayLiteralExpression(element); + case 179 /* ObjectLiteralExpression */: return visitor.visitObjectLiteralExpression(element); + case 180 /* ObjectCreationExpression */: return visitor.visitObjectCreationExpression(element); + case 181 /* ParenthesizedExpression */: return visitor.visitParenthesizedExpression(element); + case 182 /* ParenthesizedArrowFunctionExpression */: return visitor.visitParenthesizedArrowFunctionExpression(element); + case 183 /* SimpleArrowFunctionExpression */: return visitor.visitSimpleArrowFunctionExpression(element); + case 184 /* CastExpression */: return visitor.visitCastExpression(element); + case 185 /* ElementAccessExpression */: return visitor.visitElementAccessExpression(element); + case 186 /* FunctionExpression */: return visitor.visitFunctionExpression(element); + case 187 /* OmittedExpression */: return visitor.visitOmittedExpression(element); + case 188 /* TemplateExpression */: return visitor.visitTemplateExpression(element); + case 189 /* TemplateAccessExpression */: return visitor.visitTemplateAccessExpression(element); + case 190 /* VariableDeclaration */: return visitor.visitVariableDeclaration(element); + case 191 /* VariableDeclarator */: return visitor.visitVariableDeclarator(element); + case 192 /* ArgumentList */: return visitor.visitArgumentList(element); + case 193 /* ParameterList */: return visitor.visitParameterList(element); + case 194 /* TypeArgumentList */: return visitor.visitTypeArgumentList(element); + case 195 /* TypeParameterList */: return visitor.visitTypeParameterList(element); + case 196 /* HeritageClause */: return visitor.visitHeritageClause(element); + case 197 /* EqualsValueClause */: return visitor.visitEqualsValueClause(element); + case 198 /* CaseSwitchClause */: return visitor.visitCaseSwitchClause(element); + case 199 /* DefaultSwitchClause */: return visitor.visitDefaultSwitchClause(element); + case 200 /* ElseClause */: return visitor.visitElseClause(element); + case 201 /* CatchClause */: return visitor.visitCatchClause(element); + case 202 /* FinallyClause */: return visitor.visitFinallyClause(element); + case 203 /* TemplateClause */: return visitor.visitTemplateClause(element); + case 204 /* TypeParameter */: return visitor.visitTypeParameter(element); + case 205 /* Constraint */: return visitor.visitConstraint(element); + case 206 /* SimplePropertyAssignment */: return visitor.visitSimplePropertyAssignment(element); + case 207 /* FunctionPropertyAssignment */: return visitor.visitFunctionPropertyAssignment(element); + case 208 /* Parameter */: return visitor.visitParameter(element); + case 209 /* EnumElement */: return visitor.visitEnumElement(element); + case 210 /* TypeAnnotation */: return visitor.visitTypeAnnotation(element); + case 211 /* ExternalModuleReference */: return visitor.visitExternalModuleReference(element); + case 212 /* ModuleNameModuleReference */: return visitor.visitModuleNameModuleReference(element); + default: return visitor.visitToken(element); } - throw TypeScript.Errors.invalidOperation(); } TypeScript.visitNodeOrToken = visitNodeOrToken; })(TypeScript || (TypeScript = {})); @@ -22069,44 +22398,15 @@ var TypeScript; } SyntaxWalker.prototype.visitToken = function (token) { }; - SyntaxWalker.prototype.visitNode = function (node) { - TypeScript.visitNodeOrToken(this, node); - }; - SyntaxWalker.prototype.visitNodeOrToken = function (nodeOrToken) { - if (TypeScript.isToken(nodeOrToken)) { - this.visitToken(nodeOrToken); - } - else { - this.visitNode(nodeOrToken); - } - }; SyntaxWalker.prototype.visitOptionalToken = function (token) { - if (token === null) { + if (token === undefined) { return; } this.visitToken(token); }; - SyntaxWalker.prototype.visitOptionalNode = function (node) { - if (node === null) { - return; - } - this.visitNode(node); - }; - SyntaxWalker.prototype.visitOptionalNodeOrToken = function (nodeOrToken) { - if (nodeOrToken === null) { - return; - } - this.visitNodeOrToken(nodeOrToken); - }; SyntaxWalker.prototype.visitList = function (list) { for (var i = 0, n = list.length; i < n; i++) { - this.visitNodeOrToken(list[i]); - } - }; - SyntaxWalker.prototype.visitSeparatedList = function (list) { - for (var i = 0, n = TypeScript.childCount(list); i < n; i++) { - var item = TypeScript.childAt(list, i); - this.visitNodeOrToken(item); + TypeScript.visitNodeOrToken(this, list[i]); } }; SyntaxWalker.prototype.visitSourceUnit = function (node) { @@ -22114,66 +22414,76 @@ var TypeScript; this.visitToken(node.endOfFileToken); }; SyntaxWalker.prototype.visitQualifiedName = function (node) { - this.visitNodeOrToken(node.left); + TypeScript.visitNodeOrToken(this, node.left); this.visitToken(node.dotToken); this.visitToken(node.right); }; SyntaxWalker.prototype.visitObjectType = function (node) { this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); + this.visitList(node.typeMembers); this.visitToken(node.closeBraceToken); }; SyntaxWalker.prototype.visitFunctionType = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); + TypeScript.visitNodeOrToken(this, node.typeParameterList); + TypeScript.visitNodeOrToken(this, node.parameterList); this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); + TypeScript.visitNodeOrToken(this, node.type); }; SyntaxWalker.prototype.visitArrayType = function (node) { - this.visitNodeOrToken(node.type); + TypeScript.visitNodeOrToken(this, node.type); this.visitToken(node.openBracketToken); this.visitToken(node.closeBracketToken); }; SyntaxWalker.prototype.visitConstructorType = function (node) { this.visitToken(node.newKeyword); - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); + TypeScript.visitNodeOrToken(this, node.typeParameterList); + TypeScript.visitNodeOrToken(this, node.parameterList); this.visitToken(node.equalsGreaterThanToken); - this.visitNodeOrToken(node.type); + TypeScript.visitNodeOrToken(this, node.type); }; SyntaxWalker.prototype.visitGenericType = function (node) { - this.visitNodeOrToken(node.name); - this.visitNode(node.typeArgumentList); + TypeScript.visitNodeOrToken(this, node.name); + TypeScript.visitNodeOrToken(this, node.typeArgumentList); }; SyntaxWalker.prototype.visitTypeQuery = function (node) { this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.name); + TypeScript.visitNodeOrToken(this, node.name); }; SyntaxWalker.prototype.visitTupleType = function (node) { this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.types); + this.visitList(node.types); this.visitToken(node.closeBracketToken); }; + SyntaxWalker.prototype.visitUnionType = function (node) { + TypeScript.visitNodeOrToken(this, node.left); + this.visitToken(node.barToken); + TypeScript.visitNodeOrToken(this, node.right); + }; + SyntaxWalker.prototype.visitParenthesizedType = function (node) { + this.visitToken(node.openParenToken); + TypeScript.visitNodeOrToken(this, node.type); + this.visitToken(node.closeParenToken); + }; SyntaxWalker.prototype.visitInterfaceDeclaration = function (node) { this.visitList(node.modifiers); this.visitToken(node.interfaceKeyword); this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); + TypeScript.visitNodeOrToken(this, node.typeParameterList); this.visitList(node.heritageClauses); - this.visitNode(node.body); + TypeScript.visitNodeOrToken(this, node.body); }; SyntaxWalker.prototype.visitFunctionDeclaration = function (node) { this.visitList(node.modifiers); this.visitToken(node.functionKeyword); this.visitToken(node.identifier); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); + TypeScript.visitNodeOrToken(this, node.callSignature); + TypeScript.visitNodeOrToken(this, node.block); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitModuleDeclaration = function (node) { this.visitList(node.modifiers); this.visitToken(node.moduleKeyword); - this.visitOptionalNodeOrToken(node.name); + TypeScript.visitNodeOrToken(this, node.name); this.visitOptionalToken(node.stringLiteral); this.visitToken(node.openBraceToken); this.visitList(node.moduleElements); @@ -22183,7 +22493,7 @@ var TypeScript; this.visitList(node.modifiers); this.visitToken(node.classKeyword); this.visitToken(node.identifier); - this.visitOptionalNode(node.typeParameterList); + TypeScript.visitNodeOrToken(this, node.typeParameterList); this.visitList(node.heritageClauses); this.visitToken(node.openBraceToken); this.visitList(node.classElements); @@ -22194,7 +22504,7 @@ var TypeScript; this.visitToken(node.enumKeyword); this.visitToken(node.identifier); this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); + this.visitList(node.enumElements); this.visitToken(node.closeBraceToken); }; SyntaxWalker.prototype.visitImportDeclaration = function (node) { @@ -22202,7 +22512,7 @@ var TypeScript; this.visitToken(node.importKeyword); this.visitToken(node.identifier); this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.moduleReference); + TypeScript.visitNodeOrToken(this, node.moduleReference); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitExportAssignment = function (node) { @@ -22214,65 +22524,65 @@ var TypeScript; SyntaxWalker.prototype.visitMemberFunctionDeclaration = function (node) { this.visitList(node.modifiers); this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); + TypeScript.visitNodeOrToken(this, node.callSignature); + TypeScript.visitNodeOrToken(this, node.block); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitMemberVariableDeclaration = function (node) { this.visitList(node.modifiers); - this.visitNode(node.variableDeclarator); + TypeScript.visitNodeOrToken(this, node.variableDeclarator); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitConstructorDeclaration = function (node) { this.visitList(node.modifiers); this.visitToken(node.constructorKeyword); - this.visitNode(node.callSignature); - this.visitOptionalNode(node.block); + TypeScript.visitNodeOrToken(this, node.callSignature); + TypeScript.visitNodeOrToken(this, node.block); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitIndexMemberDeclaration = function (node) { this.visitList(node.modifiers); - this.visitNode(node.indexSignature); + TypeScript.visitNodeOrToken(this, node.indexSignature); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitGetAccessor = function (node) { this.visitList(node.modifiers); this.visitToken(node.getKeyword); this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); + TypeScript.visitNodeOrToken(this, node.callSignature); + TypeScript.visitNodeOrToken(this, node.block); }; SyntaxWalker.prototype.visitSetAccessor = function (node) { this.visitList(node.modifiers); this.visitToken(node.setKeyword); this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); + TypeScript.visitNodeOrToken(this, node.callSignature); + TypeScript.visitNodeOrToken(this, node.block); }; SyntaxWalker.prototype.visitPropertySignature = function (node) { this.visitToken(node.propertyName); this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); + TypeScript.visitNodeOrToken(this, node.typeAnnotation); }; SyntaxWalker.prototype.visitCallSignature = function (node) { - this.visitOptionalNode(node.typeParameterList); - this.visitNode(node.parameterList); - this.visitOptionalNode(node.typeAnnotation); + TypeScript.visitNodeOrToken(this, node.typeParameterList); + TypeScript.visitNodeOrToken(this, node.parameterList); + TypeScript.visitNodeOrToken(this, node.typeAnnotation); }; SyntaxWalker.prototype.visitConstructSignature = function (node) { this.visitToken(node.newKeyword); - this.visitNode(node.callSignature); + TypeScript.visitNodeOrToken(this, node.callSignature); }; SyntaxWalker.prototype.visitIndexSignature = function (node) { this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.parameters); + this.visitList(node.parameters); this.visitToken(node.closeBracketToken); - this.visitOptionalNode(node.typeAnnotation); + TypeScript.visitNodeOrToken(this, node.typeAnnotation); }; SyntaxWalker.prototype.visitMethodSignature = function (node) { this.visitToken(node.propertyName); this.visitOptionalToken(node.questionToken); - this.visitNode(node.callSignature); + TypeScript.visitNodeOrToken(this, node.callSignature); }; SyntaxWalker.prototype.visitBlock = function (node) { this.visitToken(node.openBraceToken); @@ -22282,29 +22592,29 @@ var TypeScript; SyntaxWalker.prototype.visitIfStatement = function (node) { this.visitToken(node.ifKeyword); this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); + TypeScript.visitNodeOrToken(this, node.condition); this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); - this.visitOptionalNode(node.elseClause); + TypeScript.visitNodeOrToken(this, node.statement); + TypeScript.visitNodeOrToken(this, node.elseClause); }; SyntaxWalker.prototype.visitVariableStatement = function (node) { this.visitList(node.modifiers); - this.visitNode(node.variableDeclaration); + TypeScript.visitNodeOrToken(this, node.variableDeclaration); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitExpressionStatement = function (node) { - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitReturnStatement = function (node) { this.visitToken(node.returnKeyword); - this.visitOptionalNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitSwitchStatement = function (node) { this.visitToken(node.switchKeyword); this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitToken(node.closeParenToken); this.visitToken(node.openBraceToken); this.visitList(node.switchClauses); @@ -22323,57 +22633,57 @@ var TypeScript; SyntaxWalker.prototype.visitForStatement = function (node) { this.visitToken(node.forKeyword); this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.initializer); + TypeScript.visitNodeOrToken(this, node.variableDeclaration); + TypeScript.visitNodeOrToken(this, node.initializer); this.visitToken(node.firstSemicolonToken); - this.visitOptionalNodeOrToken(node.condition); + TypeScript.visitNodeOrToken(this, node.condition); this.visitToken(node.secondSemicolonToken); - this.visitOptionalNodeOrToken(node.incrementor); + TypeScript.visitNodeOrToken(this, node.incrementor); this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); + TypeScript.visitNodeOrToken(this, node.statement); }; SyntaxWalker.prototype.visitForInStatement = function (node) { this.visitToken(node.forKeyword); this.visitToken(node.openParenToken); - this.visitOptionalNode(node.variableDeclaration); - this.visitOptionalNodeOrToken(node.left); + TypeScript.visitNodeOrToken(this, node.variableDeclaration); + TypeScript.visitNodeOrToken(this, node.left); this.visitToken(node.inKeyword); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); + TypeScript.visitNodeOrToken(this, node.statement); }; SyntaxWalker.prototype.visitEmptyStatement = function (node) { this.visitToken(node.semicolonToken); }; SyntaxWalker.prototype.visitThrowStatement = function (node) { this.visitToken(node.throwKeyword); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitOptionalToken(node.semicolonToken); }; SyntaxWalker.prototype.visitWhileStatement = function (node) { this.visitToken(node.whileKeyword); this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); + TypeScript.visitNodeOrToken(this, node.condition); this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); + TypeScript.visitNodeOrToken(this, node.statement); }; SyntaxWalker.prototype.visitTryStatement = function (node) { this.visitToken(node.tryKeyword); - this.visitNode(node.block); - this.visitOptionalNode(node.catchClause); - this.visitOptionalNode(node.finallyClause); + TypeScript.visitNodeOrToken(this, node.block); + TypeScript.visitNodeOrToken(this, node.catchClause); + TypeScript.visitNodeOrToken(this, node.finallyClause); }; SyntaxWalker.prototype.visitLabeledStatement = function (node) { this.visitToken(node.identifier); this.visitToken(node.colonToken); - this.visitNodeOrToken(node.statement); + TypeScript.visitNodeOrToken(this, node.statement); }; SyntaxWalker.prototype.visitDoStatement = function (node) { this.visitToken(node.doKeyword); - this.visitNodeOrToken(node.statement); + TypeScript.visitNodeOrToken(this, node.statement); this.visitToken(node.whileKeyword); this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); + TypeScript.visitNodeOrToken(this, node.condition); this.visitToken(node.closeParenToken); this.visitOptionalToken(node.semicolonToken); }; @@ -22384,144 +22694,152 @@ var TypeScript; SyntaxWalker.prototype.visitWithStatement = function (node) { this.visitToken(node.withKeyword); this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.condition); + TypeScript.visitNodeOrToken(this, node.condition); this.visitToken(node.closeParenToken); - this.visitNodeOrToken(node.statement); + TypeScript.visitNodeOrToken(this, node.statement); }; SyntaxWalker.prototype.visitPrefixUnaryExpression = function (node) { this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.operand); + TypeScript.visitNodeOrToken(this, node.operand); }; SyntaxWalker.prototype.visitDeleteExpression = function (node) { this.visitToken(node.deleteKeyword); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); }; SyntaxWalker.prototype.visitTypeOfExpression = function (node) { this.visitToken(node.typeOfKeyword); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); }; SyntaxWalker.prototype.visitVoidExpression = function (node) { this.visitToken(node.voidKeyword); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); }; SyntaxWalker.prototype.visitConditionalExpression = function (node) { - this.visitNodeOrToken(node.condition); + TypeScript.visitNodeOrToken(this, node.condition); this.visitToken(node.questionToken); - this.visitNodeOrToken(node.whenTrue); + TypeScript.visitNodeOrToken(this, node.whenTrue); this.visitToken(node.colonToken); - this.visitNodeOrToken(node.whenFalse); + TypeScript.visitNodeOrToken(this, node.whenFalse); }; SyntaxWalker.prototype.visitBinaryExpression = function (node) { - this.visitNodeOrToken(node.left); + TypeScript.visitNodeOrToken(this, node.left); this.visitToken(node.operatorToken); - this.visitNodeOrToken(node.right); + TypeScript.visitNodeOrToken(this, node.right); }; SyntaxWalker.prototype.visitPostfixUnaryExpression = function (node) { - this.visitNodeOrToken(node.operand); + TypeScript.visitNodeOrToken(this, node.operand); this.visitToken(node.operatorToken); }; SyntaxWalker.prototype.visitMemberAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitToken(node.dotToken); this.visitToken(node.name); }; SyntaxWalker.prototype.visitInvocationExpression = function (node) { - this.visitNodeOrToken(node.expression); - this.visitNode(node.argumentList); + TypeScript.visitNodeOrToken(this, node.expression); + TypeScript.visitNodeOrToken(this, node.argumentList); }; SyntaxWalker.prototype.visitArrayLiteralExpression = function (node) { this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); + this.visitList(node.expressions); this.visitToken(node.closeBracketToken); }; SyntaxWalker.prototype.visitObjectLiteralExpression = function (node) { this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); + this.visitList(node.propertyAssignments); this.visitToken(node.closeBraceToken); }; SyntaxWalker.prototype.visitObjectCreationExpression = function (node) { this.visitToken(node.newKeyword); - this.visitNodeOrToken(node.expression); - this.visitOptionalNode(node.argumentList); + TypeScript.visitNodeOrToken(this, node.expression); + TypeScript.visitNodeOrToken(this, node.argumentList); }; SyntaxWalker.prototype.visitParenthesizedExpression = function (node) { this.visitToken(node.openParenToken); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitToken(node.closeParenToken); }; SyntaxWalker.prototype.visitParenthesizedArrowFunctionExpression = function (node) { - this.visitNode(node.callSignature); + TypeScript.visitNodeOrToken(this, node.callSignature); this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.block); + TypeScript.visitNodeOrToken(this, node.expression); }; SyntaxWalker.prototype.visitSimpleArrowFunctionExpression = function (node) { - this.visitNode(node.parameter); + TypeScript.visitNodeOrToken(this, node.parameter); this.visitToken(node.equalsGreaterThanToken); - this.visitOptionalNode(node.block); - this.visitOptionalNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.block); + TypeScript.visitNodeOrToken(this, node.expression); }; SyntaxWalker.prototype.visitCastExpression = function (node) { this.visitToken(node.lessThanToken); - this.visitNodeOrToken(node.type); + TypeScript.visitNodeOrToken(this, node.type); this.visitToken(node.greaterThanToken); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); }; SyntaxWalker.prototype.visitElementAccessExpression = function (node) { - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitToken(node.openBracketToken); - this.visitNodeOrToken(node.argumentExpression); + TypeScript.visitNodeOrToken(this, node.argumentExpression); this.visitToken(node.closeBracketToken); }; SyntaxWalker.prototype.visitFunctionExpression = function (node) { this.visitToken(node.functionKeyword); this.visitOptionalToken(node.identifier); - this.visitNode(node.callSignature); - this.visitNode(node.block); + TypeScript.visitNodeOrToken(this, node.callSignature); + TypeScript.visitNodeOrToken(this, node.block); }; SyntaxWalker.prototype.visitOmittedExpression = function (node) { }; + SyntaxWalker.prototype.visitTemplateExpression = function (node) { + this.visitToken(node.templateStartToken); + this.visitList(node.templateClauses); + }; + SyntaxWalker.prototype.visitTemplateAccessExpression = function (node) { + TypeScript.visitNodeOrToken(this, node.expression); + TypeScript.visitNodeOrToken(this, node.templateExpression); + }; SyntaxWalker.prototype.visitVariableDeclaration = function (node) { this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); + this.visitList(node.variableDeclarators); }; SyntaxWalker.prototype.visitVariableDeclarator = function (node) { this.visitToken(node.propertyName); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); + TypeScript.visitNodeOrToken(this, node.typeAnnotation); + TypeScript.visitNodeOrToken(this, node.equalsValueClause); }; SyntaxWalker.prototype.visitArgumentList = function (node) { - this.visitOptionalNode(node.typeArgumentList); + TypeScript.visitNodeOrToken(this, node.typeArgumentList); this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); + this.visitList(node.arguments); this.visitToken(node.closeParenToken); }; SyntaxWalker.prototype.visitParameterList = function (node) { this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); + this.visitList(node.parameters); this.visitToken(node.closeParenToken); }; SyntaxWalker.prototype.visitTypeArgumentList = function (node) { this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); + this.visitList(node.typeArguments); this.visitToken(node.greaterThanToken); }; SyntaxWalker.prototype.visitTypeParameterList = function (node) { this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); + this.visitList(node.typeParameters); this.visitToken(node.greaterThanToken); }; SyntaxWalker.prototype.visitHeritageClause = function (node) { this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); + this.visitList(node.typeNames); }; SyntaxWalker.prototype.visitEqualsValueClause = function (node) { this.visitToken(node.equalsToken); - this.visitNodeOrToken(node.value); + TypeScript.visitNodeOrToken(this, node.value); }; SyntaxWalker.prototype.visitCaseSwitchClause = function (node) { this.visitToken(node.caseKeyword); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); this.visitToken(node.colonToken); this.visitList(node.statements); }; @@ -22532,53 +22850,57 @@ var TypeScript; }; SyntaxWalker.prototype.visitElseClause = function (node) { this.visitToken(node.elseKeyword); - this.visitNodeOrToken(node.statement); + TypeScript.visitNodeOrToken(this, node.statement); }; SyntaxWalker.prototype.visitCatchClause = function (node) { this.visitToken(node.catchKeyword); this.visitToken(node.openParenToken); this.visitToken(node.identifier); - this.visitOptionalNode(node.typeAnnotation); + TypeScript.visitNodeOrToken(this, node.typeAnnotation); this.visitToken(node.closeParenToken); - this.visitNode(node.block); + TypeScript.visitNodeOrToken(this, node.block); }; SyntaxWalker.prototype.visitFinallyClause = function (node) { this.visitToken(node.finallyKeyword); - this.visitNode(node.block); + TypeScript.visitNodeOrToken(this, node.block); + }; + SyntaxWalker.prototype.visitTemplateClause = function (node) { + TypeScript.visitNodeOrToken(this, node.expression); + this.visitToken(node.templateMiddleOrEndToken); }; SyntaxWalker.prototype.visitTypeParameter = function (node) { this.visitToken(node.identifier); - this.visitOptionalNode(node.constraint); + TypeScript.visitNodeOrToken(this, node.constraint); }; SyntaxWalker.prototype.visitConstraint = function (node) { this.visitToken(node.extendsKeyword); - this.visitNodeOrToken(node.typeOrExpression); + TypeScript.visitNodeOrToken(this, node.typeOrExpression); }; SyntaxWalker.prototype.visitSimplePropertyAssignment = function (node) { this.visitToken(node.propertyName); this.visitToken(node.colonToken); - this.visitNodeOrToken(node.expression); + TypeScript.visitNodeOrToken(this, node.expression); }; SyntaxWalker.prototype.visitFunctionPropertyAssignment = function (node) { this.visitToken(node.propertyName); - this.visitNode(node.callSignature); - this.visitNode(node.block); + TypeScript.visitNodeOrToken(this, node.callSignature); + TypeScript.visitNodeOrToken(this, node.block); }; SyntaxWalker.prototype.visitParameter = function (node) { this.visitOptionalToken(node.dotDotDotToken); this.visitList(node.modifiers); this.visitToken(node.identifier); this.visitOptionalToken(node.questionToken); - this.visitOptionalNode(node.typeAnnotation); - this.visitOptionalNode(node.equalsValueClause); + TypeScript.visitNodeOrToken(this, node.typeAnnotation); + TypeScript.visitNodeOrToken(this, node.equalsValueClause); }; SyntaxWalker.prototype.visitEnumElement = function (node) { this.visitToken(node.propertyName); - this.visitOptionalNode(node.equalsValueClause); + TypeScript.visitNodeOrToken(this, node.equalsValueClause); }; SyntaxWalker.prototype.visitTypeAnnotation = function (node) { this.visitToken(node.colonToken); - this.visitNodeOrToken(node.type); + TypeScript.visitNodeOrToken(this, node.type); }; SyntaxWalker.prototype.visitExternalModuleReference = function (node) { this.visitToken(node.requireKeyword); @@ -22587,38 +22909,16 @@ var TypeScript; this.visitToken(node.closeParenToken); }; SyntaxWalker.prototype.visitModuleNameModuleReference = function (node) { - this.visitNodeOrToken(node.moduleName); + TypeScript.visitNodeOrToken(this, node.moduleName); }; return SyntaxWalker; })(); TypeScript.SyntaxWalker = SyntaxWalker; })(TypeScript || (TypeScript = {})); var TypeScript; -(function (TypeScript) { - var DepthLimitedWalker = (function (_super) { - __extends(DepthLimitedWalker, _super); - function DepthLimitedWalker(maximumDepth) { - _super.call(this); - this._depth = 0; - this._maximumDepth = 0; - this._maximumDepth = maximumDepth; - } - DepthLimitedWalker.prototype.visitNode = function (node) { - if (this._depth < this._maximumDepth) { - this._depth++; - _super.prototype.visitNode.call(this, node); - this._depth--; - } - }; - return DepthLimitedWalker; - })(TypeScript.SyntaxWalker); - TypeScript.DepthLimitedWalker = DepthLimitedWalker; -})(TypeScript || (TypeScript = {})); -var TypeScript; (function (TypeScript) { var Parser; (function (Parser) { - Parser.syntaxFactory; var arrayPool = []; var arrayPoolCount = 0; function getArray() { @@ -22627,14 +22927,9 @@ var TypeScript; } arrayPoolCount--; var result = arrayPool[arrayPoolCount]; - arrayPool[arrayPoolCount] = null; + arrayPool[arrayPoolCount] = undefined; return result; } - function returnZeroLengthArray(array) { - if (array.length === 0) { - returnArray(array); - } - } function returnArray(array) { array.length = 0; arrayPool[arrayPoolCount] = array; @@ -22655,17 +22950,17 @@ var TypeScript; var result = parseSyntaxTreeWorker(isDeclaration); diagnostics = []; parseNodeData = 0 /* None */; - fileName = null; + fileName = undefined; source.release(); - source = null; - _source = null; + source = undefined; + _source = undefined; return result; } function parseSyntaxTreeWorker(isDeclaration) { var sourceUnit = parseSourceUnit(); var allDiagnostics = source.tokenDiagnostics().concat(diagnostics); allDiagnostics.sort(function (a, b) { return a.start() - b.start(); }); - return new TypeScript.SyntaxTree(Parser.syntaxFactory.isConcrete, sourceUnit, isDeclaration, allDiagnostics, fileName, source.text, languageVersion); + return new TypeScript.SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, fileName, source.text, languageVersion); } function getRewindPoint() { var rewindPoint = source.getRewindPoint(); @@ -22683,8 +22978,8 @@ var TypeScript; } function currentNode() { var node = source.currentNode(); - if (node === null || TypeScript.parsedInStrictMode(node) !== isInStrictMode) { - return null; + if (!node || TypeScript.parsedInStrictMode(node) !== isInStrictMode) { + return undefined; } return node; } @@ -22716,11 +23011,11 @@ var TypeScript; if (_currentToken.kind() === kind) { return consumeToken(_currentToken); } - return null; + return undefined; } function isIdentifier(token) { var tokenKind = token.kind(); - if (tokenKind === 11 /* IdentifierName */) { + if (tokenKind === 9 /* IdentifierName */) { return true; } if (tokenKind >= TypeScript.SyntaxKind.FirstFutureReservedStrictKeyword) { @@ -22734,27 +23029,27 @@ var TypeScript; function eatIdentifierNameToken() { var token = currentToken(); var tokenKind = token.kind(); - if (tokenKind === 11 /* IdentifierName */) { + if (tokenKind === 9 /* IdentifierName */) { return consumeToken(token); } if (TypeScript.SyntaxFacts.isAnyKeyword(tokenKind)) { return TypeScript.Syntax.convertKeywordToIdentifier(consumeToken(token)); } - return createMissingToken(11 /* IdentifierName */, token); + return createMissingToken(9 /* IdentifierName */, token); } function eatOptionalIdentifierToken() { - return isIdentifier(currentToken()) ? eatIdentifierToken() : null; + return isIdentifier(currentToken()) ? eatIdentifierToken() : undefined; } function eatIdentifierToken(diagnosticCode) { var token = currentToken(); if (isIdentifier(token)) { consumeToken(token); - if (token.kind() === 11 /* IdentifierName */) { + if (token.kind() === 9 /* IdentifierName */) { return token; } return TypeScript.Syntax.convertKeywordToIdentifier(token); } - return createMissingToken(11 /* IdentifierName */, token, diagnosticCode); + return createMissingToken(9 /* IdentifierName */, token, diagnosticCode); } function previousTokenHasTrailingNewLine(token) { var tokenFullStart = token.fullStart(); @@ -22768,10 +23063,10 @@ var TypeScript; function canEatAutomaticSemicolon(allowWithoutNewLine) { var token = currentToken(); var tokenKind = token.kind(); - if (tokenKind === 10 /* EndOfFileToken */) { + if (tokenKind === 8 /* EndOfFileToken */) { return true; } - if (tokenKind === 71 /* CloseBraceToken */) { + if (tokenKind === 73 /* CloseBraceToken */) { return true; } if (allowWithoutNewLine) { @@ -22784,20 +23079,20 @@ var TypeScript; } function canEatExplicitOrAutomaticSemicolon(allowWithoutNewline) { var token = currentToken(); - if (token.kind() === 78 /* SemicolonToken */) { + if (token.kind() === 80 /* SemicolonToken */) { return true; } return canEatAutomaticSemicolon(allowWithoutNewline); } function eatExplicitOrAutomaticSemicolon(allowWithoutNewline) { var token = currentToken(); - if (token.kind() === 78 /* SemicolonToken */) { + if (token.kind() === 80 /* SemicolonToken */) { return consumeToken(token); } if (canEatAutomaticSemicolon(allowWithoutNewline)) { - return null; + return undefined; } - return eatToken(78 /* SemicolonToken */); + return eatToken(80 /* SemicolonToken */); } function createMissingToken(expectedKind, actual, diagnosticCode) { var diagnostic = getExpectedTokenDiagnostic(expectedKind, actual, diagnosticCode); @@ -22806,14 +23101,14 @@ var TypeScript; } function getExpectedTokenDiagnostic(expectedKind, actual, diagnosticCode) { var token = currentToken(); - var args = null; + var args = undefined; if (!diagnosticCode) { if (TypeScript.SyntaxFacts.isAnyKeyword(expectedKind) || TypeScript.SyntaxFacts.isAnyPunctuation(expectedKind)) { diagnosticCode = TypeScript.DiagnosticCode._0_expected; args = [TypeScript.SyntaxFacts.getText(expectedKind)]; } else { - if (actual !== null && TypeScript.SyntaxFacts.isAnyKeyword(actual.kind())) { + if (actual && TypeScript.SyntaxFacts.isAnyKeyword(actual.kind())) { diagnosticCode = TypeScript.DiagnosticCode.Identifier_expected_0_is_a_keyword; args = [TypeScript.SyntaxFacts.getText(actual.kind())]; } @@ -22826,38 +23121,33 @@ var TypeScript; } function getBinaryExpressionPrecedence(tokenKind) { switch (tokenKind) { - case 104 /* BarBarToken */: - return 2 /* LogicalOrExpressionPrecedence */; - case 103 /* AmpersandAmpersandToken */: - return 3 /* LogicalAndExpressionPrecedence */; - case 99 /* BarToken */: - return 4 /* BitwiseOrExpressionPrecedence */; - case 100 /* CaretToken */: - return 5 /* BitwiseExclusiveOrExpressionPrecedence */; - case 98 /* AmpersandToken */: - return 6 /* BitwiseAndExpressionPrecedence */; - case 84 /* EqualsEqualsToken */: - case 86 /* ExclamationEqualsToken */: - case 87 /* EqualsEqualsEqualsToken */: - case 88 /* ExclamationEqualsEqualsToken */: + case 106 /* BarBarToken */: return 2 /* LogicalOrExpressionPrecedence */; + case 105 /* AmpersandAmpersandToken */: return 3 /* LogicalAndExpressionPrecedence */; + case 101 /* BarToken */: return 4 /* BitwiseOrExpressionPrecedence */; + case 102 /* CaretToken */: return 5 /* BitwiseExclusiveOrExpressionPrecedence */; + case 100 /* AmpersandToken */: return 6 /* BitwiseAndExpressionPrecedence */; + case 86 /* EqualsEqualsToken */: + case 88 /* ExclamationEqualsToken */: + case 89 /* EqualsEqualsEqualsToken */: + case 90 /* ExclamationEqualsEqualsToken */: return 7 /* EqualityExpressionPrecedence */; - case 80 /* LessThanToken */: - case 81 /* GreaterThanToken */: - case 82 /* LessThanEqualsToken */: - case 83 /* GreaterThanEqualsToken */: - case 30 /* InstanceOfKeyword */: - case 29 /* InKeyword */: + case 82 /* LessThanToken */: + case 83 /* GreaterThanToken */: + case 84 /* LessThanEqualsToken */: + case 85 /* GreaterThanEqualsToken */: + case 32 /* InstanceOfKeyword */: + case 31 /* InKeyword */: return 8 /* RelationalExpressionPrecedence */; - case 95 /* LessThanLessThanToken */: - case 96 /* GreaterThanGreaterThanToken */: - case 97 /* GreaterThanGreaterThanGreaterThanToken */: + case 97 /* LessThanLessThanToken */: + case 98 /* GreaterThanGreaterThanToken */: + case 99 /* GreaterThanGreaterThanGreaterThanToken */: return 9 /* ShiftExpressionPrecdence */; - case 89 /* PlusToken */: - case 90 /* MinusToken */: + case 91 /* PlusToken */: + case 92 /* MinusToken */: return 10 /* AdditiveExpressionPrecedence */; - case 91 /* AsteriskToken */: - case 118 /* SlashToken */: - case 92 /* PercentToken */: + case 93 /* AsteriskToken */: + case 120 /* SlashToken */: + case 94 /* PercentToken */: return 11 /* MultiplicativeExpressionPrecedence */; } throw TypeScript.Errors.invalidOperation(); @@ -22878,11 +23168,12 @@ var TypeScript; var parent = oldToken.parent; newToken.parent = parent; while (true) { - TypeScript.Debug.assert(TypeScript.isNode(parent) || TypeScript.isList(parent) || TypeScript.isSeparatedList(parent)); + TypeScript.Debug.assert(TypeScript.isNode(parent) || TypeScript.isList(parent)); var dataElement = parent; - if (dataElement.data) { - dataElement.data &= 4 /* NodeParsedInStrictModeMask */; + if (dataElement.__data) { + dataElement.__data &= 4 /* NodeParsedInStrictModeMask */; } + dataElement.__cachedTokens = undefined; if (parent === node) { break; } @@ -22909,20 +23200,6 @@ var TypeScript; } } } - else if (TypeScript.isSeparatedList(parent)) { - var list2 = parent; - for (var i = 0, n = TypeScript.childCount(list2); i < n; i++) { - if (TypeScript.childAt(list2, i) === oldToken) { - if (i % 2 === 0) { - list2[i / 2] = newToken; - } - else { - list2.separators[(i - 1) / 2] = newToken; - } - return; - } - } - } throw TypeScript.Errors.invalidOperation(); } function addSkippedTokenAfterNode(node, skippedToken) { @@ -22989,7 +23266,7 @@ var TypeScript; var skippedTokens = getArray(); var moduleElements = parseSyntaxList(0 /* SourceUnit_ModuleElements */, skippedTokens, updateStrictModeState); setStrictMode(savedIsInStrictMode); - var sourceUnit = new Parser.syntaxFactory.SourceUnitSyntax(parseNodeData, moduleElements, currentToken()); + var sourceUnit = new TypeScript.SourceUnitSyntax(parseNodeData, moduleElements, currentToken()); sourceUnit = addSkippedTokensBeforeNode(sourceUnit, skippedTokens); if (TypeScript.Debug.shouldAssert(2 /* Aggressive */)) { TypeScript.Debug.assert(TypeScript.fullWidth(sourceUnit) === source.text.length()); @@ -23027,48 +23304,43 @@ var TypeScript; var _modifierCount = modifierCount(); if (_modifierCount) { switch (peekToken(_modifierCount).kind()) { - case 49 /* ImportKeyword */: - return parseImportDeclaration(); - case 65 /* ModuleKeyword */: - return parseModuleDeclaration(); - case 52 /* InterfaceKeyword */: - return parseInterfaceDeclaration(); - case 44 /* ClassKeyword */: - return parseClassDeclaration(); - case 46 /* EnumKeyword */: - return parseEnumDeclaration(); + case 51 /* ImportKeyword */: return parseImportDeclaration(); + case 67 /* ModuleKeyword */: return parseModuleDeclaration(); + case 54 /* InterfaceKeyword */: return parseInterfaceDeclaration(); + case 46 /* ClassKeyword */: return parseClassDeclaration(); + case 48 /* EnumKeyword */: return parseEnumDeclaration(); } } var nextToken = peekToken(1); var currentTokenKind = _currentToken.kind(); switch (currentTokenKind) { - case 65 /* ModuleKeyword */: - if (isIdentifier(nextToken) || nextToken.kind() === 14 /* StringLiteral */) { + case 67 /* ModuleKeyword */: + if (isIdentifier(nextToken) || nextToken.kind() === 12 /* StringLiteral */) { return parseModuleDeclaration(); } break; - case 49 /* ImportKeyword */: + case 51 /* ImportKeyword */: if (isIdentifier(nextToken)) { return parseImportDeclaration(); } break; - case 44 /* ClassKeyword */: + case 46 /* ClassKeyword */: if (isIdentifier(nextToken)) { return parseClassDeclaration(); } break; - case 46 /* EnumKeyword */: + case 48 /* EnumKeyword */: if (isIdentifier(nextToken)) { return parseEnumDeclaration(); } break; - case 52 /* InterfaceKeyword */: + case 54 /* InterfaceKeyword */: if (isIdentifier(nextToken)) { return parseInterfaceDeclaration(); } break; - case 47 /* ExportKeyword */: - if (nextToken.kind() === 107 /* EqualsToken */) { + case 49 /* ExportKeyword */: + if (nextToken.kind() === 109 /* EqualsToken */) { return parseExportAssignment(); } break; @@ -23076,72 +23348,72 @@ var TypeScript; return tryParseStatementWorker(_currentToken, currentTokenKind, _modifierCount, inErrorRecovery); } function parseImportDeclaration() { - return new Parser.syntaxFactory.ImportDeclarationSyntax(parseNodeData, parseModifiers(), eatToken(49 /* ImportKeyword */), eatIdentifierToken(), eatToken(107 /* EqualsToken */), parseModuleReference(), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.ImportDeclarationSyntax(parseNodeData, parseModifiers(), eatToken(51 /* ImportKeyword */), eatIdentifierToken(), eatToken(109 /* EqualsToken */), parseModuleReference(), eatExplicitOrAutomaticSemicolon(false)); } function parseExportAssignment() { - return new Parser.syntaxFactory.ExportAssignmentSyntax(parseNodeData, eatToken(47 /* ExportKeyword */), eatToken(107 /* EqualsToken */), eatIdentifierToken(), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.ExportAssignmentSyntax(parseNodeData, eatToken(49 /* ExportKeyword */), eatToken(109 /* EqualsToken */), eatIdentifierToken(), eatExplicitOrAutomaticSemicolon(false)); } function parseModuleReference() { return isExternalModuleReference() ? parseExternalModuleReference() : parseModuleNameModuleReference(); } function isExternalModuleReference() { - return currentToken().kind() === 66 /* RequireKeyword */ && peekToken(1).kind() === 72 /* OpenParenToken */; + return currentToken().kind() === 68 /* RequireKeyword */ && peekToken(1).kind() === 74 /* OpenParenToken */; } function parseExternalModuleReference() { - return new Parser.syntaxFactory.ExternalModuleReferenceSyntax(parseNodeData, eatToken(66 /* RequireKeyword */), eatToken(72 /* OpenParenToken */), eatToken(14 /* StringLiteral */), eatToken(73 /* CloseParenToken */)); + return new TypeScript.ExternalModuleReferenceSyntax(parseNodeData, eatToken(68 /* RequireKeyword */), eatToken(74 /* OpenParenToken */), eatToken(12 /* StringLiteral */), eatToken(75 /* CloseParenToken */)); } function parseModuleNameModuleReference() { - return new Parser.syntaxFactory.ModuleNameModuleReferenceSyntax(parseNodeData, parseName(false)); + return new TypeScript.ModuleNameModuleReferenceSyntax(parseNodeData, parseName(false)); } function tryParseTypeArgumentList(inExpression) { var _currentToken = currentToken(); - if (_currentToken.kind() !== 80 /* LessThanToken */) { - return null; + if (_currentToken.kind() !== 82 /* LessThanToken */) { + return undefined; } if (!inExpression) { var lessThanToken = consumeToken(_currentToken); var skippedTokens = getArray(); var typeArguments = parseSeparatedSyntaxList(19 /* TypeArgumentList_Types */, skippedTokens); lessThanToken = addSkippedTokensAfterToken(lessThanToken, skippedTokens); - return new Parser.syntaxFactory.TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, eatToken(81 /* GreaterThanToken */)); + return new TypeScript.TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, eatToken(83 /* GreaterThanToken */)); } var rewindPoint = getRewindPoint(); var lessThanToken = consumeToken(_currentToken); var skippedTokens = getArray(); var typeArguments = parseSeparatedSyntaxList(19 /* TypeArgumentList_Types */, skippedTokens); var lessThanToken = addSkippedTokensAfterToken(lessThanToken, skippedTokens); - var greaterThanToken = eatToken(81 /* GreaterThanToken */); + var greaterThanToken = eatToken(83 /* GreaterThanToken */); if (greaterThanToken.fullWidth() === 0 || !canFollowTypeArgumentListInExpression(currentToken().kind())) { rewind(rewindPoint); releaseRewindPoint(rewindPoint); - return null; + return undefined; } else { releaseRewindPoint(rewindPoint); - return new Parser.syntaxFactory.TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, greaterThanToken); + return new TypeScript.TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, greaterThanToken); } } function canFollowTypeArgumentListInExpression(kind) { switch (kind) { - case 72 /* OpenParenToken */: - case 76 /* DotToken */: - case 73 /* CloseParenToken */: - case 75 /* CloseBracketToken */: - case 106 /* ColonToken */: - case 78 /* SemicolonToken */: - case 79 /* CommaToken */: - case 105 /* QuestionToken */: - case 84 /* EqualsEqualsToken */: - case 87 /* EqualsEqualsEqualsToken */: - case 86 /* ExclamationEqualsToken */: - case 88 /* ExclamationEqualsEqualsToken */: - case 103 /* AmpersandAmpersandToken */: - case 104 /* BarBarToken */: - case 100 /* CaretToken */: - case 98 /* AmpersandToken */: - case 99 /* BarToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: + case 74 /* OpenParenToken */: + case 78 /* DotToken */: + case 75 /* CloseParenToken */: + case 77 /* CloseBracketToken */: + case 108 /* ColonToken */: + case 80 /* SemicolonToken */: + case 81 /* CommaToken */: + case 107 /* QuestionToken */: + case 86 /* EqualsEqualsToken */: + case 89 /* EqualsEqualsEqualsToken */: + case 88 /* ExclamationEqualsToken */: + case 90 /* ExclamationEqualsEqualsToken */: + case 105 /* AmpersandAmpersandToken */: + case 106 /* BarBarToken */: + case 102 /* CaretToken */: + case 100 /* AmpersandToken */: + case 101 /* BarToken */: + case 73 /* CloseBraceToken */: + case 8 /* EndOfFileToken */: return true; default: return false; @@ -23155,7 +23427,7 @@ var TypeScript; if (TypeScript.SyntaxFacts.isAnyKeyword(_currentToken.kind()) && previousTokenHasTrailingNewLine(_currentToken)) { var token1 = peekToken(1); if (!TypeScript.existsNewLineBetweenTokens(_currentToken, token1, source.text) && TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { - return createMissingToken(11 /* IdentifierName */, _currentToken); + return createMissingToken(9 /* IdentifierName */, _currentToken); } } return allowIdentifierNames ? eatIdentifierNameToken() : eatIdentifierToken(); @@ -23164,59 +23436,59 @@ var TypeScript; var token0 = currentToken(); var shouldContinue = isIdentifier(token0); if (!shouldContinue) { - return null; + return undefined; } var current = eatIdentifierToken(); - while (shouldContinue && currentToken().kind() === 76 /* DotToken */) { + while (shouldContinue && currentToken().kind() === 78 /* DotToken */) { var dotToken = consumeToken(currentToken()); var identifierName = eatRightSideOfName(allowIdentifierNames); - current = new Parser.syntaxFactory.QualifiedNameSyntax(parseNodeData, current, dotToken, identifierName); + current = new TypeScript.QualifiedNameSyntax(parseNodeData, current, dotToken, identifierName); shouldContinue = identifierName.fullWidth() > 0; } return current; } function parseEnumDeclaration() { var modifiers = parseModifiers(); - var enumKeyword = eatToken(46 /* EnumKeyword */); + var enumKeyword = eatToken(48 /* EnumKeyword */); var identifier = eatIdentifierToken(); - var openBraceToken = eatToken(70 /* OpenBraceToken */); - var enumElements = TypeScript.Syntax.emptySeparatedList(); + var openBraceToken = eatToken(72 /* OpenBraceToken */); + var enumElements; if (openBraceToken.fullWidth() > 0) { var skippedTokens = getArray(); enumElements = parseSeparatedSyntaxList(8 /* EnumDeclaration_EnumElements */, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } - return new Parser.syntaxFactory.EnumDeclarationSyntax(parseNodeData, modifiers, enumKeyword, identifier, openBraceToken, enumElements, eatToken(71 /* CloseBraceToken */)); + return new TypeScript.EnumDeclarationSyntax(parseNodeData, modifiers, enumKeyword, identifier, openBraceToken, enumElements || [], eatToken(73 /* CloseBraceToken */)); } function isEnumElement(inErrorRecovery) { var node = currentNode(); - if (node !== null && node.kind() === 244 /* EnumElement */) { + if (node && node.kind() === 209 /* EnumElement */) { return true; } return isPropertyName(currentToken(), inErrorRecovery); } function tryParseEnumElementEqualsValueClause() { - return isEqualsValueClause(false) ? parseEqualsValueClause(true) : null; + return isEqualsValueClause(false) ? parseEqualsValueClause(true) : undefined; } function tryParseEnumElement(inErrorRecovery) { var node = currentNode(); - if (node !== null && node.kind() === 244 /* EnumElement */) { + if (node && node.kind() === 209 /* EnumElement */) { consumeNode(node); return node; } if (!isPropertyName(currentToken(), inErrorRecovery)) { - return null; + return undefined; } - return new Parser.syntaxFactory.EnumElementSyntax(parseNodeData, eatPropertyName(), tryParseEnumElementEqualsValueClause()); + return new TypeScript.EnumElementSyntax(parseNodeData, eatPropertyName(), tryParseEnumElementEqualsValueClause()); } function isModifierKind(kind) { switch (kind) { - case 47 /* ExportKeyword */: - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 56 /* ProtectedKeyword */: - case 58 /* StaticKeyword */: - case 63 /* DeclareKeyword */: + case 49 /* ExportKeyword */: + case 59 /* PublicKeyword */: + case 57 /* PrivateKeyword */: + case 58 /* ProtectedKeyword */: + case 60 /* StaticKeyword */: + case 65 /* DeclareKeyword */: return true; } return false; @@ -23226,10 +23498,10 @@ var TypeScript; var nextToken = peekToken(index + 1); var nextTokenKind = nextToken.kind(); switch (nextTokenKind) { - case 11 /* IdentifierName */: - case 74 /* OpenBracketToken */: - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: + case 9 /* IdentifierName */: + case 76 /* OpenBracketToken */: + case 11 /* NumericLiteral */: + case 12 /* StringLiteral */: return true; default: return TypeScript.SyntaxFacts.isAnyKeyword(nextTokenKind); @@ -23254,39 +23526,37 @@ var TypeScript; } break; } - var result = TypeScript.Syntax.list(tokens); - returnZeroLengthArray(tokens); - return result; + return TypeScript.Syntax.list(tokens); } function parseHeritageClauses() { - var heritageClauses = TypeScript.Syntax.emptyList(); + var heritageClauses; if (isHeritageClause()) { - heritageClauses = parseSyntaxList(10 /* ClassOrInterfaceDeclaration_HeritageClauses */, null); + heritageClauses = parseSyntaxList(10 /* ClassOrInterfaceDeclaration_HeritageClauses */, undefined); } - return heritageClauses; + return heritageClauses || []; } function tryParseHeritageClauseTypeName() { - return isHeritageClauseTypeName() ? tryParseNameOrGenericType() : null; + return isHeritageClauseTypeName() ? tryParseNameOrGenericType() : undefined; } function parseClassDeclaration() { var modifiers = parseModifiers(); - var classKeyword = eatToken(44 /* ClassKeyword */); + var classKeyword = eatToken(46 /* ClassKeyword */); var identifier = eatIdentifierToken(); var typeParameterList = tryParseTypeParameterList(false); var heritageClauses = parseHeritageClauses(); - var openBraceToken = eatToken(70 /* OpenBraceToken */); - var classElements = TypeScript.Syntax.emptyList(); + var openBraceToken = eatToken(72 /* OpenBraceToken */); + var classElements; if (openBraceToken.fullWidth() > 0) { var skippedTokens = getArray(); classElements = parseSyntaxList(1 /* ClassDeclaration_ClassElements */, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } ; - return new Parser.syntaxFactory.ClassDeclarationSyntax(parseNodeData, modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, eatToken(71 /* CloseBraceToken */)); + return new TypeScript.ClassDeclarationSyntax(parseNodeData, modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements || [], eatToken(73 /* CloseBraceToken */)); } function isAccessor(modifierCount, inErrorRecovery) { var tokenKind = peekToken(modifierCount).kind(); - if (tokenKind !== 64 /* GetKeyword */ && tokenKind !== 68 /* SetKeyword */) { + if (tokenKind !== 66 /* GetKeyword */ && tokenKind !== 70 /* SetKeyword */) { return false; } return isPropertyName(peekToken(modifierCount + 1), inErrorRecovery); @@ -23295,10 +23565,10 @@ var TypeScript; var modifiers = parseModifiers(); var _currenToken = currentToken(); var tokenKind = _currenToken.kind(); - if (tokenKind === 64 /* GetKeyword */) { + if (tokenKind === 66 /* GetKeyword */) { return parseGetMemberAccessorDeclaration(modifiers, _currenToken, checkForStrictMode); } - else if (tokenKind === 68 /* SetKeyword */) { + else if (tokenKind === 70 /* SetKeyword */) { return parseSetMemberAccessorDeclaration(modifiers, _currenToken, checkForStrictMode); } else { @@ -23306,10 +23576,10 @@ var TypeScript; } } function parseGetMemberAccessorDeclaration(modifiers, getKeyword, checkForStrictMode) { - return new Parser.syntaxFactory.GetAccessorSyntax(parseNodeData, modifiers, consumeToken(getKeyword), eatPropertyName(), parseCallSignature(false), parseBlock(false, checkForStrictMode)); + return new TypeScript.GetAccessorSyntax(parseNodeData, modifiers, consumeToken(getKeyword), eatPropertyName(), parseCallSignature(false), parseBlock(false, checkForStrictMode)); } function parseSetMemberAccessorDeclaration(modifiers, setKeyword, checkForStrictMode) { - return new Parser.syntaxFactory.SetAccessorSyntax(parseNodeData, modifiers, consumeToken(setKeyword), eatPropertyName(), parseCallSignature(false), parseBlock(false, checkForStrictMode)); + return new TypeScript.SetAccessorSyntax(parseNodeData, modifiers, consumeToken(setKeyword), eatPropertyName(), parseCallSignature(false), parseBlock(false, checkForStrictMode)); } function isClassElement(inErrorRecovery) { if (TypeScript.SyntaxUtilities.isClassElement(currentNode())) { @@ -23341,25 +23611,25 @@ var TypeScript; return parseIndexMemberDeclaration(); } else { - return null; + return undefined; } } function isConstructorDeclaration(modifierCount) { - return peekToken(modifierCount).kind() === 62 /* ConstructorKeyword */; + return peekToken(modifierCount).kind() === 64 /* ConstructorKeyword */; } function parseConstructorDeclaration() { var modifiers = parseModifiers(); - var constructorKeyword = eatToken(62 /* ConstructorKeyword */); + var constructorKeyword = eatToken(64 /* ConstructorKeyword */); var callSignature = parseCallSignature(false); - var semicolonToken = null; - var block = null; + var semicolonToken = undefined; + var block = undefined; if (isBlock()) { block = parseBlock(false, true); } else { semicolonToken = eatExplicitOrAutomaticSemicolon(false); } - return new Parser.syntaxFactory.ConstructorDeclarationSyntax(parseNodeData, modifiers, constructorKeyword, callSignature, block, semicolonToken); + return new TypeScript.ConstructorDeclarationSyntax(parseNodeData, modifiers, constructorKeyword, callSignature, block, semicolonToken); } function isMemberFunctionDeclaration(modifierCount, inErrorRecovery) { return isPropertyName(peekToken(modifierCount), inErrorRecovery) && isCallSignature(modifierCount + 1); @@ -23369,25 +23639,25 @@ var TypeScript; var propertyName = eatPropertyName(); var callSignature = parseCallSignature(false); var parseBlockEvenWithNoOpenBrace = tryAddUnexpectedEqualsGreaterThanToken(callSignature); - var block = null; - var semicolon = null; + var block = undefined; + var semicolon = undefined; if (parseBlockEvenWithNoOpenBrace || isBlock()) { block = parseBlock(parseBlockEvenWithNoOpenBrace, true); } else { semicolon = eatExplicitOrAutomaticSemicolon(false); } - return new Parser.syntaxFactory.MemberFunctionDeclarationSyntax(parseNodeData, modifiers, propertyName, callSignature, block, semicolon); + return new TypeScript.MemberFunctionDeclarationSyntax(parseNodeData, modifiers, propertyName, callSignature, block, semicolon); } function isDefinitelyMemberVariablePropertyName(index) { if (TypeScript.SyntaxFacts.isAnyKeyword(peekToken(index).kind())) { var nextToken = peekToken(index + 1); switch (nextToken.kind()) { - case 78 /* SemicolonToken */: - case 107 /* EqualsToken */: - case 106 /* ColonToken */: - case 71 /* CloseBraceToken */: - case 10 /* EndOfFileToken */: + case 80 /* SemicolonToken */: + case 109 /* EqualsToken */: + case 108 /* ColonToken */: + case 73 /* CloseBraceToken */: + case 8 /* EndOfFileToken */: return true; default: return previousTokenHasTrailingNewLine(nextToken); @@ -23401,92 +23671,90 @@ var TypeScript; return isPropertyName(peekToken(modifierCount), inErrorRecover) && isDefinitelyMemberVariablePropertyName(modifierCount); } function parseMemberVariableDeclaration() { - return new Parser.syntaxFactory.MemberVariableDeclarationSyntax(parseNodeData, parseModifiers(), tryParseVariableDeclarator(true, true), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.MemberVariableDeclarationSyntax(parseNodeData, parseModifiers(), tryParseVariableDeclarator(true, true), eatExplicitOrAutomaticSemicolon(false)); } function isIndexMemberDeclaration(modifierCount) { return isIndexSignature(modifierCount); } function parseIndexMemberDeclaration() { - return new Parser.syntaxFactory.IndexMemberDeclarationSyntax(parseNodeData, parseModifiers(), parseIndexSignature(), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.IndexMemberDeclarationSyntax(parseNodeData, parseModifiers(), parseIndexSignature(), eatExplicitOrAutomaticSemicolon(false)); } function tryAddUnexpectedEqualsGreaterThanToken(callSignature) { var token0 = currentToken(); - var hasEqualsGreaterThanToken = token0.kind() === 85 /* EqualsGreaterThanToken */; + var hasEqualsGreaterThanToken = token0.kind() === 87 /* EqualsGreaterThanToken */; if (hasEqualsGreaterThanToken) { var _lastToken = TypeScript.lastToken(callSignature); if (_lastToken && _lastToken.fullWidth() > 0) { - var diagnostic = new TypeScript.Diagnostic(fileName, source.text.lineMap(), TypeScript.start(token0, source.text), TypeScript.width(token0), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(70 /* OpenBraceToken */)]); + var diagnostic = new TypeScript.Diagnostic(fileName, source.text.lineMap(), TypeScript.start(token0, source.text), TypeScript.width(token0), TypeScript.DiagnosticCode.Unexpected_token_0_expected, [TypeScript.SyntaxFacts.getText(72 /* OpenBraceToken */)]); addDiagnostic(diagnostic); consumeToken(token0); - if (Parser.syntaxFactory.isConcrete) { - addSkippedTokenAfterNode(callSignature, token0); - } + addSkippedTokenAfterNode(callSignature, token0); return true; } } return false; } function isFunctionDeclaration(modifierCount) { - return peekToken(modifierCount).kind() === 27 /* FunctionKeyword */; + return peekToken(modifierCount).kind() === 29 /* FunctionKeyword */; } function parseFunctionDeclaration() { var modifiers = parseModifiers(); - var functionKeyword = eatToken(27 /* FunctionKeyword */); + var functionKeyword = eatToken(29 /* FunctionKeyword */); var identifier = eatIdentifierToken(); var callSignature = parseCallSignature(false); var parseBlockEvenWithNoOpenBrace = tryAddUnexpectedEqualsGreaterThanToken(callSignature); - var semicolonToken = null; - var block = null; + var semicolonToken = undefined; + var block = undefined; if (parseBlockEvenWithNoOpenBrace || isBlock()) { block = parseBlock(parseBlockEvenWithNoOpenBrace, true); } else { semicolonToken = eatExplicitOrAutomaticSemicolon(false); } - return new Parser.syntaxFactory.FunctionDeclarationSyntax(parseNodeData, modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + return new TypeScript.FunctionDeclarationSyntax(parseNodeData, modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); } function parseModuleDeclaration() { var modifiers = parseModifiers(); - var moduleKeyword = eatToken(65 /* ModuleKeyword */); - var moduleName = null; - var stringLiteral = null; - if (currentToken().kind() === 14 /* StringLiteral */) { - stringLiteral = eatToken(14 /* StringLiteral */); + var moduleKeyword = eatToken(67 /* ModuleKeyword */); + var moduleName = undefined; + var stringLiteral = undefined; + if (currentToken().kind() === 12 /* StringLiteral */) { + stringLiteral = eatToken(12 /* StringLiteral */); } else { moduleName = parseName(false); } - var openBraceToken = eatToken(70 /* OpenBraceToken */); - var moduleElements = TypeScript.Syntax.emptyList(); + var openBraceToken = eatToken(72 /* OpenBraceToken */); + var moduleElements; if (openBraceToken.fullWidth() > 0) { var skippedTokens = getArray(); moduleElements = parseSyntaxList(2 /* ModuleDeclaration_ModuleElements */, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } - return new Parser.syntaxFactory.ModuleDeclarationSyntax(parseNodeData, modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, eatToken(71 /* CloseBraceToken */)); + return new TypeScript.ModuleDeclarationSyntax(parseNodeData, modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements || [], eatToken(73 /* CloseBraceToken */)); } function parseInterfaceDeclaration() { - return new Parser.syntaxFactory.InterfaceDeclarationSyntax(parseNodeData, parseModifiers(), eatToken(52 /* InterfaceKeyword */), eatIdentifierToken(), tryParseTypeParameterList(false), parseHeritageClauses(), parseObjectType()); + return new TypeScript.InterfaceDeclarationSyntax(parseNodeData, parseModifiers(), eatToken(54 /* InterfaceKeyword */), eatIdentifierToken(), tryParseTypeParameterList(false), parseHeritageClauses(), parseObjectType()); } function parseObjectType() { - var openBraceToken = eatToken(70 /* OpenBraceToken */); - var typeMembers = TypeScript.Syntax.emptySeparatedList(); + var openBraceToken = eatToken(72 /* OpenBraceToken */); + var typeMembers; if (openBraceToken.fullWidth() > 0) { var skippedTokens = getArray(); typeMembers = parseSeparatedSyntaxList(9 /* ObjectType_TypeMembers */, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } - return new Parser.syntaxFactory.ObjectTypeSyntax(parseNodeData, openBraceToken, typeMembers, eatToken(71 /* CloseBraceToken */)); + return new TypeScript.ObjectTypeSyntax(parseNodeData, openBraceToken, typeMembers || [], eatToken(73 /* CloseBraceToken */)); } function parseTupleType(currentToken) { var openBracket = consumeToken(currentToken); - var types = TypeScript.Syntax.emptySeparatedList(); + var types; if (openBracket.fullWidth() > 0) { var skippedTokens = getArray(); types = parseSeparatedSyntaxList(21 /* TupleType_Types */, skippedTokens); openBracket = addSkippedTokensAfterToken(openBracket, skippedTokens); } - return new Parser.syntaxFactory.TupleTypeSyntax(parseNodeData, openBracket, types, eatToken(75 /* CloseBracketToken */)); + return new TypeScript.TupleTypeSyntax(parseNodeData, openBracket, types || [], eatToken(77 /* CloseBracketToken */)); } function isTypeMember(inErrorRecovery) { if (TypeScript.SyntaxUtilities.isTypeMember(currentNode())) { @@ -23516,44 +23784,44 @@ var TypeScript; return parsePropertySignature(); } else { - return null; + return undefined; } } function parseConstructSignature() { - return new Parser.syntaxFactory.ConstructSignatureSyntax(parseNodeData, eatToken(31 /* NewKeyword */), parseCallSignature(false)); + return new TypeScript.ConstructSignatureSyntax(parseNodeData, eatToken(33 /* NewKeyword */), parseCallSignature(false)); } function parseIndexSignature() { - var openBracketToken = eatToken(74 /* OpenBracketToken */); + var openBracketToken = eatToken(76 /* OpenBracketToken */); var skippedTokens = getArray(); var parameters = parseSeparatedSyntaxList(18 /* IndexSignature_Parameters */, skippedTokens); openBracketToken = addSkippedTokensAfterToken(openBracketToken, skippedTokens); - return new Parser.syntaxFactory.IndexSignatureSyntax(parseNodeData, openBracketToken, parameters, eatToken(75 /* CloseBracketToken */), parseOptionalTypeAnnotation(false)); + return new TypeScript.IndexSignatureSyntax(parseNodeData, openBracketToken, parameters, eatToken(77 /* CloseBracketToken */), parseOptionalTypeAnnotation(false)); } function parseMethodSignature() { - return new Parser.syntaxFactory.MethodSignatureSyntax(parseNodeData, eatPropertyName(), tryEatToken(105 /* QuestionToken */), parseCallSignature(false)); + return new TypeScript.MethodSignatureSyntax(parseNodeData, eatPropertyName(), tryEatToken(107 /* QuestionToken */), parseCallSignature(false)); } function parsePropertySignature() { - return new Parser.syntaxFactory.PropertySignatureSyntax(parseNodeData, eatPropertyName(), tryEatToken(105 /* QuestionToken */), parseOptionalTypeAnnotation(false)); + return new TypeScript.PropertySignatureSyntax(parseNodeData, eatPropertyName(), tryEatToken(107 /* QuestionToken */), parseOptionalTypeAnnotation(false)); } function isCallSignature(peekIndex) { var tokenKind = peekToken(peekIndex).kind(); - return tokenKind === 72 /* OpenParenToken */ || tokenKind === 80 /* LessThanToken */; + return tokenKind === 74 /* OpenParenToken */ || tokenKind === 82 /* LessThanToken */; } function isConstructSignature() { - if (currentToken().kind() !== 31 /* NewKeyword */) { + if (currentToken().kind() !== 33 /* NewKeyword */) { return false; } return isCallSignature(1); } function isIndexSignature(peekIndex) { - return peekToken(peekIndex).kind() === 74 /* OpenBracketToken */; + return peekToken(peekIndex).kind() === 76 /* OpenBracketToken */; } function isMethodSignature(inErrorRecovery) { if (isPropertyName(currentToken(), inErrorRecovery)) { if (isCallSignature(1)) { return true; } - if (peekToken(1).kind() === 105 /* QuestionToken */ && isCallSignature(2)) { + if (peekToken(1).kind() === 107 /* QuestionToken */ && isCallSignature(2)) { return true; } } @@ -23570,11 +23838,11 @@ var TypeScript; } function isHeritageClause() { var tokenKind = currentToken().kind(); - return tokenKind === 48 /* ExtendsKeyword */ || tokenKind === 51 /* ImplementsKeyword */; + return tokenKind === 50 /* ExtendsKeyword */ || tokenKind === 53 /* ImplementsKeyword */; } function isNotHeritageClauseTypeName() { var tokenKind = currentToken().kind(); - if (tokenKind === 51 /* ImplementsKeyword */ || tokenKind === 48 /* ExtendsKeyword */) { + if (tokenKind === 53 /* ImplementsKeyword */ || tokenKind === 50 /* ExtendsKeyword */) { return isIdentifier(peekToken(1)); } return false; @@ -23588,47 +23856,38 @@ var TypeScript; function tryParseHeritageClause() { var extendsOrImplementsKeyword = currentToken(); var tokenKind = extendsOrImplementsKeyword.kind(); - if (tokenKind !== 48 /* ExtendsKeyword */ && tokenKind !== 51 /* ImplementsKeyword */) { - return null; + if (tokenKind !== 50 /* ExtendsKeyword */ && tokenKind !== 53 /* ImplementsKeyword */) { + return undefined; } consumeToken(extendsOrImplementsKeyword); var skippedTokens = getArray(); var typeNames = parseSeparatedSyntaxList(11 /* HeritageClause_TypeNameList */, skippedTokens); extendsOrImplementsKeyword = addSkippedTokensAfterToken(extendsOrImplementsKeyword, skippedTokens); - return new Parser.syntaxFactory.HeritageClauseSyntax(parseNodeData, extendsOrImplementsKeyword, typeNames); + return new TypeScript.HeritageClauseSyntax(parseNodeData, extendsOrImplementsKeyword, typeNames); } - function isInterfaceEnumClassModuleImportOrExport(modifierCount) { - var _currentToken = currentToken(); + function isInterfaceEnumClassModuleImportOrExport(modifierCount, _currentToken) { if (modifierCount) { switch (peekToken(modifierCount).kind()) { - case 49 /* ImportKeyword */: - case 65 /* ModuleKeyword */: - case 52 /* InterfaceKeyword */: - case 44 /* ClassKeyword */: - case 46 /* EnumKeyword */: + case 51 /* ImportKeyword */: + case 67 /* ModuleKeyword */: + case 54 /* InterfaceKeyword */: + case 46 /* ClassKeyword */: + case 48 /* EnumKeyword */: return true; } } + _currentToken = _currentToken || currentToken(); var nextToken = peekToken(1); switch (_currentToken.kind()) { - case 65 /* ModuleKeyword */: - if (isIdentifier(nextToken) || nextToken.kind() === 14 /* StringLiteral */) { - return true; - } - break; - case 49 /* ImportKeyword */: - case 44 /* ClassKeyword */: - case 46 /* EnumKeyword */: - case 52 /* InterfaceKeyword */: - if (isIdentifier(nextToken)) { - return true; - } - break; - case 47 /* ExportKeyword */: - if (nextToken.kind() === 107 /* EqualsToken */) { - return true; - } - break; + case 67 /* ModuleKeyword */: + return isIdentifier(nextToken) || nextToken.kind() === 12 /* StringLiteral */; + case 51 /* ImportKeyword */: + case 46 /* ClassKeyword */: + case 48 /* EnumKeyword */: + case 54 /* InterfaceKeyword */: + return isIdentifier(nextToken); + case 49 /* ExportKeyword */: + return nextToken.kind() === 109 /* EqualsToken */; } return false; } @@ -23639,31 +23898,31 @@ var TypeScript; var _currentToken = currentToken(); var currentTokenKind = _currentToken.kind(); switch (currentTokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 56 /* ProtectedKeyword */: - case 58 /* StaticKeyword */: + case 59 /* PublicKeyword */: + case 57 /* PrivateKeyword */: + case 58 /* ProtectedKeyword */: + case 60 /* StaticKeyword */: var token1 = peekToken(1); if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token1)) { return false; } break; - case 28 /* IfKeyword */: - case 70 /* OpenBraceToken */: - case 33 /* ReturnKeyword */: - case 34 /* SwitchKeyword */: - case 36 /* ThrowKeyword */: - case 15 /* BreakKeyword */: - case 18 /* ContinueKeyword */: - case 26 /* ForKeyword */: - case 42 /* WhileKeyword */: - case 43 /* WithKeyword */: - case 22 /* DoKeyword */: - case 38 /* TryKeyword */: - case 19 /* DebuggerKeyword */: + case 30 /* IfKeyword */: + case 72 /* OpenBraceToken */: + case 35 /* ReturnKeyword */: + case 36 /* SwitchKeyword */: + case 38 /* ThrowKeyword */: + case 17 /* BreakKeyword */: + case 20 /* ContinueKeyword */: + case 28 /* ForKeyword */: + case 44 /* WhileKeyword */: + case 45 /* WithKeyword */: + case 24 /* DoKeyword */: + case 40 /* TryKeyword */: + case 21 /* DebuggerKeyword */: return true; } - if (isInterfaceEnumClassModuleImportOrExport(modifierCount)) { + if (isInterfaceEnumClassModuleImportOrExport(modifierCount, _currentToken)) { return false; } return isLabeledStatement(_currentToken) || isVariableStatement(modifierCount) || isFunctionDeclaration(modifierCount) || isEmptyStatement(_currentToken, inErrorRecovery) || isExpressionStatement(_currentToken); @@ -23683,45 +23942,32 @@ var TypeScript; } function tryParseStatementWorker(_currentToken, currentTokenKind, modifierCount, inErrorRecovery) { switch (currentTokenKind) { - case 57 /* PublicKeyword */: - case 55 /* PrivateKeyword */: - case 56 /* ProtectedKeyword */: - case 58 /* StaticKeyword */: + case 59 /* PublicKeyword */: + case 57 /* PrivateKeyword */: + case 58 /* ProtectedKeyword */: + case 60 /* StaticKeyword */: if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(peekToken(1))) { - return null; + return undefined; } else { break; } - case 28 /* IfKeyword */: - return parseIfStatement(_currentToken); - case 70 /* OpenBraceToken */: - return parseBlock(false, false); - case 33 /* ReturnKeyword */: - return parseReturnStatement(_currentToken); - case 34 /* SwitchKeyword */: - return parseSwitchStatement(_currentToken); - case 36 /* ThrowKeyword */: - return parseThrowStatement(_currentToken); - case 15 /* BreakKeyword */: - return parseBreakStatement(_currentToken); - case 18 /* ContinueKeyword */: - return parseContinueStatement(_currentToken); - case 26 /* ForKeyword */: - return parseForOrForInStatement(_currentToken); - case 42 /* WhileKeyword */: - return parseWhileStatement(_currentToken); - case 43 /* WithKeyword */: - return parseWithStatement(_currentToken); - case 22 /* DoKeyword */: - return parseDoStatement(_currentToken); - case 38 /* TryKeyword */: - return parseTryStatement(_currentToken); - case 19 /* DebuggerKeyword */: - return parseDebuggerStatement(_currentToken); + case 30 /* IfKeyword */: return parseIfStatement(_currentToken); + case 72 /* OpenBraceToken */: return parseBlock(false, false); + case 35 /* ReturnKeyword */: return parseReturnStatement(_currentToken); + case 36 /* SwitchKeyword */: return parseSwitchStatement(_currentToken); + case 38 /* ThrowKeyword */: return parseThrowStatement(_currentToken); + case 17 /* BreakKeyword */: return parseBreakStatement(_currentToken); + case 20 /* ContinueKeyword */: return parseContinueStatement(_currentToken); + case 28 /* ForKeyword */: return parseForOrForInStatement(_currentToken); + case 44 /* WhileKeyword */: return parseWhileStatement(_currentToken); + case 45 /* WithKeyword */: return parseWithStatement(_currentToken); + case 24 /* DoKeyword */: return parseDoStatement(_currentToken); + case 40 /* TryKeyword */: return parseTryStatement(_currentToken); + case 21 /* DebuggerKeyword */: return parseDebuggerStatement(_currentToken); } - if (isInterfaceEnumClassModuleImportOrExport(modifierCount)) { - return null; + if (isInterfaceEnumClassModuleImportOrExport(modifierCount, _currentToken)) { + return undefined; } else if (isVariableStatement(modifierCount)) { return parseVariableStatement(); @@ -23739,20 +23985,20 @@ var TypeScript; return parseExpressionStatement(); } else { - return null; + return undefined; } } function parseDebuggerStatement(debuggerKeyword) { - return new Parser.syntaxFactory.DebuggerStatementSyntax(parseNodeData, consumeToken(debuggerKeyword), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.DebuggerStatementSyntax(parseNodeData, consumeToken(debuggerKeyword), eatExplicitOrAutomaticSemicolon(false)); } function parseDoStatement(doKeyword) { - return new Parser.syntaxFactory.DoStatementSyntax(parseNodeData, consumeToken(doKeyword), parseStatement(false), eatToken(42 /* WhileKeyword */), eatToken(72 /* OpenParenToken */), parseExpression(true), eatToken(73 /* CloseParenToken */), eatExplicitOrAutomaticSemicolon(true)); + return new TypeScript.DoStatementSyntax(parseNodeData, consumeToken(doKeyword), parseStatement(false), eatToken(44 /* WhileKeyword */), eatToken(74 /* OpenParenToken */), parseExpression(true), eatToken(75 /* CloseParenToken */), eatExplicitOrAutomaticSemicolon(true)); } function isLabeledStatement(currentToken) { - return isIdentifier(currentToken) && peekToken(1).kind() === 106 /* ColonToken */; + return isIdentifier(currentToken) && peekToken(1).kind() === 108 /* ColonToken */; } function parseLabeledStatement(identifierToken) { - return new Parser.syntaxFactory.LabeledStatementSyntax(parseNodeData, consumeToken(identifierToken), eatToken(106 /* ColonToken */), parseStatement(false)); + return new TypeScript.LabeledStatementSyntax(parseNodeData, consumeToken(identifierToken), eatToken(108 /* ColonToken */), parseStatement(false)); } function parseTryStatement(tryKeyword) { var tryKeyword = consumeToken(tryKeyword); @@ -23760,15 +24006,15 @@ var TypeScript; listParsingState |= (1 << 6 /* TryBlock_Statements */); var block = parseBlock(false, false); listParsingState = savedListParsingState; - var catchClause = null; - if (currentToken().kind() === 17 /* CatchKeyword */) { + var catchClause = undefined; + if (currentToken().kind() === 19 /* CatchKeyword */) { catchClause = parseCatchClause(); } - var finallyClause = null; - if (catchClause === null || currentToken().kind() === 25 /* FinallyKeyword */) { + var finallyClause = undefined; + if (!catchClause || currentToken().kind() === 27 /* FinallyKeyword */) { finallyClause = parseFinallyClause(); } - return new Parser.syntaxFactory.TryStatementSyntax(parseNodeData, tryKeyword, block, catchClause, finallyClause); + return new TypeScript.TryStatementSyntax(parseNodeData, tryKeyword, block, catchClause, finallyClause); } function parseCatchClauseBlock() { var savedListParsingState = listParsingState; @@ -23778,35 +24024,35 @@ var TypeScript; return block; } function parseCatchClause() { - return new Parser.syntaxFactory.CatchClauseSyntax(parseNodeData, eatToken(17 /* CatchKeyword */), eatToken(72 /* OpenParenToken */), eatIdentifierToken(), parseOptionalTypeAnnotation(false), eatToken(73 /* CloseParenToken */), parseCatchClauseBlock()); + return new TypeScript.CatchClauseSyntax(parseNodeData, eatToken(19 /* CatchKeyword */), eatToken(74 /* OpenParenToken */), eatIdentifierToken(), parseOptionalTypeAnnotation(false), eatToken(75 /* CloseParenToken */), parseCatchClauseBlock()); } function parseFinallyClause() { - return new Parser.syntaxFactory.FinallyClauseSyntax(parseNodeData, eatToken(25 /* FinallyKeyword */), parseBlock(false, false)); + return new TypeScript.FinallyClauseSyntax(parseNodeData, eatToken(27 /* FinallyKeyword */), parseBlock(false, false)); } function parseWithStatement(withKeyword) { - return new Parser.syntaxFactory.WithStatementSyntax(parseNodeData, consumeToken(withKeyword), eatToken(72 /* OpenParenToken */), parseExpression(true), eatToken(73 /* CloseParenToken */), parseStatement(false)); + return new TypeScript.WithStatementSyntax(parseNodeData, consumeToken(withKeyword), eatToken(74 /* OpenParenToken */), parseExpression(true), eatToken(75 /* CloseParenToken */), parseStatement(false)); } function parseWhileStatement(whileKeyword) { - return new Parser.syntaxFactory.WhileStatementSyntax(parseNodeData, consumeToken(whileKeyword), eatToken(72 /* OpenParenToken */), parseExpression(true), eatToken(73 /* CloseParenToken */), parseStatement(false)); + return new TypeScript.WhileStatementSyntax(parseNodeData, consumeToken(whileKeyword), eatToken(74 /* OpenParenToken */), parseExpression(true), eatToken(75 /* CloseParenToken */), parseStatement(false)); } function isEmptyStatement(currentToken, inErrorRecovery) { if (inErrorRecovery) { return false; } - return currentToken.kind() === 78 /* SemicolonToken */; + return currentToken.kind() === 80 /* SemicolonToken */; } function parseEmptyStatement(semicolonToken) { - return new Parser.syntaxFactory.EmptyStatementSyntax(parseNodeData, consumeToken(semicolonToken)); + return new TypeScript.EmptyStatementSyntax(parseNodeData, consumeToken(semicolonToken)); } function parseForOrForInStatement(forKeyword) { consumeToken(forKeyword); - var openParenToken = eatToken(72 /* OpenParenToken */); + var openParenToken = eatToken(74 /* OpenParenToken */); var _currentToken = currentToken(); var tokenKind = _currentToken.kind(); - if (tokenKind === 40 /* VarKeyword */) { + if (tokenKind === 42 /* VarKeyword */) { return parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken); } - else if (tokenKind === 78 /* SemicolonToken */) { + else if (tokenKind === 80 /* SemicolonToken */) { return parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken); } else { @@ -23815,70 +24061,70 @@ var TypeScript; } function parseForOrForInStatementWithVariableDeclaration(forKeyword, openParenToken) { var variableDeclaration = parseVariableDeclaration(false); - return currentToken().kind() === 29 /* InKeyword */ ? parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null) : parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, null); + return currentToken().kind() === 31 /* InKeyword */ ? parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, undefined) : parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, undefined); } function parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, initializer) { - return new Parser.syntaxFactory.ForInStatementSyntax(parseNodeData, forKeyword, openParenToken, variableDeclaration, initializer, eatToken(29 /* InKeyword */), parseExpression(true), eatToken(73 /* CloseParenToken */), parseStatement(false)); + return new TypeScript.ForInStatementSyntax(parseNodeData, forKeyword, openParenToken, variableDeclaration, initializer, eatToken(31 /* InKeyword */), parseExpression(true), eatToken(75 /* CloseParenToken */), parseStatement(false)); } function parseForOrForInStatementWithInitializer(forKeyword, openParenToken) { var initializer = parseExpression(false); - return currentToken().kind() === 29 /* InKeyword */ ? parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer) : parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, initializer); + return currentToken().kind() === 31 /* InKeyword */ ? parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, undefined, initializer) : parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, undefined, initializer); } function parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword, openParenToken) { - return parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, null, null); + return parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, undefined, undefined); } function tryParseForStatementCondition() { var tokenKind = currentToken().kind(); - if (tokenKind !== 78 /* SemicolonToken */ && tokenKind !== 73 /* CloseParenToken */ && tokenKind !== 10 /* EndOfFileToken */) { + if (tokenKind !== 80 /* SemicolonToken */ && tokenKind !== 75 /* CloseParenToken */ && tokenKind !== 8 /* EndOfFileToken */) { return parseExpression(true); } - return null; + return undefined; } function tryParseForStatementIncrementor() { var tokenKind = currentToken().kind(); - if (tokenKind !== 73 /* CloseParenToken */ && tokenKind !== 10 /* EndOfFileToken */) { + if (tokenKind !== 75 /* CloseParenToken */ && tokenKind !== 8 /* EndOfFileToken */) { return parseExpression(true); } - return null; + return undefined; } function parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, initializer) { - return new Parser.syntaxFactory.ForStatementSyntax(parseNodeData, forKeyword, openParenToken, variableDeclaration, initializer, eatToken(78 /* SemicolonToken */), tryParseForStatementCondition(), eatToken(78 /* SemicolonToken */), tryParseForStatementIncrementor(), eatToken(73 /* CloseParenToken */), parseStatement(false)); + return new TypeScript.ForStatementSyntax(parseNodeData, forKeyword, openParenToken, variableDeclaration, initializer, eatToken(80 /* SemicolonToken */), tryParseForStatementCondition(), eatToken(80 /* SemicolonToken */), tryParseForStatementIncrementor(), eatToken(75 /* CloseParenToken */), parseStatement(false)); } function tryEatBreakOrContinueLabel() { - var identifier = null; + var identifier = undefined; if (!canEatExplicitOrAutomaticSemicolon(false)) { if (isIdentifier(currentToken())) { return eatIdentifierToken(); } } - return null; + return undefined; } function parseBreakStatement(breakKeyword) { - return new Parser.syntaxFactory.BreakStatementSyntax(parseNodeData, consumeToken(breakKeyword), tryEatBreakOrContinueLabel(), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.BreakStatementSyntax(parseNodeData, consumeToken(breakKeyword), tryEatBreakOrContinueLabel(), eatExplicitOrAutomaticSemicolon(false)); } function parseContinueStatement(continueKeyword) { - return new Parser.syntaxFactory.ContinueStatementSyntax(parseNodeData, consumeToken(continueKeyword), tryEatBreakOrContinueLabel(), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.ContinueStatementSyntax(parseNodeData, consumeToken(continueKeyword), tryEatBreakOrContinueLabel(), eatExplicitOrAutomaticSemicolon(false)); } function parseSwitchStatement(switchKeyword) { consumeToken(switchKeyword); - var openParenToken = eatToken(72 /* OpenParenToken */); + var openParenToken = eatToken(74 /* OpenParenToken */); var expression = parseExpression(true); - var closeParenToken = eatToken(73 /* CloseParenToken */); - var openBraceToken = eatToken(70 /* OpenBraceToken */); - var switchClauses = TypeScript.Syntax.emptyList(); + var closeParenToken = eatToken(75 /* CloseParenToken */); + var openBraceToken = eatToken(72 /* OpenBraceToken */); + var switchClauses; if (openBraceToken.fullWidth() > 0) { var skippedTokens = getArray(); switchClauses = parseSyntaxList(3 /* SwitchStatement_SwitchClauses */, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } - return new Parser.syntaxFactory.SwitchStatementSyntax(parseNodeData, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, eatToken(71 /* CloseBraceToken */)); + return new TypeScript.SwitchStatementSyntax(parseNodeData, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses || [], eatToken(73 /* CloseBraceToken */)); } function isSwitchClause() { if (TypeScript.SyntaxUtilities.isSwitchClause(currentNode())) { return true; } var currentTokenKind = currentToken().kind(); - return currentTokenKind === 16 /* CaseKeyword */ || currentTokenKind === 20 /* DefaultKeyword */; + return currentTokenKind === 18 /* CaseKeyword */ || currentTokenKind === 22 /* DefaultKeyword */; } function tryParseSwitchClause() { var node = currentNode(); @@ -23888,136 +24134,138 @@ var TypeScript; } var _currentToken = currentToken(); var kind = _currentToken.kind(); - if (kind === 16 /* CaseKeyword */) { + if (kind === 18 /* CaseKeyword */) { return parseCaseSwitchClause(_currentToken); } - else if (kind === 20 /* DefaultKeyword */) { + else if (kind === 22 /* DefaultKeyword */) { return parseDefaultSwitchClause(_currentToken); } else { - return null; + return undefined; } } function parseCaseSwitchClause(caseKeyword) { consumeToken(caseKeyword); var expression = parseExpression(true); - var colonToken = eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList(); + var colonToken = eatToken(108 /* ColonToken */); + var statements; if (colonToken.fullWidth() > 0) { var skippedTokens = getArray(); statements = parseSyntaxList(4 /* SwitchClause_Statements */, skippedTokens); colonToken = addSkippedTokensAfterToken(colonToken, skippedTokens); } - return new Parser.syntaxFactory.CaseSwitchClauseSyntax(parseNodeData, caseKeyword, expression, colonToken, statements); + return new TypeScript.CaseSwitchClauseSyntax(parseNodeData, caseKeyword, expression, colonToken, statements || []); } function parseDefaultSwitchClause(defaultKeyword) { consumeToken(defaultKeyword); - var colonToken = eatToken(106 /* ColonToken */); - var statements = TypeScript.Syntax.emptyList(); + var colonToken = eatToken(108 /* ColonToken */); + var statements; if (colonToken.fullWidth() > 0) { var skippedTokens = getArray(); statements = parseSyntaxList(4 /* SwitchClause_Statements */, skippedTokens); colonToken = addSkippedTokensAfterToken(colonToken, skippedTokens); } - return new Parser.syntaxFactory.DefaultSwitchClauseSyntax(parseNodeData, defaultKeyword, colonToken, statements); + return new TypeScript.DefaultSwitchClauseSyntax(parseNodeData, defaultKeyword, colonToken, statements || []); } function parseThrowStatementExpression() { - return canEatExplicitOrAutomaticSemicolon(false) ? createMissingToken(11 /* IdentifierName */, null) : parseExpression(true); + return canEatExplicitOrAutomaticSemicolon(false) ? createMissingToken(9 /* IdentifierName */, undefined) : parseExpression(true); } function parseThrowStatement(throwKeyword) { - return new Parser.syntaxFactory.ThrowStatementSyntax(parseNodeData, consumeToken(throwKeyword), parseThrowStatementExpression(), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.ThrowStatementSyntax(parseNodeData, consumeToken(throwKeyword), parseThrowStatementExpression(), eatExplicitOrAutomaticSemicolon(false)); } function tryParseReturnStatementExpression() { - return !canEatExplicitOrAutomaticSemicolon(false) ? parseExpression(true) : null; + return !canEatExplicitOrAutomaticSemicolon(false) ? parseExpression(true) : undefined; } function parseReturnStatement(returnKeyword) { - return new Parser.syntaxFactory.ReturnStatementSyntax(parseNodeData, consumeToken(returnKeyword), tryParseReturnStatementExpression(), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.ReturnStatementSyntax(parseNodeData, consumeToken(returnKeyword), tryParseReturnStatementExpression(), eatExplicitOrAutomaticSemicolon(false)); } function isExpressionStatement(currentToken) { var tokenKind = currentToken.kind(); - return tokenKind !== 70 /* OpenBraceToken */ && tokenKind !== 27 /* FunctionKeyword */ && isExpression(currentToken); + return tokenKind !== 72 /* OpenBraceToken */ && tokenKind !== 29 /* FunctionKeyword */ && isExpression(currentToken); } function isAssignmentOrOmittedExpression() { var _currentToken = currentToken(); - return _currentToken.kind() === 79 /* CommaToken */ || isExpression(_currentToken); + return _currentToken.kind() === 81 /* CommaToken */ || isExpression(_currentToken); } function tryParseAssignmentOrOmittedExpression() { - if (currentToken().kind() === 79 /* CommaToken */) { - return new Parser.syntaxFactory.OmittedExpressionSyntax(parseNodeData); + if (currentToken().kind() === 81 /* CommaToken */) { + return new TypeScript.OmittedExpressionSyntax(parseNodeData); } return tryParseAssignmentExpressionOrHigher(false, true); } function isExpression(currentToken) { switch (currentToken.kind()) { - case 13 /* NumericLiteral */: - case 14 /* StringLiteral */: - case 12 /* RegularExpressionLiteral */: - case 74 /* OpenBracketToken */: - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - case 89 /* PlusToken */: - case 90 /* MinusToken */: - case 102 /* TildeToken */: - case 101 /* ExclamationToken */: - case 70 /* OpenBraceToken */: - case 85 /* EqualsGreaterThanToken */: - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: - case 50 /* SuperKeyword */: - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 31 /* NewKeyword */: - case 21 /* DeleteKeyword */: - case 41 /* VoidKeyword */: - case 39 /* TypeOfKeyword */: - case 27 /* FunctionKeyword */: + case 11 /* NumericLiteral */: + case 12 /* StringLiteral */: + case 10 /* RegularExpressionLiteral */: + case 13 /* NoSubstitutionTemplateToken */: + case 14 /* TemplateStartToken */: + case 76 /* OpenBracketToken */: + case 74 /* OpenParenToken */: + case 82 /* LessThanToken */: + case 95 /* PlusPlusToken */: + case 96 /* MinusMinusToken */: + case 91 /* PlusToken */: + case 92 /* MinusToken */: + case 104 /* TildeToken */: + case 103 /* ExclamationToken */: + case 72 /* OpenBraceToken */: + case 87 /* EqualsGreaterThanToken */: + case 120 /* SlashToken */: + case 121 /* SlashEqualsToken */: + case 52 /* SuperKeyword */: + case 37 /* ThisKeyword */: + case 39 /* TrueKeyword */: + case 26 /* FalseKeyword */: + case 34 /* NullKeyword */: + case 33 /* NewKeyword */: + case 23 /* DeleteKeyword */: + case 43 /* VoidKeyword */: + case 41 /* TypeOfKeyword */: + case 29 /* FunctionKeyword */: return true; } return isIdentifier(currentToken); } function parseExpressionStatement() { - return new Parser.syntaxFactory.ExpressionStatementSyntax(parseNodeData, parseExpression(true), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.ExpressionStatementSyntax(parseNodeData, parseExpression(true), eatExplicitOrAutomaticSemicolon(false)); } function parseIfStatement(ifKeyword) { - return new Parser.syntaxFactory.IfStatementSyntax(parseNodeData, consumeToken(ifKeyword), eatToken(72 /* OpenParenToken */), parseExpression(true), eatToken(73 /* CloseParenToken */), parseStatement(false), parseOptionalElseClause()); + return new TypeScript.IfStatementSyntax(parseNodeData, consumeToken(ifKeyword), eatToken(74 /* OpenParenToken */), parseExpression(true), eatToken(75 /* CloseParenToken */), parseStatement(false), parseOptionalElseClause()); } function parseOptionalElseClause() { - return currentToken().kind() === 23 /* ElseKeyword */ ? parseElseClause() : null; + return currentToken().kind() === 25 /* ElseKeyword */ ? parseElseClause() : undefined; } function parseElseClause() { - return new Parser.syntaxFactory.ElseClauseSyntax(parseNodeData, eatToken(23 /* ElseKeyword */), parseStatement(false)); + return new TypeScript.ElseClauseSyntax(parseNodeData, eatToken(25 /* ElseKeyword */), parseStatement(false)); } function isVariableStatement(modifierCount) { - return peekToken(modifierCount).kind() === 40 /* VarKeyword */; + return peekToken(modifierCount).kind() === 42 /* VarKeyword */; } function parseVariableStatement() { - return new Parser.syntaxFactory.VariableStatementSyntax(parseNodeData, parseModifiers(), parseVariableDeclaration(true), eatExplicitOrAutomaticSemicolon(false)); + return new TypeScript.VariableStatementSyntax(parseNodeData, parseModifiers(), parseVariableDeclaration(true), eatExplicitOrAutomaticSemicolon(false)); } function parseVariableDeclaration(allowIn) { - var varKeyword = eatToken(40 /* VarKeyword */); + var varKeyword = eatToken(42 /* VarKeyword */); var listParsingState = allowIn ? 12 /* VariableDeclaration_VariableDeclarators_AllowIn */ : 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */; var skippedTokens = getArray(); var variableDeclarators = parseSeparatedSyntaxList(listParsingState, skippedTokens); varKeyword = addSkippedTokensAfterToken(varKeyword, skippedTokens); - return new Parser.syntaxFactory.VariableDeclarationSyntax(parseNodeData, varKeyword, variableDeclarators); + return new TypeScript.VariableDeclarationSyntax(parseNodeData, varKeyword, variableDeclarators); } function isVariableDeclarator() { var node = currentNode(); - if (node !== null && node.kind() === 226 /* VariableDeclarator */) { + if (node && node.kind() === 191 /* VariableDeclarator */) { return true; } return isIdentifier(currentToken()); } function canReuseVariableDeclaratorNode(node) { - if (node === null || node.kind() !== 226 /* VariableDeclarator */) { + if (!node || node.kind() !== 191 /* VariableDeclarator */) { return false; } var variableDeclarator = node; - return variableDeclarator.equalsValueClause === null; + return variableDeclarator.equalsValueClause === undefined; } function tryParseVariableDeclarator(allowIn, allowPropertyName) { var node = currentNode(); @@ -24028,30 +24276,30 @@ var TypeScript; if (allowPropertyName) { } if (!allowPropertyName && !isIdentifier(currentToken())) { - return null; + return undefined; } var propertyName = allowPropertyName ? eatPropertyName() : eatIdentifierToken(); - var equalsValueClause = null; - var typeAnnotation = null; + var equalsValueClause = undefined; + var typeAnnotation = undefined; if (propertyName.fullWidth() > 0) { typeAnnotation = parseOptionalTypeAnnotation(false); if (isEqualsValueClause(false)) { equalsValueClause = parseEqualsValueClause(allowIn); } } - return new Parser.syntaxFactory.VariableDeclaratorSyntax(parseNodeData, propertyName, typeAnnotation, equalsValueClause); + return new TypeScript.VariableDeclaratorSyntax(parseNodeData, propertyName, typeAnnotation, equalsValueClause); } function isEqualsValueClause(inParameter) { var token0 = currentToken(); - if (token0.kind() === 107 /* EqualsToken */) { + if (token0.kind() === 109 /* EqualsToken */) { return true; } if (!previousTokenHasTrailingNewLine(token0)) { var tokenKind = token0.kind(); - if (tokenKind === 85 /* EqualsGreaterThanToken */) { + if (tokenKind === 87 /* EqualsGreaterThanToken */) { return false; } - if (tokenKind === 70 /* OpenBraceToken */ && inParameter) { + if (tokenKind === 72 /* OpenBraceToken */ && inParameter) { return false; } return isExpression(token0); @@ -24059,33 +24307,33 @@ var TypeScript; return false; } function parseEqualsValueClause(allowIn) { - return new Parser.syntaxFactory.EqualsValueClauseSyntax(parseNodeData, eatToken(107 /* EqualsToken */), tryParseAssignmentExpressionOrHigher(true, allowIn)); + return new TypeScript.EqualsValueClauseSyntax(parseNodeData, eatToken(109 /* EqualsToken */), tryParseAssignmentExpressionOrHigher(true, allowIn)); } function parseExpression(allowIn) { var leftOperand = tryParseAssignmentExpressionOrHigher(true, allowIn); while (true) { var _currentToken = currentToken(); - if (_currentToken.kind() !== 79 /* CommaToken */) { + if (_currentToken.kind() !== 81 /* CommaToken */) { break; } - leftOperand = new Parser.syntaxFactory.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(_currentToken), tryParseAssignmentExpressionOrHigher(true, allowIn)); + leftOperand = new TypeScript.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(_currentToken), tryParseAssignmentExpressionOrHigher(true, allowIn)); } return leftOperand; } function tryParseAssignmentExpressionOrHigher(force, allowIn) { var _currentToken = currentToken(); var arrowFunction = tryParseAnyArrowFunctionExpression(_currentToken); - if (arrowFunction !== null) { + if (arrowFunction) { return arrowFunction; } var leftOperand = tryParseBinaryExpressionOrHigher(_currentToken, force, 1 /* Lowest */, allowIn); - if (leftOperand === null) { - return null; + if (leftOperand === undefined) { + return undefined; } if (TypeScript.SyntaxUtilities.isLeftHandSizeExpression(leftOperand)) { var operatorToken = currentOperatorToken(); if (TypeScript.SyntaxFacts.isAssignmentOperatorToken(operatorToken.kind())) { - return new Parser.syntaxFactory.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), tryParseAssignmentExpressionOrHigher(true, allowIn)); + return new TypeScript.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), tryParseAssignmentExpressionOrHigher(true, allowIn)); } } return parseConditionalExpressionRest(allowIn, leftOperand); @@ -24096,68 +24344,64 @@ var TypeScript; function tryParseUnaryExpressionOrHigher(_currentToken, force) { var currentTokenKind = _currentToken.kind(); switch (currentTokenKind) { - case 89 /* PlusToken */: - case 90 /* MinusToken */: - case 102 /* TildeToken */: - case 101 /* ExclamationToken */: - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: - return new Parser.syntaxFactory.PrefixUnaryExpressionSyntax(parseNodeData, consumeToken(_currentToken), tryParseUnaryExpressionOrHigher(currentToken(), true)); - case 39 /* TypeOfKeyword */: - return parseTypeOfExpression(_currentToken); - case 41 /* VoidKeyword */: - return parseVoidExpression(_currentToken); - case 21 /* DeleteKeyword */: - return parseDeleteExpression(_currentToken); - case 80 /* LessThanToken */: - return parseCastExpression(_currentToken); + case 91 /* PlusToken */: + case 92 /* MinusToken */: + case 104 /* TildeToken */: + case 103 /* ExclamationToken */: + case 95 /* PlusPlusToken */: + case 96 /* MinusMinusToken */: + return new TypeScript.PrefixUnaryExpressionSyntax(parseNodeData, consumeToken(_currentToken), tryParseUnaryExpressionOrHigher(currentToken(), true)); + case 41 /* TypeOfKeyword */: return parseTypeOfExpression(_currentToken); + case 43 /* VoidKeyword */: return parseVoidExpression(_currentToken); + case 23 /* DeleteKeyword */: return parseDeleteExpression(_currentToken); + case 82 /* LessThanToken */: return parseCastExpression(_currentToken); default: return tryParsePostfixExpressionOrHigher(_currentToken, force); } } function tryParseBinaryExpressionOrHigher(_currentToken, force, precedence, allowIn) { var leftOperand = tryParseUnaryExpressionOrHigher(_currentToken, force); - if (leftOperand === null) { - return null; + if (leftOperand === undefined) { + return undefined; } return parseBinaryExpressionRest(precedence, allowIn, leftOperand); } function parseConditionalExpressionRest(allowIn, leftOperand) { var _currentToken = currentToken(); - if (_currentToken.kind() !== 105 /* QuestionToken */) { + if (_currentToken.kind() !== 107 /* QuestionToken */) { return leftOperand; } - return new Parser.syntaxFactory.ConditionalExpressionSyntax(parseNodeData, leftOperand, consumeToken(_currentToken), tryParseAssignmentExpressionOrHigher(true, true), eatToken(106 /* ColonToken */), tryParseAssignmentExpressionOrHigher(true, allowIn)); + return new TypeScript.ConditionalExpressionSyntax(parseNodeData, leftOperand, consumeToken(_currentToken), tryParseAssignmentExpressionOrHigher(true, true), eatToken(108 /* ColonToken */), tryParseAssignmentExpressionOrHigher(true, allowIn)); } function parseBinaryExpressionRest(precedence, allowIn, leftOperand) { while (true) { var operatorToken = currentOperatorToken(); var tokenKind = operatorToken.kind(); - if (!TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(tokenKind) || tokenKind === 79 /* CommaToken */ || TypeScript.SyntaxFacts.isAssignmentOperatorToken(tokenKind)) { + if (!TypeScript.SyntaxFacts.isBinaryExpressionOperatorToken(tokenKind) || tokenKind === 81 /* CommaToken */ || TypeScript.SyntaxFacts.isAssignmentOperatorToken(tokenKind)) { break; } - if (tokenKind === 29 /* InKeyword */ && !allowIn) { + if (tokenKind === 31 /* InKeyword */ && !allowIn) { break; } var newPrecedence = getBinaryExpressionPrecedence(tokenKind); if (newPrecedence <= precedence) { break; } - leftOperand = new Parser.syntaxFactory.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), tryParseBinaryExpressionOrHigher(currentToken(), true, newPrecedence, allowIn)); + leftOperand = new TypeScript.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), tryParseBinaryExpressionOrHigher(currentToken(), true, newPrecedence, allowIn)); } return leftOperand; } function currentOperatorToken() { var token0 = currentToken(); - if (token0.kind() === 81 /* GreaterThanToken */) { + if (token0.kind() === 83 /* GreaterThanToken */) { return currentContextualToken(); } return token0; } function tryParseMemberExpressionOrHigher(_currentToken, force, inObjectCreation) { var expression = tryParsePrimaryExpression(_currentToken, force); - if (expression === null) { - return null; + if (expression === undefined) { + return undefined; } return parseMemberExpressionRest(expression, inObjectCreation); } @@ -24166,21 +24410,25 @@ var TypeScript; var _currentToken = currentToken(); var currentTokenKind = _currentToken.kind(); switch (currentTokenKind) { - case 72 /* OpenParenToken */: - expression = new Parser.syntaxFactory.InvocationExpressionSyntax(parseNodeData, expression, parseArgumentList(null)); + case 74 /* OpenParenToken */: + expression = new TypeScript.InvocationExpressionSyntax(parseNodeData, expression, parseArgumentList(undefined)); continue; - case 80 /* LessThanToken */: + case 82 /* LessThanToken */: var argumentList = tryParseArgumentList(); - if (argumentList === null) { + if (argumentList === undefined) { break; } - expression = new Parser.syntaxFactory.InvocationExpressionSyntax(parseNodeData, expression, argumentList); + expression = new TypeScript.InvocationExpressionSyntax(parseNodeData, expression, argumentList); continue; - case 74 /* OpenBracketToken */: + case 76 /* OpenBracketToken */: expression = parseElementAccessExpression(expression, _currentToken, false); continue; - case 76 /* DotToken */: - expression = new Parser.syntaxFactory.MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + case 78 /* DotToken */: + expression = new TypeScript.MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + continue; + case 13 /* NoSubstitutionTemplateToken */: + case 14 /* TemplateStartToken */: + expression = new TypeScript.TemplateAccessExpressionSyntax(parseNodeData, expression, parseTemplateExpression(_currentToken)); continue; } return expression; @@ -24191,25 +24439,29 @@ var TypeScript; var _currentToken = currentToken(); var currentTokenKind = _currentToken.kind(); switch (currentTokenKind) { - case 74 /* OpenBracketToken */: + case 76 /* OpenBracketToken */: expression = parseElementAccessExpression(expression, _currentToken, inObjectCreation); continue; - case 76 /* DotToken */: - expression = new Parser.syntaxFactory.MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + case 78 /* DotToken */: + expression = new TypeScript.MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + continue; + case 13 /* NoSubstitutionTemplateToken */: + case 14 /* TemplateStartToken */: + expression = new TypeScript.TemplateAccessExpressionSyntax(parseNodeData, expression, parseTemplateExpression(_currentToken)); continue; } return expression; } } function tryParseLeftHandSideExpressionOrHigher(_currentToken, force) { - var expression = null; - if (_currentToken.kind() === 50 /* SuperKeyword */) { + var expression = undefined; + if (_currentToken.kind() === 52 /* SuperKeyword */) { expression = parseSuperExpression(_currentToken); } else { expression = tryParseMemberExpressionOrHigher(_currentToken, force, false); - if (expression === null) { - return null; + if (expression === undefined) { + return undefined; } } return parseCallExpressionRest(expression); @@ -24217,22 +24469,22 @@ var TypeScript; function parseSuperExpression(superToken) { var expression = consumeToken(superToken); var currentTokenKind = currentToken().kind(); - return currentTokenKind === 72 /* OpenParenToken */ || currentTokenKind === 76 /* DotToken */ ? expression : new Parser.syntaxFactory.MemberAccessExpressionSyntax(parseNodeData, expression, eatToken(76 /* DotToken */), eatIdentifierNameToken()); + return currentTokenKind === 74 /* OpenParenToken */ || currentTokenKind === 78 /* DotToken */ ? expression : new TypeScript.MemberAccessExpressionSyntax(parseNodeData, expression, eatToken(78 /* DotToken */), eatIdentifierNameToken()); } function tryParsePostfixExpressionOrHigher(_currentToken, force) { var expression = tryParseLeftHandSideExpressionOrHigher(_currentToken, force); - if (expression === null) { - return null; + if (expression === undefined) { + return undefined; } var _currentToken = currentToken(); var currentTokenKind = _currentToken.kind(); switch (currentTokenKind) { - case 93 /* PlusPlusToken */: - case 94 /* MinusMinusToken */: + case 95 /* PlusPlusToken */: + case 96 /* MinusMinusToken */: if (previousTokenHasTrailingNewLine(_currentToken)) { break; } - return new Parser.syntaxFactory.PostfixUnaryExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken)); + return new TypeScript.PostfixUnaryExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken)); } return expression; } @@ -24241,21 +24493,21 @@ var TypeScript; var typeArgumentList = tryParseTypeArgumentList(true); var token0 = currentToken(); var tokenKind = token0.kind(); - var isOpenParen = tokenKind === 72 /* OpenParenToken */; - var isDot = tokenKind === 76 /* DotToken */; + var isOpenParen = tokenKind === 74 /* OpenParenToken */; + var isDot = tokenKind === 78 /* DotToken */; var isOpenParenOrDot = isOpenParen || isDot; - var argumentList = null; - if (typeArgumentList === null || !isOpenParenOrDot) { + var argumentList = undefined; + if (!typeArgumentList || !isOpenParenOrDot) { rewind(rewindPoint); releaseRewindPoint(rewindPoint); - return null; + return undefined; } else { releaseRewindPoint(rewindPoint); if (isDot) { - var diagnostic = new TypeScript.Diagnostic(fileName, source.text.lineMap(), TypeScript.start(token0, source.text), TypeScript.width(token0), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, null); + var diagnostic = new TypeScript.Diagnostic(fileName, source.text.lineMap(), TypeScript.start(token0, source.text), TypeScript.width(token0), TypeScript.DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, undefined); addDiagnostic(diagnostic); - return new Parser.syntaxFactory.ArgumentListSyntax(parseNodeData, typeArgumentList, TypeScript.Syntax.emptyToken(72 /* OpenParenToken */), TypeScript.Syntax.emptySeparatedList(), TypeScript.Syntax.emptyToken(73 /* CloseParenToken */)); + return new TypeScript.ArgumentListSyntax(parseNodeData, typeArgumentList, TypeScript.Syntax.emptyToken(74 /* OpenParenToken */), [], TypeScript.Syntax.emptyToken(75 /* CloseParenToken */)); } else { return parseArgumentList(typeArgumentList); @@ -24264,42 +24516,42 @@ var TypeScript; } function tryParseArgumentList() { var tokenKind = currentToken().kind(); - if (tokenKind === 80 /* LessThanToken */) { + if (tokenKind === 82 /* LessThanToken */) { return tryParseGenericArgumentList(); } - if (tokenKind === 72 /* OpenParenToken */) { - return parseArgumentList(null); + if (tokenKind === 74 /* OpenParenToken */) { + return parseArgumentList(undefined); } - return null; + return undefined; } function parseArgumentList(typeArgumentList) { - var openParenToken = eatToken(72 /* OpenParenToken */); - var _arguments = TypeScript.Syntax.emptySeparatedList(); + var openParenToken = eatToken(74 /* OpenParenToken */); + var _arguments; if (openParenToken.fullWidth() > 0) { var skippedTokens = getArray(); _arguments = parseSeparatedSyntaxList(14 /* ArgumentList_AssignmentExpressions */, skippedTokens); openParenToken = addSkippedTokensAfterToken(openParenToken, skippedTokens); } - return new Parser.syntaxFactory.ArgumentListSyntax(parseNodeData, typeArgumentList, openParenToken, _arguments, eatToken(73 /* CloseParenToken */)); + return new TypeScript.ArgumentListSyntax(parseNodeData, typeArgumentList, openParenToken, _arguments || [], eatToken(75 /* CloseParenToken */)); } function tryParseArgumentListExpression() { - var force = currentToken().kind() === 79 /* CommaToken */; + var force = currentToken().kind() === 81 /* CommaToken */; return tryParseAssignmentExpressionOrHigher(force, true); } function parseElementAccessArgumentExpression(openBracketToken, inObjectCreation) { - if (inObjectCreation && currentToken().kind() === 75 /* CloseBracketToken */) { + if (inObjectCreation && currentToken().kind() === 77 /* CloseBracketToken */) { var errorStart = TypeScript.start(openBracketToken, source.text); var errorEnd = TypeScript.end(currentToken(), source.text); - var diagnostic = new TypeScript.Diagnostic(fileName, source.text.lineMap(), errorStart, errorEnd - errorStart, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, null); + var diagnostic = new TypeScript.Diagnostic(fileName, source.text.lineMap(), errorStart, errorEnd - errorStart, TypeScript.DiagnosticCode.new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead, undefined); addDiagnostic(diagnostic); - return TypeScript.Syntax.emptyToken(11 /* IdentifierName */); + return TypeScript.Syntax.emptyToken(9 /* IdentifierName */); } else { return parseExpression(true); } } function parseElementAccessExpression(expression, openBracketToken, inObjectCreation) { - return new Parser.syntaxFactory.ElementAccessExpressionSyntax(parseNodeData, expression, consumeToken(openBracketToken), parseElementAccessArgumentExpression(openBracketToken, inObjectCreation), eatToken(75 /* CloseBracketToken */)); + return new TypeScript.ElementAccessExpressionSyntax(parseNodeData, expression, consumeToken(openBracketToken), parseElementAccessArgumentExpression(openBracketToken, inObjectCreation), eatToken(77 /* CloseBracketToken */)); } function tryParsePrimaryExpression(_currentToken, force) { if (isIdentifier(_currentToken)) { @@ -24307,41 +24559,39 @@ var TypeScript; } var currentTokenKind = _currentToken.kind(); switch (currentTokenKind) { - case 35 /* ThisKeyword */: - case 37 /* TrueKeyword */: - case 24 /* FalseKeyword */: - case 32 /* NullKeyword */: - case 13 /* NumericLiteral */: - case 12 /* RegularExpressionLiteral */: - case 14 /* StringLiteral */: + case 37 /* ThisKeyword */: + case 39 /* TrueKeyword */: + case 26 /* FalseKeyword */: + case 34 /* NullKeyword */: + case 11 /* NumericLiteral */: + case 10 /* RegularExpressionLiteral */: + case 12 /* StringLiteral */: return consumeToken(_currentToken); - case 27 /* FunctionKeyword */: - return parseFunctionExpression(_currentToken); - case 74 /* OpenBracketToken */: - return parseArrayLiteralExpression(_currentToken); - case 70 /* OpenBraceToken */: - return parseObjectLiteralExpression(_currentToken); - case 72 /* OpenParenToken */: - return parseParenthesizedExpression(_currentToken); - case 31 /* NewKeyword */: - return parseObjectCreationExpression(_currentToken); - case 118 /* SlashToken */: - case 119 /* SlashEqualsToken */: + case 29 /* FunctionKeyword */: return parseFunctionExpression(_currentToken); + case 76 /* OpenBracketToken */: return parseArrayLiteralExpression(_currentToken); + case 72 /* OpenBraceToken */: return parseObjectLiteralExpression(_currentToken); + case 74 /* OpenParenToken */: return parseParenthesizedExpression(_currentToken); + case 33 /* NewKeyword */: return parseObjectCreationExpression(_currentToken); + case 13 /* NoSubstitutionTemplateToken */: + case 14 /* TemplateStartToken */: + return parseTemplateExpression(_currentToken); + case 120 /* SlashToken */: + case 121 /* SlashEqualsToken */: var result = tryReparseDivideAsRegularExpression(); return result || eatIdentifierToken(TypeScript.DiagnosticCode.Expression_expected); } if (!force) { - return null; + return undefined; } return eatIdentifierToken(TypeScript.DiagnosticCode.Expression_expected); } function tryReparseDivideAsRegularExpression() { var currentToken = currentContextualToken(); var tokenKind = currentToken.kind(); - if (tokenKind === 118 /* SlashToken */ || tokenKind === 119 /* SlashEqualsToken */) { - return null; + if (tokenKind === 120 /* SlashToken */ || tokenKind === 121 /* SlashEqualsToken */) { + return undefined; } - else if (tokenKind === 12 /* RegularExpressionLiteral */) { + else if (tokenKind === 10 /* RegularExpressionLiteral */) { return consumeToken(currentToken); } else { @@ -24349,40 +24599,66 @@ var TypeScript; } } function parseTypeOfExpression(typeOfKeyword) { - return new Parser.syntaxFactory.TypeOfExpressionSyntax(parseNodeData, consumeToken(typeOfKeyword), tryParseUnaryExpressionOrHigher(currentToken(), true)); + return new TypeScript.TypeOfExpressionSyntax(parseNodeData, consumeToken(typeOfKeyword), tryParseUnaryExpressionOrHigher(currentToken(), true)); } function parseDeleteExpression(deleteKeyword) { - return new Parser.syntaxFactory.DeleteExpressionSyntax(parseNodeData, consumeToken(deleteKeyword), tryParseUnaryExpressionOrHigher(currentToken(), true)); + return new TypeScript.DeleteExpressionSyntax(parseNodeData, consumeToken(deleteKeyword), tryParseUnaryExpressionOrHigher(currentToken(), true)); } function parseVoidExpression(voidKeyword) { - return new Parser.syntaxFactory.VoidExpressionSyntax(parseNodeData, consumeToken(voidKeyword), tryParseUnaryExpressionOrHigher(currentToken(), true)); + return new TypeScript.VoidExpressionSyntax(parseNodeData, consumeToken(voidKeyword), tryParseUnaryExpressionOrHigher(currentToken(), true)); } function parseFunctionExpression(functionKeyword) { - return new Parser.syntaxFactory.FunctionExpressionSyntax(parseNodeData, consumeToken(functionKeyword), eatOptionalIdentifierToken(), parseCallSignature(false), parseBlock(false, true)); + return new TypeScript.FunctionExpressionSyntax(parseNodeData, consumeToken(functionKeyword), eatOptionalIdentifierToken(), parseCallSignature(false), parseBlock(false, true)); } function parseObjectCreationExpression(newKeyword) { - return new Parser.syntaxFactory.ObjectCreationExpressionSyntax(parseNodeData, consumeToken(newKeyword), tryParseMemberExpressionOrHigher(currentToken(), true, true), tryParseArgumentList()); + return new TypeScript.ObjectCreationExpressionSyntax(parseNodeData, consumeToken(newKeyword), tryParseMemberExpressionOrHigher(currentToken(), true, true), tryParseArgumentList()); + } + function parseTemplateExpression(startToken) { + consumeToken(startToken); + if (startToken.kind() === 13 /* NoSubstitutionTemplateToken */) { + return startToken; + } + var templateClauses = getArray(); + do { + templateClauses.push(parseTemplateClause()); + } while (templateClauses[templateClauses.length - 1].templateMiddleOrEndToken.kind() === 15 /* TemplateMiddleToken */); + return new TypeScript.TemplateExpressionSyntax(parseNodeData, startToken, TypeScript.Syntax.list(templateClauses)); + } + function parseTemplateClause() { + var expression = parseExpression(true); + var token = currentToken(); + if (token.kind() === 73 /* CloseBraceToken */) { + token = currentContextualToken(); + TypeScript.Debug.assert(token.kind() === 15 /* TemplateMiddleToken */ || token.kind() === 16 /* TemplateEndToken */); + consumeToken(token); + } + else { + var diagnostic = getExpectedTokenDiagnostic(73 /* CloseBraceToken */); + addDiagnostic(diagnostic); + token = TypeScript.Syntax.emptyToken(16 /* TemplateEndToken */); + } + return new TypeScript.TemplateClauseSyntax(parseNodeData, expression, token); } function parseCastExpression(lessThanToken) { - return new Parser.syntaxFactory.CastExpressionSyntax(parseNodeData, consumeToken(lessThanToken), parseType(), eatToken(81 /* GreaterThanToken */), tryParseUnaryExpressionOrHigher(currentToken(), true)); + return new TypeScript.CastExpressionSyntax(parseNodeData, consumeToken(lessThanToken), parseType(), eatToken(83 /* GreaterThanToken */), tryParseUnaryExpressionOrHigher(currentToken(), true)); } function parseParenthesizedExpression(openParenToken) { - return new Parser.syntaxFactory.ParenthesizedExpressionSyntax(parseNodeData, consumeToken(openParenToken), parseExpression(true), eatToken(73 /* CloseParenToken */)); + return new TypeScript.ParenthesizedExpressionSyntax(parseNodeData, consumeToken(openParenToken), parseExpression(true), eatToken(75 /* CloseParenToken */)); } function tryParseParenthesizedArrowFunctionExpression() { var tokenKind = currentToken().kind(); - if (tokenKind !== 72 /* OpenParenToken */ && tokenKind !== 80 /* LessThanToken */) { - return null; + if (tokenKind !== 74 /* OpenParenToken */ && tokenKind !== 82 /* LessThanToken */) { + return undefined; } if (isDefinitelyArrowFunctionExpression()) { return tryParseParenthesizedArrowFunctionExpressionWorker(false); } if (!isPossiblyArrowFunctionExpression()) { - return null; + return undefined; } var rewindPoint = getRewindPoint(); var arrowFunction = tryParseParenthesizedArrowFunctionExpressionWorker(true); - if (arrowFunction === null) { + if (arrowFunction === undefined) { rewind(rewindPoint); } releaseRewindPoint(rewindPoint); @@ -24391,16 +24667,16 @@ var TypeScript; function tryParseParenthesizedArrowFunctionExpressionWorker(requireArrow) { var _currentToken = currentToken(); var callSignature = parseCallSignature(true); - if (requireArrow && currentToken().kind() !== 85 /* EqualsGreaterThanToken */) { - return null; + if (requireArrow && currentToken().kind() !== 87 /* EqualsGreaterThanToken */) { + return undefined; } - var equalsGreaterThanToken = eatToken(85 /* EqualsGreaterThanToken */); + var equalsGreaterThanToken = eatToken(87 /* EqualsGreaterThanToken */); var block = tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { + var expression = undefined; + if (block === undefined) { expression = tryParseAssignmentExpressionOrHigher(true, true); } - return new Parser.syntaxFactory.ParenthesizedArrowFunctionExpressionSyntax(parseNodeData, callSignature, equalsGreaterThanToken, block, expression); + return new TypeScript.ParenthesizedArrowFunctionExpressionSyntax(parseNodeData, callSignature, equalsGreaterThanToken, block, expression); } function tryParseArrowFunctionBlock() { if (isBlock()) { @@ -24412,43 +24688,43 @@ var TypeScript; return parseBlock(true, false); } else { - return null; + return undefined; } } } function isSimpleArrowFunctionExpression(_currentToken) { - if (_currentToken.kind() === 85 /* EqualsGreaterThanToken */) { + if (_currentToken.kind() === 87 /* EqualsGreaterThanToken */) { return true; } - return isIdentifier(_currentToken) && peekToken(1).kind() === 85 /* EqualsGreaterThanToken */; + return isIdentifier(_currentToken) && peekToken(1).kind() === 87 /* EqualsGreaterThanToken */; } function parseSimpleArrowFunctionExpression() { var parameter = eatSimpleParameter(); - var equalsGreaterThanToken = eatToken(85 /* EqualsGreaterThanToken */); + var equalsGreaterThanToken = eatToken(87 /* EqualsGreaterThanToken */); var block = tryParseArrowFunctionBlock(); - var expression = null; - if (block === null) { + var expression = undefined; + if (block === undefined) { expression = tryParseAssignmentExpressionOrHigher(true, true); } - return new Parser.syntaxFactory.SimpleArrowFunctionExpressionSyntax(parseNodeData, parameter, equalsGreaterThanToken, block, expression); + return new TypeScript.SimpleArrowFunctionExpressionSyntax(parseNodeData, parameter, equalsGreaterThanToken, block, expression); } function isBlock() { - return currentToken().kind() === 70 /* OpenBraceToken */; + return currentToken().kind() === 72 /* OpenBraceToken */; } function isDefinitelyArrowFunctionExpression() { var token0 = currentToken(); - if (token0.kind() !== 72 /* OpenParenToken */) { + if (token0.kind() !== 74 /* OpenParenToken */) { return false; } var token1 = peekToken(1); var token1Kind = token1.kind(); var token2; - if (token1Kind === 73 /* CloseParenToken */) { + if (token1Kind === 75 /* CloseParenToken */) { token2 = peekToken(2); var token2Kind = token2.kind(); - return token2Kind === 106 /* ColonToken */ || token2Kind === 85 /* EqualsGreaterThanToken */ || token2Kind === 70 /* OpenBraceToken */; + return token2Kind === 108 /* ColonToken */ || token2Kind === 87 /* EqualsGreaterThanToken */ || token2Kind === 72 /* OpenBraceToken */; } - if (token1Kind === 77 /* DotDotDotToken */) { + if (token1Kind === 79 /* DotDotDotToken */) { return true; } token2 = peekToken(2); @@ -24461,18 +24737,18 @@ var TypeScript; if (!isIdentifier(token1)) { return false; } - if (token2Kind === 106 /* ColonToken */) { + if (token2Kind === 108 /* ColonToken */) { return true; } var token3 = peekToken(3); var token3Kind = token3.kind(); - if (token2Kind === 105 /* QuestionToken */) { - if (token3Kind === 106 /* ColonToken */ || token3Kind === 73 /* CloseParenToken */ || token3Kind === 79 /* CommaToken */) { + if (token2Kind === 107 /* QuestionToken */) { + if (token3Kind === 108 /* ColonToken */ || token3Kind === 75 /* CloseParenToken */ || token3Kind === 81 /* CommaToken */) { return true; } } - if (token2Kind === 73 /* CloseParenToken */) { - if (token3Kind === 85 /* EqualsGreaterThanToken */) { + if (token2Kind === 75 /* CloseParenToken */) { + if (token3Kind === 87 /* EqualsGreaterThanToken */) { return true; } } @@ -24480,7 +24756,7 @@ var TypeScript; } function isPossiblyArrowFunctionExpression() { var token0 = currentToken(); - if (token0.kind() !== 72 /* OpenParenToken */) { + if (token0.kind() !== 74 /* OpenParenToken */) { return true; } var token1 = peekToken(1); @@ -24489,15 +24765,15 @@ var TypeScript; } var token2 = peekToken(2); var token2Kind = token2.kind(); - if (token2Kind === 107 /* EqualsToken */) { + if (token2Kind === 109 /* EqualsToken */) { return true; } - if (token2Kind === 79 /* CommaToken */) { + if (token2Kind === 81 /* CommaToken */) { return true; } - if (token2Kind === 73 /* CloseParenToken */) { + if (token2Kind === 75 /* CloseParenToken */) { var token3 = peekToken(3); - if (token3.kind() === 106 /* ColonToken */) { + if (token3.kind() === 108 /* ColonToken */) { return true; } } @@ -24508,7 +24784,7 @@ var TypeScript; var skippedTokens = getArray(); var propertyAssignments = parseSeparatedSyntaxList(15 /* ObjectLiteralExpression_PropertyAssignments */, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); - return new Parser.syntaxFactory.ObjectLiteralExpressionSyntax(parseNodeData, openBraceToken, propertyAssignments, eatToken(71 /* CloseBraceToken */)); + return new TypeScript.ObjectLiteralExpressionSyntax(parseNodeData, openBraceToken, propertyAssignments, eatToken(73 /* CloseBraceToken */)); } function tryParsePropertyAssignment(inErrorRecovery) { if (isAccessor(modifierCount(), inErrorRecovery)) { @@ -24521,7 +24797,7 @@ var TypeScript; return parseSimplePropertyAssignment(); } else { - return null; + return undefined; } } function isPropertyAssignment(inErrorRecovery) { @@ -24535,13 +24811,13 @@ var TypeScript; return isPropertyName(currentToken(), inErrorRecovery) && isCallSignature(1); } function parseFunctionPropertyAssignment() { - return new Parser.syntaxFactory.FunctionPropertyAssignmentSyntax(parseNodeData, eatPropertyName(), parseCallSignature(false), parseBlock(false, true)); + return new TypeScript.FunctionPropertyAssignmentSyntax(parseNodeData, eatPropertyName(), parseCallSignature(false), parseBlock(false, true)); } function isSimplePropertyAssignment(inErrorRecovery) { return isPropertyName(currentToken(), inErrorRecovery); } function parseSimplePropertyAssignment() { - return new Parser.syntaxFactory.SimplePropertyAssignmentSyntax(parseNodeData, eatPropertyName(), eatToken(106 /* ColonToken */), tryParseAssignmentExpressionOrHigher(true, true)); + return new TypeScript.SimplePropertyAssignmentSyntax(parseNodeData, eatPropertyName(), eatToken(108 /* ColonToken */), tryParseAssignmentExpressionOrHigher(true, true)); } function isPropertyName(token, inErrorRecovery) { if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { @@ -24553,50 +24829,50 @@ var TypeScript; } } var kind = token.kind(); - return kind === 14 /* StringLiteral */ || kind === 13 /* NumericLiteral */; + return kind === 12 /* StringLiteral */ || kind === 11 /* NumericLiteral */ || kind === 13 /* NoSubstitutionTemplateToken */; } function parseArrayLiteralExpression(openBracketToken) { consumeToken(openBracketToken); var skippedTokens = getArray(); var expressions = parseSeparatedSyntaxList(16 /* ArrayLiteralExpression_AssignmentExpressions */, skippedTokens); openBracketToken = addSkippedTokensAfterToken(openBracketToken, skippedTokens); - return new Parser.syntaxFactory.ArrayLiteralExpressionSyntax(parseNodeData, openBracketToken, expressions, eatToken(75 /* CloseBracketToken */)); + return new TypeScript.ArrayLiteralExpressionSyntax(parseNodeData, openBracketToken, expressions, eatToken(77 /* CloseBracketToken */)); } function parseBlock(parseBlockEvenWithNoOpenBrace, checkForStrictMode) { - var openBraceToken = eatToken(70 /* OpenBraceToken */); - var statements = TypeScript.Syntax.emptyList(); + var openBraceToken = eatToken(72 /* OpenBraceToken */); + var statements; if (parseBlockEvenWithNoOpenBrace || openBraceToken.fullWidth() > 0) { var savedIsInStrictMode = isInStrictMode; - var processItems = checkForStrictMode ? updateStrictModeState : null; + var processItems = checkForStrictMode ? updateStrictModeState : undefined; var skippedTokens = getArray(); var statements = parseSyntaxList(5 /* Block_Statements */, skippedTokens, processItems); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); setStrictMode(savedIsInStrictMode); } - return new Parser.syntaxFactory.BlockSyntax(parseNodeData, openBraceToken, statements, eatToken(71 /* CloseBraceToken */)); + return new TypeScript.BlockSyntax(parseNodeData, openBraceToken, statements || [], eatToken(73 /* CloseBraceToken */)); } function parseCallSignature(requireCompleteTypeParameterList) { - return new Parser.syntaxFactory.CallSignatureSyntax(parseNodeData, tryParseTypeParameterList(requireCompleteTypeParameterList), parseParameterList(), parseOptionalTypeAnnotation(false)); + return new TypeScript.CallSignatureSyntax(parseNodeData, tryParseTypeParameterList(requireCompleteTypeParameterList), parseParameterList(), parseOptionalTypeAnnotation(false)); } function tryParseTypeParameterList(requireCompleteTypeParameterList) { var _currentToken = currentToken(); - if (_currentToken.kind() !== 80 /* LessThanToken */) { - return null; + if (_currentToken.kind() !== 82 /* LessThanToken */) { + return undefined; } var rewindPoint = getRewindPoint(); var lessThanToken = consumeToken(_currentToken); var skippedTokens = getArray(); var typeParameters = parseSeparatedSyntaxList(20 /* TypeParameterList_TypeParameters */, skippedTokens); lessThanToken = addSkippedTokensAfterToken(lessThanToken, skippedTokens); - var greaterThanToken = eatToken(81 /* GreaterThanToken */); + var greaterThanToken = eatToken(83 /* GreaterThanToken */); if (requireCompleteTypeParameterList && greaterThanToken.fullWidth() === 0) { rewind(rewindPoint); releaseRewindPoint(rewindPoint); - return null; + return undefined; } else { releaseRewindPoint(rewindPoint); - return new Parser.syntaxFactory.TypeParameterListSyntax(parseNodeData, lessThanToken, typeParameters, greaterThanToken); + return new TypeScript.TypeParameterListSyntax(parseNodeData, lessThanToken, typeParameters, greaterThanToken); } } function isTypeParameter() { @@ -24604,63 +24880,63 @@ var TypeScript; } function tryParseTypeParameter() { if (!isIdentifier(currentToken())) { - return null; + return undefined; } - return new Parser.syntaxFactory.TypeParameterSyntax(parseNodeData, eatIdentifierToken(), tryParseConstraint()); + return new TypeScript.TypeParameterSyntax(parseNodeData, eatIdentifierToken(), tryParseConstraint()); } function tryParseConstraint() { - if (currentToken().kind() !== 48 /* ExtendsKeyword */) { - return null; + if (currentToken().kind() !== 50 /* ExtendsKeyword */) { + return undefined; } - return new Parser.syntaxFactory.ConstraintSyntax(parseNodeData, eatToken(48 /* ExtendsKeyword */), parseTypeOrExpression()); + return new TypeScript.ConstraintSyntax(parseNodeData, eatToken(50 /* ExtendsKeyword */), parseTypeOrExpression()); } function tryParseParameterList() { - if (currentToken().kind() === 72 /* OpenParenToken */) { + if (currentToken().kind() === 74 /* OpenParenToken */) { var token1 = peekToken(1); - if (token1.kind() === 73 /* CloseParenToken */ || isParameterHelper(token1)) { + if (token1.kind() === 75 /* CloseParenToken */ || isParameterHelper(token1)) { return parseParameterList(); } } - return null; + return undefined; } function parseParameterList() { - var openParenToken = eatToken(72 /* OpenParenToken */); - var parameters = TypeScript.Syntax.emptySeparatedList(); + var openParenToken = eatToken(74 /* OpenParenToken */); + var parameters; if (openParenToken.fullWidth() > 0) { var skippedTokens = getArray(); parameters = parseSeparatedSyntaxList(17 /* ParameterList_Parameters */, skippedTokens); openParenToken = addSkippedTokensAfterToken(openParenToken, skippedTokens); } - return new Parser.syntaxFactory.ParameterListSyntax(parseNodeData, openParenToken, parameters, eatToken(73 /* CloseParenToken */)); + return new TypeScript.ParameterListSyntax(parseNodeData, openParenToken, parameters || [], eatToken(75 /* CloseParenToken */)); } function parseOptionalTypeAnnotation(allowStringLiteral) { - return currentToken().kind() === 106 /* ColonToken */ ? parseTypeAnnotation(allowStringLiteral) : null; + return currentToken().kind() === 108 /* ColonToken */ ? parseTypeAnnotation(allowStringLiteral) : undefined; } function parseTypeAnnotationType(allowStringLiteral) { if (allowStringLiteral) { var _currentToken = currentToken(); - if (_currentToken.kind() === 14 /* StringLiteral */) { + if (_currentToken.kind() === 12 /* StringLiteral */) { return consumeToken(_currentToken); } } return parseType(); } function parseTypeAnnotation(allowStringLiteral) { - return new Parser.syntaxFactory.TypeAnnotationSyntax(parseNodeData, consumeToken(currentToken()), parseTypeAnnotationType(allowStringLiteral)); + return new TypeScript.TypeAnnotationSyntax(parseNodeData, consumeToken(currentToken()), parseTypeAnnotationType(allowStringLiteral)); } function isType() { var _currentToken = currentToken(); switch (_currentToken.kind()) { - case 39 /* TypeOfKeyword */: - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - case 41 /* VoidKeyword */: - case 70 /* OpenBraceToken */: - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - case 31 /* NewKeyword */: + case 41 /* TypeOfKeyword */: + case 62 /* AnyKeyword */: + case 69 /* NumberKeyword */: + case 63 /* BooleanKeyword */: + case 71 /* StringKeyword */: + case 43 /* VoidKeyword */: + case 72 /* OpenBraceToken */: + case 74 /* OpenParenToken */: + case 82 /* LessThanToken */: + case 33 /* NewKeyword */: return true; default: return isIdentifier(_currentToken); @@ -24681,115 +24957,149 @@ var TypeScript; return tryParseType() || eatIdentifierToken(TypeScript.DiagnosticCode.Type_expected); } function tryParseType() { + if (isFunctionType()) { + return parseFunctionType(); + } + if (currentToken().kind() === 33 /* NewKeyword */) { + return parseConstructorType(); + } + return tryParseUnionTypeOrHigher(); + } + function tryParseUnionTypeOrHigher() { + var type = tryParsePrimaryType(); + if (type) { + var barToken; + while ((barToken = currentToken()).kind() === 101 /* BarToken */) { + consumeToken(barToken); + var right = parsePrimaryType(); + type = new TypeScript.UnionTypeSyntax(parseNodeData, type, barToken, right); + } + } + return type; + } + function parsePrimaryType() { + return tryParsePrimaryType() || eatIdentifierToken(TypeScript.DiagnosticCode.Type_expected); + } + function tryParsePrimaryType() { var type = tryParseNonArrayType(); while (type) { var _currentToken = currentToken(); - if (previousTokenHasTrailingNewLine(_currentToken) || _currentToken.kind() !== 74 /* OpenBracketToken */) { + if (previousTokenHasTrailingNewLine(_currentToken) || _currentToken.kind() !== 76 /* OpenBracketToken */) { break; } - type = new Parser.syntaxFactory.ArrayTypeSyntax(parseNodeData, type, consumeToken(_currentToken), eatToken(75 /* CloseBracketToken */)); + type = new TypeScript.ArrayTypeSyntax(parseNodeData, type, consumeToken(_currentToken), eatToken(77 /* CloseBracketToken */)); } return type; } function parseTypeQuery(typeOfKeyword) { - return new Parser.syntaxFactory.TypeQuerySyntax(parseNodeData, consumeToken(typeOfKeyword), parseName(true)); + return new TypeScript.TypeQuerySyntax(parseNodeData, consumeToken(typeOfKeyword), parseName(true)); } function tryParseNonArrayType() { var _currentToken = currentToken(); switch (_currentToken.kind()) { - case 60 /* AnyKeyword */: - case 67 /* NumberKeyword */: - case 61 /* BooleanKeyword */: - case 69 /* StringKeyword */: - if (peekToken(1).kind() === 76 /* DotToken */) { + case 62 /* AnyKeyword */: + case 69 /* NumberKeyword */: + case 63 /* BooleanKeyword */: + case 71 /* StringKeyword */: + if (peekToken(1).kind() === 78 /* DotToken */) { break; } return consumeToken(_currentToken); - case 72 /* OpenParenToken */: - case 80 /* LessThanToken */: - return tryParseFunctionType(); - case 41 /* VoidKeyword */: - return consumeToken(_currentToken); - case 70 /* OpenBraceToken */: - return parseObjectType(); - case 31 /* NewKeyword */: - return parseConstructorType(); - case 39 /* TypeOfKeyword */: - return parseTypeQuery(_currentToken); - case 74 /* OpenBracketToken */: - return parseTupleType(_currentToken); + case 43 /* VoidKeyword */: return consumeToken(_currentToken); + case 74 /* OpenParenToken */: return parseParenthesizedType(_currentToken); + case 72 /* OpenBraceToken */: return parseObjectType(); + case 41 /* TypeOfKeyword */: return parseTypeQuery(_currentToken); + case 76 /* OpenBracketToken */: return parseTupleType(_currentToken); } return tryParseNameOrGenericType(); } + function parseParenthesizedType(openParenToken) { + return new TypeScript.ParenthesizedTypeSyntax(parseNodeData, consumeToken(openParenToken), parseType(), eatToken(75 /* CloseParenToken */)); + } function tryParseNameOrGenericType() { var name = tryParseName(false); - if (name === null) { - return null; + if (name === undefined) { + return undefined; } if (previousTokenHasTrailingNewLine(currentToken())) { return name; } var typeArgumentList = tryParseTypeArgumentList(false); - return typeArgumentList === null ? name : new Parser.syntaxFactory.GenericTypeSyntax(parseNodeData, name, typeArgumentList); + return !typeArgumentList ? name : new TypeScript.GenericTypeSyntax(parseNodeData, name, typeArgumentList); } - function tryParseFunctionType() { - var typeParameterList = tryParseTypeParameterList(false); - var parameterList = null; - if (typeParameterList === null) { - parameterList = tryParseParameterList(); - if (parameterList === null) { - return null; + function isFunctionType() { + var token0 = currentToken(); + var token0Kind = token0.kind(); + if (token0Kind === 82 /* LessThanToken */) { + return true; + } + if (token0Kind === 74 /* OpenParenToken */) { + var token1 = peekToken(1); + var token1Kind = token1.kind(); + if (token1Kind === 75 /* CloseParenToken */ || token1Kind === 79 /* DotDotDotToken */) { + return true; + } + if (isModifierKind(token1Kind) || isIdentifier(token1)) { + var token2 = peekToken(2); + var token2Kind = token2.kind(); + if (token2Kind === 108 /* ColonToken */ || token2Kind === 81 /* CommaToken */ || token2Kind === 107 /* QuestionToken */ || token2Kind === 109 /* EqualsToken */ || isIdentifier(token2) || isModifierKind(token2Kind)) { + return true; + } + if (token2Kind === 75 /* CloseParenToken */) { + return peekToken(3).kind() === 87 /* EqualsGreaterThanToken */; + } } } - else { - parameterList = parseParameterList(); - } - return new Parser.syntaxFactory.FunctionTypeSyntax(parseNodeData, typeParameterList, parameterList, eatToken(85 /* EqualsGreaterThanToken */), parseType()); + return false; + } + function parseFunctionType() { + var typeParameterList = tryParseTypeParameterList(false); + var parameterList = parseParameterList(); + return new TypeScript.FunctionTypeSyntax(parseNodeData, typeParameterList, parameterList, eatToken(87 /* EqualsGreaterThanToken */), parseType()); } function parseConstructorType() { - return new Parser.syntaxFactory.ConstructorTypeSyntax(parseNodeData, eatToken(31 /* NewKeyword */), tryParseTypeParameterList(false), parseParameterList(), eatToken(85 /* EqualsGreaterThanToken */), parseType()); + return new TypeScript.ConstructorTypeSyntax(parseNodeData, eatToken(33 /* NewKeyword */), tryParseTypeParameterList(false), parseParameterList(), eatToken(87 /* EqualsGreaterThanToken */), parseType()); } function isParameter() { - if (currentNode() !== null && currentNode().kind() === 243 /* Parameter */) { + if (currentNode() && currentNode().kind() === 208 /* Parameter */) { return true; } return isParameterHelper(currentToken()); } function isParameterHelper(token) { var tokenKind = token.kind(); - return tokenKind === 77 /* DotDotDotToken */ || isModifierKind(tokenKind) || isIdentifier(token); + return tokenKind === 79 /* DotDotDotToken */ || isModifierKind(tokenKind) || isIdentifier(token); } function eatSimpleParameter() { - return new Parser.syntaxFactory.ParameterSyntax(parseNodeData, null, TypeScript.Syntax.emptyList(), eatIdentifierToken(), null, null, null); + return new TypeScript.ParameterSyntax(parseNodeData, undefined, [], eatIdentifierToken(), undefined, undefined, undefined); } function tryParseParameter() { var node = currentNode(); - if (node !== null && node.kind() === 243 /* Parameter */) { + if (node && node.kind() === 208 /* Parameter */) { consumeNode(node); return node; } - var dotDotDotToken = tryEatToken(77 /* DotDotDotToken */); + var dotDotDotToken = tryEatToken(79 /* DotDotDotToken */); var modifiers = parseModifiers(); var _currentToken = currentToken(); - if (!isIdentifier(_currentToken) && dotDotDotToken === null && modifiers.length === 0) { + if (!isIdentifier(_currentToken) && !dotDotDotToken && modifiers.length === 0) { if (isModifierKind(_currentToken.kind())) { modifiers = TypeScript.Syntax.list([consumeToken(_currentToken)]); } else { - return null; + return undefined; } } var identifier = eatIdentifierToken(); - var questionToken = tryEatToken(105 /* QuestionToken */); + var questionToken = tryEatToken(107 /* QuestionToken */); var typeAnnotation = parseOptionalTypeAnnotation(true); - var equalsValueClause = null; + var equalsValueClause = undefined; if (isEqualsValueClause(true)) { equalsValueClause = parseEqualsValueClause(true); } - return new Parser.syntaxFactory.ParameterSyntax(parseNodeData, dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + return new TypeScript.ParameterSyntax(parseNodeData, dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); } function parseSyntaxList(currentListType, skippedTokens, processItems) { - if (processItems === void 0) { processItems = null; } var savedListParsingState = listParsingState; listParsingState |= (1 << currentListType); var result = parseSyntaxListWorker(currentListType, skippedTokens, processItems); @@ -24803,7 +25113,7 @@ var TypeScript; listParsingState = savedListParsingState; return result; } - function abortParsingListOrMoveToNextToken(currentListType, nodes, separators, skippedTokens) { + function abortParsingListOrMoveToNextToken(currentListType, nodeAndSeparators, skippedTokens) { reportUnexpectedTokenDiagnostic(currentListType); for (var state = ListParsingState.LastListParsingState; state >= ListParsingState.FirstListParsingState; state--) { if ((listParsingState & (1 << state)) !== 0) { @@ -24812,70 +25122,63 @@ var TypeScript; } } } - addSkippedTokenToList(nodes, separators, skippedTokens, consumeToken(currentToken())); + addSkippedTokenToList(nodeAndSeparators, skippedTokens, consumeToken(currentToken())); return false; } - function addSkippedTokenToList(nodes, separators, skippedTokens, skippedToken) { - if (Parser.syntaxFactory.isConcrete) { - var length = nodes.length + (separators ? separators.length : 0); - for (var i = length - 1; i >= 0; i--) { - var array = separators && (i % 2 === 1) ? separators : nodes; - var arrayIndex = separators ? TypeScript.IntegerUtilities.integerDivide(i, 2) : i; - var item = array[arrayIndex]; - var _lastToken = TypeScript.lastToken(item); - if (_lastToken && _lastToken.fullWidth() > 0) { - array[arrayIndex] = addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } + function addSkippedTokenToList(nodesAndSeparators, skippedTokens, skippedToken) { + var length = nodesAndSeparators.length; + for (var i = length - 1; i >= 0; i--) { + var item = nodesAndSeparators[i]; + var _lastToken = TypeScript.lastToken(item); + if (_lastToken && _lastToken.fullWidth() > 0) { + nodesAndSeparators[i] = addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; } - skippedTokens.push(skippedToken); } + skippedTokens.push(skippedToken); } function tryParseExpectedListItem(currentListType, inErrorRecovery, items, processItems) { var item = tryParseExpectedListItemWorker(currentListType, inErrorRecovery); - if (item === null) { + if (item === undefined) { return false; } items.push(item); - if (processItems !== null) { + if (processItems) { processItems(items); } return true; } function listIsTerminated(currentListType) { - return isExpectedListTerminator(currentListType) || currentToken().kind() === 10 /* EndOfFileToken */; + return isExpectedListTerminator(currentListType) || currentToken().kind() === 8 /* EndOfFileToken */; } function parseSyntaxListWorker(currentListType, skippedTokens, processItems) { - var items = getArray(); + var items = []; while (true) { var succeeded = tryParseExpectedListItem(currentListType, false, items, processItems); if (!succeeded) { if (listIsTerminated(currentListType)) { break; } - var abort = abortParsingListOrMoveToNextToken(currentListType, items, null, skippedTokens); + var abort = abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); if (abort) { break; } } } - var result = TypeScript.Syntax.list(items); - returnZeroLengthArray(items); - return result; + return TypeScript.Syntax.list(items); } function parseSeparatedSyntaxListWorker(currentListType, skippedTokens) { - var nodes = getArray(); - var separators = getArray(); - var _separatorKind = currentListType === 9 /* ObjectType_TypeMembers */ ? 78 /* SemicolonToken */ : 79 /* CommaToken */; - var allowAutomaticSemicolonInsertion = _separatorKind === 78 /* SemicolonToken */; + var nodesAndSeparators = []; + var _separatorKind = currentListType === 9 /* ObjectType_TypeMembers */ ? 80 /* SemicolonToken */ : 81 /* CommaToken */; + var allowAutomaticSemicolonInsertion = _separatorKind === 80 /* SemicolonToken */; var inErrorRecovery = false; while (true) { - var succeeded = tryParseExpectedListItem(currentListType, inErrorRecovery, nodes, null); + var succeeded = tryParseExpectedListItem(currentListType, inErrorRecovery, nodesAndSeparators, undefined); if (!succeeded) { if (listIsTerminated(currentListType)) { break; } - var abort = abortParsingListOrMoveToNextToken(currentListType, nodes, separators, skippedTokens); + var abort = abortParsingListOrMoveToNextToken(currentListType, nodesAndSeparators, skippedTokens); if (abort) { break; } @@ -24887,25 +25190,22 @@ var TypeScript; inErrorRecovery = false; var _currentToken = currentToken(); var tokenKind = _currentToken.kind(); - if (tokenKind === _separatorKind || tokenKind === 79 /* CommaToken */) { - separators.push(consumeToken(_currentToken)); + if (tokenKind === _separatorKind || tokenKind === 81 /* CommaToken */) { + nodesAndSeparators.push(consumeToken(_currentToken)); continue; } if (listIsTerminated(currentListType)) { break; } if (allowAutomaticSemicolonInsertion && canEatAutomaticSemicolon(false)) { - var semicolonToken = eatExplicitOrAutomaticSemicolon(false) || TypeScript.Syntax.emptyToken(78 /* SemicolonToken */); - separators.push(semicolonToken); + var semicolonToken = eatExplicitOrAutomaticSemicolon(false) || TypeScript.Syntax.emptyToken(80 /* SemicolonToken */); + nodesAndSeparators.push(semicolonToken); continue; } - separators.push(eatToken(_separatorKind)); + nodesAndSeparators.push(eatToken(_separatorKind)); inErrorRecovery = true; } - var result = TypeScript.Syntax.separatedList(nodes, separators); - returnZeroLengthArray(nodes); - returnZeroLengthArray(separators); - return result; + return TypeScript.Syntax.separatedList(nodesAndSeparators); } function reportUnexpectedTokenDiagnostic(listType) { var token = currentToken(); @@ -24920,76 +25220,54 @@ var TypeScript; } function isExpectedListTerminator(currentListType) { switch (currentListType) { - case 0 /* SourceUnit_ModuleElements */: - return isExpectedSourceUnit_ModuleElementsTerminator(); - case 1 /* ClassDeclaration_ClassElements */: - return isExpectedClassDeclaration_ClassElementsTerminator(); - case 2 /* ModuleDeclaration_ModuleElements */: - return isExpectedModuleDeclaration_ModuleElementsTerminator(); - case 3 /* SwitchStatement_SwitchClauses */: - return isExpectedSwitchStatement_SwitchClausesTerminator(); - case 4 /* SwitchClause_Statements */: - return isExpectedSwitchClause_StatementsTerminator(); - case 5 /* Block_Statements */: - return isExpectedBlock_StatementsTerminator(); - case 6 /* TryBlock_Statements */: - return isExpectedTryBlock_StatementsTerminator(); - case 7 /* CatchBlock_Statements */: - return isExpectedCatchBlock_StatementsTerminator(); - case 8 /* EnumDeclaration_EnumElements */: - return isExpectedEnumDeclaration_EnumElementsTerminator(); - case 9 /* ObjectType_TypeMembers */: - return isExpectedObjectType_TypeMembersTerminator(); - case 10 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); - case 11 /* HeritageClause_TypeNameList */: - return isExpectedHeritageClause_TypeNameListTerminator(); - case 12 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); - case 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); - case 14 /* ArgumentList_AssignmentExpressions */: - return isExpectedArgumentList_AssignmentExpressionsTerminator(); - case 15 /* ObjectLiteralExpression_PropertyAssignments */: - return isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); - case 16 /* ArrayLiteralExpression_AssignmentExpressions */: - return isExpectedLiteralExpression_AssignmentExpressionsTerminator(); - case 17 /* ParameterList_Parameters */: - return isExpectedParameterList_ParametersTerminator(); - case 18 /* IndexSignature_Parameters */: - return isExpectedIndexSignature_ParametersTerminator(); - case 19 /* TypeArgumentList_Types */: - return isExpectedTypeArgumentList_TypesTerminator(); - case 20 /* TypeParameterList_TypeParameters */: - return isExpectedTypeParameterList_TypeParametersTerminator(); - case 21 /* TupleType_Types */: - return isExpectedTupleType_TypesTerminator(); + case 0 /* SourceUnit_ModuleElements */: return isExpectedSourceUnit_ModuleElementsTerminator(); + case 1 /* ClassDeclaration_ClassElements */: return isExpectedClassDeclaration_ClassElementsTerminator(); + case 2 /* ModuleDeclaration_ModuleElements */: return isExpectedModuleDeclaration_ModuleElementsTerminator(); + case 3 /* SwitchStatement_SwitchClauses */: return isExpectedSwitchStatement_SwitchClausesTerminator(); + case 4 /* SwitchClause_Statements */: return isExpectedSwitchClause_StatementsTerminator(); + case 5 /* Block_Statements */: return isExpectedBlock_StatementsTerminator(); + case 6 /* TryBlock_Statements */: return isExpectedTryBlock_StatementsTerminator(); + case 7 /* CatchBlock_Statements */: return isExpectedCatchBlock_StatementsTerminator(); + case 8 /* EnumDeclaration_EnumElements */: return isExpectedEnumDeclaration_EnumElementsTerminator(); + case 9 /* ObjectType_TypeMembers */: return isExpectedObjectType_TypeMembersTerminator(); + case 10 /* ClassOrInterfaceDeclaration_HeritageClauses */: return isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(); + case 11 /* HeritageClause_TypeNameList */: return isExpectedHeritageClause_TypeNameListTerminator(); + case 12 /* VariableDeclaration_VariableDeclarators_AllowIn */: return isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator(); + case 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */: return isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(); + case 14 /* ArgumentList_AssignmentExpressions */: return isExpectedArgumentList_AssignmentExpressionsTerminator(); + case 15 /* ObjectLiteralExpression_PropertyAssignments */: return isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(); + case 16 /* ArrayLiteralExpression_AssignmentExpressions */: return isExpectedLiteralExpression_AssignmentExpressionsTerminator(); + case 17 /* ParameterList_Parameters */: return isExpectedParameterList_ParametersTerminator(); + case 18 /* IndexSignature_Parameters */: return isExpectedIndexSignature_ParametersTerminator(); + case 19 /* TypeArgumentList_Types */: return isExpectedTypeArgumentList_TypesTerminator(); + case 20 /* TypeParameterList_TypeParameters */: return isExpectedTypeParameterList_TypeParametersTerminator(); + case 21 /* TupleType_Types */: return isExpectedTupleType_TypesTerminator(); default: throw TypeScript.Errors.invalidOperation(); } } function isExpectedSourceUnit_ModuleElementsTerminator() { - return currentToken().kind() === 10 /* EndOfFileToken */; + return currentToken().kind() === 8 /* EndOfFileToken */; } function isExpectedEnumDeclaration_EnumElementsTerminator() { - return currentToken().kind() === 71 /* CloseBraceToken */; + return currentToken().kind() === 73 /* CloseBraceToken */; } function isExpectedModuleDeclaration_ModuleElementsTerminator() { - return currentToken().kind() === 71 /* CloseBraceToken */; + return currentToken().kind() === 73 /* CloseBraceToken */; } function isExpectedObjectType_TypeMembersTerminator() { - return currentToken().kind() === 71 /* CloseBraceToken */; + return currentToken().kind() === 73 /* CloseBraceToken */; } function isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator() { - return currentToken().kind() === 71 /* CloseBraceToken */; + return currentToken().kind() === 73 /* CloseBraceToken */; } function isExpectedLiteralExpression_AssignmentExpressionsTerminator() { - return currentToken().kind() === 75 /* CloseBracketToken */; + return currentToken().kind() === 77 /* CloseBracketToken */; } function isExpectedTypeArgumentList_TypesTerminator() { var token = currentToken(); var tokenKind = token.kind(); - if (tokenKind === 81 /* GreaterThanToken */) { + if (tokenKind === 83 /* GreaterThanToken */) { return true; } if (canFollowTypeArgumentListInExpression(tokenKind)) { @@ -25000,70 +25278,70 @@ var TypeScript; function isExpectedTupleType_TypesTerminator() { var token = currentToken(); var tokenKind = token.kind(); - if (tokenKind === 75 /* CloseBracketToken */) { + if (tokenKind === 77 /* CloseBracketToken */) { return true; } return false; } function isExpectedTypeParameterList_TypeParametersTerminator() { var tokenKind = currentToken().kind(); - if (tokenKind === 81 /* GreaterThanToken */) { + if (tokenKind === 83 /* GreaterThanToken */) { return true; } - if (tokenKind === 72 /* OpenParenToken */ || tokenKind === 70 /* OpenBraceToken */ || tokenKind === 48 /* ExtendsKeyword */ || tokenKind === 51 /* ImplementsKeyword */) { + if (tokenKind === 74 /* OpenParenToken */ || tokenKind === 72 /* OpenBraceToken */ || tokenKind === 50 /* ExtendsKeyword */ || tokenKind === 53 /* ImplementsKeyword */) { return true; } return false; } function isExpectedParameterList_ParametersTerminator() { var tokenKind = currentToken().kind(); - if (tokenKind === 73 /* CloseParenToken */) { + if (tokenKind === 75 /* CloseParenToken */) { return true; } - if (tokenKind === 70 /* OpenBraceToken */) { + if (tokenKind === 72 /* OpenBraceToken */) { return true; } - if (tokenKind === 85 /* EqualsGreaterThanToken */) { + if (tokenKind === 87 /* EqualsGreaterThanToken */) { return true; } return false; } function isExpectedIndexSignature_ParametersTerminator() { var tokenKind = currentToken().kind(); - if (tokenKind === 75 /* CloseBracketToken */) { + if (tokenKind === 77 /* CloseBracketToken */) { return true; } - if (tokenKind === 70 /* OpenBraceToken */) { + if (tokenKind === 72 /* OpenBraceToken */) { return true; } return false; } function isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator() { var tokenKind = currentToken().kind(); - if (tokenKind === 78 /* SemicolonToken */ || tokenKind === 73 /* CloseParenToken */) { + if (tokenKind === 80 /* SemicolonToken */ || tokenKind === 75 /* CloseParenToken */) { return true; } - if (tokenKind === 29 /* InKeyword */) { + if (tokenKind === 31 /* InKeyword */) { return true; } return false; } function isExpectedVariableDeclaration_VariableDeclarators_AllowInTerminator() { - if (currentToken().kind() === 85 /* EqualsGreaterThanToken */) { + if (currentToken().kind() === 87 /* EqualsGreaterThanToken */) { return true; } return canEatExplicitOrAutomaticSemicolon(false); } function isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator() { var tokenKind = currentToken().kind(); - if (tokenKind === 70 /* OpenBraceToken */ || tokenKind === 71 /* CloseBraceToken */) { + if (tokenKind === 72 /* OpenBraceToken */ || tokenKind === 73 /* CloseBraceToken */) { return true; } return false; } function isExpectedHeritageClause_TypeNameListTerminator() { var tokenKind = currentToken().kind(); - if (tokenKind === 48 /* ExtendsKeyword */ || tokenKind === 51 /* ImplementsKeyword */) { + if (tokenKind === 50 /* ExtendsKeyword */ || tokenKind === 53 /* ImplementsKeyword */) { return true; } if (isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator()) { @@ -25074,75 +25352,52 @@ var TypeScript; function isExpectedArgumentList_AssignmentExpressionsTerminator() { var token0 = currentToken(); var tokenKind = token0.kind(); - return tokenKind === 73 /* CloseParenToken */ || tokenKind === 78 /* SemicolonToken */; + return tokenKind === 75 /* CloseParenToken */ || tokenKind === 80 /* SemicolonToken */; } function isExpectedClassDeclaration_ClassElementsTerminator() { - return currentToken().kind() === 71 /* CloseBraceToken */; + return currentToken().kind() === 73 /* CloseBraceToken */; } function isExpectedSwitchStatement_SwitchClausesTerminator() { - return currentToken().kind() === 71 /* CloseBraceToken */; + return currentToken().kind() === 73 /* CloseBraceToken */; } function isExpectedSwitchClause_StatementsTerminator() { - return currentToken().kind() === 71 /* CloseBraceToken */ || isSwitchClause(); + return currentToken().kind() === 73 /* CloseBraceToken */ || isSwitchClause(); } function isExpectedBlock_StatementsTerminator() { - return currentToken().kind() === 71 /* CloseBraceToken */; + return currentToken().kind() === 73 /* CloseBraceToken */; } function isExpectedTryBlock_StatementsTerminator() { var tokenKind = currentToken().kind(); - return tokenKind === 17 /* CatchKeyword */ || tokenKind === 25 /* FinallyKeyword */; + return tokenKind === 19 /* CatchKeyword */ || tokenKind === 27 /* FinallyKeyword */; } function isExpectedCatchBlock_StatementsTerminator() { - return currentToken().kind() === 25 /* FinallyKeyword */; + return currentToken().kind() === 27 /* FinallyKeyword */; } function isExpectedListItem(currentListType, inErrorRecovery) { switch (currentListType) { - case 0 /* SourceUnit_ModuleElements */: - return isModuleElement(inErrorRecovery); - case 1 /* ClassDeclaration_ClassElements */: - return isClassElement(inErrorRecovery); - case 2 /* ModuleDeclaration_ModuleElements */: - return isModuleElement(inErrorRecovery); - case 3 /* SwitchStatement_SwitchClauses */: - return isSwitchClause(); - case 4 /* SwitchClause_Statements */: - return isStatement(modifierCount(), inErrorRecovery); - case 5 /* Block_Statements */: - return isStatement(modifierCount(), inErrorRecovery); - case 6 /* TryBlock_Statements */: - return false; - case 7 /* CatchBlock_Statements */: - return false; - case 8 /* EnumDeclaration_EnumElements */: - return isEnumElement(inErrorRecovery); - case 9 /* ObjectType_TypeMembers */: - return isTypeMember(inErrorRecovery); - case 10 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return isHeritageClause(); - case 11 /* HeritageClause_TypeNameList */: - return isHeritageClauseTypeName(); - case 12 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return isVariableDeclarator(); - case 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return isVariableDeclarator(); - case 14 /* ArgumentList_AssignmentExpressions */: - return isExpectedArgumentList_AssignmentExpression(); - case 15 /* ObjectLiteralExpression_PropertyAssignments */: - return isPropertyAssignment(inErrorRecovery); - case 16 /* ArrayLiteralExpression_AssignmentExpressions */: - return isAssignmentOrOmittedExpression(); - case 17 /* ParameterList_Parameters */: - return isParameter(); - case 18 /* IndexSignature_Parameters */: - return isParameter(); - case 19 /* TypeArgumentList_Types */: - return isType(); - case 20 /* TypeParameterList_TypeParameters */: - return isTypeParameter(); - case 21 /* TupleType_Types */: - return isType(); - default: - throw TypeScript.Errors.invalidOperation(); + case 0 /* SourceUnit_ModuleElements */: return isModuleElement(inErrorRecovery); + case 1 /* ClassDeclaration_ClassElements */: return isClassElement(inErrorRecovery); + case 2 /* ModuleDeclaration_ModuleElements */: return isModuleElement(inErrorRecovery); + case 3 /* SwitchStatement_SwitchClauses */: return isSwitchClause(); + case 4 /* SwitchClause_Statements */: return isStatement(modifierCount(), inErrorRecovery); + case 5 /* Block_Statements */: return isStatement(modifierCount(), inErrorRecovery); + case 6 /* TryBlock_Statements */: return false; + case 7 /* CatchBlock_Statements */: return false; + case 8 /* EnumDeclaration_EnumElements */: return isEnumElement(inErrorRecovery); + case 9 /* ObjectType_TypeMembers */: return isTypeMember(inErrorRecovery); + case 10 /* ClassOrInterfaceDeclaration_HeritageClauses */: return isHeritageClause(); + case 11 /* HeritageClause_TypeNameList */: return isHeritageClauseTypeName(); + case 12 /* VariableDeclaration_VariableDeclarators_AllowIn */: return isVariableDeclarator(); + case 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */: return isVariableDeclarator(); + case 14 /* ArgumentList_AssignmentExpressions */: return isExpectedArgumentList_AssignmentExpression(); + case 15 /* ObjectLiteralExpression_PropertyAssignments */: return isPropertyAssignment(inErrorRecovery); + case 16 /* ArrayLiteralExpression_AssignmentExpressions */: return isAssignmentOrOmittedExpression(); + case 17 /* ParameterList_Parameters */: return isParameter(); + case 18 /* IndexSignature_Parameters */: return isParameter(); + case 19 /* TypeArgumentList_Types */: return isType(); + case 20 /* TypeParameterList_TypeParameters */: return isTypeParameter(); + case 21 /* TupleType_Types */: return isType(); + default: throw TypeScript.Errors.invalidOperation(); } } function isExpectedArgumentList_AssignmentExpression() { @@ -25150,105 +25405,61 @@ var TypeScript; if (isExpression(_currentToken)) { return true; } - if (_currentToken.kind() === 79 /* CommaToken */) { + if (_currentToken.kind() === 81 /* CommaToken */) { return true; } return false; } function tryParseExpectedListItemWorker(currentListType, inErrorRecovery) { switch (currentListType) { - case 0 /* SourceUnit_ModuleElements */: - return tryParseModuleElement(inErrorRecovery); - case 1 /* ClassDeclaration_ClassElements */: - return tryParseClassElement(inErrorRecovery); - case 2 /* ModuleDeclaration_ModuleElements */: - return tryParseModuleElement(inErrorRecovery); - case 3 /* SwitchStatement_SwitchClauses */: - return tryParseSwitchClause(); - case 4 /* SwitchClause_Statements */: - return tryParseStatement(inErrorRecovery); - case 5 /* Block_Statements */: - return tryParseStatement(inErrorRecovery); - case 6 /* TryBlock_Statements */: - return tryParseStatement(inErrorRecovery); - case 7 /* CatchBlock_Statements */: - return tryParseStatement(inErrorRecovery); - case 8 /* EnumDeclaration_EnumElements */: - return tryParseEnumElement(inErrorRecovery); - case 9 /* ObjectType_TypeMembers */: - return tryParseTypeMember(inErrorRecovery); - case 10 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return tryParseHeritageClause(); - case 11 /* HeritageClause_TypeNameList */: - return tryParseHeritageClauseTypeName(); - case 12 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return tryParseVariableDeclarator(true, false); - case 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return tryParseVariableDeclarator(false, false); - case 14 /* ArgumentList_AssignmentExpressions */: - return tryParseArgumentListExpression(); - case 15 /* ObjectLiteralExpression_PropertyAssignments */: - return tryParsePropertyAssignment(inErrorRecovery); - case 16 /* ArrayLiteralExpression_AssignmentExpressions */: - return tryParseAssignmentOrOmittedExpression(); - case 17 /* ParameterList_Parameters */: - return tryParseParameter(); - case 18 /* IndexSignature_Parameters */: - return tryParseParameter(); - case 19 /* TypeArgumentList_Types */: - return tryParseType(); - case 20 /* TypeParameterList_TypeParameters */: - return tryParseTypeParameter(); - case 21 /* TupleType_Types */: - return tryParseType(); - default: - throw TypeScript.Errors.invalidOperation(); + case 0 /* SourceUnit_ModuleElements */: return tryParseModuleElement(inErrorRecovery); + case 1 /* ClassDeclaration_ClassElements */: return tryParseClassElement(inErrorRecovery); + case 2 /* ModuleDeclaration_ModuleElements */: return tryParseModuleElement(inErrorRecovery); + case 3 /* SwitchStatement_SwitchClauses */: return tryParseSwitchClause(); + case 4 /* SwitchClause_Statements */: return tryParseStatement(inErrorRecovery); + case 5 /* Block_Statements */: return tryParseStatement(inErrorRecovery); + case 6 /* TryBlock_Statements */: return tryParseStatement(inErrorRecovery); + case 7 /* CatchBlock_Statements */: return tryParseStatement(inErrorRecovery); + case 8 /* EnumDeclaration_EnumElements */: return tryParseEnumElement(inErrorRecovery); + case 9 /* ObjectType_TypeMembers */: return tryParseTypeMember(inErrorRecovery); + case 10 /* ClassOrInterfaceDeclaration_HeritageClauses */: return tryParseHeritageClause(); + case 11 /* HeritageClause_TypeNameList */: return tryParseHeritageClauseTypeName(); + case 12 /* VariableDeclaration_VariableDeclarators_AllowIn */: return tryParseVariableDeclarator(true, false); + case 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */: return tryParseVariableDeclarator(false, false); + case 14 /* ArgumentList_AssignmentExpressions */: return tryParseArgumentListExpression(); + case 15 /* ObjectLiteralExpression_PropertyAssignments */: return tryParsePropertyAssignment(inErrorRecovery); + case 16 /* ArrayLiteralExpression_AssignmentExpressions */: return tryParseAssignmentOrOmittedExpression(); + case 17 /* ParameterList_Parameters */: return tryParseParameter(); + case 18 /* IndexSignature_Parameters */: return tryParseParameter(); + case 19 /* TypeArgumentList_Types */: return tryParseType(); + case 20 /* TypeParameterList_TypeParameters */: return tryParseTypeParameter(); + case 21 /* TupleType_Types */: return tryParseType(); + default: throw TypeScript.Errors.invalidOperation(); } } function getExpectedListElementType(currentListType) { switch (currentListType) { - case 0 /* SourceUnit_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - case 10 /* ClassOrInterfaceDeclaration_HeritageClauses */: - return '{'; - case 1 /* ClassDeclaration_ClassElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, null); - case 2 /* ModuleDeclaration_ModuleElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, null); - case 3 /* SwitchStatement_SwitchClauses */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, null); - case 4 /* SwitchClause_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - case 5 /* Block_Statements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, null); - case 12 /* VariableDeclaration_VariableDeclarators_AllowIn */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - case 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - case 8 /* EnumDeclaration_EnumElements */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, null); - case 9 /* ObjectType_TypeMembers */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, null); - case 14 /* ArgumentList_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - case 11 /* HeritageClause_TypeNameList */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, null); - case 15 /* ObjectLiteralExpression_PropertyAssignments */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, null); - case 17 /* ParameterList_Parameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); - case 18 /* IndexSignature_Parameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, null); - case 19 /* TypeArgumentList_Types */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); - case 20 /* TypeParameterList_TypeParameters */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null); - case 21 /* TupleType_Types */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null); - case 16 /* ArrayLiteralExpression_AssignmentExpressions */: - return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, null); - default: - throw TypeScript.Errors.invalidOperation(); + case 0 /* SourceUnit_ModuleElements */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, undefined); + case 10 /* ClassOrInterfaceDeclaration_HeritageClauses */: return '{'; + case 1 /* ClassDeclaration_ClassElements */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.constructor_function_accessor_or_variable, undefined); + case 2 /* ModuleDeclaration_ModuleElements */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.module_class_interface_enum_import_or_statement, undefined); + case 3 /* SwitchStatement_SwitchClauses */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.case_or_default_clause, undefined); + case 4 /* SwitchClause_Statements */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, undefined); + case 5 /* Block_Statements */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.statement, undefined); + case 12 /* VariableDeclaration_VariableDeclarators_AllowIn */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, undefined); + case 13 /* VariableDeclaration_VariableDeclarators_DisallowIn */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, undefined); + case 8 /* EnumDeclaration_EnumElements */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.identifier, undefined); + case 9 /* ObjectType_TypeMembers */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.call_construct_index_property_or_function_signature, undefined); + case 14 /* ArgumentList_AssignmentExpressions */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, undefined); + case 11 /* HeritageClause_TypeNameList */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_name, undefined); + case 15 /* ObjectLiteralExpression_PropertyAssignments */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.property_or_accessor, undefined); + case 17 /* ParameterList_Parameters */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, undefined); + case 18 /* IndexSignature_Parameters */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.parameter, undefined); + case 19 /* TypeArgumentList_Types */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, undefined); + case 20 /* TypeParameterList_TypeParameters */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, undefined); + case 21 /* TupleType_Types */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, undefined); + case 16 /* ArrayLiteralExpression_AssignmentExpressions */: return TypeScript.getLocalizedText(TypeScript.DiagnosticCode.expression, undefined); + default: throw TypeScript.Errors.invalidOperation(); } } return parseSyntaxTree; @@ -25307,810 +25518,922 @@ var TypeScript; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { - var Syntax; - (function (Syntax) { - var Concrete; - (function (Concrete) { - TypeScript.Parser.syntaxFactory = Concrete; - Concrete.isConcrete = true; - var SourceUnitSyntax = (function (_super) { - __extends(SourceUnitSyntax, _super); - function SourceUnitSyntax(data, moduleElements, endOfFileToken) { - _super.call(this, data); - this.syntaxTree = null; - this.parent = null, this.moduleElements = moduleElements, this.endOfFileToken = endOfFileToken, !TypeScript.isShared(moduleElements) && (moduleElements.parent = this), endOfFileToken.parent = this; - } - return SourceUnitSyntax; - })(TypeScript.SyntaxNode); - Concrete.SourceUnitSyntax = SourceUnitSyntax; - var QualifiedNameSyntax = (function (_super) { - __extends(QualifiedNameSyntax, _super); - function QualifiedNameSyntax(data, left, dotToken, right) { - _super.call(this, data); - this.left = left, this.dotToken = dotToken, this.right = right, left.parent = this, dotToken.parent = this, right.parent = this; - } - return QualifiedNameSyntax; - })(TypeScript.SyntaxNode); - Concrete.QualifiedNameSyntax = QualifiedNameSyntax; - var ObjectTypeSyntax = (function (_super) { - __extends(ObjectTypeSyntax, _super); - function ObjectTypeSyntax(data, openBraceToken, typeMembers, closeBraceToken) { - _super.call(this, data); - this.openBraceToken = openBraceToken, this.typeMembers = typeMembers, this.closeBraceToken = closeBraceToken, openBraceToken.parent = this, !TypeScript.isShared(typeMembers) && (typeMembers.parent = this), closeBraceToken.parent = this; - } - return ObjectTypeSyntax; - })(TypeScript.SyntaxNode); - Concrete.ObjectTypeSyntax = ObjectTypeSyntax; - var FunctionTypeSyntax = (function (_super) { - __extends(FunctionTypeSyntax, _super); - function FunctionTypeSyntax(data, typeParameterList, parameterList, equalsGreaterThanToken, type) { - _super.call(this, data); - this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.equalsGreaterThanToken = equalsGreaterThanToken, this.type = type, typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, equalsGreaterThanToken.parent = this, type.parent = this; - } - return FunctionTypeSyntax; - })(TypeScript.SyntaxNode); - Concrete.FunctionTypeSyntax = FunctionTypeSyntax; - var ArrayTypeSyntax = (function (_super) { - __extends(ArrayTypeSyntax, _super); - function ArrayTypeSyntax(data, type, openBracketToken, closeBracketToken) { - _super.call(this, data); - this.type = type, this.openBracketToken = openBracketToken, this.closeBracketToken = closeBracketToken, type.parent = this, openBracketToken.parent = this, closeBracketToken.parent = this; - } - return ArrayTypeSyntax; - })(TypeScript.SyntaxNode); - Concrete.ArrayTypeSyntax = ArrayTypeSyntax; - var ConstructorTypeSyntax = (function (_super) { - __extends(ConstructorTypeSyntax, _super); - function ConstructorTypeSyntax(data, newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { - _super.call(this, data); - this.newKeyword = newKeyword, this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.equalsGreaterThanToken = equalsGreaterThanToken, this.type = type, newKeyword.parent = this, typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, equalsGreaterThanToken.parent = this, type.parent = this; - } - return ConstructorTypeSyntax; - })(TypeScript.SyntaxNode); - Concrete.ConstructorTypeSyntax = ConstructorTypeSyntax; - var GenericTypeSyntax = (function (_super) { - __extends(GenericTypeSyntax, _super); - function GenericTypeSyntax(data, name, typeArgumentList) { - _super.call(this, data); - this.name = name, this.typeArgumentList = typeArgumentList, name.parent = this, typeArgumentList.parent = this; - } - return GenericTypeSyntax; - })(TypeScript.SyntaxNode); - Concrete.GenericTypeSyntax = GenericTypeSyntax; - var TypeQuerySyntax = (function (_super) { - __extends(TypeQuerySyntax, _super); - function TypeQuerySyntax(data, typeOfKeyword, name) { - _super.call(this, data); - this.typeOfKeyword = typeOfKeyword, this.name = name, typeOfKeyword.parent = this, name.parent = this; - } - return TypeQuerySyntax; - })(TypeScript.SyntaxNode); - Concrete.TypeQuerySyntax = TypeQuerySyntax; - var TupleTypeSyntax = (function (_super) { - __extends(TupleTypeSyntax, _super); - function TupleTypeSyntax(data, openBracketToken, types, closeBracketToken) { - _super.call(this, data); - this.openBracketToken = openBracketToken, this.types = types, this.closeBracketToken = closeBracketToken, openBracketToken.parent = this, !TypeScript.isShared(types) && (types.parent = this), closeBracketToken.parent = this; - } - return TupleTypeSyntax; - })(TypeScript.SyntaxNode); - Concrete.TupleTypeSyntax = TupleTypeSyntax; - var InterfaceDeclarationSyntax = (function (_super) { - __extends(InterfaceDeclarationSyntax, _super); - function InterfaceDeclarationSyntax(data, modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { - _super.call(this, data); - this.modifiers = modifiers, this.interfaceKeyword = interfaceKeyword, this.identifier = identifier, this.typeParameterList = typeParameterList, this.heritageClauses = heritageClauses, this.body = body, !TypeScript.isShared(modifiers) && (modifiers.parent = this), interfaceKeyword.parent = this, identifier.parent = this, typeParameterList && (typeParameterList.parent = this), !TypeScript.isShared(heritageClauses) && (heritageClauses.parent = this), body.parent = this; - } - return InterfaceDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.InterfaceDeclarationSyntax = InterfaceDeclarationSyntax; - var FunctionDeclarationSyntax = (function (_super) { - __extends(FunctionDeclarationSyntax, _super); - function FunctionDeclarationSyntax(data, modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { - _super.call(this, data); - this.modifiers = modifiers, this.functionKeyword = functionKeyword, this.identifier = identifier, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), functionKeyword.parent = this, identifier.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this); - } - return FunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.FunctionDeclarationSyntax = FunctionDeclarationSyntax; - var ModuleDeclarationSyntax = (function (_super) { - __extends(ModuleDeclarationSyntax, _super); - function ModuleDeclarationSyntax(data, modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { - _super.call(this, data); - this.modifiers = modifiers, this.moduleKeyword = moduleKeyword, this.name = name, this.stringLiteral = stringLiteral, this.openBraceToken = openBraceToken, this.moduleElements = moduleElements, this.closeBraceToken = closeBraceToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), moduleKeyword.parent = this, name && (name.parent = this), stringLiteral && (stringLiteral.parent = this), openBraceToken.parent = this, !TypeScript.isShared(moduleElements) && (moduleElements.parent = this), closeBraceToken.parent = this; - } - return ModuleDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.ModuleDeclarationSyntax = ModuleDeclarationSyntax; - var ClassDeclarationSyntax = (function (_super) { - __extends(ClassDeclarationSyntax, _super); - function ClassDeclarationSyntax(data, modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { - _super.call(this, data); - this.modifiers = modifiers, this.classKeyword = classKeyword, this.identifier = identifier, this.typeParameterList = typeParameterList, this.heritageClauses = heritageClauses, this.openBraceToken = openBraceToken, this.classElements = classElements, this.closeBraceToken = closeBraceToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), classKeyword.parent = this, identifier.parent = this, typeParameterList && (typeParameterList.parent = this), !TypeScript.isShared(heritageClauses) && (heritageClauses.parent = this), openBraceToken.parent = this, !TypeScript.isShared(classElements) && (classElements.parent = this), closeBraceToken.parent = this; - } - return ClassDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.ClassDeclarationSyntax = ClassDeclarationSyntax; - var EnumDeclarationSyntax = (function (_super) { - __extends(EnumDeclarationSyntax, _super); - function EnumDeclarationSyntax(data, modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { - _super.call(this, data); - this.modifiers = modifiers, this.enumKeyword = enumKeyword, this.identifier = identifier, this.openBraceToken = openBraceToken, this.enumElements = enumElements, this.closeBraceToken = closeBraceToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), enumKeyword.parent = this, identifier.parent = this, openBraceToken.parent = this, !TypeScript.isShared(enumElements) && (enumElements.parent = this), closeBraceToken.parent = this; - } - return EnumDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.EnumDeclarationSyntax = EnumDeclarationSyntax; - var ImportDeclarationSyntax = (function (_super) { - __extends(ImportDeclarationSyntax, _super); - function ImportDeclarationSyntax(data, modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { - _super.call(this, data); - this.modifiers = modifiers, this.importKeyword = importKeyword, this.identifier = identifier, this.equalsToken = equalsToken, this.moduleReference = moduleReference, this.semicolonToken = semicolonToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), importKeyword.parent = this, identifier.parent = this, equalsToken.parent = this, moduleReference.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return ImportDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.ImportDeclarationSyntax = ImportDeclarationSyntax; - var ExportAssignmentSyntax = (function (_super) { - __extends(ExportAssignmentSyntax, _super); - function ExportAssignmentSyntax(data, exportKeyword, equalsToken, identifier, semicolonToken) { - _super.call(this, data); - this.exportKeyword = exportKeyword, this.equalsToken = equalsToken, this.identifier = identifier, this.semicolonToken = semicolonToken, exportKeyword.parent = this, equalsToken.parent = this, identifier.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return ExportAssignmentSyntax; - })(TypeScript.SyntaxNode); - Concrete.ExportAssignmentSyntax = ExportAssignmentSyntax; - var MemberFunctionDeclarationSyntax = (function (_super) { - __extends(MemberFunctionDeclarationSyntax, _super); - function MemberFunctionDeclarationSyntax(data, modifiers, propertyName, callSignature, block, semicolonToken) { - _super.call(this, data); - this.modifiers = modifiers, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), propertyName.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this); - } - return MemberFunctionDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.MemberFunctionDeclarationSyntax = MemberFunctionDeclarationSyntax; - var MemberVariableDeclarationSyntax = (function (_super) { - __extends(MemberVariableDeclarationSyntax, _super); - function MemberVariableDeclarationSyntax(data, modifiers, variableDeclarator, semicolonToken) { - _super.call(this, data); - this.modifiers = modifiers, this.variableDeclarator = variableDeclarator, this.semicolonToken = semicolonToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), variableDeclarator.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return MemberVariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.MemberVariableDeclarationSyntax = MemberVariableDeclarationSyntax; - var ConstructorDeclarationSyntax = (function (_super) { - __extends(ConstructorDeclarationSyntax, _super); - function ConstructorDeclarationSyntax(data, modifiers, constructorKeyword, callSignature, block, semicolonToken) { - _super.call(this, data); - this.modifiers = modifiers, this.constructorKeyword = constructorKeyword, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), constructorKeyword.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this); - } - return ConstructorDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.ConstructorDeclarationSyntax = ConstructorDeclarationSyntax; - var IndexMemberDeclarationSyntax = (function (_super) { - __extends(IndexMemberDeclarationSyntax, _super); - function IndexMemberDeclarationSyntax(data, modifiers, indexSignature, semicolonToken) { - _super.call(this, data); - this.modifiers = modifiers, this.indexSignature = indexSignature, this.semicolonToken = semicolonToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), indexSignature.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return IndexMemberDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.IndexMemberDeclarationSyntax = IndexMemberDeclarationSyntax; - var GetAccessorSyntax = (function (_super) { - __extends(GetAccessorSyntax, _super); - function GetAccessorSyntax(data, modifiers, getKeyword, propertyName, callSignature, block) { - _super.call(this, data); - this.modifiers = modifiers, this.getKeyword = getKeyword, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block, !TypeScript.isShared(modifiers) && (modifiers.parent = this), getKeyword.parent = this, propertyName.parent = this, callSignature.parent = this, block.parent = this; - } - return GetAccessorSyntax; - })(TypeScript.SyntaxNode); - Concrete.GetAccessorSyntax = GetAccessorSyntax; - var SetAccessorSyntax = (function (_super) { - __extends(SetAccessorSyntax, _super); - function SetAccessorSyntax(data, modifiers, setKeyword, propertyName, callSignature, block) { - _super.call(this, data); - this.modifiers = modifiers, this.setKeyword = setKeyword, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block, !TypeScript.isShared(modifiers) && (modifiers.parent = this), setKeyword.parent = this, propertyName.parent = this, callSignature.parent = this, block.parent = this; - } - return SetAccessorSyntax; - })(TypeScript.SyntaxNode); - Concrete.SetAccessorSyntax = SetAccessorSyntax; - var PropertySignatureSyntax = (function (_super) { - __extends(PropertySignatureSyntax, _super); - function PropertySignatureSyntax(data, propertyName, questionToken, typeAnnotation) { - _super.call(this, data); - this.propertyName = propertyName, this.questionToken = questionToken, this.typeAnnotation = typeAnnotation, propertyName.parent = this, questionToken && (questionToken.parent = this), typeAnnotation && (typeAnnotation.parent = this); - } - return PropertySignatureSyntax; - })(TypeScript.SyntaxNode); - Concrete.PropertySignatureSyntax = PropertySignatureSyntax; - var CallSignatureSyntax = (function (_super) { - __extends(CallSignatureSyntax, _super); - function CallSignatureSyntax(data, typeParameterList, parameterList, typeAnnotation) { - _super.call(this, data); - this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.typeAnnotation = typeAnnotation, typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, typeAnnotation && (typeAnnotation.parent = this); - } - return CallSignatureSyntax; - })(TypeScript.SyntaxNode); - Concrete.CallSignatureSyntax = CallSignatureSyntax; - var ConstructSignatureSyntax = (function (_super) { - __extends(ConstructSignatureSyntax, _super); - function ConstructSignatureSyntax(data, newKeyword, callSignature) { - _super.call(this, data); - this.newKeyword = newKeyword, this.callSignature = callSignature, newKeyword.parent = this, callSignature.parent = this; - } - return ConstructSignatureSyntax; - })(TypeScript.SyntaxNode); - Concrete.ConstructSignatureSyntax = ConstructSignatureSyntax; - var IndexSignatureSyntax = (function (_super) { - __extends(IndexSignatureSyntax, _super); - function IndexSignatureSyntax(data, openBracketToken, parameters, closeBracketToken, typeAnnotation) { - _super.call(this, data); - this.openBracketToken = openBracketToken, this.parameters = parameters, this.closeBracketToken = closeBracketToken, this.typeAnnotation = typeAnnotation, openBracketToken.parent = this, !TypeScript.isShared(parameters) && (parameters.parent = this), closeBracketToken.parent = this, typeAnnotation && (typeAnnotation.parent = this); - } - return IndexSignatureSyntax; - })(TypeScript.SyntaxNode); - Concrete.IndexSignatureSyntax = IndexSignatureSyntax; - var MethodSignatureSyntax = (function (_super) { - __extends(MethodSignatureSyntax, _super); - function MethodSignatureSyntax(data, propertyName, questionToken, callSignature) { - _super.call(this, data); - this.propertyName = propertyName, this.questionToken = questionToken, this.callSignature = callSignature, propertyName.parent = this, questionToken && (questionToken.parent = this), callSignature.parent = this; - } - return MethodSignatureSyntax; - })(TypeScript.SyntaxNode); - Concrete.MethodSignatureSyntax = MethodSignatureSyntax; - var BlockSyntax = (function (_super) { - __extends(BlockSyntax, _super); - function BlockSyntax(data, openBraceToken, statements, closeBraceToken) { - _super.call(this, data); - this.openBraceToken = openBraceToken, this.statements = statements, this.closeBraceToken = closeBraceToken, openBraceToken.parent = this, !TypeScript.isShared(statements) && (statements.parent = this), closeBraceToken.parent = this; - } - return BlockSyntax; - })(TypeScript.SyntaxNode); - Concrete.BlockSyntax = BlockSyntax; - var IfStatementSyntax = (function (_super) { - __extends(IfStatementSyntax, _super); - function IfStatementSyntax(data, ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { - _super.call(this, data); - this.ifKeyword = ifKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement, this.elseClause = elseClause, ifKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this, elseClause && (elseClause.parent = this); - } - return IfStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.IfStatementSyntax = IfStatementSyntax; - var VariableStatementSyntax = (function (_super) { - __extends(VariableStatementSyntax, _super); - function VariableStatementSyntax(data, modifiers, variableDeclaration, semicolonToken) { - _super.call(this, data); - this.modifiers = modifiers, this.variableDeclaration = variableDeclaration, this.semicolonToken = semicolonToken, !TypeScript.isShared(modifiers) && (modifiers.parent = this), variableDeclaration.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return VariableStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.VariableStatementSyntax = VariableStatementSyntax; - var ExpressionStatementSyntax = (function (_super) { - __extends(ExpressionStatementSyntax, _super); - function ExpressionStatementSyntax(data, expression, semicolonToken) { - _super.call(this, data); - this.expression = expression, this.semicolonToken = semicolonToken, expression.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return ExpressionStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.ExpressionStatementSyntax = ExpressionStatementSyntax; - var ReturnStatementSyntax = (function (_super) { - __extends(ReturnStatementSyntax, _super); - function ReturnStatementSyntax(data, returnKeyword, expression, semicolonToken) { - _super.call(this, data); - this.returnKeyword = returnKeyword, this.expression = expression, this.semicolonToken = semicolonToken, returnKeyword.parent = this, expression && (expression.parent = this), semicolonToken && (semicolonToken.parent = this); - } - return ReturnStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.ReturnStatementSyntax = ReturnStatementSyntax; - var SwitchStatementSyntax = (function (_super) { - __extends(SwitchStatementSyntax, _super); - function SwitchStatementSyntax(data, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { - _super.call(this, data); - this.switchKeyword = switchKeyword, this.openParenToken = openParenToken, this.expression = expression, this.closeParenToken = closeParenToken, this.openBraceToken = openBraceToken, this.switchClauses = switchClauses, this.closeBraceToken = closeBraceToken, switchKeyword.parent = this, openParenToken.parent = this, expression.parent = this, closeParenToken.parent = this, openBraceToken.parent = this, !TypeScript.isShared(switchClauses) && (switchClauses.parent = this), closeBraceToken.parent = this; - } - return SwitchStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.SwitchStatementSyntax = SwitchStatementSyntax; - var BreakStatementSyntax = (function (_super) { - __extends(BreakStatementSyntax, _super); - function BreakStatementSyntax(data, breakKeyword, identifier, semicolonToken) { - _super.call(this, data); - this.breakKeyword = breakKeyword, this.identifier = identifier, this.semicolonToken = semicolonToken, breakKeyword.parent = this, identifier && (identifier.parent = this), semicolonToken && (semicolonToken.parent = this); - } - return BreakStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.BreakStatementSyntax = BreakStatementSyntax; - var ContinueStatementSyntax = (function (_super) { - __extends(ContinueStatementSyntax, _super); - function ContinueStatementSyntax(data, continueKeyword, identifier, semicolonToken) { - _super.call(this, data); - this.continueKeyword = continueKeyword, this.identifier = identifier, this.semicolonToken = semicolonToken, continueKeyword.parent = this, identifier && (identifier.parent = this), semicolonToken && (semicolonToken.parent = this); - } - return ContinueStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.ContinueStatementSyntax = ContinueStatementSyntax; - var ForStatementSyntax = (function (_super) { - __extends(ForStatementSyntax, _super); - function ForStatementSyntax(data, forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { - _super.call(this, data); - this.forKeyword = forKeyword, this.openParenToken = openParenToken, this.variableDeclaration = variableDeclaration, this.initializer = initializer, this.firstSemicolonToken = firstSemicolonToken, this.condition = condition, this.secondSemicolonToken = secondSemicolonToken, this.incrementor = incrementor, this.closeParenToken = closeParenToken, this.statement = statement, forKeyword.parent = this, openParenToken.parent = this, variableDeclaration && (variableDeclaration.parent = this), initializer && (initializer.parent = this), firstSemicolonToken.parent = this, condition && (condition.parent = this), secondSemicolonToken.parent = this, incrementor && (incrementor.parent = this), closeParenToken.parent = this, statement.parent = this; - } - return ForStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.ForStatementSyntax = ForStatementSyntax; - var ForInStatementSyntax = (function (_super) { - __extends(ForInStatementSyntax, _super); - function ForInStatementSyntax(data, forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { - _super.call(this, data); - this.forKeyword = forKeyword, this.openParenToken = openParenToken, this.variableDeclaration = variableDeclaration, this.left = left, this.inKeyword = inKeyword, this.expression = expression, this.closeParenToken = closeParenToken, this.statement = statement, forKeyword.parent = this, openParenToken.parent = this, variableDeclaration && (variableDeclaration.parent = this), left && (left.parent = this), inKeyword.parent = this, expression.parent = this, closeParenToken.parent = this, statement.parent = this; - } - return ForInStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.ForInStatementSyntax = ForInStatementSyntax; - var EmptyStatementSyntax = (function (_super) { - __extends(EmptyStatementSyntax, _super); - function EmptyStatementSyntax(data, semicolonToken) { - _super.call(this, data); - this.semicolonToken = semicolonToken, semicolonToken.parent = this; - } - return EmptyStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.EmptyStatementSyntax = EmptyStatementSyntax; - var ThrowStatementSyntax = (function (_super) { - __extends(ThrowStatementSyntax, _super); - function ThrowStatementSyntax(data, throwKeyword, expression, semicolonToken) { - _super.call(this, data); - this.throwKeyword = throwKeyword, this.expression = expression, this.semicolonToken = semicolonToken, throwKeyword.parent = this, expression.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return ThrowStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.ThrowStatementSyntax = ThrowStatementSyntax; - var WhileStatementSyntax = (function (_super) { - __extends(WhileStatementSyntax, _super); - function WhileStatementSyntax(data, whileKeyword, openParenToken, condition, closeParenToken, statement) { - _super.call(this, data); - this.whileKeyword = whileKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement, whileKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this; - } - return WhileStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.WhileStatementSyntax = WhileStatementSyntax; - var TryStatementSyntax = (function (_super) { - __extends(TryStatementSyntax, _super); - function TryStatementSyntax(data, tryKeyword, block, catchClause, finallyClause) { - _super.call(this, data); - this.tryKeyword = tryKeyword, this.block = block, this.catchClause = catchClause, this.finallyClause = finallyClause, tryKeyword.parent = this, block.parent = this, catchClause && (catchClause.parent = this), finallyClause && (finallyClause.parent = this); - } - return TryStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.TryStatementSyntax = TryStatementSyntax; - var LabeledStatementSyntax = (function (_super) { - __extends(LabeledStatementSyntax, _super); - function LabeledStatementSyntax(data, identifier, colonToken, statement) { - _super.call(this, data); - this.identifier = identifier, this.colonToken = colonToken, this.statement = statement, identifier.parent = this, colonToken.parent = this, statement.parent = this; - } - return LabeledStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.LabeledStatementSyntax = LabeledStatementSyntax; - var DoStatementSyntax = (function (_super) { - __extends(DoStatementSyntax, _super); - function DoStatementSyntax(data, doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { - _super.call(this, data); - this.doKeyword = doKeyword, this.statement = statement, this.whileKeyword = whileKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.semicolonToken = semicolonToken, doKeyword.parent = this, statement.parent = this, whileKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return DoStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.DoStatementSyntax = DoStatementSyntax; - var DebuggerStatementSyntax = (function (_super) { - __extends(DebuggerStatementSyntax, _super); - function DebuggerStatementSyntax(data, debuggerKeyword, semicolonToken) { - _super.call(this, data); - this.debuggerKeyword = debuggerKeyword, this.semicolonToken = semicolonToken, debuggerKeyword.parent = this, semicolonToken && (semicolonToken.parent = this); - } - return DebuggerStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.DebuggerStatementSyntax = DebuggerStatementSyntax; - var WithStatementSyntax = (function (_super) { - __extends(WithStatementSyntax, _super); - function WithStatementSyntax(data, withKeyword, openParenToken, condition, closeParenToken, statement) { - _super.call(this, data); - this.withKeyword = withKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement, withKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this; - } - return WithStatementSyntax; - })(TypeScript.SyntaxNode); - Concrete.WithStatementSyntax = WithStatementSyntax; - var PrefixUnaryExpressionSyntax = (function (_super) { - __extends(PrefixUnaryExpressionSyntax, _super); - function PrefixUnaryExpressionSyntax(data, operatorToken, operand) { - _super.call(this, data); - this.operatorToken = operatorToken, this.operand = operand, operatorToken.parent = this, operand.parent = this; - } - PrefixUnaryExpressionSyntax.prototype.kind = function () { - return TypeScript.SyntaxFacts.getPrefixUnaryExpressionFromOperatorToken(this.operatorToken.kind()); - }; - return PrefixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.PrefixUnaryExpressionSyntax = PrefixUnaryExpressionSyntax; - var DeleteExpressionSyntax = (function (_super) { - __extends(DeleteExpressionSyntax, _super); - function DeleteExpressionSyntax(data, deleteKeyword, expression) { - _super.call(this, data); - this.deleteKeyword = deleteKeyword, this.expression = expression, deleteKeyword.parent = this, expression.parent = this; - } - return DeleteExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.DeleteExpressionSyntax = DeleteExpressionSyntax; - var TypeOfExpressionSyntax = (function (_super) { - __extends(TypeOfExpressionSyntax, _super); - function TypeOfExpressionSyntax(data, typeOfKeyword, expression) { - _super.call(this, data); - this.typeOfKeyword = typeOfKeyword, this.expression = expression, typeOfKeyword.parent = this, expression.parent = this; - } - return TypeOfExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.TypeOfExpressionSyntax = TypeOfExpressionSyntax; - var VoidExpressionSyntax = (function (_super) { - __extends(VoidExpressionSyntax, _super); - function VoidExpressionSyntax(data, voidKeyword, expression) { - _super.call(this, data); - this.voidKeyword = voidKeyword, this.expression = expression, voidKeyword.parent = this, expression.parent = this; - } - return VoidExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.VoidExpressionSyntax = VoidExpressionSyntax; - var ConditionalExpressionSyntax = (function (_super) { - __extends(ConditionalExpressionSyntax, _super); - function ConditionalExpressionSyntax(data, condition, questionToken, whenTrue, colonToken, whenFalse) { - _super.call(this, data); - this.condition = condition, this.questionToken = questionToken, this.whenTrue = whenTrue, this.colonToken = colonToken, this.whenFalse = whenFalse, condition.parent = this, questionToken.parent = this, whenTrue.parent = this, colonToken.parent = this, whenFalse.parent = this; - } - return ConditionalExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.ConditionalExpressionSyntax = ConditionalExpressionSyntax; - var BinaryExpressionSyntax = (function (_super) { - __extends(BinaryExpressionSyntax, _super); - function BinaryExpressionSyntax(data, left, operatorToken, right) { - _super.call(this, data); - this.left = left, this.operatorToken = operatorToken, this.right = right, left.parent = this, operatorToken.parent = this, right.parent = this; - } - BinaryExpressionSyntax.prototype.kind = function () { - return TypeScript.SyntaxFacts.getBinaryExpressionFromOperatorToken(this.operatorToken.kind()); - }; - return BinaryExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.BinaryExpressionSyntax = BinaryExpressionSyntax; - var PostfixUnaryExpressionSyntax = (function (_super) { - __extends(PostfixUnaryExpressionSyntax, _super); - function PostfixUnaryExpressionSyntax(data, operand, operatorToken) { - _super.call(this, data); - this.operand = operand, this.operatorToken = operatorToken, operand.parent = this, operatorToken.parent = this; - } - PostfixUnaryExpressionSyntax.prototype.kind = function () { - return TypeScript.SyntaxFacts.getPostfixUnaryExpressionFromOperatorToken(this.operatorToken.kind()); - }; - return PostfixUnaryExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.PostfixUnaryExpressionSyntax = PostfixUnaryExpressionSyntax; - var MemberAccessExpressionSyntax = (function (_super) { - __extends(MemberAccessExpressionSyntax, _super); - function MemberAccessExpressionSyntax(data, expression, dotToken, name) { - _super.call(this, data); - this.expression = expression, this.dotToken = dotToken, this.name = name, expression.parent = this, dotToken.parent = this, name.parent = this; - } - return MemberAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.MemberAccessExpressionSyntax = MemberAccessExpressionSyntax; - var InvocationExpressionSyntax = (function (_super) { - __extends(InvocationExpressionSyntax, _super); - function InvocationExpressionSyntax(data, expression, argumentList) { - _super.call(this, data); - this.expression = expression, this.argumentList = argumentList, expression.parent = this, argumentList.parent = this; - } - return InvocationExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.InvocationExpressionSyntax = InvocationExpressionSyntax; - var ArrayLiteralExpressionSyntax = (function (_super) { - __extends(ArrayLiteralExpressionSyntax, _super); - function ArrayLiteralExpressionSyntax(data, openBracketToken, expressions, closeBracketToken) { - _super.call(this, data); - this.openBracketToken = openBracketToken, this.expressions = expressions, this.closeBracketToken = closeBracketToken, openBracketToken.parent = this, !TypeScript.isShared(expressions) && (expressions.parent = this), closeBracketToken.parent = this; - } - return ArrayLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.ArrayLiteralExpressionSyntax = ArrayLiteralExpressionSyntax; - var ObjectLiteralExpressionSyntax = (function (_super) { - __extends(ObjectLiteralExpressionSyntax, _super); - function ObjectLiteralExpressionSyntax(data, openBraceToken, propertyAssignments, closeBraceToken) { - _super.call(this, data); - this.openBraceToken = openBraceToken, this.propertyAssignments = propertyAssignments, this.closeBraceToken = closeBraceToken, openBraceToken.parent = this, !TypeScript.isShared(propertyAssignments) && (propertyAssignments.parent = this), closeBraceToken.parent = this; - } - return ObjectLiteralExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.ObjectLiteralExpressionSyntax = ObjectLiteralExpressionSyntax; - var ObjectCreationExpressionSyntax = (function (_super) { - __extends(ObjectCreationExpressionSyntax, _super); - function ObjectCreationExpressionSyntax(data, newKeyword, expression, argumentList) { - _super.call(this, data); - this.newKeyword = newKeyword, this.expression = expression, this.argumentList = argumentList, newKeyword.parent = this, expression.parent = this, argumentList && (argumentList.parent = this); - } - return ObjectCreationExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.ObjectCreationExpressionSyntax = ObjectCreationExpressionSyntax; - var ParenthesizedExpressionSyntax = (function (_super) { - __extends(ParenthesizedExpressionSyntax, _super); - function ParenthesizedExpressionSyntax(data, openParenToken, expression, closeParenToken) { - _super.call(this, data); - this.openParenToken = openParenToken, this.expression = expression, this.closeParenToken = closeParenToken, openParenToken.parent = this, expression.parent = this, closeParenToken.parent = this; - } - return ParenthesizedExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.ParenthesizedExpressionSyntax = ParenthesizedExpressionSyntax; - var ParenthesizedArrowFunctionExpressionSyntax = (function (_super) { - __extends(ParenthesizedArrowFunctionExpressionSyntax, _super); - function ParenthesizedArrowFunctionExpressionSyntax(data, callSignature, equalsGreaterThanToken, block, expression) { - _super.call(this, data); - this.callSignature = callSignature, this.equalsGreaterThanToken = equalsGreaterThanToken, this.block = block, this.expression = expression, callSignature.parent = this, equalsGreaterThanToken.parent = this, block && (block.parent = this), expression && (expression.parent = this); - } - return ParenthesizedArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.ParenthesizedArrowFunctionExpressionSyntax = ParenthesizedArrowFunctionExpressionSyntax; - var SimpleArrowFunctionExpressionSyntax = (function (_super) { - __extends(SimpleArrowFunctionExpressionSyntax, _super); - function SimpleArrowFunctionExpressionSyntax(data, parameter, equalsGreaterThanToken, block, expression) { - _super.call(this, data); - this.parameter = parameter, this.equalsGreaterThanToken = equalsGreaterThanToken, this.block = block, this.expression = expression, parameter.parent = this, equalsGreaterThanToken.parent = this, block && (block.parent = this), expression && (expression.parent = this); - } - return SimpleArrowFunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.SimpleArrowFunctionExpressionSyntax = SimpleArrowFunctionExpressionSyntax; - var CastExpressionSyntax = (function (_super) { - __extends(CastExpressionSyntax, _super); - function CastExpressionSyntax(data, lessThanToken, type, greaterThanToken, expression) { - _super.call(this, data); - this.lessThanToken = lessThanToken, this.type = type, this.greaterThanToken = greaterThanToken, this.expression = expression, lessThanToken.parent = this, type.parent = this, greaterThanToken.parent = this, expression.parent = this; - } - return CastExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.CastExpressionSyntax = CastExpressionSyntax; - var ElementAccessExpressionSyntax = (function (_super) { - __extends(ElementAccessExpressionSyntax, _super); - function ElementAccessExpressionSyntax(data, expression, openBracketToken, argumentExpression, closeBracketToken) { - _super.call(this, data); - this.expression = expression, this.openBracketToken = openBracketToken, this.argumentExpression = argumentExpression, this.closeBracketToken = closeBracketToken, expression.parent = this, openBracketToken.parent = this, argumentExpression.parent = this, closeBracketToken.parent = this; - } - return ElementAccessExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.ElementAccessExpressionSyntax = ElementAccessExpressionSyntax; - var FunctionExpressionSyntax = (function (_super) { - __extends(FunctionExpressionSyntax, _super); - function FunctionExpressionSyntax(data, functionKeyword, identifier, callSignature, block) { - _super.call(this, data); - this.functionKeyword = functionKeyword, this.identifier = identifier, this.callSignature = callSignature, this.block = block, functionKeyword.parent = this, identifier && (identifier.parent = this), callSignature.parent = this, block.parent = this; - } - return FunctionExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.FunctionExpressionSyntax = FunctionExpressionSyntax; - var OmittedExpressionSyntax = (function (_super) { - __extends(OmittedExpressionSyntax, _super); - function OmittedExpressionSyntax(data) { - _super.call(this, data); - } - return OmittedExpressionSyntax; - })(TypeScript.SyntaxNode); - Concrete.OmittedExpressionSyntax = OmittedExpressionSyntax; - var VariableDeclarationSyntax = (function (_super) { - __extends(VariableDeclarationSyntax, _super); - function VariableDeclarationSyntax(data, varKeyword, variableDeclarators) { - _super.call(this, data); - this.varKeyword = varKeyword, this.variableDeclarators = variableDeclarators, varKeyword.parent = this, !TypeScript.isShared(variableDeclarators) && (variableDeclarators.parent = this); - } - return VariableDeclarationSyntax; - })(TypeScript.SyntaxNode); - Concrete.VariableDeclarationSyntax = VariableDeclarationSyntax; - var VariableDeclaratorSyntax = (function (_super) { - __extends(VariableDeclaratorSyntax, _super); - function VariableDeclaratorSyntax(data, propertyName, typeAnnotation, equalsValueClause) { - _super.call(this, data); - this.propertyName = propertyName, this.typeAnnotation = typeAnnotation, this.equalsValueClause = equalsValueClause, propertyName.parent = this, typeAnnotation && (typeAnnotation.parent = this), equalsValueClause && (equalsValueClause.parent = this); - } - return VariableDeclaratorSyntax; - })(TypeScript.SyntaxNode); - Concrete.VariableDeclaratorSyntax = VariableDeclaratorSyntax; - var ArgumentListSyntax = (function (_super) { - __extends(ArgumentListSyntax, _super); - function ArgumentListSyntax(data, typeArgumentList, openParenToken, _arguments, closeParenToken) { - _super.call(this, data); - this.typeArgumentList = typeArgumentList, this.openParenToken = openParenToken, this.arguments = _arguments, this.closeParenToken = closeParenToken, typeArgumentList && (typeArgumentList.parent = this), openParenToken.parent = this, !TypeScript.isShared(_arguments) && (_arguments.parent = this), closeParenToken.parent = this; - } - return ArgumentListSyntax; - })(TypeScript.SyntaxNode); - Concrete.ArgumentListSyntax = ArgumentListSyntax; - var ParameterListSyntax = (function (_super) { - __extends(ParameterListSyntax, _super); - function ParameterListSyntax(data, openParenToken, parameters, closeParenToken) { - _super.call(this, data); - this.openParenToken = openParenToken, this.parameters = parameters, this.closeParenToken = closeParenToken, openParenToken.parent = this, !TypeScript.isShared(parameters) && (parameters.parent = this), closeParenToken.parent = this; - } - return ParameterListSyntax; - })(TypeScript.SyntaxNode); - Concrete.ParameterListSyntax = ParameterListSyntax; - var TypeArgumentListSyntax = (function (_super) { - __extends(TypeArgumentListSyntax, _super); - function TypeArgumentListSyntax(data, lessThanToken, typeArguments, greaterThanToken) { - _super.call(this, data); - this.lessThanToken = lessThanToken, this.typeArguments = typeArguments, this.greaterThanToken = greaterThanToken, lessThanToken.parent = this, !TypeScript.isShared(typeArguments) && (typeArguments.parent = this), greaterThanToken.parent = this; - } - return TypeArgumentListSyntax; - })(TypeScript.SyntaxNode); - Concrete.TypeArgumentListSyntax = TypeArgumentListSyntax; - var TypeParameterListSyntax = (function (_super) { - __extends(TypeParameterListSyntax, _super); - function TypeParameterListSyntax(data, lessThanToken, typeParameters, greaterThanToken) { - _super.call(this, data); - this.lessThanToken = lessThanToken, this.typeParameters = typeParameters, this.greaterThanToken = greaterThanToken, lessThanToken.parent = this, !TypeScript.isShared(typeParameters) && (typeParameters.parent = this), greaterThanToken.parent = this; - } - return TypeParameterListSyntax; - })(TypeScript.SyntaxNode); - Concrete.TypeParameterListSyntax = TypeParameterListSyntax; - var HeritageClauseSyntax = (function (_super) { - __extends(HeritageClauseSyntax, _super); - function HeritageClauseSyntax(data, extendsOrImplementsKeyword, typeNames) { - _super.call(this, data); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword, this.typeNames = typeNames, extendsOrImplementsKeyword.parent = this, !TypeScript.isShared(typeNames) && (typeNames.parent = this); - } - HeritageClauseSyntax.prototype.kind = function () { - return this.extendsOrImplementsKeyword.kind() === 48 /* ExtendsKeyword */ ? 231 /* ExtendsHeritageClause */ : 232 /* ImplementsHeritageClause */; - }; - return HeritageClauseSyntax; - })(TypeScript.SyntaxNode); - Concrete.HeritageClauseSyntax = HeritageClauseSyntax; - var EqualsValueClauseSyntax = (function (_super) { - __extends(EqualsValueClauseSyntax, _super); - function EqualsValueClauseSyntax(data, equalsToken, value) { - _super.call(this, data); - this.equalsToken = equalsToken, this.value = value, equalsToken.parent = this, value.parent = this; - } - return EqualsValueClauseSyntax; - })(TypeScript.SyntaxNode); - Concrete.EqualsValueClauseSyntax = EqualsValueClauseSyntax; - var CaseSwitchClauseSyntax = (function (_super) { - __extends(CaseSwitchClauseSyntax, _super); - function CaseSwitchClauseSyntax(data, caseKeyword, expression, colonToken, statements) { - _super.call(this, data); - this.caseKeyword = caseKeyword, this.expression = expression, this.colonToken = colonToken, this.statements = statements, caseKeyword.parent = this, expression.parent = this, colonToken.parent = this, !TypeScript.isShared(statements) && (statements.parent = this); - } - return CaseSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - Concrete.CaseSwitchClauseSyntax = CaseSwitchClauseSyntax; - var DefaultSwitchClauseSyntax = (function (_super) { - __extends(DefaultSwitchClauseSyntax, _super); - function DefaultSwitchClauseSyntax(data, defaultKeyword, colonToken, statements) { - _super.call(this, data); - this.defaultKeyword = defaultKeyword, this.colonToken = colonToken, this.statements = statements, defaultKeyword.parent = this, colonToken.parent = this, !TypeScript.isShared(statements) && (statements.parent = this); - } - return DefaultSwitchClauseSyntax; - })(TypeScript.SyntaxNode); - Concrete.DefaultSwitchClauseSyntax = DefaultSwitchClauseSyntax; - var ElseClauseSyntax = (function (_super) { - __extends(ElseClauseSyntax, _super); - function ElseClauseSyntax(data, elseKeyword, statement) { - _super.call(this, data); - this.elseKeyword = elseKeyword, this.statement = statement, elseKeyword.parent = this, statement.parent = this; - } - return ElseClauseSyntax; - })(TypeScript.SyntaxNode); - Concrete.ElseClauseSyntax = ElseClauseSyntax; - var CatchClauseSyntax = (function (_super) { - __extends(CatchClauseSyntax, _super); - function CatchClauseSyntax(data, catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { - _super.call(this, data); - this.catchKeyword = catchKeyword, this.openParenToken = openParenToken, this.identifier = identifier, this.typeAnnotation = typeAnnotation, this.closeParenToken = closeParenToken, this.block = block, catchKeyword.parent = this, openParenToken.parent = this, identifier.parent = this, typeAnnotation && (typeAnnotation.parent = this), closeParenToken.parent = this, block.parent = this; - } - return CatchClauseSyntax; - })(TypeScript.SyntaxNode); - Concrete.CatchClauseSyntax = CatchClauseSyntax; - var FinallyClauseSyntax = (function (_super) { - __extends(FinallyClauseSyntax, _super); - function FinallyClauseSyntax(data, finallyKeyword, block) { - _super.call(this, data); - this.finallyKeyword = finallyKeyword, this.block = block, finallyKeyword.parent = this, block.parent = this; - } - return FinallyClauseSyntax; - })(TypeScript.SyntaxNode); - Concrete.FinallyClauseSyntax = FinallyClauseSyntax; - var TypeParameterSyntax = (function (_super) { - __extends(TypeParameterSyntax, _super); - function TypeParameterSyntax(data, identifier, constraint) { - _super.call(this, data); - this.identifier = identifier, this.constraint = constraint, identifier.parent = this, constraint && (constraint.parent = this); - } - return TypeParameterSyntax; - })(TypeScript.SyntaxNode); - Concrete.TypeParameterSyntax = TypeParameterSyntax; - var ConstraintSyntax = (function (_super) { - __extends(ConstraintSyntax, _super); - function ConstraintSyntax(data, extendsKeyword, typeOrExpression) { - _super.call(this, data); - this.extendsKeyword = extendsKeyword, this.typeOrExpression = typeOrExpression, extendsKeyword.parent = this, typeOrExpression.parent = this; - } - return ConstraintSyntax; - })(TypeScript.SyntaxNode); - Concrete.ConstraintSyntax = ConstraintSyntax; - var SimplePropertyAssignmentSyntax = (function (_super) { - __extends(SimplePropertyAssignmentSyntax, _super); - function SimplePropertyAssignmentSyntax(data, propertyName, colonToken, expression) { - _super.call(this, data); - this.propertyName = propertyName, this.colonToken = colonToken, this.expression = expression, propertyName.parent = this, colonToken.parent = this, expression.parent = this; - } - return SimplePropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - Concrete.SimplePropertyAssignmentSyntax = SimplePropertyAssignmentSyntax; - var FunctionPropertyAssignmentSyntax = (function (_super) { - __extends(FunctionPropertyAssignmentSyntax, _super); - function FunctionPropertyAssignmentSyntax(data, propertyName, callSignature, block) { - _super.call(this, data); - this.propertyName = propertyName, this.callSignature = callSignature, this.block = block, propertyName.parent = this, callSignature.parent = this, block.parent = this; - } - return FunctionPropertyAssignmentSyntax; - })(TypeScript.SyntaxNode); - Concrete.FunctionPropertyAssignmentSyntax = FunctionPropertyAssignmentSyntax; - var ParameterSyntax = (function (_super) { - __extends(ParameterSyntax, _super); - function ParameterSyntax(data, dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { - _super.call(this, data); - this.dotDotDotToken = dotDotDotToken, this.modifiers = modifiers, this.identifier = identifier, this.questionToken = questionToken, this.typeAnnotation = typeAnnotation, this.equalsValueClause = equalsValueClause, dotDotDotToken && (dotDotDotToken.parent = this), !TypeScript.isShared(modifiers) && (modifiers.parent = this), identifier.parent = this, questionToken && (questionToken.parent = this), typeAnnotation && (typeAnnotation.parent = this), equalsValueClause && (equalsValueClause.parent = this); - } - return ParameterSyntax; - })(TypeScript.SyntaxNode); - Concrete.ParameterSyntax = ParameterSyntax; - var EnumElementSyntax = (function (_super) { - __extends(EnumElementSyntax, _super); - function EnumElementSyntax(data, propertyName, equalsValueClause) { - _super.call(this, data); - this.propertyName = propertyName, this.equalsValueClause = equalsValueClause, propertyName.parent = this, equalsValueClause && (equalsValueClause.parent = this); - } - return EnumElementSyntax; - })(TypeScript.SyntaxNode); - Concrete.EnumElementSyntax = EnumElementSyntax; - var TypeAnnotationSyntax = (function (_super) { - __extends(TypeAnnotationSyntax, _super); - function TypeAnnotationSyntax(data, colonToken, type) { - _super.call(this, data); - this.colonToken = colonToken, this.type = type, colonToken.parent = this, type.parent = this; - } - return TypeAnnotationSyntax; - })(TypeScript.SyntaxNode); - Concrete.TypeAnnotationSyntax = TypeAnnotationSyntax; - var ExternalModuleReferenceSyntax = (function (_super) { - __extends(ExternalModuleReferenceSyntax, _super); - function ExternalModuleReferenceSyntax(data, requireKeyword, openParenToken, stringLiteral, closeParenToken) { - _super.call(this, data); - this.requireKeyword = requireKeyword, this.openParenToken = openParenToken, this.stringLiteral = stringLiteral, this.closeParenToken = closeParenToken, requireKeyword.parent = this, openParenToken.parent = this, stringLiteral.parent = this, closeParenToken.parent = this; - } - return ExternalModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - Concrete.ExternalModuleReferenceSyntax = ExternalModuleReferenceSyntax; - var ModuleNameModuleReferenceSyntax = (function (_super) { - __extends(ModuleNameModuleReferenceSyntax, _super); - function ModuleNameModuleReferenceSyntax(data, moduleName) { - _super.call(this, data); - this.moduleName = moduleName, moduleName.parent = this; - } - return ModuleNameModuleReferenceSyntax; - })(TypeScript.SyntaxNode); - Concrete.ModuleNameModuleReferenceSyntax = ModuleNameModuleReferenceSyntax; - SourceUnitSyntax.prototype.__kind = 120 /* SourceUnit */, QualifiedNameSyntax.prototype.__kind = 121 /* QualifiedName */, ObjectTypeSyntax.prototype.__kind = 122 /* ObjectType */, FunctionTypeSyntax.prototype.__kind = 123 /* FunctionType */, ArrayTypeSyntax.prototype.__kind = 124 /* ArrayType */, ConstructorTypeSyntax.prototype.__kind = 125 /* ConstructorType */, GenericTypeSyntax.prototype.__kind = 126 /* GenericType */, TypeQuerySyntax.prototype.__kind = 127 /* TypeQuery */, TupleTypeSyntax.prototype.__kind = 128 /* TupleType */, InterfaceDeclarationSyntax.prototype.__kind = 129 /* InterfaceDeclaration */, FunctionDeclarationSyntax.prototype.__kind = 130 /* FunctionDeclaration */, ModuleDeclarationSyntax.prototype.__kind = 131 /* ModuleDeclaration */, ClassDeclarationSyntax.prototype.__kind = 132 /* ClassDeclaration */, EnumDeclarationSyntax.prototype.__kind = 133 /* EnumDeclaration */, ImportDeclarationSyntax.prototype.__kind = 134 /* ImportDeclaration */, ExportAssignmentSyntax.prototype.__kind = 135 /* ExportAssignment */, MemberFunctionDeclarationSyntax.prototype.__kind = 136 /* MemberFunctionDeclaration */, MemberVariableDeclarationSyntax.prototype.__kind = 137 /* MemberVariableDeclaration */, ConstructorDeclarationSyntax.prototype.__kind = 138 /* ConstructorDeclaration */, IndexMemberDeclarationSyntax.prototype.__kind = 139 /* IndexMemberDeclaration */, GetAccessorSyntax.prototype.__kind = 140 /* GetAccessor */, SetAccessorSyntax.prototype.__kind = 141 /* SetAccessor */, PropertySignatureSyntax.prototype.__kind = 142 /* PropertySignature */, CallSignatureSyntax.prototype.__kind = 143 /* CallSignature */, ConstructSignatureSyntax.prototype.__kind = 144 /* ConstructSignature */, IndexSignatureSyntax.prototype.__kind = 145 /* IndexSignature */, MethodSignatureSyntax.prototype.__kind = 146 /* MethodSignature */, BlockSyntax.prototype.__kind = 147 /* Block */, IfStatementSyntax.prototype.__kind = 148 /* IfStatement */, VariableStatementSyntax.prototype.__kind = 149 /* VariableStatement */, ExpressionStatementSyntax.prototype.__kind = 150 /* ExpressionStatement */, ReturnStatementSyntax.prototype.__kind = 151 /* ReturnStatement */, SwitchStatementSyntax.prototype.__kind = 152 /* SwitchStatement */, BreakStatementSyntax.prototype.__kind = 153 /* BreakStatement */, ContinueStatementSyntax.prototype.__kind = 154 /* ContinueStatement */, ForStatementSyntax.prototype.__kind = 155 /* ForStatement */, ForInStatementSyntax.prototype.__kind = 156 /* ForInStatement */, EmptyStatementSyntax.prototype.__kind = 157 /* EmptyStatement */, ThrowStatementSyntax.prototype.__kind = 158 /* ThrowStatement */, WhileStatementSyntax.prototype.__kind = 159 /* WhileStatement */, TryStatementSyntax.prototype.__kind = 160 /* TryStatement */, LabeledStatementSyntax.prototype.__kind = 161 /* LabeledStatement */, DoStatementSyntax.prototype.__kind = 162 /* DoStatement */, DebuggerStatementSyntax.prototype.__kind = 163 /* DebuggerStatement */, WithStatementSyntax.prototype.__kind = 164 /* WithStatement */, DeleteExpressionSyntax.prototype.__kind = 171 /* DeleteExpression */, TypeOfExpressionSyntax.prototype.__kind = 172 /* TypeOfExpression */, VoidExpressionSyntax.prototype.__kind = 173 /* VoidExpression */, ConditionalExpressionSyntax.prototype.__kind = 187 /* ConditionalExpression */, MemberAccessExpressionSyntax.prototype.__kind = 213 /* MemberAccessExpression */, InvocationExpressionSyntax.prototype.__kind = 214 /* InvocationExpression */, ArrayLiteralExpressionSyntax.prototype.__kind = 215 /* ArrayLiteralExpression */, ObjectLiteralExpressionSyntax.prototype.__kind = 216 /* ObjectLiteralExpression */, ObjectCreationExpressionSyntax.prototype.__kind = 217 /* ObjectCreationExpression */, ParenthesizedExpressionSyntax.prototype.__kind = 218 /* ParenthesizedExpression */, ParenthesizedArrowFunctionExpressionSyntax.prototype.__kind = 219 /* ParenthesizedArrowFunctionExpression */, SimpleArrowFunctionExpressionSyntax.prototype.__kind = 220 /* SimpleArrowFunctionExpression */, CastExpressionSyntax.prototype.__kind = 221 /* CastExpression */, ElementAccessExpressionSyntax.prototype.__kind = 222 /* ElementAccessExpression */, FunctionExpressionSyntax.prototype.__kind = 223 /* FunctionExpression */, OmittedExpressionSyntax.prototype.__kind = 224 /* OmittedExpression */, VariableDeclarationSyntax.prototype.__kind = 225 /* VariableDeclaration */, VariableDeclaratorSyntax.prototype.__kind = 226 /* VariableDeclarator */, ArgumentListSyntax.prototype.__kind = 227 /* ArgumentList */, ParameterListSyntax.prototype.__kind = 228 /* ParameterList */, TypeArgumentListSyntax.prototype.__kind = 229 /* TypeArgumentList */, TypeParameterListSyntax.prototype.__kind = 230 /* TypeParameterList */, EqualsValueClauseSyntax.prototype.__kind = 233 /* EqualsValueClause */, CaseSwitchClauseSyntax.prototype.__kind = 234 /* CaseSwitchClause */, DefaultSwitchClauseSyntax.prototype.__kind = 235 /* DefaultSwitchClause */, ElseClauseSyntax.prototype.__kind = 236 /* ElseClause */, CatchClauseSyntax.prototype.__kind = 237 /* CatchClause */, FinallyClauseSyntax.prototype.__kind = 238 /* FinallyClause */, TypeParameterSyntax.prototype.__kind = 239 /* TypeParameter */, ConstraintSyntax.prototype.__kind = 240 /* Constraint */, SimplePropertyAssignmentSyntax.prototype.__kind = 241 /* SimplePropertyAssignment */, FunctionPropertyAssignmentSyntax.prototype.__kind = 242 /* FunctionPropertyAssignment */, ParameterSyntax.prototype.__kind = 243 /* Parameter */, EnumElementSyntax.prototype.__kind = 244 /* EnumElement */, TypeAnnotationSyntax.prototype.__kind = 245 /* TypeAnnotation */, ExternalModuleReferenceSyntax.prototype.__kind = 246 /* ExternalModuleReference */, ModuleNameModuleReferenceSyntax.prototype.__kind = 247 /* ModuleNameModuleReference */; - })(Concrete = Syntax.Concrete || (Syntax.Concrete = {})); - })(Syntax = TypeScript.Syntax || (TypeScript.Syntax = {})); + TypeScript.SourceUnitSyntax = function (data, moduleElements, endOfFileToken) { + if (data) { + this.__data = data; + } + this.moduleElements = moduleElements, this.endOfFileToken = endOfFileToken; + moduleElements.parent = this, endOfFileToken.parent = this; + }; + TypeScript.SourceUnitSyntax.prototype.kind = function () { + return 122 /* SourceUnit */; + }; + TypeScript.QualifiedNameSyntax = function (data, left, dotToken, right) { + if (data) { + this.__data = data; + } + this.left = left, this.dotToken = dotToken, this.right = right; + left.parent = this, dotToken.parent = this, right.parent = this; + }; + TypeScript.QualifiedNameSyntax.prototype.kind = function () { + return 123 /* QualifiedName */; + }; + TypeScript.ObjectTypeSyntax = function (data, openBraceToken, typeMembers, closeBraceToken) { + if (data) { + this.__data = data; + } + this.openBraceToken = openBraceToken, this.typeMembers = typeMembers, this.closeBraceToken = closeBraceToken; + openBraceToken.parent = this, typeMembers.parent = this, closeBraceToken.parent = this; + }; + TypeScript.ObjectTypeSyntax.prototype.kind = function () { + return 124 /* ObjectType */; + }; + TypeScript.FunctionTypeSyntax = function (data, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (data) { + this.__data = data; + } + this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.equalsGreaterThanToken = equalsGreaterThanToken, this.type = type; + typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, equalsGreaterThanToken.parent = this, type.parent = this; + }; + TypeScript.FunctionTypeSyntax.prototype.kind = function () { + return 125 /* FunctionType */; + }; + TypeScript.ArrayTypeSyntax = function (data, type, openBracketToken, closeBracketToken) { + if (data) { + this.__data = data; + } + this.type = type, this.openBracketToken = openBracketToken, this.closeBracketToken = closeBracketToken; + type.parent = this, openBracketToken.parent = this, closeBracketToken.parent = this; + }; + TypeScript.ArrayTypeSyntax.prototype.kind = function () { + return 126 /* ArrayType */; + }; + TypeScript.ConstructorTypeSyntax = function (data, newKeyword, typeParameterList, parameterList, equalsGreaterThanToken, type) { + if (data) { + this.__data = data; + } + this.newKeyword = newKeyword, this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.equalsGreaterThanToken = equalsGreaterThanToken, this.type = type; + newKeyword.parent = this, typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, equalsGreaterThanToken.parent = this, type.parent = this; + }; + TypeScript.ConstructorTypeSyntax.prototype.kind = function () { + return 127 /* ConstructorType */; + }; + TypeScript.GenericTypeSyntax = function (data, name, typeArgumentList) { + if (data) { + this.__data = data; + } + this.name = name, this.typeArgumentList = typeArgumentList; + name.parent = this, typeArgumentList.parent = this; + }; + TypeScript.GenericTypeSyntax.prototype.kind = function () { + return 128 /* GenericType */; + }; + TypeScript.TypeQuerySyntax = function (data, typeOfKeyword, name) { + if (data) { + this.__data = data; + } + this.typeOfKeyword = typeOfKeyword, this.name = name; + typeOfKeyword.parent = this, name.parent = this; + }; + TypeScript.TypeQuerySyntax.prototype.kind = function () { + return 129 /* TypeQuery */; + }; + TypeScript.TupleTypeSyntax = function (data, openBracketToken, types, closeBracketToken) { + if (data) { + this.__data = data; + } + this.openBracketToken = openBracketToken, this.types = types, this.closeBracketToken = closeBracketToken; + openBracketToken.parent = this, types.parent = this, closeBracketToken.parent = this; + }; + TypeScript.TupleTypeSyntax.prototype.kind = function () { + return 130 /* TupleType */; + }; + TypeScript.UnionTypeSyntax = function (data, left, barToken, right) { + if (data) { + this.__data = data; + } + this.left = left, this.barToken = barToken, this.right = right; + left.parent = this, barToken.parent = this, right.parent = this; + }; + TypeScript.UnionTypeSyntax.prototype.kind = function () { + return 131 /* UnionType */; + }; + TypeScript.ParenthesizedTypeSyntax = function (data, openParenToken, type, closeParenToken) { + if (data) { + this.__data = data; + } + this.openParenToken = openParenToken, this.type = type, this.closeParenToken = closeParenToken; + openParenToken.parent = this, type.parent = this, closeParenToken.parent = this; + }; + TypeScript.ParenthesizedTypeSyntax.prototype.kind = function () { + return 132 /* ParenthesizedType */; + }; + TypeScript.InterfaceDeclarationSyntax = function (data, modifiers, interfaceKeyword, identifier, typeParameterList, heritageClauses, body) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.interfaceKeyword = interfaceKeyword, this.identifier = identifier, this.typeParameterList = typeParameterList, this.heritageClauses = heritageClauses, this.body = body; + modifiers.parent = this, interfaceKeyword.parent = this, identifier.parent = this, typeParameterList && (typeParameterList.parent = this), heritageClauses.parent = this, body.parent = this; + }; + TypeScript.InterfaceDeclarationSyntax.prototype.kind = function () { + return 133 /* InterfaceDeclaration */; + }; + TypeScript.FunctionDeclarationSyntax = function (data, modifiers, functionKeyword, identifier, callSignature, block, semicolonToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.functionKeyword = functionKeyword, this.identifier = identifier, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken; + modifiers.parent = this, functionKeyword.parent = this, identifier.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.FunctionDeclarationSyntax.prototype.kind = function () { + return 134 /* FunctionDeclaration */; + }; + TypeScript.ModuleDeclarationSyntax = function (data, modifiers, moduleKeyword, name, stringLiteral, openBraceToken, moduleElements, closeBraceToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.moduleKeyword = moduleKeyword, this.name = name, this.stringLiteral = stringLiteral, this.openBraceToken = openBraceToken, this.moduleElements = moduleElements, this.closeBraceToken = closeBraceToken; + modifiers.parent = this, moduleKeyword.parent = this, name && (name.parent = this), stringLiteral && (stringLiteral.parent = this), openBraceToken.parent = this, moduleElements.parent = this, closeBraceToken.parent = this; + }; + TypeScript.ModuleDeclarationSyntax.prototype.kind = function () { + return 135 /* ModuleDeclaration */; + }; + TypeScript.ClassDeclarationSyntax = function (data, modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, closeBraceToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.classKeyword = classKeyword, this.identifier = identifier, this.typeParameterList = typeParameterList, this.heritageClauses = heritageClauses, this.openBraceToken = openBraceToken, this.classElements = classElements, this.closeBraceToken = closeBraceToken; + modifiers.parent = this, classKeyword.parent = this, identifier.parent = this, typeParameterList && (typeParameterList.parent = this), heritageClauses.parent = this, openBraceToken.parent = this, classElements.parent = this, closeBraceToken.parent = this; + }; + TypeScript.ClassDeclarationSyntax.prototype.kind = function () { + return 136 /* ClassDeclaration */; + }; + TypeScript.EnumDeclarationSyntax = function (data, modifiers, enumKeyword, identifier, openBraceToken, enumElements, closeBraceToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.enumKeyword = enumKeyword, this.identifier = identifier, this.openBraceToken = openBraceToken, this.enumElements = enumElements, this.closeBraceToken = closeBraceToken; + modifiers.parent = this, enumKeyword.parent = this, identifier.parent = this, openBraceToken.parent = this, enumElements.parent = this, closeBraceToken.parent = this; + }; + TypeScript.EnumDeclarationSyntax.prototype.kind = function () { + return 137 /* EnumDeclaration */; + }; + TypeScript.ImportDeclarationSyntax = function (data, modifiers, importKeyword, identifier, equalsToken, moduleReference, semicolonToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.importKeyword = importKeyword, this.identifier = identifier, this.equalsToken = equalsToken, this.moduleReference = moduleReference, this.semicolonToken = semicolonToken; + modifiers.parent = this, importKeyword.parent = this, identifier.parent = this, equalsToken.parent = this, moduleReference.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.ImportDeclarationSyntax.prototype.kind = function () { + return 138 /* ImportDeclaration */; + }; + TypeScript.ExportAssignmentSyntax = function (data, exportKeyword, equalsToken, identifier, semicolonToken) { + if (data) { + this.__data = data; + } + this.exportKeyword = exportKeyword, this.equalsToken = equalsToken, this.identifier = identifier, this.semicolonToken = semicolonToken; + exportKeyword.parent = this, equalsToken.parent = this, identifier.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.ExportAssignmentSyntax.prototype.kind = function () { + return 139 /* ExportAssignment */; + }; + TypeScript.MemberFunctionDeclarationSyntax = function (data, modifiers, propertyName, callSignature, block, semicolonToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken; + modifiers.parent = this, propertyName.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.MemberFunctionDeclarationSyntax.prototype.kind = function () { + return 140 /* MemberFunctionDeclaration */; + }; + TypeScript.MemberVariableDeclarationSyntax = function (data, modifiers, variableDeclarator, semicolonToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.variableDeclarator = variableDeclarator, this.semicolonToken = semicolonToken; + modifiers.parent = this, variableDeclarator.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.MemberVariableDeclarationSyntax.prototype.kind = function () { + return 141 /* MemberVariableDeclaration */; + }; + TypeScript.ConstructorDeclarationSyntax = function (data, modifiers, constructorKeyword, callSignature, block, semicolonToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.constructorKeyword = constructorKeyword, this.callSignature = callSignature, this.block = block, this.semicolonToken = semicolonToken; + modifiers.parent = this, constructorKeyword.parent = this, callSignature.parent = this, block && (block.parent = this), semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.ConstructorDeclarationSyntax.prototype.kind = function () { + return 142 /* ConstructorDeclaration */; + }; + TypeScript.IndexMemberDeclarationSyntax = function (data, modifiers, indexSignature, semicolonToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.indexSignature = indexSignature, this.semicolonToken = semicolonToken; + modifiers.parent = this, indexSignature.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.IndexMemberDeclarationSyntax.prototype.kind = function () { + return 143 /* IndexMemberDeclaration */; + }; + TypeScript.GetAccessorSyntax = function (data, modifiers, getKeyword, propertyName, callSignature, block) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.getKeyword = getKeyword, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block; + modifiers.parent = this, getKeyword.parent = this, propertyName.parent = this, callSignature.parent = this, block.parent = this; + }; + TypeScript.GetAccessorSyntax.prototype.kind = function () { + return 144 /* GetAccessor */; + }; + TypeScript.SetAccessorSyntax = function (data, modifiers, setKeyword, propertyName, callSignature, block) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.setKeyword = setKeyword, this.propertyName = propertyName, this.callSignature = callSignature, this.block = block; + modifiers.parent = this, setKeyword.parent = this, propertyName.parent = this, callSignature.parent = this, block.parent = this; + }; + TypeScript.SetAccessorSyntax.prototype.kind = function () { + return 145 /* SetAccessor */; + }; + TypeScript.PropertySignatureSyntax = function (data, propertyName, questionToken, typeAnnotation) { + if (data) { + this.__data = data; + } + this.propertyName = propertyName, this.questionToken = questionToken, this.typeAnnotation = typeAnnotation; + propertyName.parent = this, questionToken && (questionToken.parent = this), typeAnnotation && (typeAnnotation.parent = this); + }; + TypeScript.PropertySignatureSyntax.prototype.kind = function () { + return 146 /* PropertySignature */; + }; + TypeScript.CallSignatureSyntax = function (data, typeParameterList, parameterList, typeAnnotation) { + if (data) { + this.__data = data; + } + this.typeParameterList = typeParameterList, this.parameterList = parameterList, this.typeAnnotation = typeAnnotation; + typeParameterList && (typeParameterList.parent = this), parameterList.parent = this, typeAnnotation && (typeAnnotation.parent = this); + }; + TypeScript.CallSignatureSyntax.prototype.kind = function () { + return 147 /* CallSignature */; + }; + TypeScript.ConstructSignatureSyntax = function (data, newKeyword, callSignature) { + if (data) { + this.__data = data; + } + this.newKeyword = newKeyword, this.callSignature = callSignature; + newKeyword.parent = this, callSignature.parent = this; + }; + TypeScript.ConstructSignatureSyntax.prototype.kind = function () { + return 148 /* ConstructSignature */; + }; + TypeScript.IndexSignatureSyntax = function (data, openBracketToken, parameters, closeBracketToken, typeAnnotation) { + if (data) { + this.__data = data; + } + this.openBracketToken = openBracketToken, this.parameters = parameters, this.closeBracketToken = closeBracketToken, this.typeAnnotation = typeAnnotation; + openBracketToken.parent = this, parameters.parent = this, closeBracketToken.parent = this, typeAnnotation && (typeAnnotation.parent = this); + }; + TypeScript.IndexSignatureSyntax.prototype.kind = function () { + return 149 /* IndexSignature */; + }; + TypeScript.MethodSignatureSyntax = function (data, propertyName, questionToken, callSignature) { + if (data) { + this.__data = data; + } + this.propertyName = propertyName, this.questionToken = questionToken, this.callSignature = callSignature; + propertyName.parent = this, questionToken && (questionToken.parent = this), callSignature.parent = this; + }; + TypeScript.MethodSignatureSyntax.prototype.kind = function () { + return 150 /* MethodSignature */; + }; + TypeScript.BlockSyntax = function (data, openBraceToken, statements, closeBraceToken) { + if (data) { + this.__data = data; + } + this.openBraceToken = openBraceToken, this.statements = statements, this.closeBraceToken = closeBraceToken; + openBraceToken.parent = this, statements.parent = this, closeBraceToken.parent = this; + }; + TypeScript.BlockSyntax.prototype.kind = function () { + return 151 /* Block */; + }; + TypeScript.IfStatementSyntax = function (data, ifKeyword, openParenToken, condition, closeParenToken, statement, elseClause) { + if (data) { + this.__data = data; + } + this.ifKeyword = ifKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement, this.elseClause = elseClause; + ifKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this, elseClause && (elseClause.parent = this); + }; + TypeScript.IfStatementSyntax.prototype.kind = function () { + return 152 /* IfStatement */; + }; + TypeScript.VariableStatementSyntax = function (data, modifiers, variableDeclaration, semicolonToken) { + if (data) { + this.__data = data; + } + this.modifiers = modifiers, this.variableDeclaration = variableDeclaration, this.semicolonToken = semicolonToken; + modifiers.parent = this, variableDeclaration.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.VariableStatementSyntax.prototype.kind = function () { + return 153 /* VariableStatement */; + }; + TypeScript.ExpressionStatementSyntax = function (data, expression, semicolonToken) { + if (data) { + this.__data = data; + } + this.expression = expression, this.semicolonToken = semicolonToken; + expression.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.ExpressionStatementSyntax.prototype.kind = function () { + return 154 /* ExpressionStatement */; + }; + TypeScript.ReturnStatementSyntax = function (data, returnKeyword, expression, semicolonToken) { + if (data) { + this.__data = data; + } + this.returnKeyword = returnKeyword, this.expression = expression, this.semicolonToken = semicolonToken; + returnKeyword.parent = this, expression && (expression.parent = this), semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.ReturnStatementSyntax.prototype.kind = function () { + return 155 /* ReturnStatement */; + }; + TypeScript.SwitchStatementSyntax = function (data, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, closeBraceToken) { + if (data) { + this.__data = data; + } + this.switchKeyword = switchKeyword, this.openParenToken = openParenToken, this.expression = expression, this.closeParenToken = closeParenToken, this.openBraceToken = openBraceToken, this.switchClauses = switchClauses, this.closeBraceToken = closeBraceToken; + switchKeyword.parent = this, openParenToken.parent = this, expression.parent = this, closeParenToken.parent = this, openBraceToken.parent = this, switchClauses.parent = this, closeBraceToken.parent = this; + }; + TypeScript.SwitchStatementSyntax.prototype.kind = function () { + return 156 /* SwitchStatement */; + }; + TypeScript.BreakStatementSyntax = function (data, breakKeyword, identifier, semicolonToken) { + if (data) { + this.__data = data; + } + this.breakKeyword = breakKeyword, this.identifier = identifier, this.semicolonToken = semicolonToken; + breakKeyword.parent = this, identifier && (identifier.parent = this), semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.BreakStatementSyntax.prototype.kind = function () { + return 157 /* BreakStatement */; + }; + TypeScript.ContinueStatementSyntax = function (data, continueKeyword, identifier, semicolonToken) { + if (data) { + this.__data = data; + } + this.continueKeyword = continueKeyword, this.identifier = identifier, this.semicolonToken = semicolonToken; + continueKeyword.parent = this, identifier && (identifier.parent = this), semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.ContinueStatementSyntax.prototype.kind = function () { + return 158 /* ContinueStatement */; + }; + TypeScript.ForStatementSyntax = function (data, forKeyword, openParenToken, variableDeclaration, initializer, firstSemicolonToken, condition, secondSemicolonToken, incrementor, closeParenToken, statement) { + if (data) { + this.__data = data; + } + this.forKeyword = forKeyword, this.openParenToken = openParenToken, this.variableDeclaration = variableDeclaration, this.initializer = initializer, this.firstSemicolonToken = firstSemicolonToken, this.condition = condition, this.secondSemicolonToken = secondSemicolonToken, this.incrementor = incrementor, this.closeParenToken = closeParenToken, this.statement = statement; + forKeyword.parent = this, openParenToken.parent = this, variableDeclaration && (variableDeclaration.parent = this), initializer && (initializer.parent = this), firstSemicolonToken.parent = this, condition && (condition.parent = this), secondSemicolonToken.parent = this, incrementor && (incrementor.parent = this), closeParenToken.parent = this, statement.parent = this; + }; + TypeScript.ForStatementSyntax.prototype.kind = function () { + return 159 /* ForStatement */; + }; + TypeScript.ForInStatementSyntax = function (data, forKeyword, openParenToken, variableDeclaration, left, inKeyword, expression, closeParenToken, statement) { + if (data) { + this.__data = data; + } + this.forKeyword = forKeyword, this.openParenToken = openParenToken, this.variableDeclaration = variableDeclaration, this.left = left, this.inKeyword = inKeyword, this.expression = expression, this.closeParenToken = closeParenToken, this.statement = statement; + forKeyword.parent = this, openParenToken.parent = this, variableDeclaration && (variableDeclaration.parent = this), left && (left.parent = this), inKeyword.parent = this, expression.parent = this, closeParenToken.parent = this, statement.parent = this; + }; + TypeScript.ForInStatementSyntax.prototype.kind = function () { + return 160 /* ForInStatement */; + }; + TypeScript.EmptyStatementSyntax = function (data, semicolonToken) { + if (data) { + this.__data = data; + } + this.semicolonToken = semicolonToken; + semicolonToken.parent = this; + }; + TypeScript.EmptyStatementSyntax.prototype.kind = function () { + return 161 /* EmptyStatement */; + }; + TypeScript.ThrowStatementSyntax = function (data, throwKeyword, expression, semicolonToken) { + if (data) { + this.__data = data; + } + this.throwKeyword = throwKeyword, this.expression = expression, this.semicolonToken = semicolonToken; + throwKeyword.parent = this, expression.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.ThrowStatementSyntax.prototype.kind = function () { + return 162 /* ThrowStatement */; + }; + TypeScript.WhileStatementSyntax = function (data, whileKeyword, openParenToken, condition, closeParenToken, statement) { + if (data) { + this.__data = data; + } + this.whileKeyword = whileKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement; + whileKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this; + }; + TypeScript.WhileStatementSyntax.prototype.kind = function () { + return 163 /* WhileStatement */; + }; + TypeScript.TryStatementSyntax = function (data, tryKeyword, block, catchClause, finallyClause) { + if (data) { + this.__data = data; + } + this.tryKeyword = tryKeyword, this.block = block, this.catchClause = catchClause, this.finallyClause = finallyClause; + tryKeyword.parent = this, block.parent = this, catchClause && (catchClause.parent = this), finallyClause && (finallyClause.parent = this); + }; + TypeScript.TryStatementSyntax.prototype.kind = function () { + return 164 /* TryStatement */; + }; + TypeScript.LabeledStatementSyntax = function (data, identifier, colonToken, statement) { + if (data) { + this.__data = data; + } + this.identifier = identifier, this.colonToken = colonToken, this.statement = statement; + identifier.parent = this, colonToken.parent = this, statement.parent = this; + }; + TypeScript.LabeledStatementSyntax.prototype.kind = function () { + return 165 /* LabeledStatement */; + }; + TypeScript.DoStatementSyntax = function (data, doKeyword, statement, whileKeyword, openParenToken, condition, closeParenToken, semicolonToken) { + if (data) { + this.__data = data; + } + this.doKeyword = doKeyword, this.statement = statement, this.whileKeyword = whileKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.semicolonToken = semicolonToken; + doKeyword.parent = this, statement.parent = this, whileKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.DoStatementSyntax.prototype.kind = function () { + return 166 /* DoStatement */; + }; + TypeScript.DebuggerStatementSyntax = function (data, debuggerKeyword, semicolonToken) { + if (data) { + this.__data = data; + } + this.debuggerKeyword = debuggerKeyword, this.semicolonToken = semicolonToken; + debuggerKeyword.parent = this, semicolonToken && (semicolonToken.parent = this); + }; + TypeScript.DebuggerStatementSyntax.prototype.kind = function () { + return 167 /* DebuggerStatement */; + }; + TypeScript.WithStatementSyntax = function (data, withKeyword, openParenToken, condition, closeParenToken, statement) { + if (data) { + this.__data = data; + } + this.withKeyword = withKeyword, this.openParenToken = openParenToken, this.condition = condition, this.closeParenToken = closeParenToken, this.statement = statement; + withKeyword.parent = this, openParenToken.parent = this, condition.parent = this, closeParenToken.parent = this, statement.parent = this; + }; + TypeScript.WithStatementSyntax.prototype.kind = function () { + return 168 /* WithStatement */; + }; + TypeScript.PrefixUnaryExpressionSyntax = function (data, operatorToken, operand) { + if (data) { + this.__data = data; + } + this.operatorToken = operatorToken, this.operand = operand; + operatorToken.parent = this, operand.parent = this; + }; + TypeScript.PrefixUnaryExpressionSyntax.prototype.kind = function () { + return 169 /* PrefixUnaryExpression */; + }; + TypeScript.DeleteExpressionSyntax = function (data, deleteKeyword, expression) { + if (data) { + this.__data = data; + } + this.deleteKeyword = deleteKeyword, this.expression = expression; + deleteKeyword.parent = this, expression.parent = this; + }; + TypeScript.DeleteExpressionSyntax.prototype.kind = function () { + return 170 /* DeleteExpression */; + }; + TypeScript.TypeOfExpressionSyntax = function (data, typeOfKeyword, expression) { + if (data) { + this.__data = data; + } + this.typeOfKeyword = typeOfKeyword, this.expression = expression; + typeOfKeyword.parent = this, expression.parent = this; + }; + TypeScript.TypeOfExpressionSyntax.prototype.kind = function () { + return 171 /* TypeOfExpression */; + }; + TypeScript.VoidExpressionSyntax = function (data, voidKeyword, expression) { + if (data) { + this.__data = data; + } + this.voidKeyword = voidKeyword, this.expression = expression; + voidKeyword.parent = this, expression.parent = this; + }; + TypeScript.VoidExpressionSyntax.prototype.kind = function () { + return 172 /* VoidExpression */; + }; + TypeScript.ConditionalExpressionSyntax = function (data, condition, questionToken, whenTrue, colonToken, whenFalse) { + if (data) { + this.__data = data; + } + this.condition = condition, this.questionToken = questionToken, this.whenTrue = whenTrue, this.colonToken = colonToken, this.whenFalse = whenFalse; + condition.parent = this, questionToken.parent = this, whenTrue.parent = this, colonToken.parent = this, whenFalse.parent = this; + }; + TypeScript.ConditionalExpressionSyntax.prototype.kind = function () { + return 173 /* ConditionalExpression */; + }; + TypeScript.BinaryExpressionSyntax = function (data, left, operatorToken, right) { + if (data) { + this.__data = data; + } + this.left = left, this.operatorToken = operatorToken, this.right = right; + left.parent = this, operatorToken.parent = this, right.parent = this; + }; + TypeScript.BinaryExpressionSyntax.prototype.kind = function () { + return 174 /* BinaryExpression */; + }; + TypeScript.PostfixUnaryExpressionSyntax = function (data, operand, operatorToken) { + if (data) { + this.__data = data; + } + this.operand = operand, this.operatorToken = operatorToken; + operand.parent = this, operatorToken.parent = this; + }; + TypeScript.PostfixUnaryExpressionSyntax.prototype.kind = function () { + return 175 /* PostfixUnaryExpression */; + }; + TypeScript.MemberAccessExpressionSyntax = function (data, expression, dotToken, name) { + if (data) { + this.__data = data; + } + this.expression = expression, this.dotToken = dotToken, this.name = name; + expression.parent = this, dotToken.parent = this, name.parent = this; + }; + TypeScript.MemberAccessExpressionSyntax.prototype.kind = function () { + return 176 /* MemberAccessExpression */; + }; + TypeScript.InvocationExpressionSyntax = function (data, expression, argumentList) { + if (data) { + this.__data = data; + } + this.expression = expression, this.argumentList = argumentList; + expression.parent = this, argumentList.parent = this; + }; + TypeScript.InvocationExpressionSyntax.prototype.kind = function () { + return 177 /* InvocationExpression */; + }; + TypeScript.ArrayLiteralExpressionSyntax = function (data, openBracketToken, expressions, closeBracketToken) { + if (data) { + this.__data = data; + } + this.openBracketToken = openBracketToken, this.expressions = expressions, this.closeBracketToken = closeBracketToken; + openBracketToken.parent = this, expressions.parent = this, closeBracketToken.parent = this; + }; + TypeScript.ArrayLiteralExpressionSyntax.prototype.kind = function () { + return 178 /* ArrayLiteralExpression */; + }; + TypeScript.ObjectLiteralExpressionSyntax = function (data, openBraceToken, propertyAssignments, closeBraceToken) { + if (data) { + this.__data = data; + } + this.openBraceToken = openBraceToken, this.propertyAssignments = propertyAssignments, this.closeBraceToken = closeBraceToken; + openBraceToken.parent = this, propertyAssignments.parent = this, closeBraceToken.parent = this; + }; + TypeScript.ObjectLiteralExpressionSyntax.prototype.kind = function () { + return 179 /* ObjectLiteralExpression */; + }; + TypeScript.ObjectCreationExpressionSyntax = function (data, newKeyword, expression, argumentList) { + if (data) { + this.__data = data; + } + this.newKeyword = newKeyword, this.expression = expression, this.argumentList = argumentList; + newKeyword.parent = this, expression.parent = this, argumentList && (argumentList.parent = this); + }; + TypeScript.ObjectCreationExpressionSyntax.prototype.kind = function () { + return 180 /* ObjectCreationExpression */; + }; + TypeScript.ParenthesizedExpressionSyntax = function (data, openParenToken, expression, closeParenToken) { + if (data) { + this.__data = data; + } + this.openParenToken = openParenToken, this.expression = expression, this.closeParenToken = closeParenToken; + openParenToken.parent = this, expression.parent = this, closeParenToken.parent = this; + }; + TypeScript.ParenthesizedExpressionSyntax.prototype.kind = function () { + return 181 /* ParenthesizedExpression */; + }; + TypeScript.ParenthesizedArrowFunctionExpressionSyntax = function (data, callSignature, equalsGreaterThanToken, block, expression) { + if (data) { + this.__data = data; + } + this.callSignature = callSignature, this.equalsGreaterThanToken = equalsGreaterThanToken, this.block = block, this.expression = expression; + callSignature.parent = this, equalsGreaterThanToken.parent = this, block && (block.parent = this), expression && (expression.parent = this); + }; + TypeScript.ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = function () { + return 182 /* ParenthesizedArrowFunctionExpression */; + }; + TypeScript.SimpleArrowFunctionExpressionSyntax = function (data, parameter, equalsGreaterThanToken, block, expression) { + if (data) { + this.__data = data; + } + this.parameter = parameter, this.equalsGreaterThanToken = equalsGreaterThanToken, this.block = block, this.expression = expression; + parameter.parent = this, equalsGreaterThanToken.parent = this, block && (block.parent = this), expression && (expression.parent = this); + }; + TypeScript.SimpleArrowFunctionExpressionSyntax.prototype.kind = function () { + return 183 /* SimpleArrowFunctionExpression */; + }; + TypeScript.CastExpressionSyntax = function (data, lessThanToken, type, greaterThanToken, expression) { + if (data) { + this.__data = data; + } + this.lessThanToken = lessThanToken, this.type = type, this.greaterThanToken = greaterThanToken, this.expression = expression; + lessThanToken.parent = this, type.parent = this, greaterThanToken.parent = this, expression.parent = this; + }; + TypeScript.CastExpressionSyntax.prototype.kind = function () { + return 184 /* CastExpression */; + }; + TypeScript.ElementAccessExpressionSyntax = function (data, expression, openBracketToken, argumentExpression, closeBracketToken) { + if (data) { + this.__data = data; + } + this.expression = expression, this.openBracketToken = openBracketToken, this.argumentExpression = argumentExpression, this.closeBracketToken = closeBracketToken; + expression.parent = this, openBracketToken.parent = this, argumentExpression.parent = this, closeBracketToken.parent = this; + }; + TypeScript.ElementAccessExpressionSyntax.prototype.kind = function () { + return 185 /* ElementAccessExpression */; + }; + TypeScript.FunctionExpressionSyntax = function (data, functionKeyword, identifier, callSignature, block) { + if (data) { + this.__data = data; + } + this.functionKeyword = functionKeyword, this.identifier = identifier, this.callSignature = callSignature, this.block = block; + functionKeyword.parent = this, identifier && (identifier.parent = this), callSignature.parent = this, block.parent = this; + }; + TypeScript.FunctionExpressionSyntax.prototype.kind = function () { + return 186 /* FunctionExpression */; + }; + TypeScript.OmittedExpressionSyntax = function (data) { + if (data) { + this.__data = data; + } + }; + TypeScript.OmittedExpressionSyntax.prototype.kind = function () { + return 187 /* OmittedExpression */; + }; + TypeScript.TemplateExpressionSyntax = function (data, templateStartToken, templateClauses) { + if (data) { + this.__data = data; + } + this.templateStartToken = templateStartToken, this.templateClauses = templateClauses; + templateStartToken.parent = this, templateClauses.parent = this; + }; + TypeScript.TemplateExpressionSyntax.prototype.kind = function () { + return 188 /* TemplateExpression */; + }; + TypeScript.TemplateAccessExpressionSyntax = function (data, expression, templateExpression) { + if (data) { + this.__data = data; + } + this.expression = expression, this.templateExpression = templateExpression; + expression.parent = this, templateExpression.parent = this; + }; + TypeScript.TemplateAccessExpressionSyntax.prototype.kind = function () { + return 189 /* TemplateAccessExpression */; + }; + TypeScript.VariableDeclarationSyntax = function (data, varKeyword, variableDeclarators) { + if (data) { + this.__data = data; + } + this.varKeyword = varKeyword, this.variableDeclarators = variableDeclarators; + varKeyword.parent = this, variableDeclarators.parent = this; + }; + TypeScript.VariableDeclarationSyntax.prototype.kind = function () { + return 190 /* VariableDeclaration */; + }; + TypeScript.VariableDeclaratorSyntax = function (data, propertyName, typeAnnotation, equalsValueClause) { + if (data) { + this.__data = data; + } + this.propertyName = propertyName, this.typeAnnotation = typeAnnotation, this.equalsValueClause = equalsValueClause; + propertyName.parent = this, typeAnnotation && (typeAnnotation.parent = this), equalsValueClause && (equalsValueClause.parent = this); + }; + TypeScript.VariableDeclaratorSyntax.prototype.kind = function () { + return 191 /* VariableDeclarator */; + }; + TypeScript.ArgumentListSyntax = function (data, typeArgumentList, openParenToken, _arguments, closeParenToken) { + if (data) { + this.__data = data; + } + this.typeArgumentList = typeArgumentList, this.openParenToken = openParenToken, this.arguments = _arguments, this.closeParenToken = closeParenToken; + typeArgumentList && (typeArgumentList.parent = this), openParenToken.parent = this, _arguments.parent = this, closeParenToken.parent = this; + }; + TypeScript.ArgumentListSyntax.prototype.kind = function () { + return 192 /* ArgumentList */; + }; + TypeScript.ParameterListSyntax = function (data, openParenToken, parameters, closeParenToken) { + if (data) { + this.__data = data; + } + this.openParenToken = openParenToken, this.parameters = parameters, this.closeParenToken = closeParenToken; + openParenToken.parent = this, parameters.parent = this, closeParenToken.parent = this; + }; + TypeScript.ParameterListSyntax.prototype.kind = function () { + return 193 /* ParameterList */; + }; + TypeScript.TypeArgumentListSyntax = function (data, lessThanToken, typeArguments, greaterThanToken) { + if (data) { + this.__data = data; + } + this.lessThanToken = lessThanToken, this.typeArguments = typeArguments, this.greaterThanToken = greaterThanToken; + lessThanToken.parent = this, typeArguments.parent = this, greaterThanToken.parent = this; + }; + TypeScript.TypeArgumentListSyntax.prototype.kind = function () { + return 194 /* TypeArgumentList */; + }; + TypeScript.TypeParameterListSyntax = function (data, lessThanToken, typeParameters, greaterThanToken) { + if (data) { + this.__data = data; + } + this.lessThanToken = lessThanToken, this.typeParameters = typeParameters, this.greaterThanToken = greaterThanToken; + lessThanToken.parent = this, typeParameters.parent = this, greaterThanToken.parent = this; + }; + TypeScript.TypeParameterListSyntax.prototype.kind = function () { + return 195 /* TypeParameterList */; + }; + TypeScript.HeritageClauseSyntax = function (data, extendsOrImplementsKeyword, typeNames) { + if (data) { + this.__data = data; + } + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword, this.typeNames = typeNames; + extendsOrImplementsKeyword.parent = this, typeNames.parent = this; + }; + TypeScript.HeritageClauseSyntax.prototype.kind = function () { + return 196 /* HeritageClause */; + }; + TypeScript.EqualsValueClauseSyntax = function (data, equalsToken, value) { + if (data) { + this.__data = data; + } + this.equalsToken = equalsToken, this.value = value; + equalsToken.parent = this, value.parent = this; + }; + TypeScript.EqualsValueClauseSyntax.prototype.kind = function () { + return 197 /* EqualsValueClause */; + }; + TypeScript.CaseSwitchClauseSyntax = function (data, caseKeyword, expression, colonToken, statements) { + if (data) { + this.__data = data; + } + this.caseKeyword = caseKeyword, this.expression = expression, this.colonToken = colonToken, this.statements = statements; + caseKeyword.parent = this, expression.parent = this, colonToken.parent = this, statements.parent = this; + }; + TypeScript.CaseSwitchClauseSyntax.prototype.kind = function () { + return 198 /* CaseSwitchClause */; + }; + TypeScript.DefaultSwitchClauseSyntax = function (data, defaultKeyword, colonToken, statements) { + if (data) { + this.__data = data; + } + this.defaultKeyword = defaultKeyword, this.colonToken = colonToken, this.statements = statements; + defaultKeyword.parent = this, colonToken.parent = this, statements.parent = this; + }; + TypeScript.DefaultSwitchClauseSyntax.prototype.kind = function () { + return 199 /* DefaultSwitchClause */; + }; + TypeScript.ElseClauseSyntax = function (data, elseKeyword, statement) { + if (data) { + this.__data = data; + } + this.elseKeyword = elseKeyword, this.statement = statement; + elseKeyword.parent = this, statement.parent = this; + }; + TypeScript.ElseClauseSyntax.prototype.kind = function () { + return 200 /* ElseClause */; + }; + TypeScript.CatchClauseSyntax = function (data, catchKeyword, openParenToken, identifier, typeAnnotation, closeParenToken, block) { + if (data) { + this.__data = data; + } + this.catchKeyword = catchKeyword, this.openParenToken = openParenToken, this.identifier = identifier, this.typeAnnotation = typeAnnotation, this.closeParenToken = closeParenToken, this.block = block; + catchKeyword.parent = this, openParenToken.parent = this, identifier.parent = this, typeAnnotation && (typeAnnotation.parent = this), closeParenToken.parent = this, block.parent = this; + }; + TypeScript.CatchClauseSyntax.prototype.kind = function () { + return 201 /* CatchClause */; + }; + TypeScript.FinallyClauseSyntax = function (data, finallyKeyword, block) { + if (data) { + this.__data = data; + } + this.finallyKeyword = finallyKeyword, this.block = block; + finallyKeyword.parent = this, block.parent = this; + }; + TypeScript.FinallyClauseSyntax.prototype.kind = function () { + return 202 /* FinallyClause */; + }; + TypeScript.TemplateClauseSyntax = function (data, expression, templateMiddleOrEndToken) { + if (data) { + this.__data = data; + } + this.expression = expression, this.templateMiddleOrEndToken = templateMiddleOrEndToken; + expression.parent = this, templateMiddleOrEndToken.parent = this; + }; + TypeScript.TemplateClauseSyntax.prototype.kind = function () { + return 203 /* TemplateClause */; + }; + TypeScript.TypeParameterSyntax = function (data, identifier, constraint) { + if (data) { + this.__data = data; + } + this.identifier = identifier, this.constraint = constraint; + identifier.parent = this, constraint && (constraint.parent = this); + }; + TypeScript.TypeParameterSyntax.prototype.kind = function () { + return 204 /* TypeParameter */; + }; + TypeScript.ConstraintSyntax = function (data, extendsKeyword, typeOrExpression) { + if (data) { + this.__data = data; + } + this.extendsKeyword = extendsKeyword, this.typeOrExpression = typeOrExpression; + extendsKeyword.parent = this, typeOrExpression.parent = this; + }; + TypeScript.ConstraintSyntax.prototype.kind = function () { + return 205 /* Constraint */; + }; + TypeScript.SimplePropertyAssignmentSyntax = function (data, propertyName, colonToken, expression) { + if (data) { + this.__data = data; + } + this.propertyName = propertyName, this.colonToken = colonToken, this.expression = expression; + propertyName.parent = this, colonToken.parent = this, expression.parent = this; + }; + TypeScript.SimplePropertyAssignmentSyntax.prototype.kind = function () { + return 206 /* SimplePropertyAssignment */; + }; + TypeScript.FunctionPropertyAssignmentSyntax = function (data, propertyName, callSignature, block) { + if (data) { + this.__data = data; + } + this.propertyName = propertyName, this.callSignature = callSignature, this.block = block; + propertyName.parent = this, callSignature.parent = this, block.parent = this; + }; + TypeScript.FunctionPropertyAssignmentSyntax.prototype.kind = function () { + return 207 /* FunctionPropertyAssignment */; + }; + TypeScript.ParameterSyntax = function (data, dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause) { + if (data) { + this.__data = data; + } + this.dotDotDotToken = dotDotDotToken, this.modifiers = modifiers, this.identifier = identifier, this.questionToken = questionToken, this.typeAnnotation = typeAnnotation, this.equalsValueClause = equalsValueClause; + dotDotDotToken && (dotDotDotToken.parent = this), modifiers.parent = this, identifier.parent = this, questionToken && (questionToken.parent = this), typeAnnotation && (typeAnnotation.parent = this), equalsValueClause && (equalsValueClause.parent = this); + }; + TypeScript.ParameterSyntax.prototype.kind = function () { + return 208 /* Parameter */; + }; + TypeScript.EnumElementSyntax = function (data, propertyName, equalsValueClause) { + if (data) { + this.__data = data; + } + this.propertyName = propertyName, this.equalsValueClause = equalsValueClause; + propertyName.parent = this, equalsValueClause && (equalsValueClause.parent = this); + }; + TypeScript.EnumElementSyntax.prototype.kind = function () { + return 209 /* EnumElement */; + }; + TypeScript.TypeAnnotationSyntax = function (data, colonToken, type) { + if (data) { + this.__data = data; + } + this.colonToken = colonToken, this.type = type; + colonToken.parent = this, type.parent = this; + }; + TypeScript.TypeAnnotationSyntax.prototype.kind = function () { + return 210 /* TypeAnnotation */; + }; + TypeScript.ExternalModuleReferenceSyntax = function (data, requireKeyword, openParenToken, stringLiteral, closeParenToken) { + if (data) { + this.__data = data; + } + this.requireKeyword = requireKeyword, this.openParenToken = openParenToken, this.stringLiteral = stringLiteral, this.closeParenToken = closeParenToken; + requireKeyword.parent = this, openParenToken.parent = this, stringLiteral.parent = this, closeParenToken.parent = this; + }; + TypeScript.ExternalModuleReferenceSyntax.prototype.kind = function () { + return 211 /* ExternalModuleReference */; + }; + TypeScript.ModuleNameModuleReferenceSyntax = function (data, moduleName) { + if (data) { + this.__data = data; + } + this.moduleName = moduleName; + moduleName.parent = this; + }; + TypeScript.ModuleNameModuleReferenceSyntax.prototype.kind = function () { + return 212 /* ModuleNameModuleReference */; + }; })(TypeScript || (TypeScript = {})); var TypeScript; (function (TypeScript) { TypeScript.syntaxDiagnosticsTime = 0; var SyntaxTree = (function () { - function SyntaxTree(isConcrete, sourceUnit, isDeclaration, diagnostics, fileName, text, languageVersion) { + function SyntaxTree(sourceUnit, isDeclaration, diagnostics, fileName, text, languageVersion) { this.text = text; - this._allDiagnostics = null; - this._isConcrete = isConcrete; + this._allDiagnostics = undefined; this._sourceUnit = sourceUnit; this._isDeclaration = isDeclaration; this._parserDiagnostics = diagnostics; @@ -26119,9 +26442,6 @@ var TypeScript; this._languageVersion = languageVersion; sourceUnit.syntaxTree = this; } - SyntaxTree.prototype.isConcrete = function () { - return this._isConcrete; - }; SyntaxTree.prototype.sourceUnit = function () { return this._sourceUnit; }; @@ -26137,7 +26457,7 @@ var TypeScript; return diagnostics; }; SyntaxTree.prototype.diagnostics = function () { - if (this._allDiagnostics === null) { + if (!this._allDiagnostics) { var start = new Date().getTime(); this._allDiagnostics = this.computeDiagnostics(); TypeScript.syntaxDiagnosticsTime += new Date().getTime() - start; @@ -26156,7 +26476,7 @@ var TypeScript; SyntaxTree.prototype.cacheSyntaxTreeInfo = function () { var firstToken = firstSyntaxTreeToken(this); var leadingTrivia = firstToken.leadingTrivia(this.text); - this._isExternalModule = externalModuleIndicatorSpanWorker(this, firstToken) !== null; + this._isExternalModule = !!externalModuleIndicatorSpanWorker(this, firstToken); var amdDependencies = []; for (var i = 0, n = leadingTrivia.count(); i < n; i++) { var trivia = leadingTrivia.syntaxTriviaAt(i); @@ -26172,7 +26492,7 @@ var TypeScript; SyntaxTree.prototype.getAmdDependency = function (comment) { var amdDependencyRegEx = /^\/\/\/\s* 0) { return false; } @@ -26310,7 +26629,7 @@ var TypeScript; _super.prototype.visitParameterList.call(this, node); }; GrammarCheckerWalker.prototype.visitHeritageClause = function (node) { - if (this.checkForTrailingComma(node.typeNames) || this.checkForAtLeastOneElement(node, node.typeNames, node.extendsOrImplementsKeyword, TypeScript.SyntaxFacts.getText(node.extendsOrImplementsKeyword.kind()))) { + if (this.checkForTrailingComma(node.typeNames) || this.checkForAtLeastOneElement(node.typeNames, node.extendsOrImplementsKeyword, TypeScript.SyntaxFacts.getText(node.extendsOrImplementsKeyword.kind()))) { return; } _super.prototype.visitHeritageClause.call(this, node); @@ -26322,25 +26641,25 @@ var TypeScript; _super.prototype.visitArgumentList.call(this, node); }; GrammarCheckerWalker.prototype.visitVariableDeclaration = function (node) { - if (this.checkForAtLeastOneElement(node, node.variableDeclarators, node.varKeyword, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.variable_declaration, null)) || this.checkForTrailingComma(node.variableDeclarators)) { + if (this.checkForAtLeastOneElement(node.variableDeclarators, node.varKeyword, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.variable_declaration, undefined)) || this.checkForTrailingComma(node.variableDeclarators)) { return; } _super.prototype.visitVariableDeclaration.call(this, node); }; GrammarCheckerWalker.prototype.visitTypeArgumentList = function (node) { - if (this.checkForTrailingComma(node.typeArguments) || this.checkForAtLeastOneElement(node, node.typeArguments, node.lessThanToken, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_argument, null))) { + if (this.checkForTrailingComma(node.typeArguments) || this.checkForAtLeastOneElement(node.typeArguments, node.lessThanToken, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_argument, undefined))) { return; } _super.prototype.visitTypeArgumentList.call(this, node); }; GrammarCheckerWalker.prototype.visitTupleType = function (node) { - if (this.checkForTrailingComma(node.types) || this.checkForAtLeastOneElement(node, node.types, node.openBracketToken, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, null))) { + if (this.checkForTrailingComma(node.types) || this.checkForAtLeastOneElement(node.types, node.openBracketToken, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type, undefined))) { return; } _super.prototype.visitTupleType.call(this, node); }; GrammarCheckerWalker.prototype.visitTypeParameterList = function (node) { - if (this.checkForTrailingComma(node.typeParameters) || this.checkForAtLeastOneElement(node, node.typeParameters, node.lessThanToken, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, null))) { + if (this.checkForTrailingComma(node.typeParameters) || this.checkForAtLeastOneElement(node.typeParameters, node.lessThanToken, TypeScript.getLocalizedText(TypeScript.DiagnosticCode.type_parameter, undefined))) { return; } _super.prototype.visitTypeParameterList.call(this, node); @@ -26350,7 +26669,7 @@ var TypeScript; this.pushDiagnostic(node.openBracketToken, TypeScript.DiagnosticCode.Index_signature_must_have_exactly_one_parameter); return true; } - var parameter = node.parameters[0]; + var parameter = TypeScript.nonSeparatorAt(node.parameters, 0); if (parameter.dotDotDotToken) { this.pushDiagnostic(parameter, TypeScript.DiagnosticCode.Index_signatures_cannot_have_rest_parameters); return true; @@ -26371,7 +26690,7 @@ var TypeScript; this.pushDiagnostic(parameter, TypeScript.DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); return true; } - else if (parameter.typeAnnotation.type.kind() !== 69 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 67 /* NumberKeyword */) { + else if (parameter.typeAnnotation.type.kind() !== 71 /* StringKeyword */ && parameter.typeAnnotation.type.kind() !== 69 /* NumberKeyword */) { this.pushDiagnostic(parameter, TypeScript.DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); return true; } @@ -26393,7 +26712,7 @@ var TypeScript; for (var i = 0, n = node.heritageClauses.length; i < n; i++) { TypeScript.Debug.assert(i <= 2); var heritageClause = node.heritageClauses[i]; - if (heritageClause.extendsOrImplementsKeyword.kind() === 48 /* ExtendsKeyword */) { + if (heritageClause.extendsOrImplementsKeyword.kind() === 50 /* ExtendsKeyword */) { if (seenExtendsClause) { this.pushDiagnostic(heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); return true; @@ -26402,14 +26721,14 @@ var TypeScript; this.pushDiagnostic(heritageClause, TypeScript.DiagnosticCode.extends_clause_must_precede_implements_clause); return true; } - if (heritageClause.typeNames.length > 1) { + if (TypeScript.nonSeparatorCount(heritageClause.typeNames) > 1) { this.pushDiagnostic(heritageClause, TypeScript.DiagnosticCode.Classes_can_only_extend_a_single_class); return true; } seenExtendsClause = true; } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === 51 /* ImplementsKeyword */); + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === 53 /* ImplementsKeyword */); if (seenImplementsClause) { this.pushDiagnostic(heritageClause, TypeScript.DiagnosticCode.implements_clause_already_seen); return true; @@ -26421,7 +26740,7 @@ var TypeScript; }; GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifier = function (modifiers) { if (this.inAmbientDeclaration) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 65 /* DeclareKeyword */); if (declareToken) { this.pushDiagnostic(declareToken, TypeScript.DiagnosticCode.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); return true; @@ -26431,7 +26750,7 @@ var TypeScript; }; GrammarCheckerWalker.prototype.checkForRequiredDeclareModifier = function (moduleElement, reportToken, modifiers) { if (!this.inAmbientDeclaration && this.syntaxTree.isDeclaration()) { - if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 63 /* DeclareKeyword */)) { + if (!TypeScript.SyntaxUtilities.containsToken(modifiers, 65 /* DeclareKeyword */)) { this.pushDiagnostic(reportToken, TypeScript.DiagnosticCode.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); return true; } @@ -26442,7 +26761,7 @@ var TypeScript; return; } var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 65 /* DeclareKeyword */); _super.prototype.visitClassDeclaration.call(this, node); this.inAmbientDeclaration = savedInAmbientDeclaration; }; @@ -26451,7 +26770,7 @@ var TypeScript; for (var i = 0, n = node.heritageClauses.length; i < n; i++) { TypeScript.Debug.assert(i <= 1); var heritageClause = node.heritageClauses[i]; - if (heritageClause.extendsOrImplementsKeyword.kind() === 48 /* ExtendsKeyword */) { + if (heritageClause.extendsOrImplementsKeyword.kind() === 50 /* ExtendsKeyword */) { if (seenExtendsClause) { this.pushDiagnostic(heritageClause, TypeScript.DiagnosticCode.extends_clause_already_seen); return true; @@ -26459,7 +26778,7 @@ var TypeScript; seenExtendsClause = true; } else { - TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === 51 /* ImplementsKeyword */); + TypeScript.Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === 53 /* ImplementsKeyword */); this.pushDiagnostic(heritageClause, TypeScript.DiagnosticCode.Interface_declaration_cannot_have_implements_clause); return true; } @@ -26469,7 +26788,7 @@ var TypeScript; GrammarCheckerWalker.prototype.checkInterfaceModifiers = function (modifiers) { for (var i = 0, n = modifiers.length; i < n; i++) { var modifier = modifiers[i]; - if (modifier.kind() === 63 /* DeclareKeyword */) { + if (modifier.kind() === 65 /* DeclareKeyword */) { this.pushDiagnostic(modifier, TypeScript.DiagnosticCode.A_declare_modifier_cannot_be_used_with_an_interface_declaration); return true; } @@ -26499,7 +26818,7 @@ var TypeScript; } seenAccessibilityModifier = true; } - else if (modifier.kind() === 58 /* StaticKeyword */) { + else if (modifier.kind() === 60 /* StaticKeyword */) { if (seenStaticModifier) { this.pushDiagnostic(modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); return true; @@ -26519,8 +26838,20 @@ var TypeScript; } _super.prototype.visitMemberVariableDeclaration.call(this, node); }; + GrammarCheckerWalker.prototype.visitMethodSignature = function (node) { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + _super.prototype.visitMethodSignature.call(this, node); + }; + GrammarCheckerWalker.prototype.visitPropertySignature = function (node) { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + _super.prototype.visitPropertySignature.call(this, node); + }; GrammarCheckerWalker.prototype.visitMemberFunctionDeclaration = function (node) { - if (this.checkClassElementModifiers(node.modifiers)) { + if (this.checkClassElementModifiers(node.modifiers) || this.checkForTemplatePropertyName(node.propertyName)) { return; } _super.prototype.visitMemberFunctionDeclaration.call(this, node); @@ -26540,12 +26871,12 @@ var TypeScript; }; GrammarCheckerWalker.prototype.checkIndexMemberModifiers = function (node) { if (node.modifiers.length > 0) { - this.pushDiagnostic(TypeScript.childAt(node.modifiers, 0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + this.pushDiagnostic(node.modifiers[0], TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); return true; } return false; }; - GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (parent, reportToken, languageVersion, diagnosticKey) { + GrammarCheckerWalker.prototype.checkEcmaScriptVersionIsAtLeast = function (reportToken, languageVersion, diagnosticKey) { if (this.syntaxTree.languageVersion() < languageVersion) { this.pushDiagnostic(reportToken, diagnosticKey); return true; @@ -26559,7 +26890,7 @@ var TypeScript; this.inObjectLiteralExpression = savedInObjectLiteralExpression; }; GrammarCheckerWalker.prototype.visitGetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.propertyName, 1 /* ES5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkForDisallowedAccessorTypeParameters(node.callSignature) || this.checkGetAccessorParameter(node)) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node.propertyName, 1 /* ES5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkForDisallowedAccessorTypeParameters(node.callSignature) || this.checkGetAccessorParameter(node) || this.checkForTemplatePropertyName(node.propertyName)) { return; } _super.prototype.visitGetAccessor.call(this, node); @@ -26572,7 +26903,7 @@ var TypeScript; return false; }; GrammarCheckerWalker.prototype.checkForDisallowedAccessorTypeParameters = function (callSignature) { - if (callSignature.typeParameterList !== null) { + if (callSignature.typeParameterList) { this.pushDiagnostic(callSignature.typeParameterList, TypeScript.DiagnosticCode.Type_parameters_cannot_appear_on_an_accessor); return true; } @@ -26587,11 +26918,11 @@ var TypeScript; }; GrammarCheckerWalker.prototype.checkSetAccessorParameter = function (node) { var parameters = node.callSignature.parameterList.parameters; - if (TypeScript.childCount(parameters) !== 1) { + if (TypeScript.nonSeparatorCount(parameters) !== 1) { this.pushDiagnostic(node.propertyName, TypeScript.DiagnosticCode.set_accessor_must_have_exactly_one_parameter); return true; } - var parameter = parameters[0]; + var parameter = TypeScript.nonSeparatorAt(parameters, 0); if (parameter.questionToken) { this.pushDiagnostic(parameter, TypeScript.DiagnosticCode.set_accessor_parameter_cannot_be_optional); return true; @@ -26606,8 +26937,14 @@ var TypeScript; } return false; }; + GrammarCheckerWalker.prototype.visitSimplePropertyAssignment = function (node) { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + _super.prototype.visitSimplePropertyAssignment.call(this, node); + }; GrammarCheckerWalker.prototype.visitSetAccessor = function (node) { - if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node, node.propertyName, 1 /* ES5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkForDisallowedAccessorTypeParameters(node.callSignature) || this.checkForDisallowedSetAccessorTypeAnnotation(node) || this.checkSetAccessorParameter(node)) { + if (this.checkForAccessorDeclarationInAmbientContext(node) || this.checkEcmaScriptVersionIsAtLeast(node.propertyName, 1 /* ES5 */, TypeScript.DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || this.checkForDisallowedModifiers(node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkForDisallowedAccessorTypeParameters(node.callSignature) || this.checkForDisallowedSetAccessorTypeAnnotation(node) || this.checkSetAccessorParameter(node) || this.checkForTemplatePropertyName(node.propertyName)) { return; } _super.prototype.visitSetAccessor.call(this, node); @@ -26617,29 +26954,29 @@ var TypeScript; return; } var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 65 /* DeclareKeyword */); _super.prototype.visitEnumDeclaration.call(this, node); this.inAmbientDeclaration = savedInAmbientDeclaration; }; GrammarCheckerWalker.prototype.checkEnumElements = function (node) { var previousValueWasComputed = false; - for (var i = 0, n = TypeScript.childCount(node.enumElements); i < n; i++) { - var child = TypeScript.childAt(node.enumElements, i); - if (i % 2 === 0) { - var enumElement = child; - if (!enumElement.equalsValueClause && previousValueWasComputed) { - this.pushDiagnostic(enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer); - return true; - } - if (enumElement.equalsValueClause) { - var value = enumElement.equalsValueClause.value; - previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); - } + for (var i = 0, n = TypeScript.nonSeparatorCount(node.enumElements); i < n; i++) { + var enumElement = TypeScript.nonSeparatorAt(node.enumElements, i); + if (!enumElement.equalsValueClause && previousValueWasComputed) { + this.pushDiagnostic(enumElement, TypeScript.DiagnosticCode.Enum_member_must_have_initializer); + return true; + } + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + previousValueWasComputed = !TypeScript.Syntax.isIntegerLiteral(value); } } return false; }; GrammarCheckerWalker.prototype.visitEnumElement = function (node) { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } if (this.inAmbientDeclaration && node.equalsValueClause) { var expression = node.equalsValueClause.value; if (!TypeScript.Syntax.isIntegerLiteral(expression)) { @@ -26650,7 +26987,7 @@ var TypeScript; _super.prototype.visitEnumElement.call(this, node); }; GrammarCheckerWalker.prototype.visitInvocationExpression = function (node) { - if (node.expression.kind() === 50 /* SuperKeyword */ && node.argumentList.typeArgumentList !== null) { + if (node.expression.kind() === 52 /* SuperKeyword */ && node.argumentList.typeArgumentList) { this.pushDiagnostic(node, TypeScript.DiagnosticCode.super_invocation_cannot_have_type_arguments); } _super.prototype.visitInvocationExpression.call(this, node); @@ -26660,24 +26997,24 @@ var TypeScript; var seenDeclareModifier = false; for (var i = 0, n = modifiers.length; i < n; i++) { var modifier = modifiers[i]; - if (TypeScript.SyntaxFacts.isAccessibilityModifier(modifier.kind()) || modifier.kind() === 58 /* StaticKeyword */) { + if (TypeScript.SyntaxFacts.isAccessibilityModifier(modifier.kind()) || modifier.kind() === 60 /* StaticKeyword */) { this.pushDiagnostic(modifier, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); return true; } - if (modifier.kind() === 63 /* DeclareKeyword */) { + if (modifier.kind() === 65 /* DeclareKeyword */) { if (seenDeclareModifier) { this.pushDiagnostic(modifier, TypeScript.DiagnosticCode.Accessibility_modifier_already_seen); return; } seenDeclareModifier = true; } - else if (modifier.kind() === 47 /* ExportKeyword */) { + else if (modifier.kind() === 49 /* ExportKeyword */) { if (seenExportModifier) { this.pushDiagnostic(modifier, TypeScript.DiagnosticCode._0_modifier_already_seen, [modifier.text()]); return; } if (seenDeclareModifier) { - this.pushDiagnostic(modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(47 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(63 /* DeclareKeyword */)]); + this.pushDiagnostic(modifier, TypeScript.DiagnosticCode._0_modifier_must_precede_1_modifier, [TypeScript.SyntaxFacts.getText(49 /* ExportKeyword */), TypeScript.SyntaxFacts.getText(65 /* DeclareKeyword */)]); return; } seenExportModifier = true; @@ -26689,9 +27026,9 @@ var TypeScript; if (!node.stringLiteral) { for (var i = 0, n = node.moduleElements.length; i < n; i++) { var child = node.moduleElements[i]; - if (child.kind() === 134 /* ImportDeclaration */) { + if (child.kind() === 138 /* ImportDeclaration */) { var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === 246 /* ExternalModuleReference */) { + if (importDeclaration.moduleReference.kind() === 211 /* ExternalModuleReference */) { this.pushDiagnostic(importDeclaration, TypeScript.DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); } } @@ -26700,7 +27037,7 @@ var TypeScript; return false; }; GrammarCheckerWalker.prototype.checkForDisallowedDeclareModifierOnImportDeclaration = function (modifiers) { - var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 63 /* DeclareKeyword */); + var declareToken = TypeScript.SyntaxUtilities.getToken(modifiers, 65 /* DeclareKeyword */); if (declareToken) { this.pushDiagnostic(declareToken, TypeScript.DiagnosticCode.A_declare_modifier_cannot_be_used_with_an_import_declaration); return true; @@ -26717,7 +27054,7 @@ var TypeScript; return; } if (node.stringLiteral) { - if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */)) { + if (!this.inAmbientDeclaration && !TypeScript.SyntaxUtilities.containsToken(node.modifiers, 65 /* DeclareKeyword */)) { this.pushDiagnostic(node.stringLiteral, TypeScript.DiagnosticCode.Only_ambient_modules_can_use_quoted_names); return; } @@ -26726,14 +27063,14 @@ var TypeScript; return; } var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 65 /* DeclareKeyword */); _super.prototype.visitModuleDeclaration.call(this, node); this.inAmbientDeclaration = savedInAmbientDeclaration; }; GrammarCheckerWalker.prototype.checkForDisallowedExportAssignment = function (node) { for (var i = 0, n = node.moduleElements.length; i < n; i++) { var child = node.moduleElements[i]; - if (child.kind() === 135 /* ExportAssignment */) { + if (child.kind() === 139 /* ExportAssignment */) { this.pushDiagnostic(child, TypeScript.DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); return true; } @@ -26807,7 +27144,7 @@ var TypeScript; }; GrammarCheckerWalker.prototype.inSwitchStatement = function (ast) { while (ast) { - if (ast.kind() === 152 /* SwitchStatement */) { + if (ast.kind() === 156 /* SwitchStatement */) { return true; } if (TypeScript.SyntaxUtilities.isAnyFunctionExpressionOrDeclaration(ast)) { @@ -26819,10 +27156,10 @@ var TypeScript; }; GrammarCheckerWalker.prototype.isIterationStatement = function (ast) { switch (ast.kind()) { - case 155 /* ForStatement */: - case 156 /* ForInStatement */: - case 159 /* WhileStatement */: - case 162 /* DoStatement */: + case 159 /* ForStatement */: + case 160 /* ForInStatement */: + case 163 /* WhileStatement */: + case 166 /* DoStatement */: return true; } return false; @@ -26843,7 +27180,7 @@ var TypeScript; var result = []; element = element.parent; while (element) { - if (element.kind() === 161 /* LabeledStatement */) { + if (element.kind() === 165 /* LabeledStatement */) { var labeledStatement = element; if (breakable) { result.push(labeledStatement); @@ -26863,12 +27200,12 @@ var TypeScript; }; GrammarCheckerWalker.prototype.labelIsOnContinuableConstruct = function (statement) { switch (statement.kind()) { - case 161 /* LabeledStatement */: + case 165 /* LabeledStatement */: return this.labelIsOnContinuableConstruct(statement.statement); - case 159 /* WhileStatement */: - case 155 /* ForStatement */: - case 156 /* ForInStatement */: - case 162 /* DoStatement */: + case 163 /* WhileStatement */: + case 159 /* ForStatement */: + case 160 /* ForInStatement */: + case 166 /* DoStatement */: return true; default: return false; @@ -27023,21 +27360,21 @@ var TypeScript; } return false; }; - GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (parent, modifiers) { + GrammarCheckerWalker.prototype.checkForDisallowedModifiers = function (modifiers) { if (this.inBlock || this.inObjectLiteralExpression) { if (modifiers.length > 0) { - this.pushDiagnostic(TypeScript.childAt(modifiers, 0), TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); + this.pushDiagnostic(modifiers[0], TypeScript.DiagnosticCode.Modifiers_cannot_appear_here); return true; } } return false; }; GrammarCheckerWalker.prototype.visitFunctionDeclaration = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.identifier, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedEvalOrArguments(node, node.identifier)) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.identifier, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedEvalOrArguments(node, node.identifier)) { return; } var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 65 /* DeclareKeyword */); _super.prototype.visitFunctionDeclaration.call(this, node); this.inAmbientDeclaration = savedInAmbientDeclaration; }; @@ -27047,26 +27384,32 @@ var TypeScript; } _super.prototype.visitFunctionExpression.call(this, node); }; + GrammarCheckerWalker.prototype.visitFunctionPropertyAssignment = function (node) { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + _super.prototype.visitFunctionPropertyAssignment.call(this, node); + }; GrammarCheckerWalker.prototype.visitVariableStatement = function (node) { - if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node, node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration.varKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { + if (this.checkForDisallowedDeclareModifier(node.modifiers) || this.checkForDisallowedModifiers(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration.varKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { return; } var savedInAmbientDeclaration = this.inAmbientDeclaration; - this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 63 /* DeclareKeyword */); + this.inAmbientDeclaration = this.inAmbientDeclaration || this.syntaxTree.isDeclaration() || TypeScript.SyntaxUtilities.containsToken(node.modifiers, 65 /* DeclareKeyword */); _super.prototype.visitVariableStatement.call(this, node); this.inAmbientDeclaration = savedInAmbientDeclaration; }; - GrammarCheckerWalker.prototype.checkListSeparators = function (parent, list, kind) { - for (var i = 0, n = TypeScript.childCount(list); i < n; i++) { - var child = TypeScript.childAt(list, i); - if (i % 2 === 1 && child.kind() !== kind) { + GrammarCheckerWalker.prototype.checkListSeparators = function (list, kind) { + for (var i = 0, n = TypeScript.separatorCount(list); i < n; i++) { + var child = TypeScript.separatorAt(list, i); + if (child.kind() !== kind) { this.pushDiagnostic(child, TypeScript.DiagnosticCode._0_expected, [TypeScript.SyntaxFacts.getText(kind)]); } } return false; }; GrammarCheckerWalker.prototype.visitObjectType = function (node) { - if (this.checkListSeparators(node, node.typeMembers, 78 /* SemicolonToken */)) { + if (this.checkListSeparators(node.typeMembers, 80 /* SemicolonToken */)) { return; } var savedInAmbientDeclaration = this.inAmbientDeclaration; @@ -27093,13 +27436,20 @@ var TypeScript; this.inAmbientDeclaration = savedInAmbientDeclaration; }; GrammarCheckerWalker.prototype.visitVariableDeclarator = function (node) { - if (this.checkVariableDeclaratorInitializer(node) || this.checkVariableDeclaratorIdentifier(node)) { + if (this.checkVariableDeclaratorInitializer(node) || this.checkVariableDeclaratorIdentifier(node) || this.checkForTemplatePropertyName(node.propertyName)) { return; } _super.prototype.visitVariableDeclarator.call(this, node); }; + GrammarCheckerWalker.prototype.checkForTemplatePropertyName = function (token) { + if (token.kind() === 13 /* NoSubstitutionTemplateToken */) { + this.pushDiagnostic(token, TypeScript.DiagnosticCode.Template_literal_cannot_be_used_as_an_element_name); + return true; + } + return false; + }; GrammarCheckerWalker.prototype.checkVariableDeclaratorIdentifier = function (node) { - if (node.parent.kind() !== 137 /* MemberVariableDeclaration */) { + if (node.parent.kind() !== 141 /* MemberVariableDeclaration */) { if (this.checkForDisallowedEvalOrArguments(node, node.propertyName)) { return true; } @@ -27122,7 +27472,7 @@ var TypeScript; GrammarCheckerWalker.prototype.checkConstructorModifiers = function (modifiers) { for (var i = 0, n = modifiers.length; i < n; i++) { var child = modifiers[i]; - if (child.kind() !== 57 /* PublicKeyword */) { + if (child.kind() !== 59 /* PublicKeyword */) { this.pushDiagnostic(child, TypeScript.DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [TypeScript.SyntaxFacts.getText(child.kind())]); return true; } @@ -27177,15 +27527,15 @@ var TypeScript; return false; }; GrammarCheckerWalker.prototype.isPreIncrementOrDecrementExpression = function (node) { - switch (node.kind()) { - case 170 /* PreDecrementExpression */: - case 169 /* PreIncrementExpression */: + switch (node.operatorToken.kind()) { + case 96 /* MinusMinusToken */: + case 95 /* PlusPlusToken */: return true; } return false; }; GrammarCheckerWalker.prototype.visitDeleteExpression = function (node) { - if (TypeScript.parsedInStrictMode(node) && node.expression.kind() === 11 /* IdentifierName */) { + if (TypeScript.parsedInStrictMode(node) && node.expression.kind() === 9 /* IdentifierName */) { this.pushDiagnostic(TypeScript.firstToken(node), TypeScript.DiagnosticCode.delete_cannot_be_called_on_an_identifier_in_strict_mode); return; } @@ -27199,16 +27549,16 @@ var TypeScript; return false; }; GrammarCheckerWalker.prototype.getEvalOrArguments = function (expr) { - if (expr.kind() === 11 /* IdentifierName */) { + if (expr.kind() === 9 /* IdentifierName */) { var text = TypeScript.tokenValueText(expr); if (text === "eval" || text === "arguments") { return text; } } - return null; + return undefined; }; GrammarCheckerWalker.prototype.isEvalOrArguments = function (expr) { - return this.getEvalOrArguments(expr) !== null; + return !!this.getEvalOrArguments(expr); }; GrammarCheckerWalker.prototype.visitConstraint = function (node) { if (this.checkConstraintType(node)) { @@ -27250,7 +27600,7 @@ var TypeScript; } } } - return null; + return undefined; } function implicitImportSpanWorker(trivia) { var implicitImportRegEx = /^(\/\/\/\s*/gim; @@ -27258,24 +27608,24 @@ var TypeScript; if (match) { return new TypeScript.TextSpan(trivia.fullStart(), trivia.fullWidth()); } - return null; + return undefined; } function topLevelImportOrExportSpan(node) { for (var i = 0, n = node.moduleElements.length; i < n; i++) { var moduleElement = node.moduleElements[i]; var _firstToken = TypeScript.firstToken(moduleElement); - if (_firstToken !== null && _firstToken.kind() === 47 /* ExportKeyword */) { + if (_firstToken && _firstToken.kind() === 49 /* ExportKeyword */) { return new TypeScript.TextSpan(TypeScript.start(_firstToken), TypeScript.width(_firstToken)); } - if (moduleElement.kind() === 134 /* ImportDeclaration */) { + if (moduleElement.kind() === 138 /* ImportDeclaration */) { var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === 246 /* ExternalModuleReference */) { + if (importDecl.moduleReference.kind() === 211 /* ExternalModuleReference */) { var literal = importDecl.moduleReference.stringLiteral; return new TypeScript.TextSpan(TypeScript.start(literal), TypeScript.width(literal)); } } } - return null; + return undefined; } })(TypeScript || (TypeScript = {})); var TypeScript; @@ -27360,8 +27710,8 @@ var TypeScript; _scannerParserSource = TypeScript.Scanner.createParserSource(oldSyntaxTree.fileName(), text, oldSyntaxTree.languageVersion()); function release() { _scannerParserSource.release(); - _scannerParserSource = null; - _oldSourceUnitCursor = null; + _scannerParserSource = undefined; + _oldSourceUnitCursor = undefined; _outstandingRewindPointCount = 0; } function extendToAffectedRange(changeRange, sourceUnit) { @@ -27397,11 +27747,11 @@ var TypeScript; _changeDelta = rewindPoint.changeDelta; returnSyntaxCursor(_oldSourceUnitCursor); _oldSourceUnitCursor = rewindPoint.oldSourceUnitCursor; - rewindPoint.oldSourceUnitCursor = null; + rewindPoint.oldSourceUnitCursor = undefined; _scannerParserSource.rewind(rewindPoint); } function releaseRewindPoint(rewindPoint) { - if (rewindPoint.oldSourceUnitCursor !== null) { + if (rewindPoint.oldSourceUnitCursor) { returnSyntaxCursor(rewindPoint.oldSourceUnitCursor); } _scannerParserSource.releaseRewindPoint(rewindPoint); @@ -27415,34 +27765,53 @@ var TypeScript; if (isPinned()) { return false; } - if (_changeRange !== null && _changeRangeNewSpan.intersectsWithPosition(absolutePosition())) { + if (_changeRange && _changeRangeNewSpan.intersectsWithPosition(absolutePosition())) { return false; } syncCursorToNewTextIfBehind(); return _changeDelta === 0 && !_oldSourceUnitCursor.isFinished(); } function updateTokens(nodeOrToken) { - var position = absolutePosition(); - var tokenWasMoved = isPastChangeRange() && TypeScript.fullStart(nodeOrToken) !== position; - if (tokenWasMoved) { - setTokenFullStartWalker.position = position; - TypeScript.visitNodeOrToken(setTokenFullStartWalker, nodeOrToken); + if (isPastChangeRange()) { + var position = absolutePosition(); + if (TypeScript.isToken(nodeOrToken)) { + nodeOrToken.setFullStart(position); + } + else { + var tokens = getTokens(nodeOrToken); + for (var i = 0, n = tokens.length; i < n; i++) { + var token = tokens[i]; + token.setFullStart(position); + position += token.fullWidth(); + } + } } } + function getTokens(node) { + var tokens = node.__cachedTokens; + if (!tokens) { + tokens = []; + tokenCollectorWalker.tokens = tokens; + TypeScript.visitNodeOrToken(tokenCollectorWalker, node); + node.__cachedTokens = tokens; + tokenCollectorWalker.tokens = undefined; + } + return tokens; + } function currentNode() { if (canReadFromOldSourceUnit()) { var node = tryGetNodeFromOldSourceUnit(); - if (node !== null) { + if (node) { updateTokens(node); return node; } } - return null; + return undefined; } function currentToken() { if (canReadFromOldSourceUnit()) { var token = tryGetTokenFromOldSourceUnit(); - if (token !== null) { + if (token) { updateTokens(token); return token; } @@ -27476,8 +27845,8 @@ var TypeScript; function tryGetNodeFromOldSourceUnit() { while (true) { var node = _oldSourceUnitCursor.currentNode(); - if (node === null) { - return null; + if (node === undefined) { + return undefined; } if (!intersectsWithChangeRangeSpanInOriginalText(absolutePosition(), TypeScript.fullWidth(node))) { var isIncrementallyUnusuable = TypeScript.isIncrementallyUnusable(node); @@ -27489,7 +27858,7 @@ var TypeScript; } } function canReuseTokenFromOldSourceUnit(position, token) { - if (token !== null) { + if (token) { if (!intersectsWithChangeRangeSpanInOriginalText(position, token.fullWidth())) { if (!token.isIncrementallyUnusable() && !TypeScript.Scanner.isContextualToken(token)) { return true; @@ -27500,12 +27869,12 @@ var TypeScript; } function tryGetTokenFromOldSourceUnit() { var token = _oldSourceUnitCursor.currentToken(); - return canReuseTokenFromOldSourceUnit(absolutePosition(), token) ? token : null; + return canReuseTokenFromOldSourceUnit(absolutePosition(), token) ? token : undefined; } function peekToken(n) { if (canReadFromOldSourceUnit()) { var token = tryPeekTokenFromOldSourceUnit(n); - if (token !== null) { + if (token) { return token; } } @@ -27524,13 +27893,13 @@ var TypeScript; for (var i = 0; i < n; i++) { var interimToken = _oldSourceUnitCursor.currentToken(); if (!canReuseTokenFromOldSourceUnit(currentPosition, interimToken)) { - return null; + return undefined; } currentPosition += interimToken.fullWidth(); _oldSourceUnitCursor.moveToNextSibling(); } var token = _oldSourceUnitCursor.currentToken(); - return canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : null; + return canReuseTokenFromOldSourceUnit(currentPosition, token) ? token : undefined; } function consumeNode(node) { _oldSourceUnitCursor.moveToNextSibling(); @@ -27549,13 +27918,13 @@ var TypeScript; if (!isPastChangeRange()) { if (absolutePosition() >= _changeRangeNewSpan.end()) { _changeDelta += _changeRange.newLength() - _changeRange.span().length(); - _changeRange = null; + _changeRange = undefined; } } } } function isPastChangeRange() { - return _changeRange === null; + return _changeRange === undefined; } return { text: text, @@ -27588,7 +27957,7 @@ var TypeScript; var cursor = syntaxCursorPoolCount > 0 ? syntaxCursorPool[syntaxCursorPoolCount - 1] : createSyntaxCursor(); if (syntaxCursorPoolCount > 0) { syntaxCursorPoolCount--; - syntaxCursorPool[syntaxCursorPoolCount] = null; + syntaxCursorPool[syntaxCursorPoolCount] = undefined; } return cursor; } @@ -27603,10 +27972,10 @@ var TypeScript; function clean() { for (var i = 0, n = pieces.length; i < n; i++) { var piece = pieces[i]; - if (piece.element === null) { + if (piece.element === undefined) { break; } - piece.element = null; + piece.element = undefined; piece.indexInParent = -1; } currentPieceIndex = -1; @@ -27614,7 +27983,7 @@ var TypeScript; function deepCopyFrom(other) { for (var i = 0, n = other.pieces.length; i < n; i++) { var piece = other.pieces[i]; - if (piece.element === null) { + if (piece.element === undefined) { break; } pushElement(piece.element, piece.indexInParent); @@ -27625,18 +27994,21 @@ var TypeScript; } function currentNodeOrToken() { if (isFinished()) { - return null; + return undefined; } var result = pieces[currentPieceIndex].element; return result; } function currentNode() { var element = currentNodeOrToken(); - return TypeScript.isNode(element) ? element : null; + return TypeScript.isNode(element) ? element : undefined; + } + function isEmptyList(element) { + return TypeScript.isList(element) && element.length === 0; } function moveToFirstChild() { var nodeOrToken = currentNodeOrToken(); - if (nodeOrToken === null) { + if (nodeOrToken === undefined) { return; } if (TypeScript.isToken(nodeOrToken)) { @@ -27644,7 +28016,7 @@ var TypeScript; } for (var i = 0, n = TypeScript.childCount(nodeOrToken); i < n; i++) { var child = TypeScript.childAt(nodeOrToken, i); - if (child !== null && !TypeScript.isShared(child)) { + if (child && !isEmptyList(child)) { pushElement(child, i); moveToFirstChildIfList(); return; @@ -27658,21 +28030,21 @@ var TypeScript; var parent = currentPiece.element.parent; for (var i = currentPiece.indexInParent + 1, n = TypeScript.childCount(parent); i < n; i++) { var sibling = TypeScript.childAt(parent, i); - if (sibling !== null && !TypeScript.isShared(sibling)) { + if (sibling && !isEmptyList(sibling)) { currentPiece.element = sibling; currentPiece.indexInParent = i; moveToFirstChildIfList(); return; } } - currentPiece.element = null; + currentPiece.element = undefined; currentPiece.indexInParent = -1; currentPieceIndex--; } } function moveToFirstChildIfList() { var element = pieces[currentPieceIndex].element; - if (TypeScript.isList(element) || TypeScript.isSeparatedList(element)) { + if (TypeScript.isList(element)) { pushElement(TypeScript.childAt(element, 0), 0); } } @@ -27700,7 +28072,7 @@ var TypeScript; function currentToken() { moveToFirstToken(); var element = currentNodeOrToken(); - return element === null ? null : element; + return element; } return { pieces: pieces, @@ -27716,21 +28088,19 @@ var TypeScript; deepCopyFrom: deepCopyFrom }; } - var SetTokenFullStartWalker = (function (_super) { - __extends(SetTokenFullStartWalker, _super); - function SetTokenFullStartWalker() { + var TokenCollectorWalker = (function (_super) { + __extends(TokenCollectorWalker, _super); + function TokenCollectorWalker() { _super.apply(this, arguments); + this.tokens = []; } - SetTokenFullStartWalker.prototype.visitToken = function (token) { - var position = this.position; - token.setFullStart(position); - this.position = position + token.fullWidth(); + TokenCollectorWalker.prototype.visitToken = function (token) { + this.tokens.push(token); }; - return SetTokenFullStartWalker; + return TokenCollectorWalker; })(TypeScript.SyntaxWalker); - var setTokenFullStartWalker = new SetTokenFullStartWalker(); + var tokenCollectorWalker = new TokenCollectorWalker(); function parse(oldSyntaxTree, textChangeRange, newText) { - TypeScript.Debug.assert(oldSyntaxTree.isConcrete(), "Can only incrementally parse a concrete syntax tree."); if (textChangeRange.isUnchanged()) { return oldSyntaxTree; } @@ -27759,10 +28129,10 @@ var ts; } function autoCollapse(node) { switch (node.kind) { - case 182 /* ModuleBlock */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: + case 189 /* ModuleBlock */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: return false; } return true; @@ -27774,11 +28144,11 @@ var ts; return; } switch (n.kind) { - case 151 /* Block */: + case 158 /* Block */: var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 9 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 10 /* CloseBraceToken */, sourceFile); - if (parent.kind === 156 /* DoStatement */ || parent.kind === 159 /* ForInStatement */ || parent.kind === 158 /* ForStatement */ || parent.kind === 155 /* IfStatement */ || parent.kind === 157 /* WhileStatement */ || parent.kind === 163 /* WithStatement */) { + var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); + if (parent.kind === 163 /* DoStatement */ || parent.kind === 166 /* ForInStatement */ || parent.kind === 165 /* ForStatement */ || parent.kind === 162 /* IfStatement */ || parent.kind === 164 /* WhileStatement */ || parent.kind === 170 /* WithStatement */) { addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); } else { @@ -27791,27 +28161,27 @@ var ts; }); } break; - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: - var openBrace = ts.findChildOfKind(n, 9 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 10 /* CloseBraceToken */, sourceFile); + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: + var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: - case 136 /* ObjectLiteral */: - case 164 /* SwitchStatement */: - var openBrace = ts.findChildOfKind(n, 9 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 10 /* CloseBraceToken */, sourceFile); + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: + case 140 /* ObjectLiteral */: + case 171 /* SwitchStatement */: + var openBrace = ts.findChildOfKind(n, 13 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 14 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; - case 135 /* ArrayLiteral */: - var openBracket = ts.findChildOfKind(n, 13 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 14 /* CloseBracketToken */, sourceFile); + case 139 /* ArrayLiteral */: + var openBracket = ts.findChildOfKind(n, 17 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 18 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -27837,14 +28207,14 @@ var ts; var current = node.parent; while (current) { switch (current.kind) { - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: do { current = current.parent; - } while (current.kind === 181 /* ModuleDeclaration */); - case 177 /* ClassDeclaration */: - case 180 /* EnumDeclaration */: - case 178 /* InterfaceDeclaration */: - case 175 /* FunctionDeclaration */: + } while (current.kind === 188 /* ModuleDeclaration */); + case 184 /* ClassDeclaration */: + case 187 /* EnumDeclaration */: + case 185 /* InterfaceDeclaration */: + case 182 /* FunctionDeclaration */: indent++; } current = current.parent; @@ -27855,10 +28225,10 @@ var ts; var childNodes = []; for (var i = 0, n = nodes.length; i < n; i++) { var node = nodes[i]; - if (node.kind === 177 /* ClassDeclaration */ || node.kind === 180 /* EnumDeclaration */ || node.kind === 178 /* InterfaceDeclaration */ || node.kind === 181 /* ModuleDeclaration */ || node.kind === 175 /* FunctionDeclaration */) { + if (node.kind === 184 /* ClassDeclaration */ || node.kind === 187 /* EnumDeclaration */ || node.kind === 185 /* InterfaceDeclaration */ || node.kind === 188 /* ModuleDeclaration */ || node.kind === 182 /* FunctionDeclaration */) { childNodes.push(node); } - else if (node.kind === 152 /* VariableStatement */) { + else if (node.kind === 159 /* VariableStatement */) { childNodes.push.apply(childNodes, node.declarations); } } @@ -27891,17 +28261,17 @@ var ts; for (var i = 0, n = nodes.length; i < n; i++) { var node = nodes[i]; switch (node.kind) { - case 177 /* ClassDeclaration */: - case 180 /* EnumDeclaration */: - case 178 /* InterfaceDeclaration */: + case 184 /* ClassDeclaration */: + case 187 /* EnumDeclaration */: + case 185 /* InterfaceDeclaration */: topLevelNodes.push(node); break; - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: var moduleDeclaration = node; topLevelNodes.push(node); addTopLevelNodes(getInnermostModule(moduleDeclaration).body.statements, topLevelNodes); break; - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: var functionDeclaration = node; if (isTopLevelFunctionDeclaration(functionDeclaration)) { topLevelNodes.push(node); @@ -27912,12 +28282,12 @@ var ts; } } function isTopLevelFunctionDeclaration(functionDeclaration) { - if (functionDeclaration.kind === 175 /* FunctionDeclaration */) { - if (functionDeclaration.body && functionDeclaration.body.kind === 176 /* FunctionBlock */) { - if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 175 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { + if (functionDeclaration.kind === 182 /* FunctionDeclaration */) { + if (functionDeclaration.body && functionDeclaration.body.kind === 183 /* FunctionBlock */) { + if (ts.forEach(functionDeclaration.body.statements, function (s) { return s.kind === 182 /* FunctionDeclaration */ && !isEmpty(s.name.text); })) { return true; } - if (functionDeclaration.parent.kind !== 176 /* FunctionBlock */) { + if (functionDeclaration.parent.kind !== 183 /* FunctionBlock */) { return true; } } @@ -27967,37 +28337,37 @@ var ts; } function createChildItem(node) { switch (node.kind) { - case 119 /* Parameter */: - if ((node.flags & ts.NodeFlags.Modifier) === 0) { + case 123 /* Parameter */: + if ((node.flags & 243 /* Modifier */) === 0) { return undefined; } return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 121 /* Method */: + case 125 /* Method */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberFunctionElement); - case 123 /* GetAccessor */: + case 127 /* GetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberGetAccessorElement); - case 124 /* SetAccessor */: + case 128 /* SetAccessor */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberSetAccessorElement); - case 127 /* IndexSignature */: + case 131 /* IndexSignature */: return createItem(node, "[]", ts.ScriptElementKind.indexSignatureElement); - case 185 /* EnumMember */: + case 192 /* EnumMember */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 125 /* CallSignature */: + case 129 /* CallSignature */: return createItem(node, "()", ts.ScriptElementKind.callSignatureElement); - case 126 /* ConstructSignature */: + case 130 /* ConstructSignature */: return createItem(node, "new()", ts.ScriptElementKind.constructSignatureElement); - case 120 /* Property */: + case 124 /* Property */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.memberVariableElement); - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.functionElement); - case 174 /* VariableDeclaration */: + case 181 /* VariableDeclaration */: if (node.flags & 4096 /* Const */) { return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.constantElement); } else { return createItem(node, getTextOfNode(node.name), ts.ScriptElementKind.variableElement); } - case 122 /* Constructor */: + case 126 /* Constructor */: return createItem(node, "constructor", ts.ScriptElementKind.constructorImplementationElement); } return undefined; @@ -28027,17 +28397,17 @@ var ts; } function createTopLevelItem(node) { switch (node.kind) { - case 186 /* SourceFile */: + case 193 /* SourceFile */: return createSourceFileItem(node); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: return createClassItem(node); - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: return createEnumItem(node); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return createIterfaceItem(node); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return createModuleItem(node); - case 175 /* FunctionDeclaration */: + case 182 /* FunctionDeclaration */: return createFunctionItem(node); } return undefined; @@ -28047,7 +28417,7 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 181 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 188 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -28059,7 +28429,7 @@ var ts; return getNavigationBarItem(moduleName, ts.ScriptElementKind.moduleElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } function createFunctionItem(node) { - if (node.name && node.body && node.body.kind === 176 /* FunctionBlock */) { + if (node.name && node.body && node.body.kind === 183 /* FunctionBlock */) { var childItems = getItemsWorker(sortNodes(node.body.statements), createChildItem); return getNavigationBarItem(node.name.text, ts.ScriptElementKind.functionElement, ts.getNodeModifiers(node), [getNodeSpan(node)], childItems, getIndent(node)); } @@ -28078,7 +28448,7 @@ var ts; var childItems; if (node.members) { var constructor = ts.forEach(node.members, function (member) { - return member.kind === 122 /* Constructor */ && member; + return member.kind === 126 /* Constructor */ && member; }); var nodes = constructor ? constructor.parameters.concat(node.members) : node.members; var childItems = getItemsWorker(sortNodes(nodes), createChildItem); @@ -28095,13 +28465,13 @@ var ts; } } function getInnermostModule(node) { - while (node.body.kind === 181 /* ModuleDeclaration */) { + while (node.body.kind === 188 /* ModuleDeclaration */) { node = node.body; } return node; } function getNodeSpan(node) { - return node.kind === 186 /* SourceFile */ ? TypeScript.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd()); + return node.kind === 193 /* SourceFile */ ? TypeScript.TextSpan.fromBounds(node.getFullStart(), node.getEnd()) : TypeScript.TextSpan.fromBounds(node.getStart(), node.getEnd()); } function getTextOfNode(node) { return ts.getTextOfNodeFromSourceText(sourceFile.text, node); @@ -28149,10 +28519,10 @@ var TypeScript; var leadingTrivia = firstTokenInLine.leadingTrivia(); for (var i = leadingTrivia.count() - 1; i >= 0; i--) { var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 5 /* NewLineTrivia */) { + if (trivia.kind() === 3 /* NewLineTrivia */) { break; } - if (trivia.kind() === 6 /* MultiLineCommentTrivia */) { + if (trivia.kind() === 4 /* MultiLineCommentTrivia */) { var lineSegments = TypeScript.Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia); leadingTextInReverse.push(TypeScript.ArrayUtilities.last(lineSegments)); if (lineSegments.length > 0) { @@ -28234,13 +28604,13 @@ var ts; } return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); function getImmediatelyContainingArgumentInfo(node) { - if (node.parent.kind !== 140 /* CallExpression */ && node.parent.kind !== 141 /* NewExpression */) { + if (node.parent.kind !== 144 /* CallExpression */ && node.parent.kind !== 145 /* NewExpression */) { return undefined; } var parent = node.parent; - if (node.kind === 19 /* LessThanToken */ || node.kind === 11 /* OpenParenToken */) { + if (node.kind === 23 /* LessThanToken */ || node.kind === 15 /* OpenParenToken */) { var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile); - ts.Debug.assert(list); + ts.Debug.assert(list !== undefined); return { list: list, listItemIndex: 0 @@ -28249,12 +28619,12 @@ var ts; return ts.findListItemInfo(node); } function getContainingArgumentInfo(node) { - for (var n = node; n.kind !== 186 /* SourceFile */; n = n.parent) { - if (n.kind === 176 /* FunctionBlock */) { + for (var n = node; n.kind !== 193 /* SourceFile */; n = n.parent) { + if (n.kind === 183 /* FunctionBlock */) { return undefined; } if (n.pos < n.parent.pos || n.end > n.parent.end) { - ts.Debug.fail("Node of kind " + ts.SyntaxKind[n.kind] + " is not a subspan of its parent of kind " + ts.SyntaxKind[n.parent.kind]); + ts.Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); } var argumentInfo = getImmediatelyContainingArgumentInfo(n); if (argumentInfo) { @@ -28300,20 +28670,20 @@ var ts; prefixParts.push.apply(prefixParts, callTargetDisplayParts); } if (isTypeParameterHelp) { - prefixParts.push(ts.punctuationPart(19 /* LessThanToken */)); + prefixParts.push(ts.punctuationPart(23 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixParts.push(ts.punctuationPart(20 /* GreaterThanToken */)); + suffixParts.push(ts.punctuationPart(24 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, argumentListOrTypeArgumentList); }); suffixParts.push.apply(suffixParts, parameterParts); } else { var typeParameterParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, argumentListOrTypeArgumentList); }); prefixParts.push.apply(prefixParts, typeParameterParts); - prefixParts.push(ts.punctuationPart(11 /* OpenParenToken */)); + prefixParts.push(ts.punctuationPart(15 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixParts.push(ts.punctuationPart(12 /* CloseParenToken */)); + suffixParts.push(ts.punctuationPart(16 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, argumentListOrTypeArgumentList); }); suffixParts.push.apply(suffixParts, returnTypeParts); @@ -28321,7 +28691,7 @@ var ts; isVariadic: candidateSignature.hasRestParameter, prefixDisplayParts: prefixParts, suffixDisplayParts: suffixParts, - separatorDisplayParts: [ts.punctuationPart(18 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(22 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, documentation: candidateSignature.getDocumentationComment() }; @@ -28330,7 +28700,7 @@ var ts; var applicableSpanEnd = ts.skipTrivia(sourceFile.text, argumentListOrTypeArgumentList.end, false); var applicableSpan = new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); var argumentIndex = (argumentInfoOrTypeArgumentInfo.listItemIndex + 1) >> 1; - var argumentCount = argumentListOrTypeArgumentList.getChildCount() === 0 ? 0 : 1 + ts.countWhere(argumentListOrTypeArgumentList.getChildren(), function (arg) { return arg.kind === 18 /* CommaToken */; }); + var argumentCount = argumentListOrTypeArgumentList.getChildCount() === 0 ? 0 : 1 + ts.countWhere(argumentListOrTypeArgumentList.getChildren(), function (arg) { return arg.kind === 22 /* CommaToken */; }); var selectedItemIndex = candidates.indexOf(bestSignature); if (selectedItemIndex < 0) { selectedItemIndex = selectBestInvalidOverloadIndex(candidates, argumentCount); @@ -28387,7 +28757,7 @@ var ts; ts.findChildOfKind = findChildOfKind; function findContainingList(node) { var syntaxList = ts.forEach(node.parent.getChildren(), function (c) { - if (c.kind === 188 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { + if (c.kind === 195 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -28395,7 +28765,7 @@ var ts; } ts.findContainingList = findContainingList; function findListItemIndexContainingPosition(list, position) { - ts.Debug.assert(list.kind === 188 /* SyntaxList */); + ts.Debug.assert(list.kind === 195 /* SyntaxList */); var children = list.getChildren(); for (var i = 0; i < children.length; i++) { if (children[i].pos <= position && children[i].end > position) { @@ -28502,7 +28872,7 @@ var ts; } } } - ts.Debug.assert(startNode || n.kind === 186 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 193 /* SourceFile */); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -28518,30 +28888,30 @@ var ts; } ts.findPrecedingToken = findPrecedingToken; function nodeHasTokens(n) { - if (n.kind === 154 /* ExpressionStatement */) { + if (n.kind === 161 /* ExpressionStatement */) { return nodeHasTokens(n.expression); } - if (n.kind === 1 /* EndOfFileToken */ || n.kind === 150 /* OmittedExpression */ || n.kind === 116 /* Missing */) { + if (n.kind === 1 /* EndOfFileToken */ || n.kind === 157 /* OmittedExpression */ || n.kind === 120 /* Missing */) { return false; } - return n.kind !== 188 /* SyntaxList */ || n.getChildCount() !== 0; + return n.kind !== 195 /* SyntaxList */ || n.getChildCount() !== 0; } function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 128 /* TypeReference */ || node.kind === 140 /* CallExpression */) { + if (node.kind === 132 /* TypeReference */ || node.kind === 144 /* CallExpression */) { return node.typeArguments; } - if (ts.isAnyFunction(node) || node.kind === 177 /* ClassDeclaration */ || node.kind === 178 /* InterfaceDeclaration */) { + if (ts.isAnyFunction(node) || node.kind === 184 /* ClassDeclaration */ || node.kind === 185 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; function isToken(n) { - return n.kind >= ts.SyntaxKind.FirstToken && n.kind <= ts.SyntaxKind.LastToken; + return n.kind >= 1 /* FirstToken */ && n.kind <= 119 /* LastToken */; } ts.isToken = isToken; function isWord(n) { - return n.kind === 59 /* Identifier */ || ts.isKeyword(n.kind); + return n.kind === 63 /* Identifier */ || ts.isKeyword(n.kind); } function isPropertyName(n) { return n.kind === 7 /* StringLiteral */ || n.kind === 6 /* NumericLiteral */ || isWord(n); @@ -28551,7 +28921,7 @@ var ts; } ts.isComment = isComment; function isPunctuation(n) { - return ts.SyntaxKind.FirstPunctuation <= n.kind && n.kind <= ts.SyntaxKind.LastPunctuation; + return 13 /* FirstPunctuation */ <= n.kind && n.kind <= 62 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; })(ts || (ts = {})); @@ -28802,7 +29172,7 @@ var TypeScript; FormattingManager.prototype.formatOnSemicolon = function (caretPosition) { var sourceUnit = this.syntaxTree.sourceUnit(); var semicolonPositionedToken = TypeScript.findToken(sourceUnit, caretPosition - 1); - if (semicolonPositionedToken.kind() === 78 /* SemicolonToken */) { + if (semicolonPositionedToken.kind() === 80 /* SemicolonToken */) { var current = semicolonPositionedToken; while (current.parent !== null && TypeScript.end(current.parent) === TypeScript.end(semicolonPositionedToken) && current.parent.kind() !== 1 /* List */) { current = current.parent; @@ -28815,7 +29185,7 @@ var TypeScript; FormattingManager.prototype.formatOnClosingCurlyBrace = function (caretPosition) { var sourceUnit = this.syntaxTree.sourceUnit(); var closeBracePositionedToken = TypeScript.findToken(sourceUnit, caretPosition - 1); - if (closeBracePositionedToken.kind() === 71 /* CloseBraceToken */) { + if (closeBracePositionedToken.kind() === 73 /* CloseBraceToken */) { var current = closeBracePositionedToken; while (current.parent !== null && TypeScript.end(current.parent) === TypeScript.end(closeBracePositionedToken) && current.parent.kind() !== 1 /* List */) { current = current.parent; @@ -29029,71 +29399,71 @@ var TypeScript; var Rules = (function () { function Rules() { this.IgnoreBeforeComment = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.Any, Formatting.Shared.TokenRange.Comments), Formatting.RuleOperation.create1(0 /* Ignore */)); - this.IgnoreAfterLineComment = new Formatting.Rule(Formatting.RuleDescriptor.create3(7 /* SingleLineCommentTrivia */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create1(0 /* Ignore */)); - this.NoSpaceBeforeSemicolon = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 78 /* SemicolonToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceBeforeColon = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 106 /* ColonToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 3 /* Delete */)); - this.NoSpaceBeforeQMark = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 105 /* QuestionToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 3 /* Delete */)); - this.SpaceAfterColon = new Formatting.Rule(Formatting.RuleDescriptor.create3(106 /* ColonToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 1 /* Space */)); - this.SpaceAfterQMark = new Formatting.Rule(Formatting.RuleDescriptor.create3(105 /* QuestionToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 1 /* Space */)); - this.SpaceAfterSemicolon = new Formatting.Rule(Formatting.RuleDescriptor.create3(78 /* SemicolonToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.SpaceAfterCloseBrace = new Formatting.Rule(Formatting.RuleDescriptor.create3(71 /* CloseBraceToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 1 /* Space */)); - this.SpaceBetweenCloseBraceAndElse = new Formatting.Rule(Formatting.RuleDescriptor.create1(71 /* CloseBraceToken */, 23 /* ElseKeyword */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new Formatting.Rule(Formatting.RuleDescriptor.create1(71 /* CloseBraceToken */, 42 /* WhileKeyword */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.NoSpaceAfterCloseBrace = new Formatting.Rule(Formatting.RuleDescriptor.create3(71 /* CloseBraceToken */, Formatting.Shared.TokenRange.FromTokens([73 /* CloseParenToken */, 75 /* CloseBracketToken */, 79 /* CommaToken */, 78 /* SemicolonToken */])), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceBeforeDot = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 76 /* DotToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceAfterDot = new Formatting.Rule(Formatting.RuleDescriptor.create3(76 /* DotToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceBeforeOpenBracket = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 74 /* OpenBracketToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceAfterOpenBracket = new Formatting.Rule(Formatting.RuleDescriptor.create3(74 /* OpenBracketToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceBeforeCloseBracket = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 75 /* CloseBracketToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceAfterCloseBracket = new Formatting.Rule(Formatting.RuleDescriptor.create3(75 /* CloseBracketToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.IgnoreAfterLineComment = new Formatting.Rule(Formatting.RuleDescriptor.create3(5 /* SingleLineCommentTrivia */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create1(0 /* Ignore */)); + this.NoSpaceBeforeSemicolon = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 80 /* SemicolonToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceBeforeColon = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 108 /* ColonToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 3 /* Delete */)); + this.NoSpaceBeforeQMark = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 107 /* QuestionToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 3 /* Delete */)); + this.SpaceAfterColon = new Formatting.Rule(Formatting.RuleDescriptor.create3(108 /* ColonToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 1 /* Space */)); + this.SpaceAfterQMark = new Formatting.Rule(Formatting.RuleDescriptor.create3(107 /* QuestionToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 1 /* Space */)); + this.SpaceAfterSemicolon = new Formatting.Rule(Formatting.RuleDescriptor.create3(80 /* SemicolonToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.SpaceAfterCloseBrace = new Formatting.Rule(Formatting.RuleDescriptor.create3(73 /* CloseBraceToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsAfterCodeBlockContext), 1 /* Space */)); + this.SpaceBetweenCloseBraceAndElse = new Formatting.Rule(Formatting.RuleDescriptor.create1(73 /* CloseBraceToken */, 25 /* ElseKeyword */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new Formatting.Rule(Formatting.RuleDescriptor.create1(73 /* CloseBraceToken */, 44 /* WhileKeyword */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.NoSpaceAfterCloseBrace = new Formatting.Rule(Formatting.RuleDescriptor.create3(73 /* CloseBraceToken */, Formatting.Shared.TokenRange.FromTokens([75 /* CloseParenToken */, 77 /* CloseBracketToken */, 81 /* CommaToken */, 80 /* SemicolonToken */])), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceBeforeDot = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 78 /* DotToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceAfterDot = new Formatting.Rule(Formatting.RuleDescriptor.create3(78 /* DotToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceBeforeOpenBracket = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 76 /* OpenBracketToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceAfterOpenBracket = new Formatting.Rule(Formatting.RuleDescriptor.create3(76 /* OpenBracketToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceBeforeCloseBracket = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 77 /* CloseBracketToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceAfterCloseBracket = new Formatting.Rule(Formatting.RuleDescriptor.create3(77 /* CloseBracketToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); this.FunctionOpenBraceLeftTokenRange = Formatting.Shared.TokenRange.AnyIncludingMultilineComments; - this.SpaceBeforeOpenBraceInFunction = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 70 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 1 /* Space */), 1 /* CanDeleteNewLines */); - this.TypeScriptOpenBraceLeftTokenRange = Formatting.Shared.TokenRange.FromTokens([11 /* IdentifierName */, 6 /* MultiLineCommentTrivia */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 70 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 1 /* Space */), 1 /* CanDeleteNewLines */); - this.ControlOpenBraceLeftTokenRange = Formatting.Shared.TokenRange.FromTokens([73 /* CloseParenToken */, 6 /* MultiLineCommentTrivia */, 22 /* DoKeyword */, 38 /* TryKeyword */, 25 /* FinallyKeyword */, 23 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 70 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 1 /* Space */), 1 /* CanDeleteNewLines */); - this.SpaceAfterOpenBrace = new Formatting.Rule(Formatting.RuleDescriptor.create3(70 /* OpenBraceToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 1 /* Space */)); - this.SpaceBeforeCloseBrace = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 71 /* CloseBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 1 /* Space */)); - this.NoSpaceBetweenEmptyBraceBrackets = new Formatting.Rule(Formatting.RuleDescriptor.create1(70 /* OpenBraceToken */, 71 /* CloseBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 3 /* Delete */)); - this.NewLineAfterOpenBraceInBlockContext = new Formatting.Rule(Formatting.RuleDescriptor.create3(70 /* OpenBraceToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 2 /* NewLine */)); - this.NewLineBeforeCloseBraceInBlockContext = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.AnyIncludingMultilineComments, 71 /* CloseBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 2 /* NewLine */)); + this.SpaceBeforeOpenBraceInFunction = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 72 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 1 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = Formatting.Shared.TokenRange.FromTokens([9 /* IdentifierName */, 4 /* MultiLineCommentTrivia */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 72 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 1 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = Formatting.Shared.TokenRange.FromTokens([75 /* CloseParenToken */, 4 /* MultiLineCommentTrivia */, 24 /* DoKeyword */, 40 /* TryKeyword */, 27 /* FinallyKeyword */, 25 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 72 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 1 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceAfterOpenBrace = new Formatting.Rule(Formatting.RuleDescriptor.create3(72 /* OpenBraceToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 1 /* Space */)); + this.SpaceBeforeCloseBrace = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 73 /* CloseBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSingleLineBlockContext), 1 /* Space */)); + this.NoSpaceBetweenEmptyBraceBrackets = new Formatting.Rule(Formatting.RuleDescriptor.create1(72 /* OpenBraceToken */, 73 /* CloseBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectContext), 3 /* Delete */)); + this.NewLineAfterOpenBraceInBlockContext = new Formatting.Rule(Formatting.RuleDescriptor.create3(72 /* OpenBraceToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 2 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.AnyIncludingMultilineComments, 73 /* CloseBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 2 /* NewLine */)); this.NoSpaceAfterUnaryPrefixOperator = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.UnaryPrefixOperators, Formatting.Shared.TokenRange.UnaryPrefixExpressions), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 3 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new Formatting.Rule(Formatting.RuleDescriptor.create3(93 /* PlusPlusToken */, Formatting.Shared.TokenRange.UnaryPreincrementExpressions), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new Formatting.Rule(Formatting.RuleDescriptor.create3(94 /* MinusMinusToken */, Formatting.Shared.TokenRange.UnaryPredecrementExpressions), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceBeforeUnaryPostincrementOperator = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.UnaryPostincrementExpressions, 93 /* PlusPlusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 94 /* MinusMinusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new Formatting.Rule(Formatting.RuleDescriptor.create1(93 /* PlusPlusToken */, 89 /* PlusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new Formatting.Rule(Formatting.RuleDescriptor.create1(89 /* PlusToken */, 89 /* PlusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new Formatting.Rule(Formatting.RuleDescriptor.create1(89 /* PlusToken */, 93 /* PlusPlusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new Formatting.Rule(Formatting.RuleDescriptor.create1(94 /* MinusMinusToken */, 90 /* MinusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new Formatting.Rule(Formatting.RuleDescriptor.create1(90 /* MinusToken */, 90 /* MinusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new Formatting.Rule(Formatting.RuleDescriptor.create1(90 /* MinusToken */, 94 /* MinusMinusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); - this.NoSpaceBeforeComma = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 79 /* CommaToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.SpaceAfterCertainKeywords = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.FromTokens([40 /* VarKeyword */, 36 /* ThrowKeyword */, 31 /* NewKeyword */, 21 /* DeleteKeyword */, 33 /* ReturnKeyword */, 39 /* TypeOfKeyword */]), Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncCall = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 72 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext), 3 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new Formatting.Rule(Formatting.RuleDescriptor.create3(27 /* FunctionKeyword */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 1 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 72 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 3 /* Delete */)); - this.SpaceAfterVoidOperator = new Formatting.Rule(Formatting.RuleDescriptor.create3(41 /* VoidKeyword */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 1 /* Space */)); - this.NoSpaceBetweenReturnAndSemicolon = new Formatting.Rule(Formatting.RuleDescriptor.create1(33 /* ReturnKeyword */, 78 /* SemicolonToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.SpaceBetweenStatements = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.FromTokens([73 /* CloseParenToken */, 22 /* DoKeyword */, 23 /* ElseKeyword */, 16 /* CaseKeyword */]), Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 1 /* Space */)); - this.SpaceAfterTryFinally = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.FromTokens([38 /* TryKeyword */, 25 /* FinallyKeyword */]), 70 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.SpaceAfterGetSetInMember = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.FromTokens([64 /* GetKeyword */, 68 /* SetKeyword */]), 11 /* IdentifierName */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 1 /* Space */)); + this.NoSpaceAfterUnaryPreincrementOperator = new Formatting.Rule(Formatting.RuleDescriptor.create3(95 /* PlusPlusToken */, Formatting.Shared.TokenRange.UnaryPreincrementExpressions), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new Formatting.Rule(Formatting.RuleDescriptor.create3(96 /* MinusMinusToken */, Formatting.Shared.TokenRange.UnaryPredecrementExpressions), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceBeforeUnaryPostincrementOperator = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.UnaryPostincrementExpressions, 95 /* PlusPlusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 96 /* MinusMinusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new Formatting.Rule(Formatting.RuleDescriptor.create1(95 /* PlusPlusToken */, 91 /* PlusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new Formatting.Rule(Formatting.RuleDescriptor.create1(91 /* PlusToken */, 91 /* PlusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new Formatting.Rule(Formatting.RuleDescriptor.create1(91 /* PlusToken */, 95 /* PlusPlusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new Formatting.Rule(Formatting.RuleDescriptor.create1(96 /* MinusMinusToken */, 92 /* MinusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new Formatting.Rule(Formatting.RuleDescriptor.create1(92 /* MinusToken */, 92 /* MinusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new Formatting.Rule(Formatting.RuleDescriptor.create1(92 /* MinusToken */, 96 /* MinusMinusToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); + this.NoSpaceBeforeComma = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 81 /* CommaToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.SpaceAfterCertainKeywords = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.FromTokens([42 /* VarKeyword */, 38 /* ThrowKeyword */, 33 /* NewKeyword */, 23 /* DeleteKeyword */, 35 /* ReturnKeyword */, 41 /* TypeOfKeyword */]), Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncCall = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 74 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionCallOrNewContext), 3 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new Formatting.Rule(Formatting.RuleDescriptor.create3(29 /* FunctionKeyword */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 1 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 74 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsFunctionDeclContext), 3 /* Delete */)); + this.SpaceAfterVoidOperator = new Formatting.Rule(Formatting.RuleDescriptor.create3(43 /* VoidKeyword */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsVoidOpContext), 1 /* Space */)); + this.NoSpaceBetweenReturnAndSemicolon = new Formatting.Rule(Formatting.RuleDescriptor.create1(35 /* ReturnKeyword */, 80 /* SemicolonToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.SpaceBetweenStatements = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.FromTokens([75 /* CloseParenToken */, 24 /* DoKeyword */, 25 /* ElseKeyword */, 18 /* CaseKeyword */]), Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotForContext), 1 /* Space */)); + this.SpaceAfterTryFinally = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.FromTokens([40 /* TryKeyword */, 27 /* FinallyKeyword */]), 72 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.SpaceAfterGetSetInMember = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.FromTokens([66 /* GetKeyword */, 70 /* SetKeyword */]), 9 /* IdentifierName */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 1 /* Space */)); this.SpaceBeforeBinaryKeywordOperator = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.Any, Formatting.Shared.TokenRange.BinaryKeywordOperators), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); this.SpaceAfterBinaryKeywordOperator = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.BinaryKeywordOperators, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); - this.NoSpaceAfterConstructor = new Formatting.Rule(Formatting.RuleDescriptor.create1(62 /* ConstructorKeyword */, 72 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceAfterModuleImport = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.FromTokens([65 /* ModuleKeyword */, 66 /* RequireKeyword */]), 72 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.SpaceAfterCertainTypeScriptKeywords = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.FromTokens([44 /* ClassKeyword */, 63 /* DeclareKeyword */, 46 /* EnumKeyword */, 47 /* ExportKeyword */, 48 /* ExtendsKeyword */, 64 /* GetKeyword */, 51 /* ImplementsKeyword */, 49 /* ImportKeyword */, 52 /* InterfaceKeyword */, 65 /* ModuleKeyword */, 55 /* PrivateKeyword */, 57 /* PublicKeyword */, 68 /* SetKeyword */, 58 /* StaticKeyword */]), Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.SpaceBeforeCertainTypeScriptKeywords = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.Any, Formatting.Shared.TokenRange.FromTokens([48 /* ExtendsKeyword */, 51 /* ImplementsKeyword */])), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.SpaceAfterModuleName = new Formatting.Rule(Formatting.RuleDescriptor.create1(14 /* StringLiteral */, 70 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsModuleDeclContext), 1 /* Space */)); - this.SpaceAfterArrow = new Formatting.Rule(Formatting.RuleDescriptor.create3(85 /* EqualsGreaterThanToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.NoSpaceAfterEllipsis = new Formatting.Rule(Formatting.RuleDescriptor.create1(77 /* DotDotDotToken */, 11 /* IdentifierName */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new Formatting.Rule(Formatting.RuleDescriptor.create3(105 /* QuestionToken */, Formatting.Shared.TokenRange.FromTokens([73 /* CloseParenToken */, 79 /* CommaToken */])), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 3 /* Delete */)); - this.NoSpaceBeforeOpenAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.TypeNames, 80 /* LessThanToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create1(73 /* CloseParenToken */, 80 /* LessThanToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create3(80 /* LessThanToken */, Formatting.Shared.TokenRange.TypeNames), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); - this.NoSpaceBeforeCloseAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 81 /* GreaterThanToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create3(81 /* GreaterThanToken */, Formatting.Shared.TokenRange.FromTokens([72 /* OpenParenToken */, 74 /* OpenBracketToken */, 81 /* GreaterThanToken */, 79 /* CommaToken */])), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new Formatting.Rule(Formatting.RuleDescriptor.create1(70 /* OpenBraceToken */, 71 /* CloseBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 3 /* Delete */)); + this.NoSpaceAfterConstructor = new Formatting.Rule(Formatting.RuleDescriptor.create1(64 /* ConstructorKeyword */, 74 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceAfterModuleImport = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.FromTokens([67 /* ModuleKeyword */, 68 /* RequireKeyword */]), 74 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.SpaceAfterCertainTypeScriptKeywords = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.FromTokens([46 /* ClassKeyword */, 65 /* DeclareKeyword */, 48 /* EnumKeyword */, 49 /* ExportKeyword */, 50 /* ExtendsKeyword */, 66 /* GetKeyword */, 53 /* ImplementsKeyword */, 51 /* ImportKeyword */, 54 /* InterfaceKeyword */, 67 /* ModuleKeyword */, 57 /* PrivateKeyword */, 59 /* PublicKeyword */, 70 /* SetKeyword */, 60 /* StaticKeyword */]), Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.SpaceBeforeCertainTypeScriptKeywords = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.Any, Formatting.Shared.TokenRange.FromTokens([50 /* ExtendsKeyword */, 53 /* ImplementsKeyword */])), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.SpaceAfterModuleName = new Formatting.Rule(Formatting.RuleDescriptor.create1(12 /* StringLiteral */, 72 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsModuleDeclContext), 1 /* Space */)); + this.SpaceAfterArrow = new Formatting.Rule(Formatting.RuleDescriptor.create3(87 /* EqualsGreaterThanToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.NoSpaceAfterEllipsis = new Formatting.Rule(Formatting.RuleDescriptor.create1(79 /* DotDotDotToken */, 9 /* IdentifierName */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new Formatting.Rule(Formatting.RuleDescriptor.create3(107 /* QuestionToken */, Formatting.Shared.TokenRange.FromTokens([75 /* CloseParenToken */, 81 /* CommaToken */])), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsNotBinaryOpContext), 3 /* Delete */)); + this.NoSpaceBeforeOpenAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.TypeNames, 82 /* LessThanToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create1(75 /* CloseParenToken */, 82 /* LessThanToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create3(82 /* LessThanToken */, Formatting.Shared.TokenRange.TypeNames), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); + this.NoSpaceBeforeCloseAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 83 /* GreaterThanToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new Formatting.Rule(Formatting.RuleDescriptor.create3(83 /* GreaterThanToken */, Formatting.Shared.TokenRange.FromTokens([74 /* OpenParenToken */, 76 /* OpenBracketToken */, 83 /* GreaterThanToken */, 81 /* CommaToken */])), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsTypeArgumentOrParameterContext), 3 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new Formatting.Rule(Formatting.RuleDescriptor.create1(72 /* OpenBraceToken */, 73 /* CloseBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), 3 /* Delete */)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -29161,26 +29531,26 @@ var TypeScript; this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new Formatting.Rule(Formatting.RuleDescriptor.create3(79 /* CommaToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.NoSpaceAfterComma = new Formatting.Rule(Formatting.RuleDescriptor.create3(79 /* CommaToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.SpaceAfterComma = new Formatting.Rule(Formatting.RuleDescriptor.create3(81 /* CommaToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.NoSpaceAfterComma = new Formatting.Rule(Formatting.RuleDescriptor.create3(81 /* CommaToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); this.SpaceBeforeBinaryOperator = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.Any, Formatting.Shared.TokenRange.BinaryOperators), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); this.SpaceAfterBinaryOperator = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.BinaryOperators, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 1 /* Space */)); this.NoSpaceBeforeBinaryOperator = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.Any, Formatting.Shared.TokenRange.BinaryOperators), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 3 /* Delete */)); this.NoSpaceAfterBinaryOperator = new Formatting.Rule(Formatting.RuleDescriptor.create4(Formatting.Shared.TokenRange.BinaryOperators, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsBinaryOpContext), 3 /* Delete */)); - this.SpaceAfterKeywordInControl = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Keywords, 72 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsControlDeclContext), 1 /* Space */)); - this.NoSpaceAfterKeywordInControl = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Keywords, 72 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsControlDeclContext), 3 /* Delete */)); - this.NewLineBeforeOpenBraceInFunction = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 70 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 2 /* NewLine */), 1 /* CanDeleteNewLines */); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 70 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 2 /* NewLine */), 1 /* CanDeleteNewLines */); - this.NewLineBeforeOpenBraceInControl = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 70 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 2 /* NewLine */), 1 /* CanDeleteNewLines */); - this.SpaceAfterSemicolonInFor = new Formatting.Rule(Formatting.RuleDescriptor.create3(78 /* SemicolonToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 1 /* Space */)); - this.NoSpaceAfterSemicolonInFor = new Formatting.Rule(Formatting.RuleDescriptor.create3(78 /* SemicolonToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 3 /* Delete */)); - this.SpaceAfterOpenParen = new Formatting.Rule(Formatting.RuleDescriptor.create3(72 /* OpenParenToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.SpaceBeforeCloseParen = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 73 /* CloseParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); - this.NoSpaceBetweenParens = new Formatting.Rule(Formatting.RuleDescriptor.create1(72 /* OpenParenToken */, 73 /* CloseParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceAfterOpenParen = new Formatting.Rule(Formatting.RuleDescriptor.create3(72 /* OpenParenToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.NoSpaceBeforeCloseParen = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 73 /* CloseParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); - this.SpaceAfterAnonymousFunctionKeyword = new Formatting.Rule(Formatting.RuleDescriptor.create1(27 /* FunctionKeyword */, 72 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 1 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new Formatting.Rule(Formatting.RuleDescriptor.create1(27 /* FunctionKeyword */, 72 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 3 /* Delete */)); + this.SpaceAfterKeywordInControl = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Keywords, 74 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsControlDeclContext), 1 /* Space */)); + this.NoSpaceAfterKeywordInControl = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Keywords, 74 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsControlDeclContext), 3 /* Delete */)); + this.NewLineBeforeOpenBraceInFunction = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 72 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 2 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 72 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 2 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new Formatting.Rule(Formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 72 /* OpenBraceToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 2 /* NewLine */), 1 /* CanDeleteNewLines */); + this.SpaceAfterSemicolonInFor = new Formatting.Rule(Formatting.RuleDescriptor.create3(80 /* SemicolonToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 1 /* Space */)); + this.NoSpaceAfterSemicolonInFor = new Formatting.Rule(Formatting.RuleDescriptor.create3(80 /* SemicolonToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsForContext), 3 /* Delete */)); + this.SpaceAfterOpenParen = new Formatting.Rule(Formatting.RuleDescriptor.create3(74 /* OpenParenToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.SpaceBeforeCloseParen = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 75 /* CloseParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 1 /* Space */)); + this.NoSpaceBetweenParens = new Formatting.Rule(Formatting.RuleDescriptor.create1(74 /* OpenParenToken */, 75 /* CloseParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceAfterOpenParen = new Formatting.Rule(Formatting.RuleDescriptor.create3(74 /* OpenParenToken */, Formatting.Shared.TokenRange.Any), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.NoSpaceBeforeCloseParen = new Formatting.Rule(Formatting.RuleDescriptor.create2(Formatting.Shared.TokenRange.Any, 75 /* CloseParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsSameLineTokenContext), 3 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new Formatting.Rule(Formatting.RuleDescriptor.create1(29 /* FunctionKeyword */, 74 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 1 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new Formatting.Rule(Formatting.RuleDescriptor.create1(29 /* FunctionKeyword */, 74 /* OpenParenToken */), Formatting.RuleOperation.create2(new Formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 3 /* Delete */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -29192,56 +29562,22 @@ var TypeScript; throw new Error(TypeScript.getDiagnosticMessage(TypeScript.DiagnosticCode.Unknown_rule, null)); }; Rules.IsForContext = function (context) { - return context.contextNode.kind() === 155 /* ForStatement */; + return context.contextNode.kind() === 159 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind()) { - case 175 /* AssignmentExpression */: - case 176 /* AddAssignmentExpression */: - case 177 /* SubtractAssignmentExpression */: - case 178 /* MultiplyAssignmentExpression */: - case 179 /* DivideAssignmentExpression */: - case 180 /* ModuloAssignmentExpression */: - case 181 /* AndAssignmentExpression */: - case 182 /* ExclusiveOrAssignmentExpression */: - case 183 /* OrAssignmentExpression */: - case 184 /* LeftShiftAssignmentExpression */: - case 185 /* SignedRightShiftAssignmentExpression */: - case 186 /* UnsignedRightShiftAssignmentExpression */: - case 187 /* ConditionalExpression */: - case 188 /* LogicalOrExpression */: - case 189 /* LogicalAndExpression */: - case 190 /* BitwiseOrExpression */: - case 191 /* BitwiseExclusiveOrExpression */: - case 192 /* BitwiseAndExpression */: - case 193 /* EqualsWithTypeConversionExpression */: - case 194 /* NotEqualsWithTypeConversionExpression */: - case 195 /* EqualsExpression */: - case 196 /* NotEqualsExpression */: - case 197 /* LessThanExpression */: - case 198 /* GreaterThanExpression */: - case 199 /* LessThanOrEqualExpression */: - case 200 /* GreaterThanOrEqualExpression */: - case 201 /* InstanceOfExpression */: - case 202 /* InExpression */: - case 203 /* LeftShiftExpression */: - case 204 /* SignedRightShiftExpression */: - case 205 /* UnsignedRightShiftExpression */: - case 206 /* MultiplyExpression */: - case 207 /* DivideExpression */: - case 208 /* ModuloExpression */: - case 209 /* AddExpression */: - case 210 /* SubtractExpression */: + case 174 /* BinaryExpression */: + case 173 /* ConditionalExpression */: return true; - case 134 /* ImportDeclaration */: - case 226 /* VariableDeclarator */: - case 233 /* EqualsValueClause */: - return context.currentTokenSpan.kind === 107 /* EqualsToken */ || context.nextTokenSpan.kind === 107 /* EqualsToken */; - case 156 /* ForInStatement */: - return context.currentTokenSpan.kind === 29 /* InKeyword */ || context.nextTokenSpan.kind === 29 /* InKeyword */; + case 138 /* ImportDeclaration */: + case 191 /* VariableDeclarator */: + case 197 /* EqualsValueClause */: + return context.currentTokenSpan.kind === 109 /* EqualsToken */ || context.nextTokenSpan.kind === 109 /* EqualsToken */; + case 160 /* ForInStatement */: + return context.currentTokenSpan.kind === 31 /* InKeyword */ || context.nextTokenSpan.kind === 31 /* InKeyword */; } return false; }; @@ -29271,26 +29607,26 @@ var TypeScript; return true; } switch (node.kind()) { - case 147 /* Block */: - case 152 /* SwitchStatement */: - case 216 /* ObjectLiteralExpression */: + case 151 /* Block */: + case 156 /* SwitchStatement */: + case 179 /* ObjectLiteralExpression */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind()) { - case 130 /* FunctionDeclaration */: - case 136 /* MemberFunctionDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: - case 146 /* MethodSignature */: - case 143 /* CallSignature */: - case 223 /* FunctionExpression */: - case 138 /* ConstructorDeclaration */: - case 220 /* SimpleArrowFunctionExpression */: - case 219 /* ParenthesizedArrowFunctionExpression */: - case 129 /* InterfaceDeclaration */: + case 134 /* FunctionDeclaration */: + case 140 /* MemberFunctionDeclaration */: + case 144 /* GetAccessor */: + case 145 /* SetAccessor */: + case 150 /* MethodSignature */: + case 147 /* CallSignature */: + case 186 /* FunctionExpression */: + case 142 /* ConstructorDeclaration */: + case 183 /* SimpleArrowFunctionExpression */: + case 182 /* ParenthesizedArrowFunctionExpression */: + case 133 /* InterfaceDeclaration */: return true; } return false; @@ -29300,51 +29636,51 @@ var TypeScript; }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind()) { - case 132 /* ClassDeclaration */: - case 133 /* EnumDeclaration */: - case 122 /* ObjectType */: - case 131 /* ModuleDeclaration */: + case 136 /* ClassDeclaration */: + case 137 /* EnumDeclaration */: + case 124 /* ObjectType */: + case 135 /* ModuleDeclaration */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind()) { - case 132 /* ClassDeclaration */: - case 131 /* ModuleDeclaration */: - case 133 /* EnumDeclaration */: - case 147 /* Block */: - case 152 /* SwitchStatement */: + case 136 /* ClassDeclaration */: + case 135 /* ModuleDeclaration */: + case 137 /* EnumDeclaration */: + case 151 /* Block */: + case 156 /* SwitchStatement */: return true; } return false; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind()) { - case 148 /* IfStatement */: - case 152 /* SwitchStatement */: - case 155 /* ForStatement */: - case 156 /* ForInStatement */: - case 159 /* WhileStatement */: - case 160 /* TryStatement */: - case 162 /* DoStatement */: - case 164 /* WithStatement */: - case 236 /* ElseClause */: - case 237 /* CatchClause */: - case 238 /* FinallyClause */: + case 152 /* IfStatement */: + case 156 /* SwitchStatement */: + case 159 /* ForStatement */: + case 160 /* ForInStatement */: + case 163 /* WhileStatement */: + case 164 /* TryStatement */: + case 166 /* DoStatement */: + case 168 /* WithStatement */: + case 200 /* ElseClause */: + case 201 /* CatchClause */: + case 202 /* FinallyClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind() === 216 /* ObjectLiteralExpression */; + return context.contextNode.kind() === 179 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind() === 214 /* InvocationExpression */; + return context.contextNode.kind() === 177 /* InvocationExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind() === 217 /* ObjectCreationExpression */; + return context.contextNode.kind() === 180 /* ObjectCreationExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); @@ -29356,19 +29692,19 @@ var TypeScript; return context.formattingRequestKind != 2 /* FormatOnEnter */; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind() === 131 /* ModuleDeclaration */; + return context.contextNode.kind() === 135 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind() === 122 /* ObjectType */ && context.contextNode.parent().kind() !== 129 /* InterfaceDeclaration */; + return context.contextNode.kind() === 124 /* ObjectType */ && context.contextNode.parent().kind() !== 133 /* InterfaceDeclaration */; }; Rules.IsTypeArgumentOrParameter = function (tokenKind, parentKind) { - return ((tokenKind === 80 /* LessThanToken */ || tokenKind === 81 /* GreaterThanToken */) && (parentKind === 230 /* TypeParameterList */ || parentKind === 229 /* TypeArgumentList */)); + return ((tokenKind === 82 /* LessThanToken */ || tokenKind === 83 /* GreaterThanToken */) && (parentKind === 195 /* TypeParameterList */ || parentKind === 194 /* TypeArgumentList */)); }; Rules.IsTypeArgumentOrParameterContext = function (context) { return Rules.IsTypeArgumentOrParameter(context.currentTokenSpan.kind, context.currentTokenParent.kind()) || Rules.IsTypeArgumentOrParameter(context.nextTokenSpan.kind, context.nextTokenParent.kind()); }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 41 /* VoidKeyword */ && context.currentTokenParent.kind() === 173 /* VoidExpression */; + return context.currentTokenSpan.kind === 43 /* VoidKeyword */ && context.currentTokenParent.kind() === 172 /* VoidExpression */; }; return Rules; })(); @@ -29721,20 +30057,20 @@ var TypeScript; return this.tokenAccess.toString(); }; TokenRange.Any = TokenRange.AllTokens(); - TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([6 /* MultiLineCommentTrivia */])); + TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([4 /* MultiLineCommentTrivia */])); TokenRange.Keywords = TokenRange.FromRange(TypeScript.SyntaxKind.FirstKeyword, TypeScript.SyntaxKind.LastKeyword); - TokenRange.Operators = TokenRange.FromRange(78 /* SemicolonToken */, 119 /* SlashEqualsToken */); - TokenRange.BinaryOperators = TokenRange.FromRange(80 /* LessThanToken */, 119 /* SlashEqualsToken */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([29 /* InKeyword */, 30 /* InstanceOfKeyword */]); + TokenRange.Operators = TokenRange.FromRange(80 /* SemicolonToken */, 121 /* SlashEqualsToken */); + TokenRange.BinaryOperators = TokenRange.FromRange(82 /* LessThanToken */, 121 /* SlashEqualsToken */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([31 /* InKeyword */, 32 /* InstanceOfKeyword */]); TokenRange.ReservedKeywords = TokenRange.FromRange(TypeScript.SyntaxKind.FirstFutureReservedStrictKeyword, TypeScript.SyntaxKind.LastFutureReservedStrictKeyword); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([93 /* PlusPlusToken */, 94 /* MinusMinusToken */, 102 /* TildeToken */, 101 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([13 /* NumericLiteral */, 11 /* IdentifierName */, 72 /* OpenParenToken */, 74 /* OpenBracketToken */, 70 /* OpenBraceToken */, 35 /* ThisKeyword */, 31 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([11 /* IdentifierName */, 72 /* OpenParenToken */, 35 /* ThisKeyword */, 31 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([11 /* IdentifierName */, 73 /* CloseParenToken */, 75 /* CloseBracketToken */, 31 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([11 /* IdentifierName */, 72 /* OpenParenToken */, 35 /* ThisKeyword */, 31 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([11 /* IdentifierName */, 73 /* CloseParenToken */, 75 /* CloseBracketToken */, 31 /* NewKeyword */]); - TokenRange.Comments = TokenRange.FromTokens([7 /* SingleLineCommentTrivia */, 6 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([11 /* IdentifierName */, 67 /* NumberKeyword */, 69 /* StringKeyword */, 61 /* BooleanKeyword */, 41 /* VoidKeyword */, 60 /* AnyKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([95 /* PlusPlusToken */, 96 /* MinusMinusToken */, 104 /* TildeToken */, 103 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([11 /* NumericLiteral */, 9 /* IdentifierName */, 74 /* OpenParenToken */, 76 /* OpenBracketToken */, 72 /* OpenBraceToken */, 37 /* ThisKeyword */, 33 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([9 /* IdentifierName */, 74 /* OpenParenToken */, 37 /* ThisKeyword */, 33 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([9 /* IdentifierName */, 75 /* CloseParenToken */, 77 /* CloseBracketToken */, 33 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([9 /* IdentifierName */, 74 /* OpenParenToken */, 37 /* ThisKeyword */, 33 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([9 /* IdentifierName */, 75 /* CloseParenToken */, 77 /* CloseBracketToken */, 33 /* NewKeyword */]); + TokenRange.Comments = TokenRange.FromTokens([5 /* SingleLineCommentTrivia */, 4 /* MultiLineCommentTrivia */]); + TokenRange.TypeNames = TokenRange.FromTokens([9 /* IdentifierName */, 69 /* NumberKeyword */, 71 /* StringKeyword */, 63 /* BooleanKeyword */, 43 /* VoidKeyword */, 62 /* AnyKeyword */]); return TokenRange; })(); Shared.TokenRange = TokenRange; @@ -29873,10 +30209,8 @@ var TypeScript; (function (Services) { var Formatting; (function (Formatting) { - var IndentationTrackingWalker = (function (_super) { - __extends(IndentationTrackingWalker, _super); + var IndentationTrackingWalker = (function () { function IndentationTrackingWalker(textSpan, sourceUnit, snapshot, indentFirstToken, options) { - _super.call(this); this.options = options; this._position = 0; this._parent = null; @@ -29925,17 +30259,34 @@ var TypeScript; if (tokenSpan.intersectsWithTextSpan(this._textSpan)) { this.visitTokenInSpan(token); var trivia = token.trailingTrivia(); - this._lastTriviaWasNewLine = trivia.hasNewLine() && trivia.syntaxTriviaAt(trivia.count() - 1).kind() == 5 /* NewLineTrivia */; + this._lastTriviaWasNewLine = trivia.hasNewLine() && trivia.syntaxTriviaAt(trivia.count() - 1).kind() == 3 /* NewLineTrivia */; } this._position += token.fullWidth(); }; + IndentationTrackingWalker.prototype.walk = function (element) { + if (element) { + if (TypeScript.isToken(element)) { + this.visitToken(element); + } + else if (element.kind() === 1 /* List */) { + for (var i = 0, n = TypeScript.childCount(element); i < n; i++) { + this.walk(TypeScript.childAt(element, i)); + } + } + else { + this.visitNode(element); + } + } + }; IndentationTrackingWalker.prototype.visitNode = function (node) { var nodeSpan = new TypeScript.TextSpan(this._position, TypeScript.fullWidth(node)); if (nodeSpan.intersectsWithTextSpan(this._textSpan)) { var indentation = this.getNodeIndentation(node); var currentParent = this._parent; this._parent = this._indentationNodeContextPool.getNode(currentParent, node, this._position, indentation.indentationAmount, indentation.indentationAmountDelta); - TypeScript.visitNodeOrToken(this, node); + for (var i = 0, n = TypeScript.childCount(node); i < n; i++) { + this.walk(TypeScript.childAt(node, i)); + } this._indentationNodeContextPool.releaseNode(this._parent); this._parent = currentParent; } @@ -29944,13 +30295,13 @@ var TypeScript; } }; IndentationTrackingWalker.prototype.getTokenIndentationAmount = function (token) { - if (TypeScript.firstToken(this._parent.node()) === token || token.kind() === 70 /* OpenBraceToken */ || token.kind() === 71 /* CloseBraceToken */ || token.kind() === 74 /* OpenBracketToken */ || token.kind() === 75 /* CloseBracketToken */ || (token.kind() === 42 /* WhileKeyword */ && this._parent.node().kind() == 162 /* DoStatement */)) { + if (TypeScript.firstToken(this._parent.node()) === token || token.kind() === 72 /* OpenBraceToken */ || token.kind() === 73 /* CloseBraceToken */ || token.kind() === 76 /* OpenBracketToken */ || token.kind() === 77 /* CloseBracketToken */ || (token.kind() === 44 /* WhileKeyword */ && this._parent.node().kind() == 166 /* DoStatement */)) { return this._parent.indentationAmount(); } return (this._parent.indentationAmount() + this._parent.childIndentationAmountDelta()); }; IndentationTrackingWalker.prototype.getCommentIndentationAmount = function (token) { - if (token.kind() === 71 /* CloseBraceToken */ || token.kind() === 75 /* CloseBracketToken */) { + if (token.kind() === 73 /* CloseBraceToken */ || token.kind() === 77 /* CloseBracketToken */) { return (this._parent.indentationAmount() + this._parent.childIndentationAmountDelta()); } return this._parent.indentationAmount(); @@ -29962,7 +30313,7 @@ var TypeScript; parentIndentationAmount = parent.indentationAmount(); } else { - if (parent.kind() === 147 /* Block */ && !this.shouldIndentBlockInParent(this._parent.parent())) { + if (parent.kind() === 151 /* Block */ && !this.shouldIndentBlockInParent(this._parent.parent())) { parent = this._parent.parent(); } var line = this._snapshot.getLineFromPosition(parent.start()).getText(); @@ -29978,46 +30329,46 @@ var TypeScript; indentationAmount = (parentIndentationAmount + parentIndentationAmountDelta); indentationAmountDelta = 0; break; - case 132 /* ClassDeclaration */: - case 131 /* ModuleDeclaration */: - case 122 /* ObjectType */: - case 133 /* EnumDeclaration */: - case 152 /* SwitchStatement */: - case 216 /* ObjectLiteralExpression */: - case 138 /* ConstructorDeclaration */: - case 130 /* FunctionDeclaration */: - case 223 /* FunctionExpression */: - case 136 /* MemberFunctionDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: - case 139 /* IndexMemberDeclaration */: - case 237 /* CatchClause */: - case 215 /* ArrayLiteralExpression */: - case 124 /* ArrayType */: - case 222 /* ElementAccessExpression */: - case 145 /* IndexSignature */: - case 155 /* ForStatement */: - case 156 /* ForInStatement */: - case 159 /* WhileStatement */: - case 162 /* DoStatement */: - case 164 /* WithStatement */: - case 234 /* CaseSwitchClause */: - case 235 /* DefaultSwitchClause */: - case 151 /* ReturnStatement */: - case 158 /* ThrowStatement */: - case 220 /* SimpleArrowFunctionExpression */: - case 219 /* ParenthesizedArrowFunctionExpression */: - case 225 /* VariableDeclaration */: - case 135 /* ExportAssignment */: - case 214 /* InvocationExpression */: - case 217 /* ObjectCreationExpression */: - case 143 /* CallSignature */: - case 144 /* ConstructSignature */: + case 136 /* ClassDeclaration */: + case 135 /* ModuleDeclaration */: + case 124 /* ObjectType */: + case 137 /* EnumDeclaration */: + case 156 /* SwitchStatement */: + case 179 /* ObjectLiteralExpression */: + case 142 /* ConstructorDeclaration */: + case 134 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 140 /* MemberFunctionDeclaration */: + case 144 /* GetAccessor */: + case 145 /* SetAccessor */: + case 143 /* IndexMemberDeclaration */: + case 201 /* CatchClause */: + case 178 /* ArrayLiteralExpression */: + case 126 /* ArrayType */: + case 185 /* ElementAccessExpression */: + case 149 /* IndexSignature */: + case 159 /* ForStatement */: + case 160 /* ForInStatement */: + case 163 /* WhileStatement */: + case 166 /* DoStatement */: + case 168 /* WithStatement */: + case 198 /* CaseSwitchClause */: + case 199 /* DefaultSwitchClause */: + case 155 /* ReturnStatement */: + case 162 /* ThrowStatement */: + case 183 /* SimpleArrowFunctionExpression */: + case 182 /* ParenthesizedArrowFunctionExpression */: + case 190 /* VariableDeclaration */: + case 139 /* ExportAssignment */: + case 177 /* InvocationExpression */: + case 180 /* ObjectCreationExpression */: + case 147 /* CallSignature */: + case 148 /* ConstructSignature */: indentationAmount = (parentIndentationAmount + parentIndentationAmountDelta); indentationAmountDelta = this.options.indentSpaces; break; - case 148 /* IfStatement */: - if (parent.kind() === 236 /* ElseClause */ && !TypeScript.SyntaxUtilities.isLastTokenOnLine(parentNode.elseKeyword, this._text)) { + case 152 /* IfStatement */: + if (parent.kind() === 200 /* ElseClause */ && !TypeScript.SyntaxUtilities.isLastTokenOnLine(parentNode.elseKeyword, this._text)) { indentationAmount = parentIndentationAmount; } else { @@ -30025,11 +30376,11 @@ var TypeScript; } indentationAmountDelta = this.options.indentSpaces; break; - case 236 /* ElseClause */: + case 200 /* ElseClause */: indentationAmount = parentIndentationAmount; indentationAmountDelta = this.options.indentSpaces; break; - case 147 /* Block */: + case 151 /* Block */: if (this.shouldIndentBlockInParent(parent)) { indentationAmount = parentIndentationAmount + parentIndentationAmountDelta; } @@ -30056,11 +30407,11 @@ var TypeScript; }; IndentationTrackingWalker.prototype.shouldIndentBlockInParent = function (parent) { switch (parent.kind()) { - case 120 /* SourceUnit */: - case 131 /* ModuleDeclaration */: - case 147 /* Block */: - case 234 /* CaseSwitchClause */: - case 235 /* DefaultSwitchClause */: + case 122 /* SourceUnit */: + case 135 /* ModuleDeclaration */: + case 151 /* Block */: + case 198 /* CaseSwitchClause */: + case 199 /* DefaultSwitchClause */: return true; default: return false; @@ -30076,7 +30427,7 @@ var TypeScript; } }; return IndentationTrackingWalker; - })(TypeScript.SyntaxWalker); + })(); Formatting.IndentationTrackingWalker = IndentationTrackingWalker; })(Formatting = Services.Formatting || (Services.Formatting = {})); })(Services = TypeScript.Services || (TypeScript.Services = {})); @@ -30126,19 +30477,19 @@ var TypeScript; continue; } switch (trivia.kind()) { - case 6 /* MultiLineCommentTrivia */: + case 4 /* MultiLineCommentTrivia */: this.recordIndentationEditsForMultiLineComment(trivia, position, commentIndentationString, leadingWhiteSpace, !indentNextTokenOrTrivia); indentNextTokenOrTrivia = false; leadingWhiteSpace = ""; break; - case 7 /* SingleLineCommentTrivia */: - case 8 /* SkippedTokenTrivia */: + case 5 /* SingleLineCommentTrivia */: + case 6 /* SkippedTokenTrivia */: if (indentNextTokenOrTrivia) { this.recordIndentationEditsForSingleLineOrSkippedText(trivia, position, commentIndentationString); indentNextTokenOrTrivia = false; } break; - case 4 /* WhitespaceTrivia */: + case 2 /* WhitespaceTrivia */: var nextTrivia = length > i + 1 && triviaList.syntaxTriviaAt(i + 1); var whiteSpaceIndentationString = nextTrivia && nextTrivia.isComment() ? commentIndentationString : indentationString; if (indentNextTokenOrTrivia) { @@ -30149,7 +30500,7 @@ var TypeScript; } leadingWhiteSpace += trivia.fullText(); break; - case 5 /* NewLineTrivia */: + case 3 /* NewLineTrivia */: indentNextTokenOrTrivia = true; leadingWhiteSpace = ""; break; @@ -30158,7 +30509,7 @@ var TypeScript; } } } - if (token.kind() !== 10 /* EndOfFileToken */ && indentNextTokenOrTrivia) { + if (token.kind() !== 8 /* EndOfFileToken */ && indentNextTokenOrTrivia) { if (indentationString.length > 0) { this.recordEdit(position, 0, indentationString); } @@ -30241,7 +30592,7 @@ var TypeScript; } Formatter.getEdits = function (textSpan, sourceUnit, options, indentFirstToken, snapshot, rulesProvider, formattingRequestKind) { var walker = new Formatter(textSpan, sourceUnit, indentFirstToken, options, snapshot, rulesProvider, formattingRequestKind); - TypeScript.visitNodeOrToken(walker, sourceUnit); + walker.walk(sourceUnit); return walker.edits(); }; Formatter.prototype.visitTokenInSpan = function (token) { @@ -30365,7 +30716,7 @@ var TypeScript; } }; Formatter.prototype.trimWhitespace = function (line, token) { - if (token && (token.kind == 6 /* MultiLineCommentTrivia */ || token.kind == 7 /* SingleLineCommentTrivia */) && token.start() <= line.endPosition() && token.end() >= line.endPosition()) + if (token && (token.kind == 4 /* MultiLineCommentTrivia */ || token.kind == 5 /* SingleLineCommentTrivia */) && token.start() <= line.endPosition() && token.end() >= line.endPosition()) return; var text = line.getText(); var index = 0; @@ -30456,7 +30807,7 @@ var ts; return 0; } var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line; - if (precedingToken.kind === 18 /* CommaToken */ && precedingToken.parent.kind !== 148 /* BinaryExpression */) { + if (precedingToken.kind === 22 /* CommaToken */ && precedingToken.parent.kind !== 153 /* BinaryExpression */) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -30516,7 +30867,7 @@ var ts; return deriveActualIndentationFromList(commaItemInfo.list.getChildren(), commaItemInfo.listItemIndex - 1, sourceFile, options); } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { - var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 186 /* SourceFile */ || !parentAndChildShareLine); + var useActualIndentation = (ts.isDeclaration(current) || ts.isStatement(current)) && (parent.kind === 193 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } @@ -30527,10 +30878,10 @@ var ts; if (!nextToken) { return false; } - if (nextToken.kind === 9 /* OpenBraceToken */) { + if (nextToken.kind === 13 /* OpenBraceToken */) { return true; } - else if (nextToken.kind === 10 /* CloseBraceToken */) { + else if (nextToken.kind === 14 /* CloseBraceToken */) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; return lineAtPosition === nextTokenStartLine; } @@ -30543,9 +30894,9 @@ var ts; return candidate.end > position || !isCompletedNode(candidate, sourceFile); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 155 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 70 /* ElseKeyword */, sourceFile); - ts.Debug.assert(elseKeyword); + if (parent.kind === 162 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 74 /* ElseKeyword */, sourceFile); + ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; } @@ -30553,29 +30904,29 @@ var ts; function getActualIndentationForListItem(node, sourceFile, options) { if (node.parent) { switch (node.parent.kind) { - case 128 /* TypeReference */: + case 132 /* TypeReference */: if (node.parent.typeArguments) { return getActualIndentationFromList(node.parent.typeArguments); } break; - case 136 /* ObjectLiteral */: + case 140 /* ObjectLiteral */: return getActualIndentationFromList(node.parent.properties); - case 130 /* TypeLiteral */: + case 134 /* TypeLiteral */: return getActualIndentationFromList(node.parent.members); - case 135 /* ArrayLiteral */: + case 139 /* ArrayLiteral */: return getActualIndentationFromList(node.parent.elements); - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 121 /* Method */: - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 125 /* Method */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: if (node.parent.typeParameters && node.end < node.parent.typeParameters.end) { return getActualIndentationFromList(node.parent.typeParameters); } return getActualIndentationFromList(node.parent.parameters); - case 141 /* NewExpression */: - case 140 /* CallExpression */: + case 145 /* NewExpression */: + case 144 /* CallExpression */: if (node.parent.typeArguments && node.end < node.parent.typeArguments.end) { return getActualIndentationFromList(node.parent.typeArguments); } @@ -30593,7 +30944,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; --i) { - if (list[i].kind === 18 /* CommaToken */) { + if (list[i].kind === 22 /* CommaToken */) { continue; } var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line; @@ -30623,45 +30974,45 @@ var ts; } function nodeContentIsIndented(parent, child) { switch (parent.kind) { - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: return true; - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return false; - case 175 /* FunctionDeclaration */: - case 121 /* Method */: - case 144 /* FunctionExpression */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 122 /* Constructor */: + case 182 /* FunctionDeclaration */: + case 125 /* Method */: + case 149 /* FunctionExpression */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 126 /* Constructor */: return false; - case 156 /* DoStatement */: - case 157 /* WhileStatement */: - case 159 /* ForInStatement */: - case 158 /* ForStatement */: - return child && child.kind !== 151 /* Block */; - case 155 /* IfStatement */: - return child && child.kind !== 151 /* Block */; - case 169 /* TryStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: + case 166 /* ForInStatement */: + case 165 /* ForStatement */: + return child && child.kind !== 158 /* Block */; + case 162 /* IfStatement */: + return child && child.kind !== 158 /* Block */; + case 176 /* TryStatement */: return false; - case 135 /* ArrayLiteral */: - case 151 /* Block */: - case 176 /* FunctionBlock */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: - case 182 /* ModuleBlock */: - case 136 /* ObjectLiteral */: - case 130 /* TypeLiteral */: - case 164 /* SwitchStatement */: - case 166 /* DefaultClause */: - case 165 /* CaseClause */: - case 143 /* ParenExpression */: - case 140 /* CallExpression */: - case 141 /* NewExpression */: - case 152 /* VariableStatement */: - case 174 /* VariableDeclaration */: + case 139 /* ArrayLiteral */: + case 158 /* Block */: + case 183 /* FunctionBlock */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: + case 189 /* ModuleBlock */: + case 140 /* ObjectLiteral */: + case 134 /* TypeLiteral */: + case 171 /* SwitchStatement */: + case 173 /* DefaultClause */: + case 172 /* CaseClause */: + case 148 /* ParenExpression */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: + case 159 /* VariableStatement */: + case 181 /* VariableDeclaration */: return true; default: return false; @@ -30674,7 +31025,7 @@ var ts; if (last.kind === expectedLastToken) { return true; } - else if (last.kind === 17 /* SemicolonToken */ && children.length !== 1) { + else if (last.kind === 21 /* SemicolonToken */ && children.length !== 1) { return children[children.length - 2].kind === expectedLastToken; } } @@ -30682,49 +31033,49 @@ var ts; } function isCompletedNode(n, sourceFile) { switch (n.kind) { - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: - case 136 /* ObjectLiteral */: - case 151 /* Block */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: - case 176 /* FunctionBlock */: - case 182 /* ModuleBlock */: - case 164 /* SwitchStatement */: - return nodeEndsWith(n, 10 /* CloseBraceToken */, sourceFile); - case 143 /* ParenExpression */: - case 125 /* CallSignature */: - case 140 /* CallExpression */: - case 126 /* ConstructSignature */: - return nodeEndsWith(n, 12 /* CloseParenToken */, sourceFile); - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 121 /* Method */: - case 145 /* ArrowFunction */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: + case 140 /* ObjectLiteral */: + case 158 /* Block */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: + case 183 /* FunctionBlock */: + case 189 /* ModuleBlock */: + case 171 /* SwitchStatement */: + return nodeEndsWith(n, 14 /* CloseBraceToken */, sourceFile); + case 148 /* ParenExpression */: + case 129 /* CallSignature */: + case 144 /* CallExpression */: + case 130 /* ConstructSignature */: + return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile); + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 125 /* Method */: + case 150 /* ArrowFunction */: return !n.body || isCompletedNode(n.body, sourceFile); - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: return n.body && isCompletedNode(n.body, sourceFile); - case 155 /* IfStatement */: + case 162 /* IfStatement */: if (n.elseStatement) { return isCompletedNode(n.elseStatement, sourceFile); } return isCompletedNode(n.thenStatement, sourceFile); - case 154 /* ExpressionStatement */: + case 161 /* ExpressionStatement */: return isCompletedNode(n.expression, sourceFile); - case 135 /* ArrayLiteral */: - return nodeEndsWith(n, 14 /* CloseBracketToken */, sourceFile); - case 116 /* Missing */: + case 139 /* ArrayLiteral */: + return nodeEndsWith(n, 18 /* CloseBracketToken */, sourceFile); + case 120 /* Missing */: return false; - case 165 /* CaseClause */: - case 166 /* DefaultClause */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: return false; - case 157 /* WhileStatement */: + case 164 /* WhileStatement */: return isCompletedNode(n.statement, sourceFile); - case 156 /* DoStatement */: - var hasWhileKeyword = ts.findChildOfKind(n, 94 /* WhileKeyword */, sourceFile); + case 163 /* DoStatement */: + var hasWhileKeyword = ts.findChildOfKind(n, 98 /* WhileKeyword */, sourceFile); if (hasWhileKeyword) { - return nodeEndsWith(n, 12 /* CloseParenToken */, sourceFile); + return nodeEndsWith(n, 16 /* CloseParenToken */, sourceFile); } return isCompletedNode(n.statement, sourceFile); default: @@ -30769,1203 +31120,6 @@ var TypeScript; TypeScript.createIntrinsicsObject = createIntrinsicsObject; })(TypeScript || (TypeScript = {})); var TypeScript; -(function (TypeScript) { - var Comment = (function () { - function Comment(_trivia, endsLine, _start, _end) { - this._trivia = _trivia; - this.endsLine = endsLine; - this._start = _start; - this._end = _end; - } - Comment.prototype.start = function () { - return this._start; - }; - Comment.prototype.end = function () { - return this._end; - }; - Comment.prototype.fullText = function () { - return this._trivia.fullText(); - }; - Comment.prototype.kind = function () { - return this._trivia.kind(); - }; - Comment.prototype.structuralEquals = function (ast, includingPosition) { - if (includingPosition) { - if (this.start() !== ast.start() || this.end() !== ast.end()) { - return false; - } - } - return this._trivia.fullText() === ast._trivia.fullText() && this.endsLine === ast.endsLine; - }; - return Comment; - })(); - TypeScript.Comment = Comment; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - function walkListChildren(preAst, walker) { - for (var i = 0, n = preAst.length; i < n; i++) { - walker.walk(preAst[i]); - } - } - function walkThrowStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - function walkPrefixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - function walkPostfixUnaryExpressionChildren(preAst, walker) { - walker.walk(preAst.operand); - } - function walkDeleteExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - function walkTypeArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArguments); - } - function walkTupleTypeChildren(preAst, walker) { - walker.walk(preAst.types); - } - function walkTypeOfExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - function walkVoidExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - function walkArgumentListChildren(preAst, walker) { - walker.walk(preAst.typeArgumentList); - walker.walk(preAst.arguments); - } - function walkArrayLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.expressions); - } - function walkSimplePropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.expression); - } - function walkFunctionPropertyAssignmentChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - function walkGetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - function walkSeparatedListChildren(preAst, walker) { - for (var i = 0, n = preAst.length; i < n; i++) { - walker.walk(preAst[i]); - } - } - function walkSetAccessorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - function walkObjectLiteralExpressionChildren(preAst, walker) { - walker.walk(preAst.propertyAssignments); - } - function walkCastExpressionChildren(preAst, walker) { - walker.walk(preAst.type); - walker.walk(preAst.expression); - } - function walkParenthesizedExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - } - function walkElementAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentExpression); - } - function walkMemberAccessExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.name); - } - function walkQualifiedNameChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - function walkBinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.left); - walker.walk(preAst.right); - } - function walkEqualsValueClauseChildren(preAst, walker) { - walker.walk(preAst.value); - } - function walkTypeParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.constraint); - } - function walkTypeParameterListChildren(preAst, walker) { - walker.walk(preAst.typeParameters); - } - function walkGenericTypeChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.typeArgumentList); - } - function walkTypeAnnotationChildren(preAst, walker) { - walker.walk(preAst.type); - } - function walkTypeQueryChildren(preAst, walker) { - walker.walk(preAst.name); - } - function walkInvocationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - function walkObjectCreationExpressionChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.argumentList); - } - function walkTrinaryExpressionChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.whenTrue); - walker.walk(preAst.whenFalse); - } - function walkFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - function walkFunctionTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - function walkParenthesizedArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - function walkSimpleArrowFunctionExpressionChildren(preAst, walker) { - walker.walk(preAst.parameter); - walker.walk(preAst.block); - walker.walk(preAst.expression); - } - function walkMemberFunctionDeclarationChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - function walkFuncDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - function walkIndexMemberDeclarationChildren(preAst, walker) { - walker.walk(preAst.indexSignature); - } - function walkIndexSignatureChildren(preAst, walker) { - walker.walk(preAst.parameters); - walker.walk(preAst.typeAnnotation); - } - function walkCallSignatureChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.typeAnnotation); - } - function walkConstraintChildren(preAst, walker) { - walker.walk(preAst.typeOrExpression); - } - function walkConstructorDeclarationChildren(preAst, walker) { - walker.walk(preAst.callSignature); - walker.walk(preAst.block); - } - function walkConstructorTypeChildren(preAst, walker) { - walker.walk(preAst.typeParameterList); - walker.walk(preAst.parameterList); - walker.walk(preAst.type); - } - function walkConstructSignatureChildren(preAst, walker) { - walker.walk(preAst.callSignature); - } - function walkParameterChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - function walkParameterListChildren(preAst, walker) { - walker.walk(preAst.parameters); - } - function walkPropertySignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - } - function walkVariableDeclaratorChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.equalsValueClause); - } - function walkMemberVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.variableDeclarator); - } - function walkMethodSignatureChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.callSignature); - } - function walkReturnStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - function walkForStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.initializer); - walker.walk(preAst.condition); - walker.walk(preAst.incrementor); - walker.walk(preAst.statement); - } - function walkForInStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - walker.walk(preAst.left); - walker.walk(preAst.expression); - walker.walk(preAst.statement); - } - function walkIfStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - walker.walk(preAst.elseClause); - } - function walkElseClauseChildren(preAst, walker) { - walker.walk(preAst.statement); - } - function walkWhileStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - function walkDoStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - function walkBlockChildren(preAst, walker) { - walker.walk(preAst.statements); - } - function walkVariableDeclarationChildren(preAst, walker) { - walker.walk(preAst.variableDeclarators); - } - function walkCaseSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.statements); - } - function walkDefaultSwitchClauseChildren(preAst, walker) { - walker.walk(preAst.statements); - } - function walkSwitchStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - walker.walk(preAst.switchClauses); - } - function walkTryStatementChildren(preAst, walker) { - walker.walk(preAst.block); - walker.walk(preAst.catchClause); - walker.walk(preAst.finallyClause); - } - function walkCatchClauseChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeAnnotation); - walker.walk(preAst.block); - } - function walkExternalModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.stringLiteral); - } - function walkFinallyClauseChildren(preAst, walker) { - walker.walk(preAst.block); - } - function walkClassDeclChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.classElements); - } - function walkScriptChildren(preAst, walker) { - walker.walk(preAst.moduleElements); - } - function walkHeritageClauseChildren(preAst, walker) { - walker.walk(preAst.typeNames); - } - function walkInterfaceDeclerationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.typeParameterList); - walker.walk(preAst.heritageClauses); - walker.walk(preAst.body); - } - function walkObjectTypeChildren(preAst, walker) { - walker.walk(preAst.typeMembers); - } - function walkArrayTypeChildren(preAst, walker) { - walker.walk(preAst.type); - } - function walkModuleDeclarationChildren(preAst, walker) { - walker.walk(preAst.name); - walker.walk(preAst.stringLiteral); - walker.walk(preAst.moduleElements); - } - function walkModuleNameModuleReferenceChildren(preAst, walker) { - walker.walk(preAst.moduleName); - } - function walkEnumDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.enumElements); - } - function walkEnumElementChildren(preAst, walker) { - walker.walk(preAst.propertyName); - walker.walk(preAst.equalsValueClause); - } - function walkImportDeclarationChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.moduleReference); - } - function walkExportAssignmentChildren(preAst, walker) { - walker.walk(preAst.identifier); - } - function walkWithStatementChildren(preAst, walker) { - walker.walk(preAst.condition); - walker.walk(preAst.statement); - } - function walkExpressionStatementChildren(preAst, walker) { - walker.walk(preAst.expression); - } - function walkLabeledStatementChildren(preAst, walker) { - walker.walk(preAst.identifier); - walker.walk(preAst.statement); - } - function walkVariableStatementChildren(preAst, walker) { - walker.walk(preAst.variableDeclaration); - } - var childrenWalkers = new Array(TypeScript.SyntaxKind.LastNode + 1); - for (var i = TypeScript.SyntaxKind.FirstToken, n = TypeScript.SyntaxKind.LastToken; i <= n; i++) { - childrenWalkers[i] = null; - } - for (var i = TypeScript.SyntaxKind.FirstTrivia, n = TypeScript.SyntaxKind.LastTrivia; i <= n; i++) { - childrenWalkers[i] = null; - } - childrenWalkers[176 /* AddAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[209 /* AddExpression */] = walkBinaryExpressionChildren; - childrenWalkers[181 /* AndAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[60 /* AnyKeyword */] = null; - childrenWalkers[227 /* ArgumentList */] = walkArgumentListChildren; - childrenWalkers[215 /* ArrayLiteralExpression */] = walkArrayLiteralExpressionChildren; - childrenWalkers[124 /* ArrayType */] = walkArrayTypeChildren; - childrenWalkers[220 /* SimpleArrowFunctionExpression */] = walkSimpleArrowFunctionExpressionChildren; - childrenWalkers[219 /* ParenthesizedArrowFunctionExpression */] = walkParenthesizedArrowFunctionExpressionChildren; - childrenWalkers[175 /* AssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[192 /* BitwiseAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[191 /* BitwiseExclusiveOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[167 /* BitwiseNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[190 /* BitwiseOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[147 /* Block */] = walkBlockChildren; - childrenWalkers[61 /* BooleanKeyword */] = null; - childrenWalkers[153 /* BreakStatement */] = null; - childrenWalkers[143 /* CallSignature */] = walkCallSignatureChildren; - childrenWalkers[234 /* CaseSwitchClause */] = walkCaseSwitchClauseChildren; - childrenWalkers[221 /* CastExpression */] = walkCastExpressionChildren; - childrenWalkers[237 /* CatchClause */] = walkCatchClauseChildren; - childrenWalkers[132 /* ClassDeclaration */] = walkClassDeclChildren; - childrenWalkers[174 /* CommaExpression */] = walkBinaryExpressionChildren; - childrenWalkers[187 /* ConditionalExpression */] = walkTrinaryExpressionChildren; - childrenWalkers[240 /* Constraint */] = walkConstraintChildren; - childrenWalkers[138 /* ConstructorDeclaration */] = walkConstructorDeclarationChildren; - childrenWalkers[144 /* ConstructSignature */] = walkConstructSignatureChildren; - childrenWalkers[154 /* ContinueStatement */] = null; - childrenWalkers[125 /* ConstructorType */] = walkConstructorTypeChildren; - childrenWalkers[163 /* DebuggerStatement */] = null; - childrenWalkers[235 /* DefaultSwitchClause */] = walkDefaultSwitchClauseChildren; - childrenWalkers[171 /* DeleteExpression */] = walkDeleteExpressionChildren; - childrenWalkers[179 /* DivideAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[207 /* DivideExpression */] = walkBinaryExpressionChildren; - childrenWalkers[162 /* DoStatement */] = walkDoStatementChildren; - childrenWalkers[222 /* ElementAccessExpression */] = walkElementAccessExpressionChildren; - childrenWalkers[236 /* ElseClause */] = walkElseClauseChildren; - childrenWalkers[157 /* EmptyStatement */] = null; - childrenWalkers[133 /* EnumDeclaration */] = walkEnumDeclarationChildren; - childrenWalkers[244 /* EnumElement */] = walkEnumElementChildren; - childrenWalkers[195 /* EqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[233 /* EqualsValueClause */] = walkEqualsValueClauseChildren; - childrenWalkers[193 /* EqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[182 /* ExclusiveOrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[135 /* ExportAssignment */] = walkExportAssignmentChildren; - childrenWalkers[150 /* ExpressionStatement */] = walkExpressionStatementChildren; - childrenWalkers[231 /* ExtendsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[246 /* ExternalModuleReference */] = walkExternalModuleReferenceChildren; - childrenWalkers[24 /* FalseKeyword */] = null; - childrenWalkers[238 /* FinallyClause */] = walkFinallyClauseChildren; - childrenWalkers[156 /* ForInStatement */] = walkForInStatementChildren; - childrenWalkers[155 /* ForStatement */] = walkForStatementChildren; - childrenWalkers[130 /* FunctionDeclaration */] = walkFuncDeclChildren; - childrenWalkers[223 /* FunctionExpression */] = walkFunctionExpressionChildren; - childrenWalkers[242 /* FunctionPropertyAssignment */] = walkFunctionPropertyAssignmentChildren; - childrenWalkers[123 /* FunctionType */] = walkFunctionTypeChildren; - childrenWalkers[126 /* GenericType */] = walkGenericTypeChildren; - childrenWalkers[140 /* GetAccessor */] = walkGetAccessorChildren; - childrenWalkers[198 /* GreaterThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[200 /* GreaterThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[148 /* IfStatement */] = walkIfStatementChildren; - childrenWalkers[232 /* ImplementsHeritageClause */] = walkHeritageClauseChildren; - childrenWalkers[134 /* ImportDeclaration */] = walkImportDeclarationChildren; - childrenWalkers[139 /* IndexMemberDeclaration */] = walkIndexMemberDeclarationChildren; - childrenWalkers[145 /* IndexSignature */] = walkIndexSignatureChildren; - childrenWalkers[202 /* InExpression */] = walkBinaryExpressionChildren; - childrenWalkers[201 /* InstanceOfExpression */] = walkBinaryExpressionChildren; - childrenWalkers[129 /* InterfaceDeclaration */] = walkInterfaceDeclerationChildren; - childrenWalkers[214 /* InvocationExpression */] = walkInvocationExpressionChildren; - childrenWalkers[161 /* LabeledStatement */] = walkLabeledStatementChildren; - childrenWalkers[184 /* LeftShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[203 /* LeftShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[197 /* LessThanExpression */] = walkBinaryExpressionChildren; - childrenWalkers[199 /* LessThanOrEqualExpression */] = walkBinaryExpressionChildren; - childrenWalkers[1 /* List */] = walkListChildren; - childrenWalkers[189 /* LogicalAndExpression */] = walkBinaryExpressionChildren; - childrenWalkers[168 /* LogicalNotExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[188 /* LogicalOrExpression */] = walkBinaryExpressionChildren; - childrenWalkers[213 /* MemberAccessExpression */] = walkMemberAccessExpressionChildren; - childrenWalkers[136 /* MemberFunctionDeclaration */] = walkMemberFunctionDeclarationChildren; - childrenWalkers[137 /* MemberVariableDeclaration */] = walkMemberVariableDeclarationChildren; - childrenWalkers[146 /* MethodSignature */] = walkMethodSignatureChildren; - childrenWalkers[131 /* ModuleDeclaration */] = walkModuleDeclarationChildren; - childrenWalkers[247 /* ModuleNameModuleReference */] = walkModuleNameModuleReferenceChildren; - childrenWalkers[180 /* ModuloAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[208 /* ModuloExpression */] = walkBinaryExpressionChildren; - childrenWalkers[178 /* MultiplyAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[206 /* MultiplyExpression */] = walkBinaryExpressionChildren; - childrenWalkers[11 /* IdentifierName */] = null; - childrenWalkers[166 /* NegateExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[0 /* None */] = null; - childrenWalkers[196 /* NotEqualsExpression */] = walkBinaryExpressionChildren; - childrenWalkers[194 /* NotEqualsWithTypeConversionExpression */] = walkBinaryExpressionChildren; - childrenWalkers[32 /* NullKeyword */] = null; - childrenWalkers[67 /* NumberKeyword */] = null; - childrenWalkers[13 /* NumericLiteral */] = null; - childrenWalkers[217 /* ObjectCreationExpression */] = walkObjectCreationExpressionChildren; - childrenWalkers[216 /* ObjectLiteralExpression */] = walkObjectLiteralExpressionChildren; - childrenWalkers[122 /* ObjectType */] = walkObjectTypeChildren; - childrenWalkers[224 /* OmittedExpression */] = null; - childrenWalkers[183 /* OrAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[243 /* Parameter */] = walkParameterChildren; - childrenWalkers[228 /* ParameterList */] = walkParameterListChildren; - childrenWalkers[218 /* ParenthesizedExpression */] = walkParenthesizedExpressionChildren; - childrenWalkers[165 /* PlusExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[212 /* PostDecrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[211 /* PostIncrementExpression */] = walkPostfixUnaryExpressionChildren; - childrenWalkers[170 /* PreDecrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[169 /* PreIncrementExpression */] = walkPrefixUnaryExpressionChildren; - childrenWalkers[142 /* PropertySignature */] = walkPropertySignatureChildren; - childrenWalkers[121 /* QualifiedName */] = walkQualifiedNameChildren; - childrenWalkers[12 /* RegularExpressionLiteral */] = null; - childrenWalkers[151 /* ReturnStatement */] = walkReturnStatementChildren; - childrenWalkers[120 /* SourceUnit */] = walkScriptChildren; - childrenWalkers[2 /* SeparatedList */] = walkSeparatedListChildren; - childrenWalkers[141 /* SetAccessor */] = walkSetAccessorChildren; - childrenWalkers[185 /* SignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[204 /* SignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[241 /* SimplePropertyAssignment */] = walkSimplePropertyAssignmentChildren; - childrenWalkers[14 /* StringLiteral */] = null; - childrenWalkers[69 /* StringKeyword */] = null; - childrenWalkers[177 /* SubtractAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[210 /* SubtractExpression */] = walkBinaryExpressionChildren; - childrenWalkers[50 /* SuperKeyword */] = null; - childrenWalkers[152 /* SwitchStatement */] = walkSwitchStatementChildren; - childrenWalkers[35 /* ThisKeyword */] = null; - childrenWalkers[158 /* ThrowStatement */] = walkThrowStatementChildren; - childrenWalkers[3 /* TriviaList */] = null; - childrenWalkers[37 /* TrueKeyword */] = null; - childrenWalkers[160 /* TryStatement */] = walkTryStatementChildren; - childrenWalkers[128 /* TupleType */] = walkTupleTypeChildren; - childrenWalkers[245 /* TypeAnnotation */] = walkTypeAnnotationChildren; - childrenWalkers[229 /* TypeArgumentList */] = walkTypeArgumentListChildren; - childrenWalkers[172 /* TypeOfExpression */] = walkTypeOfExpressionChildren; - childrenWalkers[239 /* TypeParameter */] = walkTypeParameterChildren; - childrenWalkers[230 /* TypeParameterList */] = walkTypeParameterListChildren; - childrenWalkers[127 /* TypeQuery */] = walkTypeQueryChildren; - childrenWalkers[186 /* UnsignedRightShiftAssignmentExpression */] = walkBinaryExpressionChildren; - childrenWalkers[205 /* UnsignedRightShiftExpression */] = walkBinaryExpressionChildren; - childrenWalkers[225 /* VariableDeclaration */] = walkVariableDeclarationChildren; - childrenWalkers[226 /* VariableDeclarator */] = walkVariableDeclaratorChildren; - childrenWalkers[149 /* VariableStatement */] = walkVariableStatementChildren; - childrenWalkers[173 /* VoidExpression */] = walkVoidExpressionChildren; - childrenWalkers[41 /* VoidKeyword */] = null; - childrenWalkers[159 /* WhileStatement */] = walkWhileStatementChildren; - childrenWalkers[164 /* WithStatement */] = walkWithStatementChildren; - for (var e in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind.hasOwnProperty(e) && TypeScript.StringUtilities.isString(TypeScript.SyntaxKind[e])) { - TypeScript.Debug.assert(childrenWalkers[e] !== undefined, "Fix initWalkers: " + TypeScript.SyntaxKind[e]); - } - } - var AstWalkOptions = (function () { - function AstWalkOptions() { - this.goChildren = true; - this.stopWalking = false; - } - return AstWalkOptions; - })(); - TypeScript.AstWalkOptions = AstWalkOptions; - var SimplePreAstWalker = (function () { - function SimplePreAstWalker(pre, state) { - this.pre = pre; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePreAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - this.pre(ast, this.state); - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - }; - return SimplePreAstWalker; - })(); - var SimplePrePostAstWalker = (function () { - function SimplePrePostAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - SimplePrePostAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - this.pre(ast, this.state); - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - this.post(ast, this.state); - }; - return SimplePrePostAstWalker; - })(); - var NormalAstWalker = (function () { - function NormalAstWalker(pre, post, state) { - this.pre = pre; - this.post = post; - this.state = state; - this.options = new AstWalkOptions(); - } - NormalAstWalker.prototype.walk = function (ast) { - if (!ast) { - return; - } - if (this.options.stopWalking) { - return; - } - this.pre(ast, this); - if (this.options.stopWalking) { - return; - } - if (this.options.goChildren) { - var walker = childrenWalkers[ast.kind()]; - if (walker) { - walker(ast, this); - } - } - else { - this.options.goChildren = true; - } - if (this.post) { - this.post(ast, this); - } - }; - return NormalAstWalker; - })(); - var AstWalkerFactory = (function () { - function AstWalkerFactory() { - } - AstWalkerFactory.prototype.walk = function (ast, pre, post, state) { - new NormalAstWalker(pre, post, state).walk(ast); - }; - AstWalkerFactory.prototype.simpleWalk = function (ast, pre, post, state) { - if (post) { - new SimplePrePostAstWalker(pre, post, state).walk(ast); - } - else { - new SimplePreAstWalker(pre, state).walk(ast); - } - }; - return AstWalkerFactory; - })(); - TypeScript.AstWalkerFactory = AstWalkerFactory; - var globalAstWalkerFactory = new AstWalkerFactory(); - function getAstWalkerFactory() { - return globalAstWalkerFactory; - } - TypeScript.getAstWalkerFactory = getAstWalkerFactory; -})(TypeScript || (TypeScript = {})); -var TypeScript; -(function (TypeScript) { - var ASTHelpers; - (function (ASTHelpers) { - var sentinelEmptyArray = []; - function isValidAstNode(ast) { - return ast && !TypeScript.isShared(ast) && TypeScript.start(ast) !== -1 && TypeScript.end(ast) !== -1; - } - ASTHelpers.isValidAstNode = isValidAstNode; - function isValidSpan(ast) { - if (!ast) - return false; - if (ast.start() === -1 || ast.end() === -1) - return false; - return true; - } - ASTHelpers.isValidSpan = isValidSpan; - function getAstAtPosition(script, pos, useTrailingTriviaAsLimChar, forceInclusive) { - if (useTrailingTriviaAsLimChar === void 0) { useTrailingTriviaAsLimChar = true; } - if (forceInclusive === void 0) { forceInclusive = false; } - var top = null; - var pre = function (cur, walker) { - if (!TypeScript.isShared(cur) && isValidAstNode(cur)) { - var isInvalid1 = cur.kind() === 150 /* ExpressionStatement */ && TypeScript.width(cur) === 0; - if (isInvalid1) { - walker.options.goChildren = false; - } - else { - var inclusive = forceInclusive || cur.kind() === 11 /* IdentifierName */ || cur.kind() === 213 /* MemberAccessExpression */ || cur.kind() === 121 /* QualifiedName */ || cur.kind() === 225 /* VariableDeclaration */ || cur.kind() === 226 /* VariableDeclarator */ || cur.kind() === 214 /* InvocationExpression */ || pos === TypeScript.end(script) + TypeScript.lastToken(script).trailingTriviaWidth(); - var minChar = TypeScript.start(cur); - var limChar = TypeScript.end(cur) + (useTrailingTriviaAsLimChar ? TypeScript.trailingTriviaWidth(cur) : 0) + (inclusive ? 1 : 0); - if (pos >= minChar && pos < limChar) { - if ((cur.kind() !== 1 /* List */ && cur.kind() !== 2 /* SeparatedList */) || TypeScript.end(cur) > TypeScript.start(cur)) { - if (top === null) { - top = cur; - } - else if (TypeScript.start(cur) >= TypeScript.start(top) && (TypeScript.end(cur) + (useTrailingTriviaAsLimChar ? TypeScript.trailingTriviaWidth(cur) : 0)) <= (TypeScript.end(top) + (useTrailingTriviaAsLimChar ? TypeScript.trailingTriviaWidth(top) : 0))) { - if (TypeScript.width(top) !== 0 || TypeScript.width(cur) !== 0) { - top = cur; - } - } - } - } - walker.options.goChildren = (minChar <= pos && pos <= limChar); - } - } - }; - TypeScript.getAstWalkerFactory().walk(script, pre); - return top; - } - ASTHelpers.getAstAtPosition = getAstAtPosition; - function getExtendsHeritageClause(clauses) { - return getHeritageClause(clauses, 231 /* ExtendsHeritageClause */); - } - ASTHelpers.getExtendsHeritageClause = getExtendsHeritageClause; - function getImplementsHeritageClause(clauses) { - return getHeritageClause(clauses, 232 /* ImplementsHeritageClause */); - } - ASTHelpers.getImplementsHeritageClause = getImplementsHeritageClause; - function getHeritageClause(clauses, kind) { - if (clauses) { - for (var i = 0, n = clauses.length; i < n; i++) { - var child = clauses[i]; - if (child.typeNames.length > 0 && child.kind() === kind) { - return child; - } - } - } - return null; - } - function isCallExpression(ast) { - return (ast && ast.kind() === 214 /* InvocationExpression */) || (ast && ast.kind() === 217 /* ObjectCreationExpression */); - } - ASTHelpers.isCallExpression = isCallExpression; - function isCallExpressionTarget(ast) { - return !!getCallExpressionTarget(ast); - } - ASTHelpers.isCallExpressionTarget = isCallExpressionTarget; - function getCallExpressionTarget(ast) { - if (!ast) { - return null; - } - var current = ast; - while (current && current.parent) { - if (current.parent.kind() === 213 /* MemberAccessExpression */ && current.parent.name === current) { - current = current.parent; - continue; - } - break; - } - if (current && current.parent) { - if (current.parent.kind() === 214 /* InvocationExpression */ || current.parent.kind() === 217 /* ObjectCreationExpression */) { - return current === current.parent.expression ? current : null; - } - } - return null; - } - ASTHelpers.getCallExpressionTarget = getCallExpressionTarget; - function isNameOfSomeDeclaration(ast) { - if (ast === null || ast.parent === null) { - return false; - } - if (ast.kind() !== 11 /* IdentifierName */) { - return false; - } - switch (ast.parent.kind()) { - case 132 /* ClassDeclaration */: - return ast.parent.identifier === ast; - case 129 /* InterfaceDeclaration */: - return ast.parent.identifier === ast; - case 133 /* EnumDeclaration */: - return ast.parent.identifier === ast; - case 131 /* ModuleDeclaration */: - return ast.parent.name === ast || ast.parent.stringLiteral === ast; - case 226 /* VariableDeclarator */: - return ast.parent.propertyName === ast; - case 130 /* FunctionDeclaration */: - return ast.parent.identifier === ast; - case 136 /* MemberFunctionDeclaration */: - return ast.parent.propertyName === ast; - case 243 /* Parameter */: - return ast.parent.identifier === ast; - case 239 /* TypeParameter */: - return ast.parent.identifier === ast; - case 241 /* SimplePropertyAssignment */: - return ast.parent.propertyName === ast; - case 242 /* FunctionPropertyAssignment */: - return ast.parent.propertyName === ast; - case 244 /* EnumElement */: - return ast.parent.propertyName === ast; - case 134 /* ImportDeclaration */: - return ast.parent.identifier === ast; - case 146 /* MethodSignature */: - return ast.parent.propertyName === ast; - case 142 /* PropertySignature */: - return ast.parent.propertyName === ast; - } - return false; - } - function isDeclarationASTOrDeclarationNameAST(ast) { - return isNameOfSomeDeclaration(ast) || ASTHelpers.isDeclarationAST(ast); - } - ASTHelpers.isDeclarationASTOrDeclarationNameAST = isDeclarationASTOrDeclarationNameAST; - function getEnclosingParameterForInitializer(ast) { - var current = ast; - while (current) { - switch (current.kind()) { - case 233 /* EqualsValueClause */: - if (current.parent && current.parent.kind() === 243 /* Parameter */) { - return current.parent; - } - break; - case 132 /* ClassDeclaration */: - case 129 /* InterfaceDeclaration */: - case 131 /* ModuleDeclaration */: - return null; - } - current = current.parent; - } - return null; - } - ASTHelpers.getEnclosingParameterForInitializer = getEnclosingParameterForInitializer; - function getEnclosingMemberDeclaration(ast) { - var current = ast; - while (current) { - switch (current.kind()) { - case 137 /* MemberVariableDeclaration */: - case 146 /* MethodSignature */: - case 136 /* MemberFunctionDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: - return current; - case 132 /* ClassDeclaration */: - case 129 /* InterfaceDeclaration */: - case 131 /* ModuleDeclaration */: - return null; - } - current = current.parent; - } - return null; - } - ASTHelpers.getEnclosingMemberDeclaration = getEnclosingMemberDeclaration; - function isNameOfFunction(ast) { - return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 130 /* FunctionDeclaration */ && ast.parent.identifier === ast; - } - ASTHelpers.isNameOfFunction = isNameOfFunction; - function isNameOfMemberFunction(ast) { - return ast && ast.parent && ast.kind() === 11 /* IdentifierName */ && ast.parent.kind() === 136 /* MemberFunctionDeclaration */ && ast.parent.propertyName === ast; - } - ASTHelpers.isNameOfMemberFunction = isNameOfMemberFunction; - function isNameOfMemberAccessExpression(ast) { - if (ast && ast.parent && ast.parent.kind() === 213 /* MemberAccessExpression */ && ast.parent.name === ast) { - return true; - } - return false; - } - ASTHelpers.isNameOfMemberAccessExpression = isNameOfMemberAccessExpression; - function isRightSideOfQualifiedName(ast) { - if (ast && ast.parent && ast.parent.kind() === 121 /* QualifiedName */ && ast.parent.right === ast) { - return true; - } - return false; - } - ASTHelpers.isRightSideOfQualifiedName = isRightSideOfQualifiedName; - function parentIsModuleDeclaration(ast) { - return ast.parent && ast.parent.kind() === 131 /* ModuleDeclaration */; - } - ASTHelpers.parentIsModuleDeclaration = parentIsModuleDeclaration; - function isDeclarationAST(ast) { - switch (ast.kind()) { - case 226 /* VariableDeclarator */: - return getVariableStatement(ast) !== null; - case 134 /* ImportDeclaration */: - case 132 /* ClassDeclaration */: - case 129 /* InterfaceDeclaration */: - case 243 /* Parameter */: - case 220 /* SimpleArrowFunctionExpression */: - case 219 /* ParenthesizedArrowFunctionExpression */: - case 145 /* IndexSignature */: - case 130 /* FunctionDeclaration */: - case 131 /* ModuleDeclaration */: - case 124 /* ArrayType */: - case 122 /* ObjectType */: - case 239 /* TypeParameter */: - case 138 /* ConstructorDeclaration */: - case 136 /* MemberFunctionDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: - case 137 /* MemberVariableDeclaration */: - case 139 /* IndexMemberDeclaration */: - case 133 /* EnumDeclaration */: - case 244 /* EnumElement */: - case 241 /* SimplePropertyAssignment */: - case 242 /* FunctionPropertyAssignment */: - case 223 /* FunctionExpression */: - case 143 /* CallSignature */: - case 144 /* ConstructSignature */: - case 146 /* MethodSignature */: - case 142 /* PropertySignature */: - return true; - default: - return false; - } - } - ASTHelpers.isDeclarationAST = isDeclarationAST; - function preComments(element, text) { - if (element) { - switch (element.kind()) { - case 149 /* VariableStatement */: - case 150 /* ExpressionStatement */: - case 132 /* ClassDeclaration */: - case 134 /* ImportDeclaration */: - case 130 /* FunctionDeclaration */: - case 131 /* ModuleDeclaration */: - case 133 /* EnumDeclaration */: - case 148 /* IfStatement */: - case 241 /* SimplePropertyAssignment */: - case 136 /* MemberFunctionDeclaration */: - case 129 /* InterfaceDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: - case 151 /* ReturnStatement */: - case 138 /* ConstructorDeclaration */: - case 137 /* MemberVariableDeclaration */: - case 244 /* EnumElement */: - case 143 /* CallSignature */: - case 144 /* ConstructSignature */: - case 145 /* IndexSignature */: - case 142 /* PropertySignature */: - case 146 /* MethodSignature */: - case 242 /* FunctionPropertyAssignment */: - case 243 /* Parameter */: - return convertNodeLeadingComments(element, text); - } - } - return null; - } - ASTHelpers.preComments = preComments; - function postComments(element, text) { - if (element) { - switch (element.kind()) { - case 150 /* ExpressionStatement */: - return convertNodeTrailingComments(element, text, true); - case 149 /* VariableStatement */: - case 132 /* ClassDeclaration */: - case 134 /* ImportDeclaration */: - case 130 /* FunctionDeclaration */: - case 131 /* ModuleDeclaration */: - case 133 /* EnumDeclaration */: - case 148 /* IfStatement */: - case 241 /* SimplePropertyAssignment */: - case 136 /* MemberFunctionDeclaration */: - case 129 /* InterfaceDeclaration */: - case 140 /* GetAccessor */: - case 141 /* SetAccessor */: - case 151 /* ReturnStatement */: - case 138 /* ConstructorDeclaration */: - case 137 /* MemberVariableDeclaration */: - case 244 /* EnumElement */: - case 143 /* CallSignature */: - case 144 /* ConstructSignature */: - case 145 /* IndexSignature */: - case 142 /* PropertySignature */: - case 146 /* MethodSignature */: - case 242 /* FunctionPropertyAssignment */: - case 243 /* Parameter */: - return convertNodeTrailingComments(element, text); - } - } - return null; - } - ASTHelpers.postComments = postComments; - function convertNodeTrailingComments(node, text, allowWithNewLine) { - if (allowWithNewLine === void 0) { allowWithNewLine = false; } - var _lastToken = TypeScript.lastToken(node); - if (_lastToken === null || !_lastToken.hasTrailingTrivia()) { - return null; - } - if (!allowWithNewLine && TypeScript.SyntaxUtilities.isLastTokenOnLine(_lastToken, text)) { - return null; - } - return convertComments(_lastToken.trailingTrivia(text), TypeScript.fullStart(node) + TypeScript.fullWidth(node) - _lastToken.trailingTriviaWidth(text)); - } - function convertNodeLeadingComments(element, text) { - if (element) { - return convertTokenLeadingComments(TypeScript.firstToken(element), text); - } - return null; - } - function convertTokenLeadingComments(token, text) { - if (token === null) { - return null; - } - return token.hasLeadingTrivia() ? convertComments(token.leadingTrivia(text), token.fullStart()) : null; - } - ASTHelpers.convertTokenLeadingComments = convertTokenLeadingComments; - function convertTokenTrailingComments(token, text) { - if (token === null) { - return null; - } - return token.hasTrailingTrivia() ? convertComments(token.trailingTrivia(text), TypeScript.fullEnd(token) - token.trailingTriviaWidth(text)) : null; - } - ASTHelpers.convertTokenTrailingComments = convertTokenTrailingComments; - function convertComments(triviaList, commentStartPosition) { - var result = null; - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isComment()) { - var hasTrailingNewLine = ((i + 1) < n) && triviaList.syntaxTriviaAt(i + 1).isNewLine(); - result = result || []; - result.push(convertComment(trivia, commentStartPosition, hasTrailingNewLine)); - } - commentStartPosition += trivia.fullWidth(); - } - return result; - } - function convertComment(trivia, commentStartPosition, hasTrailingNewLine) { - var comment = new TypeScript.Comment(trivia, hasTrailingNewLine, commentStartPosition, commentStartPosition + trivia.fullWidth()); - return comment; - } - function docComments(ast, text) { - if (isDeclarationAST(ast)) { - var comments = null; - if (ast.kind() === 226 /* VariableDeclarator */) { - comments = TypeScript.ASTHelpers.preComments(getVariableStatement(ast), text); - } - else if (ast.kind() === 243 /* Parameter */) { - comments = TypeScript.ASTHelpers.preComments(ast, text); - if (!comments) { - var previousToken = TypeScript.findToken(TypeScript.syntaxTree(ast).sourceUnit(), TypeScript.firstToken(ast).fullStart() - 1); - if (previousToken && (previousToken.kind() === 72 /* OpenParenToken */ || previousToken.kind() === 79 /* CommaToken */)) { - comments = convertTokenTrailingComments(previousToken, text); - } - } - } - else { - comments = TypeScript.ASTHelpers.preComments(ast, text); - } - if (comments && comments.length > 0) { - return comments.filter(function (c) { return isDocComment(c); }); - } - } - return sentinelEmptyArray; - } - ASTHelpers.docComments = docComments; - function isDocComment(comment) { - if (comment.kind() === 6 /* MultiLineCommentTrivia */) { - var fullText = comment.fullText(); - return fullText.charAt(2) === "*" && fullText.charAt(3) !== "/"; - } - return false; - } - ASTHelpers.isDocComment = isDocComment; - function getParameterList(ast) { - if (ast) { - switch (ast.kind()) { - case 138 /* ConstructorDeclaration */: - return getParameterList(ast.callSignature); - case 130 /* FunctionDeclaration */: - return getParameterList(ast.callSignature); - case 219 /* ParenthesizedArrowFunctionExpression */: - return getParameterList(ast.callSignature); - case 144 /* ConstructSignature */: - return getParameterList(ast.callSignature); - case 136 /* MemberFunctionDeclaration */: - return getParameterList(ast.callSignature); - case 242 /* FunctionPropertyAssignment */: - return getParameterList(ast.callSignature); - case 223 /* FunctionExpression */: - return getParameterList(ast.callSignature); - case 146 /* MethodSignature */: - return getParameterList(ast.callSignature); - case 125 /* ConstructorType */: - return ast.parameterList; - case 123 /* FunctionType */: - return ast.parameterList; - case 143 /* CallSignature */: - return ast.parameterList; - case 140 /* GetAccessor */: - return getParameterList(ast.callSignature); - case 141 /* SetAccessor */: - return getParameterList(ast.callSignature); - } - } - return null; - } - ASTHelpers.getParameterList = getParameterList; - function getType(ast) { - if (ast) { - switch (ast.kind()) { - case 130 /* FunctionDeclaration */: - return getType(ast.callSignature); - case 219 /* ParenthesizedArrowFunctionExpression */: - return getType(ast.callSignature); - case 144 /* ConstructSignature */: - return getType(ast.callSignature); - case 136 /* MemberFunctionDeclaration */: - return getType(ast.callSignature); - case 242 /* FunctionPropertyAssignment */: - return getType(ast.callSignature); - case 223 /* FunctionExpression */: - return getType(ast.callSignature); - case 146 /* MethodSignature */: - return getType(ast.callSignature); - case 143 /* CallSignature */: - return getType(ast.typeAnnotation); - case 145 /* IndexSignature */: - return getType(ast.typeAnnotation); - case 142 /* PropertySignature */: - return getType(ast.typeAnnotation); - case 140 /* GetAccessor */: - return getType(ast.callSignature); - case 243 /* Parameter */: - return getType(ast.typeAnnotation); - case 137 /* MemberVariableDeclaration */: - return getType(ast.variableDeclarator); - case 226 /* VariableDeclarator */: - return getType(ast.typeAnnotation); - case 237 /* CatchClause */: - return getType(ast.typeAnnotation); - case 125 /* ConstructorType */: - return ast.type; - case 123 /* FunctionType */: - return ast.type; - case 245 /* TypeAnnotation */: - return ast.type; - } - } - return null; - } - ASTHelpers.getType = getType; - function getVariableStatement(variableDeclarator) { - if (variableDeclarator && variableDeclarator.parent && variableDeclarator.parent.parent && variableDeclarator.parent.parent.parent && variableDeclarator.parent.kind() === 2 /* SeparatedList */ && variableDeclarator.parent.parent.kind() === 225 /* VariableDeclaration */ && variableDeclarator.parent.parent.parent.kind() === 149 /* VariableStatement */) { - return variableDeclarator.parent.parent.parent; - } - return null; - } - function getVariableDeclaratorModifiers(variableDeclarator) { - var variableStatement = getVariableStatement(variableDeclarator); - return variableStatement ? variableStatement.modifiers : TypeScript.Syntax.emptyList(); - } - ASTHelpers.getVariableDeclaratorModifiers = getVariableDeclaratorModifiers; - function isIntegerLiteralAST(expression) { - if (expression) { - switch (expression.kind()) { - case 165 /* PlusExpression */: - case 166 /* NegateExpression */: - expression = expression.operand; - return expression.kind() === 13 /* NumericLiteral */ && TypeScript.IntegerUtilities.isInteger(expression.text()); - case 13 /* NumericLiteral */: - var text = expression.text(); - return TypeScript.IntegerUtilities.isInteger(text) || TypeScript.IntegerUtilities.isHexInteger(text); - } - } - return false; - } - ASTHelpers.isIntegerLiteralAST = isIntegerLiteralAST; - function getEnclosingModuleDeclaration(ast) { - while (ast) { - if (ast.kind() === 131 /* ModuleDeclaration */) { - return ast; - } - ast = ast.parent; - } - return null; - } - ASTHelpers.getEnclosingModuleDeclaration = getEnclosingModuleDeclaration; - function isEntireNameOfModuleDeclaration(nameAST) { - return parentIsModuleDeclaration(nameAST) && nameAST.parent.name === nameAST; - } - function getModuleDeclarationFromNameAST(ast) { - if (ast) { - switch (ast.kind()) { - case 14 /* StringLiteral */: - if (parentIsModuleDeclaration(ast) && ast.parent.stringLiteral === ast) { - return ast.parent; - } - return null; - case 11 /* IdentifierName */: - case 121 /* QualifiedName */: - if (isEntireNameOfModuleDeclaration(ast)) { - return ast.parent; - } - break; - default: - return null; - } - for (ast = ast.parent; ast && ast.kind() === 121 /* QualifiedName */; ast = ast.parent) { - if (isEntireNameOfModuleDeclaration(ast)) { - return ast.parent; - } - } - } - return null; - } - ASTHelpers.getModuleDeclarationFromNameAST = getModuleDeclarationFromNameAST; - function isLastNameOfModule(ast, astName) { - if (ast) { - if (ast.stringLiteral) { - return astName === ast.stringLiteral; - } - else if (ast.name.kind() === 121 /* QualifiedName */) { - return astName === ast.name.right; - } - else { - return astName === ast.name; - } - } - return false; - } - ASTHelpers.isLastNameOfModule = isLastNameOfModule; - function getNameOfIdentifierOrQualifiedName(name) { - if (name.kind() === 11 /* IdentifierName */) { - return name.text(); - } - else { - TypeScript.Debug.assert(name.kind() == 121 /* QualifiedName */); - var dotExpr = name; - return getNameOfIdentifierOrQualifiedName(dotExpr.left) + "." + getNameOfIdentifierOrQualifiedName(dotExpr.right); - } - } - ASTHelpers.getNameOfIdentifierOrQualifiedName = getNameOfIdentifierOrQualifiedName; - function getModuleNames(name, result) { - result = result || []; - if (name.kind() === 121 /* QualifiedName */) { - getModuleNames(name.left, result); - result.push(name.right); - } - else { - result.push(name); - } - return result; - } - ASTHelpers.getModuleNames = getModuleNames; - })(ASTHelpers = TypeScript.ASTHelpers || (TypeScript.ASTHelpers = {})); -})(TypeScript || (TypeScript = {})); -var TypeScript; (function (TypeScript) { function stripStartAndEndQuotes(str) { var firstCharCode = str && str.charCodeAt(0); @@ -31975,143 +31129,31 @@ var TypeScript; return str; } TypeScript.stripStartAndEndQuotes = stripStartAndEndQuotes; - function isSingleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 39 /* singleQuote */; - } - TypeScript.isSingleQuoted = isSingleQuoted; - function isDoubleQuoted(str) { - return str && str.length >= 2 && str.charCodeAt(0) === str.charCodeAt(str.length - 1) && str.charCodeAt(0) === 34 /* doubleQuote */; - } - TypeScript.isDoubleQuoted = isDoubleQuoted; - function isQuoted(str) { - return isDoubleQuoted(str) || isSingleQuoted(str); - } - TypeScript.isQuoted = isQuoted; - function quoteStr(str) { - return "\"" + str + "\""; - } - TypeScript.quoteStr = quoteStr; var switchToForwardSlashesRegEx = /\\/g; function switchToForwardSlashes(path) { return path.replace(switchToForwardSlashesRegEx, "/"); } TypeScript.switchToForwardSlashes = switchToForwardSlashes; - function trimModName(modName) { - if (modName.length > 5 && modName.substring(modName.length - 5, modName.length) === ".d.ts") { - return modName.substring(0, modName.length - 5); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".ts") { - return modName.substring(0, modName.length - 3); - } - if (modName.length > 3 && modName.substring(modName.length - 3, modName.length) === ".js") { - return modName.substring(0, modName.length - 3); - } - return modName; - } - TypeScript.trimModName = trimModName; - function getDeclareFilePath(fname) { - return isTSFile(fname) ? changePathToDTS(fname) : changePathToDTS(fname); - } - TypeScript.getDeclareFilePath = getDeclareFilePath; function isFileOfExtension(fname, ext) { var invariantFname = fname.toLocaleUpperCase(); var invariantExt = ext.toLocaleUpperCase(); var extLength = invariantExt.length; return invariantFname.length > extLength && invariantFname.substring(invariantFname.length - extLength, invariantFname.length) === invariantExt; } - function isTSFile(fname) { - return isFileOfExtension(fname, ".ts"); - } - TypeScript.isTSFile = isTSFile; function isDTSFile(fname) { return isFileOfExtension(fname, ".d.ts"); } TypeScript.isDTSFile = isDTSFile; - function getPrettyName(modPath, quote, treatAsFileName) { - if (quote === void 0) { quote = true; } - if (treatAsFileName === void 0) { treatAsFileName = false; } - var modName = treatAsFileName ? switchToForwardSlashes(modPath) : trimModName(stripStartAndEndQuotes(modPath)); - var components = this.getPathComponents(modName); - return components.length ? (quote ? quoteStr(components[components.length - 1]) : components[components.length - 1]) : modPath; - } - TypeScript.getPrettyName = getPrettyName; function getPathComponents(path) { return path.split("/"); } TypeScript.getPathComponents = getPathComponents; - function getRelativePathToFixedPath(fixedModFilePath, absoluteModPath, isAbsoultePathURL) { - if (isAbsoultePathURL === void 0) { isAbsoultePathURL = true; } - absoluteModPath = switchToForwardSlashes(absoluteModPath); - var modComponents = this.getPathComponents(absoluteModPath); - var fixedModComponents = this.getPathComponents(fixedModFilePath); - var joinStartIndex = 0; - for (; joinStartIndex < modComponents.length && joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== modComponents[joinStartIndex]) { - break; - } - } - if (joinStartIndex !== 0) { - var relativePath = ""; - var relativePathComponents = modComponents.slice(joinStartIndex, modComponents.length); - for (; joinStartIndex < fixedModComponents.length; joinStartIndex++) { - if (fixedModComponents[joinStartIndex] !== "") { - relativePath = relativePath + "../"; - } - } - return relativePath + relativePathComponents.join("/"); - } - if (isAbsoultePathURL && absoluteModPath.indexOf("://") === -1) { - absoluteModPath = "file:///" + absoluteModPath; - } - return absoluteModPath; - } - TypeScript.getRelativePathToFixedPath = getRelativePathToFixedPath; - function changePathToDTS(modPath) { - return trimModName(stripStartAndEndQuotes(modPath)) + ".d.ts"; - } - TypeScript.changePathToDTS = changePathToDTS; - function isRelative(path) { - return path.length > 0 && path.charAt(0) === "."; - } - TypeScript.isRelative = isRelative; - function isRooted(path) { - return path.length > 0 && (path.charAt(0) === "\\" || path.charAt(0) === "/" || (path.indexOf(":\\") !== -1) || (path.indexOf(":/") !== -1)); - } - TypeScript.isRooted = isRooted; - function getRootFilePath(outFname) { - if (outFname === "") { - return outFname; - } - else { - var isPath = outFname.indexOf("/") !== -1; - return isPath ? filePath(outFname) : ""; - } - } - TypeScript.getRootFilePath = getRootFilePath; - function filePathComponents(fullPath) { - fullPath = switchToForwardSlashes(fullPath); - var components = getPathComponents(fullPath); - return components.slice(0, components.length - 1); - } - TypeScript.filePathComponents = filePathComponents; - function filePath(fullPath) { - var path = filePathComponents(fullPath); - return path.join("/") + "/"; - } - TypeScript.filePath = filePath; - function convertToDirectoryPath(dirPath) { - if (dirPath && dirPath.charAt(dirPath.length - 1) !== "/") { - dirPath += "/"; - } - return dirPath; - } - TypeScript.convertToDirectoryPath = convertToDirectoryPath; var normalizePathRegEx = /^\\\\[^\\]/; function normalizePath(path) { if (normalizePathRegEx.test(path)) { path = "file:" + path; } - var parts = this.getPathComponents(switchToForwardSlashes(path)); + var parts = getPathComponents(switchToForwardSlashes(path)); var normalizedParts = []; for (var i = 0; i < parts.length; i++) { var part = parts[i]; @@ -32130,7 +31172,7 @@ var TypeScript; })(TypeScript || (TypeScript = {})); var ts; (function (ts) { - var scanner = ts.createScanner(ts.ScriptTarget.Latest, true); + var scanner = ts.createScanner(2 /* Latest */, true); var emptyArray = []; function createNode(kind, pos, end, flags, parent) { var node = new (ts.getNodeConstructor(kind))(); @@ -32181,7 +31223,7 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(188 /* SyntaxList */, nodes.pos, nodes.end, 512 /* Synthetic */, this); + var list = createNode(195 /* SyntaxList */, nodes.pos, nodes.end, 512 /* Synthetic */, this); list._children = []; var pos = nodes.pos; for (var i = 0, len = nodes.length; i < len; i++) { @@ -32199,7 +31241,7 @@ var ts; }; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; - if (this.kind > 116 /* Missing */) { + if (this.kind > 120 /* Missing */) { scanner.setText((sourceFile || this.getSourceFile()).text); var children = []; var pos = this.pos; @@ -32244,9 +31286,9 @@ var ts; var children = this.getChildren(); for (var i = 0; i < children.length; i++) { var child = children[i]; - if (child.kind < 116 /* Missing */) + if (child.kind < 120 /* Missing */) return child; - if (child.kind > 116 /* Missing */) + if (child.kind > 120 /* Missing */) return child.getFirstToken(sourceFile); } }; @@ -32254,9 +31296,9 @@ var ts; var children = this.getChildren(sourceFile); for (var i = children.length - 1; i >= 0; i--) { var child = children[i]; - if (child.kind < 116 /* Missing */) + if (child.kind < 120 /* Missing */) return child; - if (child.kind > 116 /* Missing */) + if (child.kind > 120 /* Missing */) return child.getLastToken(sourceFile); } }; @@ -32299,7 +31341,7 @@ var ts; var jsDocCommentParts = []; ts.forEach(declarations, function (declaration) { var sourceFileOfDeclaration = ts.getSourceFileOfNode(declaration); - if (canUseParsedParamTagComments && declaration.kind === 119 /* Parameter */) { + if (canUseParsedParamTagComments && declaration.kind === 123 /* Parameter */) { ts.forEach(getJsDocCommentTextRange(declaration.parent, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedParamJsDocComment = getCleanedParamJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedParamJsDocComment) { @@ -32307,13 +31349,13 @@ var ts; } }); } - if (declaration.kind === 181 /* ModuleDeclaration */ && declaration.body.kind === 181 /* ModuleDeclaration */) { + if (declaration.kind === 188 /* ModuleDeclaration */ && declaration.body.kind === 188 /* ModuleDeclaration */) { return; } - while (declaration.kind === 181 /* ModuleDeclaration */ && declaration.parent.kind === 181 /* ModuleDeclaration */) { + while (declaration.kind === 188 /* ModuleDeclaration */ && declaration.parent.kind === 188 /* ModuleDeclaration */) { declaration = declaration.parent; } - ts.forEach(getJsDocCommentTextRange(declaration.kind === 174 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { + ts.forEach(getJsDocCommentTextRange(declaration.kind === 181 /* VariableDeclaration */ ? declaration.parent : declaration, sourceFileOfDeclaration), function (jsDocCommentTextRange) { var cleanedJsDocComment = getCleanedJsDocComment(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); if (cleanedJsDocComment) { jsDocCommentParts.push.apply(jsDocCommentParts, cleanedJsDocComment); @@ -32574,10 +31616,10 @@ var ts; var namedDeclarations = []; ts.forEachChild(sourceFile, function visit(node) { switch (node.kind) { - case 175 /* FunctionDeclaration */: - case 121 /* Method */: + case 182 /* FunctionDeclaration */: + case 125 /* Method */: var functionDeclaration = node; - if (functionDeclaration.name && functionDeclaration.name.kind !== 116 /* Missing */) { + if (functionDeclaration.name && functionDeclaration.name.kind !== 120 /* Missing */) { var lastDeclaration = namedDeclarations.length > 0 ? namedDeclarations[namedDeclarations.length - 1] : undefined; if (lastDeclaration && functionDeclaration.symbol === lastDeclaration.symbol) { if (functionDeclaration.body && !lastDeclaration.body) { @@ -32590,31 +31632,31 @@ var ts; ts.forEachChild(node, visit); } break; - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 180 /* EnumDeclaration */: - case 181 /* ModuleDeclaration */: - case 183 /* ImportDeclaration */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 130 /* TypeLiteral */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 187 /* EnumDeclaration */: + case 188 /* ModuleDeclaration */: + case 190 /* ImportDeclaration */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 134 /* TypeLiteral */: if (node.name) { namedDeclarations.push(node); } - case 122 /* Constructor */: - case 152 /* VariableStatement */: - case 182 /* ModuleBlock */: - case 176 /* FunctionBlock */: + case 126 /* Constructor */: + case 159 /* VariableStatement */: + case 189 /* ModuleBlock */: + case 183 /* FunctionBlock */: ts.forEachChild(node, visit); break; - case 119 /* Parameter */: - if (!(node.flags & ts.NodeFlags.AccessibilityModifier)) { + case 123 /* Parameter */: + if (!(node.flags & 112 /* AccessibilityModifier */)) { break; } - case 174 /* VariableDeclaration */: - case 185 /* EnumMember */: - case 120 /* Property */: + case 181 /* VariableDeclaration */: + case 192 /* EnumMember */: + case 124 /* Property */: namedDeclarations.push(node); break; } @@ -32680,19 +31722,6 @@ var ts; SymbolDisplayPartKind[SymbolDisplayPartKind["regularExpressionLiteral"] = 21] = "regularExpressionLiteral"; })(ts.SymbolDisplayPartKind || (ts.SymbolDisplayPartKind = {})); var SymbolDisplayPartKind = ts.SymbolDisplayPartKind; - (function (OutputFileType) { - OutputFileType[OutputFileType["JavaScript"] = 0] = "JavaScript"; - OutputFileType[OutputFileType["SourceMap"] = 1] = "SourceMap"; - OutputFileType[OutputFileType["Declaration"] = 2] = "Declaration"; - })(ts.OutputFileType || (ts.OutputFileType = {})); - var OutputFileType = ts.OutputFileType; - (function (EndOfLineState) { - EndOfLineState[EndOfLineState["Start"] = 0] = "Start"; - EndOfLineState[EndOfLineState["InMultiLineCommentTrivia"] = 1] = "InMultiLineCommentTrivia"; - EndOfLineState[EndOfLineState["InSingleQuoteStringLiteral"] = 2] = "InSingleQuoteStringLiteral"; - EndOfLineState[EndOfLineState["InDoubleQuoteStringLiteral"] = 3] = "InDoubleQuoteStringLiteral"; - })(ts.EndOfLineState || (ts.EndOfLineState = {})); - var EndOfLineState = ts.EndOfLineState; (function (TokenClass) { TokenClass[TokenClass["Punctuation"] = 0] = "Punctuation"; TokenClass[TokenClass["Keyword"] = 1] = "Keyword"; @@ -32865,21 +31894,21 @@ var ts; } ts.lineBreakPart = lineBreakPart; function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 119 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 123 /* Parameter */; } function isLocalVariableOrFunction(symbol) { if (symbol.parent) { return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 144 /* FunctionExpression */) { + if (declaration.kind === 149 /* FunctionExpression */) { return true; } - if (declaration.kind !== 174 /* VariableDeclaration */ && declaration.kind !== 175 /* FunctionDeclaration */) { + if (declaration.kind !== 181 /* VariableDeclaration */ && declaration.kind !== 182 /* FunctionDeclaration */) { return false; } - for (var parent = declaration.parent; parent.kind !== 176 /* FunctionBlock */; parent = parent.parent) { - if (parent.kind === 186 /* SourceFile */ || parent.kind === 182 /* ModuleBlock */) { + for (var parent = declaration.parent; parent.kind !== 183 /* FunctionBlock */; parent = parent.parent) { + if (parent.kind === 193 /* SourceFile */ || parent.kind === 189 /* ModuleBlock */) { return false; } } @@ -32890,7 +31919,7 @@ var ts; return displayPart(text, displayPartKind(symbol), symbol); function displayPartKind(symbol) { var flags = symbol.flags; - if (flags & ts.SymbolFlags.Variable) { + if (flags & 3 /* Variable */) { return isFirstDeclarationOfSymbolParameter(symbol) ? 13 /* parameterName */ : 9 /* localName */; } else if (flags & 4 /* Property */) { @@ -32908,16 +31937,16 @@ var ts; else if (flags & 64 /* Interface */) { return 4 /* interfaceName */; } - else if (flags & 128 /* Enum */) { + else if (flags & 384 /* Enum */) { return 2 /* enumName */; } - else if (flags & ts.SymbolFlags.Module) { + else if (flags & 1536 /* Module */) { return 11 /* moduleName */; } - else if (flags & 4096 /* Method */) { + else if (flags & 8192 /* Method */) { return 10 /* methodName */; } - else if (flags & 524288 /* TypeParameter */) { + else if (flags & 1048576 /* TypeParameter */) { return 18 /* typeParameterName */; } return 17 /* text */; @@ -32950,7 +31979,7 @@ var ts; } function getDefaultCompilerOptions() { return { - target: ts.ScriptTarget.Latest, + target: 2 /* Latest */, module: 0 /* None */ }; } @@ -33098,7 +32127,7 @@ var ts; this.host.log("SyntaxTreeCache.Initialize: fixupParentRefs : " + (new Date().getTime() - start)); } if (syntaxTree !== null) { - ts.Debug.assert(sourceFile); + ts.Debug.assert(sourceFile !== undefined); this.currentFileVersion = version; this.currentFilename = filename; this.currentFileSyntaxTree = syntaxTree; @@ -33179,7 +32208,7 @@ var ts; function createDocumentRegistry() { var buckets = {}; function getKeyFromCompilationSettings(settings) { - return "_" + ts.ScriptTarget[settings.target]; + return "_" + settings.target; } function getBucketForCompilationSettings(settings, createIfMissing) { var key = getKeyFromCompilationSettings(settings); @@ -33225,9 +32254,9 @@ var ts; } function updateDocument(sourceFile, filename, compilationSettings, scriptSnapshot, version, isOpen, textChangeRange) { var bucket = getBucketForCompilationSettings(compilationSettings, false); - ts.Debug.assert(bucket); + ts.Debug.assert(bucket !== undefined); var entry = ts.lookUp(bucket, filename); - ts.Debug.assert(entry); + ts.Debug.assert(entry !== undefined); if (entry.sourceFile.isOpen === isOpen && entry.sourceFile.version === version) { return entry.sourceFile; } @@ -33236,7 +32265,7 @@ var ts; } function releaseDocument(filename, compilationSettings) { var bucket = getBucketForCompilationSettings(compilationSettings, false); - ts.Debug.assert(bucket); + ts.Debug.assert(bucket !== undefined); var entry = ts.lookUp(bucket, filename); entry.refCount--; ts.Debug.assert(entry.refCount >= 0); @@ -33272,7 +32301,7 @@ var ts; ts.getNodeModifiers = getNodeModifiers; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 167 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 174 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -33280,13 +32309,13 @@ var ts; return undefined; } function isJumpStatementTarget(node) { - return node.kind === 59 /* Identifier */ && (node.parent.kind === 161 /* BreakStatement */ || node.parent.kind === 160 /* ContinueStatement */) && node.parent.label === node; + return node.kind === 63 /* Identifier */ && (node.parent.kind === 168 /* BreakStatement */ || node.parent.kind === 167 /* ContinueStatement */) && node.parent.label === node; } function isLabelOfLabeledStatement(node) { - return node.kind === 59 /* Identifier */ && node.parent.kind === 167 /* LabeledStatement */ && node.parent.label === node; + return node.kind === 63 /* Identifier */ && node.parent.kind === 174 /* LabeledStatement */ && node.parent.label === node; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 167 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 174 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -33297,51 +32326,51 @@ var ts; return isLabelOfLabeledStatement(node) || isJumpStatementTarget(node); } function isRightSideOfQualifiedName(node) { - return node.parent.kind === 117 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node; } function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 138 /* PropertyAccess */ && node.parent.right === node; + return node && node.parent && node.parent.kind === 142 /* PropertyAccess */ && node.parent.right === node; } function isCallExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 140 /* CallExpression */ && node.parent.func === node; + return node && node.parent && node.parent.kind === 144 /* CallExpression */ && node.parent.func === node; } function isNewExpressionTarget(node) { if (isRightSideOfPropertyAccess(node)) { node = node.parent; } - return node && node.parent && node.parent.kind === 141 /* NewExpression */ && node.parent.func === node; + return node && node.parent && node.parent.kind === 145 /* NewExpression */ && node.parent.func === node; } function isNameOfModuleDeclaration(node) { - return node.parent.kind === 181 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 188 /* ModuleDeclaration */ && node.parent.name === node; } function isNameOfFunctionDeclaration(node) { - return node.kind === 59 /* Identifier */ && ts.isAnyFunction(node.parent) && node.parent.name === node; + return node.kind === 63 /* Identifier */ && ts.isAnyFunction(node.parent) && node.parent.name === node; } function isNameOfPropertyAssignment(node) { - return (node.kind === 59 /* Identifier */ || node.kind === 7 /* StringLiteral */ || node.kind === 6 /* NumericLiteral */) && node.parent.kind === 137 /* PropertyAssignment */ && node.parent.name === node; + return (node.kind === 63 /* Identifier */ || node.kind === 7 /* StringLiteral */ || node.kind === 6 /* NumericLiteral */) && node.parent.kind === 141 /* PropertyAssignment */ && node.parent.name === node; } function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 7 /* StringLiteral */ || node.kind === 6 /* NumericLiteral */) { switch (node.parent.kind) { - case 120 /* Property */: - case 137 /* PropertyAssignment */: - case 185 /* EnumMember */: - case 121 /* Method */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 181 /* ModuleDeclaration */: + case 124 /* Property */: + case 141 /* PropertyAssignment */: + case 192 /* EnumMember */: + case 125 /* Method */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 188 /* ModuleDeclaration */: return node.parent.name === node; - case 139 /* IndexedAccess */: + case 143 /* IndexedAccess */: return node.parent.index === node; } } return false; } function isNameOfExternalModuleImportOrDeclaration(node) { - return node.kind === 7 /* StringLiteral */ && (isNameOfModuleDeclaration(node) || (node.parent.kind === 183 /* ImportDeclaration */ && node.parent.externalModuleName === node)); + return node.kind === 7 /* StringLiteral */ && (isNameOfModuleDeclaration(node) || (node.parent.kind === 190 /* ImportDeclaration */ && node.parent.externalModuleName === node)); } function isInsideComment(sourceFile, token, position) { return position <= token.getStart(sourceFile) && (isInsideCommentRange(ts.getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || isInsideCommentRange(ts.getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); @@ -33364,23 +32393,8 @@ var ts; }); } } - var SemanticMeaning; - (function (SemanticMeaning) { - SemanticMeaning[SemanticMeaning["None"] = 0x0] = "None"; - SemanticMeaning[SemanticMeaning["Value"] = 0x1] = "Value"; - SemanticMeaning[SemanticMeaning["Type"] = 0x2] = "Type"; - SemanticMeaning[SemanticMeaning["Namespace"] = 0x4] = "Namespace"; - SemanticMeaning[SemanticMeaning["All"] = SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace] = "All"; - })(SemanticMeaning || (SemanticMeaning = {})); - var BreakContinueSearchType; - (function (BreakContinueSearchType) { - BreakContinueSearchType[BreakContinueSearchType["None"] = 0x0] = "None"; - BreakContinueSearchType[BreakContinueSearchType["Unlabeled"] = 0x1] = "Unlabeled"; - BreakContinueSearchType[BreakContinueSearchType["Labeled"] = 0x2] = "Labeled"; - BreakContinueSearchType[BreakContinueSearchType["All"] = BreakContinueSearchType.Unlabeled | BreakContinueSearchType.Labeled] = "All"; - })(BreakContinueSearchType || (BreakContinueSearchType = {})); var keywordCompletions = []; - for (var i = ts.SyntaxKind.FirstKeyword; i <= ts.SyntaxKind.LastKeyword; i++) { + for (var i = 64 /* FirstKeyword */; i <= 119 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ScriptElementKind.keyword, @@ -33537,7 +32551,7 @@ var ts; var displayName = symbol.getName(); if (displayName && displayName.length > 0) { var firstCharCode = displayName.charCodeAt(0); - if ((symbol.flags & ts.SymbolFlags.Namespace) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { + if ((symbol.flags & 1536 /* Namespace */) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { return undefined; } if (displayName && displayName.length >= 2 && firstCharCode === displayName.charCodeAt(displayName.length - 1) && (firstCharCode === 39 /* singleQuote */ || firstCharCode === 34 /* doubleQuote */)) { @@ -33567,15 +32581,25 @@ var ts; function getCompletionsAtPosition(filename, position, isMemberCompletion) { synchronizeHostData(); filename = TypeScript.switchToForwardSlashes(filename); + var syntacticStart = new Date().getTime(); var sourceFile = getSourceFile(filename); + var start = new Date().getTime(); var currentToken = ts.getTokenAtPosition(sourceFile, position); - if (isInsideComment(sourceFile, currentToken, position)) { + host.log("getCompletionsAtPosition: Get current token: " + (new Date().getTime() - start)); + var start = new Date().getTime(); + var insideComment = isInsideComment(sourceFile, currentToken, position); + host.log("getCompletionsAtPosition: Is inside comment: " + (new Date().getTime() - start)); + if (insideComment) { host.log("Returning an empty list because completion was inside a comment."); return undefined; } + var start = new Date().getTime(); var previousToken = ts.findPrecedingToken(position, sourceFile); - if (previousToken && position <= previousToken.end && previousToken.kind === 59 /* Identifier */) { + host.log("getCompletionsAtPosition: Get previous token 1: " + (new Date().getTime() - start)); + if (previousToken && position <= previousToken.end && previousToken.kind === 63 /* Identifier */) { + var start = new Date().getTime(); previousToken = ts.findPrecedingToken(previousToken.pos, sourceFile); + host.log("getCompletionsAtPosition: Get previous token 2: " + (new Date().getTime() - start)); } if (previousToken && isCompletionListBlocker(previousToken)) { host.log("Returning an empty list because completion was requested in an invalid position."); @@ -33583,7 +32607,7 @@ var ts; } var node; var isRightOfDot; - if (previousToken && previousToken.kind === 15 /* DotToken */ && (previousToken.parent.kind === 138 /* PropertyAccess */ || previousToken.parent.kind === 117 /* QualifiedName */)) { + if (previousToken && previousToken.kind === 19 /* DotToken */ && (previousToken.parent.kind === 142 /* PropertyAccess */ || previousToken.parent.kind === 121 /* QualifiedName */)) { node = previousToken.parent.left; isRightOfDot = true; } @@ -33598,15 +32622,17 @@ var ts; symbols: {}, typeChecker: typeInfoResolver }; + host.log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart)); + var semanticStart = new Date().getTime(); if (isRightOfDot) { var symbols = []; isMemberCompletion = true; - if (node.kind === 59 /* Identifier */ || node.kind === 117 /* QualifiedName */ || node.kind === 138 /* PropertyAccess */) { + if (node.kind === 63 /* Identifier */ || node.kind === 121 /* QualifiedName */ || node.kind === 142 /* PropertyAccess */) { var symbol = typeInfoResolver.getSymbolInfo(node); - if (symbol && symbol.flags & 16777216 /* Import */) { + if (symbol && symbol.flags & 33554432 /* Import */) { symbol = typeInfoResolver.getAliasedSymbol(symbol); } - if (symbol && symbol.flags & ts.SymbolFlags.HasExports) { + if (symbol && symbol.flags & 1952 /* HasExports */) { ts.forEachValue(symbol.exports, function (symbol) { if (typeInfoResolver.isValidPropertyAccess((node.parent), symbol.name)) { symbols.push(symbol); @@ -33640,7 +32666,7 @@ var ts; } else { isMemberCompletion = false; - var symbolMeanings = ts.SymbolFlags.Type | ts.SymbolFlags.Value | ts.SymbolFlags.Namespace | 16777216 /* Import */; + var symbolMeanings = 3152352 /* Type */ | 107455 /* Value */ | 1536 /* Namespace */ | 33554432 /* Import */; var symbols = typeInfoResolver.getSymbolsInScope(node, symbolMeanings); getCompletionEntriesFromSymbols(symbols, activeCompletionSession); } @@ -33648,11 +32674,13 @@ var ts; if (!isMemberCompletion) { Array.prototype.push.apply(activeCompletionSession.entries, keywordCompletions); } + host.log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart)); return { isMemberCompletion: isMemberCompletion, entries: activeCompletionSession.entries }; function getCompletionEntriesFromSymbols(symbols, session) { + var start = new Date().getTime(); ts.forEach(symbols, function (symbol) { var entry = createCompletionEntry(symbol, session.typeChecker); if (entry && !ts.lookUp(session.symbols, entry.name)) { @@ -33660,12 +32688,16 @@ var ts; session.symbols[entry.name] = symbol; } }); + host.log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - semanticStart)); } function isCompletionListBlocker(previousToken) { - return isInStringOrRegularExpressionLiteral(previousToken) || isIdentifierDefinitionLocation(previousToken) || isRightOfIllegalDot(previousToken); + var start = new Date().getTime(); + var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || isIdentifierDefinitionLocation(previousToken) || isRightOfIllegalDot(previousToken); + host.log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - semanticStart)); + return result; } - function isInStringOrRegularExpressionLiteral(previousToken) { - if (previousToken.kind === 7 /* StringLiteral */) { + function isInStringOrRegularExpressionOrTemplateLiteral(previousToken) { + if (previousToken.kind === 7 /* StringLiteral */ || ts.isTemplateLiteralKind(previousToken.kind)) { var start = previousToken.getStart(); var end = previousToken.getEnd(); if (start < position && position < end) { @@ -33674,7 +32706,20 @@ var ts; else if (position === end) { var width = end - start; var text = previousToken.getSourceFile().text; - return width <= 1 || text.charCodeAt(start) !== text.charCodeAt(end - 1) || text.charCodeAt(end - 2) === 92 /* backslash */; + if (width <= 1 || text.charCodeAt(end - 2) === 92 /* backslash */) { + return true; + } + switch (previousToken.kind) { + case 7 /* StringLiteral */: + case 9 /* NoSubstitutionTemplateLiteral */: + return text.charCodeAt(start) !== text.charCodeAt(end - 1); + case 10 /* TemplateHead */: + case 11 /* TemplateMiddle */: + return text.charCodeAt(end - 1) !== 123 /* openBrace */ || text.charCodeAt(end - 2) !== 36 /* $ */; + case 12 /* TemplateTail */: + return text.charCodeAt(end - 1) !== 96 /* backtick */; + } + return false; } } else if (previousToken.kind === 8 /* RegularExpressionLiteral */) { @@ -33686,9 +32731,9 @@ var ts; if (previousToken) { var parent = previousToken.parent; switch (previousToken.kind) { - case 9 /* OpenBraceToken */: - case 18 /* CommaToken */: - if (parent && parent.kind === 136 /* ObjectLiteral */) { + case 13 /* OpenBraceToken */: + case 22 /* CommaToken */: + if (parent && parent.kind === 140 /* ObjectLiteral */) { return parent; } break; @@ -33698,16 +32743,16 @@ var ts; } function isFunction(kind) { switch (kind) { - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 175 /* FunctionDeclaration */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 125 /* CallSignature */: - case 126 /* ConstructSignature */: - case 127 /* IndexSignature */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 182 /* FunctionDeclaration */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 129 /* CallSignature */: + case 130 /* ConstructSignature */: + case 131 /* IndexSignature */: return true; } return false; @@ -33716,27 +32761,27 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 18 /* CommaToken */: - return containingNodeKind === 174 /* VariableDeclaration */ || containingNodeKind === 152 /* VariableStatement */ || containingNodeKind === 180 /* EnumDeclaration */ || isFunction(containingNodeKind); - case 11 /* OpenParenToken */: - return containingNodeKind === 171 /* CatchBlock */ || isFunction(containingNodeKind); - case 9 /* OpenBraceToken */: - return containingNodeKind === 180 /* EnumDeclaration */ || containingNodeKind === 178 /* InterfaceDeclaration */; - case 17 /* SemicolonToken */: - return containingNodeKind === 120 /* Property */ && previousToken.parent.parent.kind === 178 /* InterfaceDeclaration */; - case 102 /* PublicKeyword */: - case 100 /* PrivateKeyword */: - case 103 /* StaticKeyword */: - case 16 /* DotDotDotToken */: - return containingNodeKind === 119 /* Parameter */; - case 63 /* ClassKeyword */: - case 110 /* ModuleKeyword */: - case 71 /* EnumKeyword */: - case 97 /* InterfaceKeyword */: - case 77 /* FunctionKeyword */: - case 92 /* VarKeyword */: - case 109 /* GetKeyword */: - case 113 /* SetKeyword */: + case 22 /* CommaToken */: + return containingNodeKind === 181 /* VariableDeclaration */ || containingNodeKind === 159 /* VariableStatement */ || containingNodeKind === 187 /* EnumDeclaration */ || isFunction(containingNodeKind); + case 15 /* OpenParenToken */: + return containingNodeKind === 178 /* CatchBlock */ || isFunction(containingNodeKind); + case 13 /* OpenBraceToken */: + return containingNodeKind === 187 /* EnumDeclaration */ || containingNodeKind === 185 /* InterfaceDeclaration */; + case 21 /* SemicolonToken */: + return containingNodeKind === 124 /* Property */ && previousToken.parent.parent.kind === 185 /* InterfaceDeclaration */; + case 106 /* PublicKeyword */: + case 104 /* PrivateKeyword */: + case 107 /* StaticKeyword */: + case 20 /* DotDotDotToken */: + return containingNodeKind === 123 /* Parameter */; + case 67 /* ClassKeyword */: + case 114 /* ModuleKeyword */: + case 75 /* EnumKeyword */: + case 101 /* InterfaceKeyword */: + case 81 /* FunctionKeyword */: + case 96 /* VarKeyword */: + case 113 /* GetKeyword */: + case 117 /* SetKeyword */: return true; } switch (previousToken.getText()) { @@ -33764,7 +32809,7 @@ var ts; } var existingMemberNames = {}; ts.forEach(existingMembers, function (m) { - if (m.kind !== 137 /* PropertyAssignment */) { + if (m.kind !== 141 /* PropertyAssignment */) { return; } if (m.getStart() <= position && position <= m.getEnd()) { @@ -33791,10 +32836,10 @@ var ts; var symbol = ts.lookUp(activeCompletionSession.symbols, entryName); if (symbol) { var type = session.typeChecker.getTypeOfSymbol(symbol); - ts.Debug.assert(type, "Could not find type for symbol"); + ts.Debug.assert(type !== undefined, "Could not find type for symbol"); var completionEntry = createCompletionEntry(symbol, session.typeChecker); var location = ts.getTouchingPropertyName(sourceFile, position); - var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), location, session.typeChecker, location, SemanticMeaning.All); + var displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getSourceFile(filename), location, session.typeChecker, location, 7 /* All */); return { name: entryName, kind: displayPartsDocumentationsAndSymbolKind.symbolKind, @@ -33820,16 +32865,16 @@ var ts; return node; } switch (node.kind) { - case 186 /* SourceFile */: - case 121 /* Method */: - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 177 /* ClassDeclaration */: - case 178 /* InterfaceDeclaration */: - case 180 /* EnumDeclaration */: - case 181 /* ModuleDeclaration */: + case 193 /* SourceFile */: + case 125 /* Method */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 184 /* ClassDeclaration */: + case 185 /* InterfaceDeclaration */: + case 187 /* EnumDeclaration */: + case 188 /* ModuleDeclaration */: return node; } } @@ -33838,21 +32883,21 @@ var ts; var flags = symbol.getFlags(); if (flags & 32 /* Class */) return ScriptElementKind.classElement; - if (flags & 128 /* Enum */) + if (flags & 384 /* Enum */) return ScriptElementKind.enumElement; - if (flags & 1048576 /* TypeAlias */) + if (flags & 2097152 /* TypeAlias */) return ScriptElementKind.typeElement; if (flags & 64 /* Interface */) return ScriptElementKind.interfaceElement; - if (flags & 524288 /* TypeParameter */) + if (flags & 1048576 /* TypeParameter */) return ScriptElementKind.typeParameterElement; var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, flags, typeResolver); if (result === ScriptElementKind.unknown) { - if (flags & 524288 /* TypeParameter */) + if (flags & 1048576 /* TypeParameter */) return ScriptElementKind.typeParameterElement; if (flags & 8 /* EnumMember */) return ScriptElementKind.variableElement; - if (flags & 16777216 /* Import */) + if (flags & 33554432 /* Import */) return ScriptElementKind.alias; } return result; @@ -33864,7 +32909,7 @@ var ts; if (typeResolver.isArgumentsSymbol(symbol)) { return ScriptElementKind.localVariableElement; } - if (flags & ts.SymbolFlags.Variable) { + if (flags & 3 /* Variable */) { if (isFirstDeclarationOfSymbolParameter(symbol)) { return ScriptElementKind.parameterElement; } @@ -33875,26 +32920,26 @@ var ts; } if (flags & 16 /* Function */) return isLocalVariableOrFunction(symbol) ? ScriptElementKind.localFunctionElement : ScriptElementKind.functionElement; - if (flags & 16384 /* GetAccessor */) + if (flags & 32768 /* GetAccessor */) return ScriptElementKind.memberGetAccessorElement; - if (flags & 32768 /* SetAccessor */) + if (flags & 65536 /* SetAccessor */) return ScriptElementKind.memberSetAccessorElement; - if (flags & 4096 /* Method */) + if (flags & 8192 /* Method */) return ScriptElementKind.memberFunctionElement; - if (flags & 8192 /* Constructor */) + if (flags & 16384 /* Constructor */) return ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 536870912 /* UnionProperty */) { + if (flags & 1073741824 /* UnionProperty */) { return ts.forEach(typeInfoResolver.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & 4 /* Property */) { return ScriptElementKind.memberVariableElement; } - if (rootSymbolFlags & 16384 /* GetAccessor */) + if (rootSymbolFlags & 32768 /* GetAccessor */) return ScriptElementKind.memberVariableElement; - if (rootSymbolFlags & 32768 /* SetAccessor */) + if (rootSymbolFlags & 65536 /* SetAccessor */) return ScriptElementKind.memberVariableElement; - ts.Debug.assert(rootSymbolFlags & 4096 /* Method */); + ts.Debug.assert((rootSymbolFlags & 8192 /* Method */) !== undefined); }) || ScriptElementKind.memberFunctionElement; } return ScriptElementKind.memberVariableElement; @@ -33911,7 +32956,7 @@ var ts; return ScriptElementKind.interfaceElement; if (flags & 512 /* TypeParameter */) return ScriptElementKind.typeParameterElement; - if (flags & ts.TypeFlags.Intrinsic) + if (flags & 127 /* Intrinsic */) return ScriptElementKind.primitiveType; if (flags & 256 /* StringLiteral */) return ScriptElementKind.primitiveType; @@ -33919,42 +32964,24 @@ var ts; } function getNodeKind(node) { switch (node.kind) { - case 181 /* ModuleDeclaration */: - return ScriptElementKind.moduleElement; - case 177 /* ClassDeclaration */: - return ScriptElementKind.classElement; - case 178 /* InterfaceDeclaration */: - return ScriptElementKind.interfaceElement; - case 179 /* TypeAliasDeclaration */: - return ScriptElementKind.typeElement; - case 180 /* EnumDeclaration */: - return ScriptElementKind.enumElement; - case 174 /* VariableDeclaration */: - return node.flags & 4096 /* Const */ ? ScriptElementKind.constantElement : ScriptElementKind.variableElement; - case 175 /* FunctionDeclaration */: - return ScriptElementKind.functionElement; - case 123 /* GetAccessor */: - return ScriptElementKind.memberGetAccessorElement; - case 124 /* SetAccessor */: - return ScriptElementKind.memberSetAccessorElement; - case 121 /* Method */: - return ScriptElementKind.memberFunctionElement; - case 120 /* Property */: - return ScriptElementKind.memberVariableElement; - case 127 /* IndexSignature */: - return ScriptElementKind.indexSignatureElement; - case 126 /* ConstructSignature */: - return ScriptElementKind.constructSignatureElement; - case 125 /* CallSignature */: - return ScriptElementKind.callSignatureElement; - case 122 /* Constructor */: - return ScriptElementKind.constructorImplementationElement; - case 118 /* TypeParameter */: - return ScriptElementKind.typeParameterElement; - case 185 /* EnumMember */: - return ScriptElementKind.variableElement; - case 119 /* Parameter */: - return (node.flags & ts.NodeFlags.AccessibilityModifier) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; + case 188 /* ModuleDeclaration */: return ScriptElementKind.moduleElement; + case 184 /* ClassDeclaration */: return ScriptElementKind.classElement; + case 185 /* InterfaceDeclaration */: return ScriptElementKind.interfaceElement; + case 186 /* TypeAliasDeclaration */: return ScriptElementKind.typeElement; + case 187 /* EnumDeclaration */: return ScriptElementKind.enumElement; + case 181 /* VariableDeclaration */: return node.flags & 4096 /* Const */ ? ScriptElementKind.constantElement : ScriptElementKind.variableElement; + case 182 /* FunctionDeclaration */: return ScriptElementKind.functionElement; + case 127 /* GetAccessor */: return ScriptElementKind.memberGetAccessorElement; + case 128 /* SetAccessor */: return ScriptElementKind.memberSetAccessorElement; + case 125 /* Method */: return ScriptElementKind.memberFunctionElement; + case 124 /* Property */: return ScriptElementKind.memberVariableElement; + case 131 /* IndexSignature */: return ScriptElementKind.indexSignatureElement; + case 130 /* ConstructSignature */: return ScriptElementKind.constructSignatureElement; + case 129 /* CallSignature */: return ScriptElementKind.callSignatureElement; + case 126 /* Constructor */: return ScriptElementKind.constructorImplementationElement; + case 122 /* TypeParameter */: return ScriptElementKind.typeParameterElement; + case 192 /* EnumMember */: return ScriptElementKind.variableElement; + case 123 /* Parameter */: return (node.flags & 112 /* AccessibilityModifier */) ? ScriptElementKind.memberVariableElement : ScriptElementKind.parameterElement; } return ScriptElementKind.unknown; } @@ -33968,20 +32995,20 @@ var ts; var symbolFlags = symbol.flags; var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, typeResolver); var hasAddedSymbolInfo; - if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 16777216 /* Import */) { + if (symbolKind !== ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 33554432 /* Import */) { if (symbolKind === ScriptElementKind.memberGetAccessorElement || symbolKind === ScriptElementKind.memberSetAccessorElement) { symbolKind = ScriptElementKind.memberVariableElement; } var type = typeResolver.getTypeOfSymbol(symbol); if (type) { - if (location.parent && location.parent.kind === 138 /* PropertyAccess */) { + if (location.parent && location.parent.kind === 142 /* PropertyAccess */) { var right = location.parent.right; - if (right === location || (right && right.kind === 116 /* Missing */)) { + if (right === location || (right && right.kind === 120 /* Missing */)) { location = location.parent; } } var callExpression; - if (location.kind === 140 /* CallExpression */ || location.kind === 141 /* NewExpression */) { + if (location.kind === 144 /* CallExpression */ || location.kind === 145 /* NewExpression */) { callExpression = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -33993,7 +33020,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpression.kind === 141 /* NewExpression */ || callExpression.func.kind === 85 /* SuperKeyword */; + var useConstructSignatures = callExpression.kind === 145 /* NewExpression */ || callExpression.func.kind === 89 /* SuperKeyword */; var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target || signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -34003,14 +33030,14 @@ var ts; symbolKind = ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } - else if (symbolFlags & 16777216 /* Import */) { + else if (symbolFlags & 33554432 /* Import */) { symbolKind = ScriptElementKind.alias; - displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(punctuationPart(15 /* OpenParenToken */)); displayParts.push(textPart(symbolKind)); - displayParts.push(punctuationPart(12 /* CloseParenToken */)); + displayParts.push(punctuationPart(16 /* CloseParenToken */)); displayParts.push(spacePart()); if (useConstructSignatures) { - displayParts.push(keywordPart(82 /* NewKeyword */)); + displayParts.push(keywordPart(86 /* NewKeyword */)); displayParts.push(spacePart()); } addFullSymbolName(symbol); @@ -34024,10 +33051,10 @@ var ts; case ScriptElementKind.constantElement: case ScriptElementKind.parameterElement: case ScriptElementKind.localVariableElement: - displayParts.push(punctuationPart(46 /* ColonToken */)); + displayParts.push(punctuationPart(50 /* ColonToken */)); displayParts.push(spacePart()); if (useConstructSignatures) { - displayParts.push(keywordPart(82 /* NewKeyword */)); + displayParts.push(keywordPart(86 /* NewKeyword */)); displayParts.push(spacePart()); } if (!(type.flags & 32768 /* Anonymous */)) { @@ -34041,21 +33068,21 @@ var ts; hasAddedSymbolInfo = true; } } - else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & ts.SymbolFlags.Accessor)) || (location.kind === 107 /* ConstructorKeyword */ && location.parent.kind === 122 /* Constructor */)) { + else if ((isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || (location.kind === 111 /* ConstructorKeyword */ && location.parent.kind === 126 /* Constructor */)) { var signature; var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 122 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); + var allSignatures = functionDeclaration.kind === 126 /* Constructor */ ? type.getConstructSignatures() : type.getCallSignatures(); if (!typeResolver.isImplementationOfOverload(functionDeclaration)) { signature = typeResolver.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 122 /* Constructor */) { + if (functionDeclaration.kind === 126 /* Constructor */) { addPrefixForAnyFunctionOrVar(type.symbol, ScriptElementKind.constructorImplementationElement); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 125 /* CallSignature */ && !(type.symbol.flags & 1024 /* TypeLiteral */ || type.symbol.flags & 2048 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 129 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); hasAddedSymbolInfo = true; @@ -34063,62 +33090,62 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo) { - displayParts.push(keywordPart(63 /* ClassKeyword */)); + displayParts.push(keywordPart(67 /* ClassKeyword */)); displayParts.push(spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(97 /* InterfaceKeyword */)); + displayParts.push(keywordPart(101 /* InterfaceKeyword */)); displayParts.push(spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } - if (symbolFlags & 1048576 /* TypeAlias */) { + if (symbolFlags & 2097152 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(115 /* TypeKeyword */)); + displayParts.push(keywordPart(119 /* TypeKeyword */)); displayParts.push(spacePart()); addFullSymbolName(symbol); displayParts.push(spacePart()); - displayParts.push(punctuationPart(47 /* EqualsToken */)); + displayParts.push(punctuationPart(51 /* EqualsToken */)); displayParts.push(spacePart()); displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, typeResolver.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration)); } - if (symbolFlags & 128 /* Enum */) { + if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(71 /* EnumKeyword */)); + displayParts.push(keywordPart(75 /* EnumKeyword */)); displayParts.push(spacePart()); addFullSymbolName(symbol); } - if (symbolFlags & ts.SymbolFlags.Module) { + if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(110 /* ModuleKeyword */)); + displayParts.push(keywordPart(114 /* ModuleKeyword */)); displayParts.push(spacePart()); addFullSymbolName(symbol); } - if ((symbolFlags & 524288 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { + if ((symbolFlags & 1048576 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(punctuationPart(15 /* OpenParenToken */)); displayParts.push(textPart("type parameter")); - displayParts.push(punctuationPart(12 /* CloseParenToken */)); + displayParts.push(punctuationPart(16 /* CloseParenToken */)); displayParts.push(spacePart()); addFullSymbolName(symbol); displayParts.push(spacePart()); - displayParts.push(keywordPart(80 /* InKeyword */)); + displayParts.push(keywordPart(84 /* InKeyword */)); displayParts.push(spacePart()); if (symbol.parent) { addFullSymbolName(symbol.parent, enclosingDeclaration); writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var signatureDeclaration = ts.getDeclarationOfKind(symbol, 118 /* TypeParameter */).parent; + var signatureDeclaration = ts.getDeclarationOfKind(symbol, 122 /* TypeParameter */).parent; var signature = typeResolver.getSignatureFromDeclaration(signatureDeclaration); - if (signatureDeclaration.kind === 126 /* ConstructSignature */) { - displayParts.push(keywordPart(82 /* NewKeyword */)); + if (signatureDeclaration.kind === 130 /* ConstructSignature */) { + displayParts.push(keywordPart(86 /* NewKeyword */)); displayParts.push(spacePart()); } - else if (signatureDeclaration.kind !== 125 /* CallSignature */ && signatureDeclaration.name) { + else if (signatureDeclaration.kind !== 129 /* CallSignature */ && signatureDeclaration.name) { addFullSymbolName(signatureDeclaration.symbol); } displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); @@ -34127,32 +33154,32 @@ var ts; if (symbolFlags & 8 /* EnumMember */) { addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 185 /* EnumMember */) { + if (declaration.kind === 192 /* EnumMember */) { var constantValue = typeResolver.getEnumMemberValue(declaration); if (constantValue !== undefined) { displayParts.push(spacePart()); - displayParts.push(operatorPart(47 /* EqualsToken */)); + displayParts.push(operatorPart(51 /* EqualsToken */)); displayParts.push(spacePart()); displayParts.push(displayPart(constantValue.toString(), 7 /* numericLiteral */)); } } } - if (symbolFlags & 16777216 /* Import */) { + if (symbolFlags & 33554432 /* Import */) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(79 /* ImportKeyword */)); + displayParts.push(keywordPart(83 /* ImportKeyword */)); displayParts.push(spacePart()); addFullSymbolName(symbol); displayParts.push(spacePart()); - displayParts.push(punctuationPart(47 /* EqualsToken */)); + displayParts.push(punctuationPart(51 /* EqualsToken */)); displayParts.push(spacePart()); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 183 /* ImportDeclaration */) { + if (declaration.kind === 190 /* ImportDeclaration */) { var importDeclaration = declaration; if (importDeclaration.externalModuleName) { - displayParts.push(keywordPart(111 /* RequireKeyword */)); - displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(keywordPart(115 /* RequireKeyword */)); + displayParts.push(punctuationPart(15 /* OpenParenToken */)); displayParts.push(displayPart(ts.getTextOfNode(importDeclaration.externalModuleName), 8 /* stringLiteral */)); - displayParts.push(punctuationPart(12 /* CloseParenToken */)); + displayParts.push(punctuationPart(16 /* CloseParenToken */)); } else { var internalAliasSymbol = typeResolver.getSymbolInfo(importDeclaration.entityName); @@ -34166,10 +33193,10 @@ var ts; if (symbolKind !== ScriptElementKind.unknown) { if (type) { addPrefixForAnyFunctionOrVar(symbol, symbolKind); - if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & ts.SymbolFlags.Variable || symbolKind === ScriptElementKind.localVariableElement) { - displayParts.push(punctuationPart(46 /* ColonToken */)); + if (symbolKind === ScriptElementKind.memberVariableElement || symbolFlags & 3 /* Variable */ || symbolKind === ScriptElementKind.localVariableElement) { + displayParts.push(punctuationPart(50 /* ColonToken */)); displayParts.push(spacePart()); - if (type.symbol && type.symbol.flags & 524288 /* TypeParameter */) { + if (type.symbol && type.symbol.flags & 1048576 /* TypeParameter */) { var typeParameterParts = mapToDisplayParts(function (writer) { typeResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(type, writer, enclosingDeclaration); }); @@ -34179,7 +33206,7 @@ var ts; displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, type, enclosingDeclaration)); } } - else if (symbolFlags & 16 /* Function */ || symbolFlags & 4096 /* Method */ || symbolFlags & 8192 /* Constructor */ || symbolFlags & ts.SymbolFlags.Signature || symbolFlags & ts.SymbolFlags.Accessor || symbolKind === ScriptElementKind.memberFunctionElement) { + else if (symbolFlags & 16 /* Function */ || symbolFlags & 8192 /* Method */ || symbolFlags & 16384 /* Constructor */ || symbolFlags & 917504 /* Signature */ || symbolFlags & 98304 /* Accessor */ || symbolKind === ScriptElementKind.memberFunctionElement) { var allSignatures = type.getCallSignatures(); addSignatureDisplayParts(allSignatures[0], allSignatures); } @@ -34205,9 +33232,9 @@ var ts; function addPrefixForAnyFunctionOrVar(symbol, symbolKind) { addNewLineIfDisplayPartsExist(); if (symbolKind) { - displayParts.push(punctuationPart(11 /* OpenParenToken */)); + displayParts.push(punctuationPart(15 /* OpenParenToken */)); displayParts.push(textPart(symbolKind)); - displayParts.push(punctuationPart(12 /* CloseParenToken */)); + displayParts.push(punctuationPart(16 /* CloseParenToken */)); displayParts.push(spacePart()); addFullSymbolName(symbol); } @@ -34216,12 +33243,12 @@ var ts; displayParts.push.apply(displayParts, signatureToDisplayParts(typeResolver, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(spacePart()); - displayParts.push(punctuationPart(11 /* OpenParenToken */)); - displayParts.push(operatorPart(28 /* PlusToken */)); + displayParts.push(punctuationPart(15 /* OpenParenToken */)); + displayParts.push(operatorPart(32 /* PlusToken */)); displayParts.push(displayPart((allSignatures.length - 1).toString(), 7 /* numericLiteral */)); displayParts.push(spacePart()); displayParts.push(textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(punctuationPart(12 /* CloseParenToken */)); + displayParts.push(punctuationPart(16 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); } @@ -34243,11 +33270,11 @@ var ts; var symbol = typeInfoResolver.getSymbolInfo(node); if (!symbol) { switch (node.kind) { - case 59 /* Identifier */: - case 138 /* PropertyAccess */: - case 117 /* QualifiedName */: - case 87 /* ThisKeyword */: - case 85 /* SuperKeyword */: + case 63 /* Identifier */: + case 142 /* PropertyAccess */: + case 121 /* QualifiedName */: + case 91 /* ThisKeyword */: + case 89 /* SuperKeyword */: var type = typeInfoResolver.getTypeOfNode(node); if (type) { return { @@ -34285,7 +33312,7 @@ var ts; var declarations = []; var definition; ts.forEach(signatureDeclarations, function (d) { - if ((selectConstructors && d.kind === 122 /* Constructor */) || (!selectConstructors && (d.kind === 175 /* FunctionDeclaration */ || d.kind === 121 /* Method */))) { + if ((selectConstructors && d.kind === 126 /* Constructor */) || (!selectConstructors && (d.kind === 182 /* FunctionDeclaration */ || d.kind === 125 /* Method */))) { declarations.push(d); if (d.body) definition = d; @@ -34302,10 +33329,10 @@ var ts; return false; } function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (isNewExpressionTarget(location) || location.kind === 107 /* ConstructorKeyword */) { + if (isNewExpressionTarget(location) || location.kind === 111 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { var classDeclaration = symbol.getDeclarations()[0]; - ts.Debug.assert(classDeclaration && classDeclaration.kind === 177 /* ClassDeclaration */); + ts.Debug.assert(classDeclaration && classDeclaration.kind === 184 /* ClassDeclaration */); return tryAddSignature(classDeclaration.members, true, symbolKind, symbolName, containerName, result); } } @@ -34370,94 +33397,94 @@ var ts; if (!node) { return undefined; } - if (node.kind === 59 /* Identifier */ || node.kind === 87 /* ThisKeyword */ || node.kind === 85 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { + if (node.kind === 63 /* Identifier */ || node.kind === 91 /* ThisKeyword */ || node.kind === 89 /* SuperKeyword */ || isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { return getReferencesForNode(node, [sourceFile], false, false); } switch (node.kind) { - case 78 /* IfKeyword */: - case 70 /* ElseKeyword */: - if (hasKind(node.parent, 155 /* IfStatement */)) { + case 82 /* IfKeyword */: + case 74 /* ElseKeyword */: + if (hasKind(node.parent, 162 /* IfStatement */)) { return getIfElseOccurrences(node.parent); } break; - case 84 /* ReturnKeyword */: - if (hasKind(node.parent, 162 /* ReturnStatement */)) { + case 88 /* ReturnKeyword */: + if (hasKind(node.parent, 169 /* ReturnStatement */)) { return getReturnOccurrences(node.parent); } break; - case 88 /* ThrowKeyword */: - if (hasKind(node.parent, 168 /* ThrowStatement */)) { + case 92 /* ThrowKeyword */: + if (hasKind(node.parent, 175 /* ThrowStatement */)) { return getThrowOccurrences(node.parent); } break; - case 90 /* TryKeyword */: - case 62 /* CatchKeyword */: - case 75 /* FinallyKeyword */: - if (hasKind(parent(parent(node)), 169 /* TryStatement */)) { + case 94 /* TryKeyword */: + case 66 /* CatchKeyword */: + case 79 /* FinallyKeyword */: + if (hasKind(parent(parent(node)), 176 /* TryStatement */)) { return getTryCatchFinallyOccurrences(node.parent.parent); } break; - case 86 /* SwitchKeyword */: - if (hasKind(node.parent, 164 /* SwitchStatement */)) { + case 90 /* SwitchKeyword */: + if (hasKind(node.parent, 171 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent); } break; - case 61 /* CaseKeyword */: - case 67 /* DefaultKeyword */: - if (hasKind(parent(parent(node)), 164 /* SwitchStatement */)) { + case 65 /* CaseKeyword */: + case 71 /* DefaultKeyword */: + if (hasKind(parent(parent(node)), 171 /* SwitchStatement */)) { return getSwitchCaseDefaultOccurrences(node.parent.parent); } break; - case 60 /* BreakKeyword */: - case 65 /* ContinueKeyword */: - if (hasKind(node.parent, 161 /* BreakStatement */) || hasKind(node.parent, 160 /* ContinueStatement */)) { + case 64 /* BreakKeyword */: + case 69 /* ContinueKeyword */: + if (hasKind(node.parent, 168 /* BreakStatement */) || hasKind(node.parent, 167 /* ContinueStatement */)) { return getBreakOrContinueStatementOccurences(node.parent); } break; - case 76 /* ForKeyword */: - if (hasKind(node.parent, 158 /* ForStatement */) || hasKind(node.parent, 159 /* ForInStatement */)) { + case 80 /* ForKeyword */: + if (hasKind(node.parent, 165 /* ForStatement */) || hasKind(node.parent, 166 /* ForInStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 94 /* WhileKeyword */: - case 69 /* DoKeyword */: - if (hasKind(node.parent, 157 /* WhileStatement */) || hasKind(node.parent, 156 /* DoStatement */)) { + case 98 /* WhileKeyword */: + case 73 /* DoKeyword */: + if (hasKind(node.parent, 164 /* WhileStatement */) || hasKind(node.parent, 163 /* DoStatement */)) { return getLoopBreakContinueOccurrences(node.parent); } break; - case 107 /* ConstructorKeyword */: - if (hasKind(node.parent, 122 /* Constructor */)) { + case 111 /* ConstructorKeyword */: + if (hasKind(node.parent, 126 /* Constructor */)) { return getConstructorOccurrences(node.parent); } break; - case 109 /* GetKeyword */: - case 113 /* SetKeyword */: - if (hasKind(node.parent, 123 /* GetAccessor */) || hasKind(node.parent, 124 /* SetAccessor */)) { + case 113 /* GetKeyword */: + case 117 /* SetKeyword */: + if (hasKind(node.parent, 127 /* GetAccessor */) || hasKind(node.parent, 128 /* SetAccessor */)) { return getGetAndSetOccurrences(node.parent); } } return undefined; function getIfElseOccurrences(ifStatement) { var keywords = []; - while (hasKind(ifStatement.parent, 155 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 162 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 78 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 82 /* IfKeyword */); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 70 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 74 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 155 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 162 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 70 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 74 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldHighlightNextKeyword = true; @@ -34483,15 +33510,15 @@ var ts; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 176 /* FunctionBlock */))) { + if (!(func && hasKind(func.body, 183 /* FunctionBlock */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 84 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 88 /* ReturnKeyword */); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 88 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 92 /* ThrowKeyword */); }); return ts.map(keywords, getReferenceEntryFromNode); } @@ -34502,11 +33529,11 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 88 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 92 /* ThrowKeyword */); }); - if (owner.kind === 176 /* FunctionBlock */) { + if (owner.kind === 183 /* FunctionBlock */) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 84 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 88 /* ReturnKeyword */); }); } return ts.map(keywords, getReferenceEntryFromNode); @@ -34516,10 +33543,10 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 168 /* ThrowStatement */) { + if (node.kind === 175 /* ThrowStatement */) { statementAccumulator.push(node); } - else if (node.kind === 169 /* TryStatement */) { + else if (node.kind === 176 /* TryStatement */) { var tryStatement = node; if (tryStatement.catchBlock) { aggregate(tryStatement.catchBlock); @@ -34541,10 +33568,10 @@ var ts; var child = throwStatement; while (child.parent) { var parent = child.parent; - if (parent.kind === 176 /* FunctionBlock */ || parent.kind === 186 /* SourceFile */) { + if (parent.kind === 183 /* FunctionBlock */ || parent.kind === 193 /* SourceFile */) { return parent; } - if (parent.kind === 169 /* TryStatement */) { + if (parent.kind === 176 /* TryStatement */) { var tryStatement = parent; if (tryStatement.tryBlock === child && tryStatement.catchBlock) { return child; @@ -34556,22 +33583,22 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 90 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 94 /* TryKeyword */); if (tryStatement.catchBlock) { - pushKeywordIf(keywords, tryStatement.catchBlock.getFirstToken(), 62 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchBlock.getFirstToken(), 66 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - pushKeywordIf(keywords, tryStatement.finallyBlock.getFirstToken(), 75 /* FinallyKeyword */); + pushKeywordIf(keywords, tryStatement.finallyBlock.getFirstToken(), 79 /* FinallyKeyword */); } return ts.map(keywords, getReferenceEntryFromNode); } function getLoopBreakContinueOccurrences(loopNode) { var keywords = []; - if (pushKeywordIf(keywords, loopNode.getFirstToken(), 76 /* ForKeyword */, 94 /* WhileKeyword */, 69 /* DoKeyword */)) { - if (loopNode.kind === 156 /* DoStatement */) { + if (pushKeywordIf(keywords, loopNode.getFirstToken(), 80 /* ForKeyword */, 98 /* WhileKeyword */, 73 /* DoKeyword */)) { + if (loopNode.kind === 163 /* DoStatement */) { var loopTokens = loopNode.getChildren(); for (var i = loopTokens.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 94 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 98 /* WhileKeyword */)) { break; } } @@ -34580,21 +33607,21 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 60 /* BreakKeyword */, 65 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 64 /* BreakKeyword */, 69 /* ContinueKeyword */); } }); return ts.map(keywords, getReferenceEntryFromNode); } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 86 /* SwitchKeyword */); - var breakSearchType = BreakContinueSearchType.All; + pushKeywordIf(keywords, switchStatement.getFirstToken(), 90 /* SwitchKeyword */); + var breakSearchType = 3 /* All */; ts.forEach(switchStatement.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 61 /* CaseKeyword */, 67 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 65 /* CaseKeyword */, 71 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 60 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 64 /* BreakKeyword */); } }); }); @@ -34604,12 +33631,12 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 156 /* DoStatement */: - case 157 /* WhileStatement */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 163 /* DoStatement */: + case 164 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -34620,7 +33647,7 @@ var ts; aggregate(node); return statementAccumulator; function aggregate(node) { - if (node.kind === 161 /* BreakStatement */ || node.kind === 160 /* ContinueStatement */) { + if (node.kind === 168 /* BreakStatement */ || node.kind === 167 /* ContinueStatement */) { statementAccumulator.push(node); } else if (!ts.isAnyFunction(node)) { @@ -34636,14 +33663,14 @@ var ts; function getBreakOrContinueOwner(statement) { for (var node = statement.parent; node; node = node.parent) { switch (node.kind) { - case 164 /* SwitchStatement */: - if (statement.kind === 160 /* ContinueStatement */) { + case 171 /* SwitchStatement */: + if (statement.kind === 167 /* ContinueStatement */) { continue; } - case 158 /* ForStatement */: - case 159 /* ForInStatement */: - case 157 /* WhileStatement */: - case 156 /* DoStatement */: + case 165 /* ForStatement */: + case 166 /* ForInStatement */: + case 164 /* WhileStatement */: + case 163 /* DoStatement */: if (!statement.label || isLabeledBy(node, statement.label.text)) { return node; } @@ -34662,20 +33689,20 @@ var ts; var keywords = []; ts.forEach(declarations, function (declaration) { ts.forEach(declaration.getChildren(), function (token) { - return pushKeywordIf(keywords, token, 107 /* ConstructorKeyword */); + return pushKeywordIf(keywords, token, 111 /* ConstructorKeyword */); }); }); return ts.map(keywords, getReferenceEntryFromNode); } function getGetAndSetOccurrences(accessorDeclaration) { var keywords = []; - tryPushAccessorKeyword(accessorDeclaration.symbol, 123 /* GetAccessor */); - tryPushAccessorKeyword(accessorDeclaration.symbol, 124 /* SetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 127 /* GetAccessor */); + tryPushAccessorKeyword(accessorDeclaration.symbol, 128 /* SetAccessor */); return ts.map(keywords, getReferenceEntryFromNode); function tryPushAccessorKeyword(accessorSymbol, accessorKind) { var accessor = ts.getDeclarationOfKind(accessorSymbol, accessorKind); if (accessor) { - ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 109 /* GetKeyword */, 113 /* SetKeyword */); }); + ts.forEach(accessor.getChildren(), function (child) { return pushKeywordIf(keywords, child, 113 /* GetKeyword */, 117 /* SetKeyword */); }); } } } @@ -34711,10 +33738,10 @@ var ts; if (!node) { return undefined; } - if (node.kind !== 59 /* Identifier */ && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { + if (node.kind !== 63 /* Identifier */ && !isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && !isNameOfExternalModuleImportOrDeclaration(node)) { return undefined; } - ts.Debug.assert(node.kind === 59 /* Identifier */ || node.kind === 6 /* NumericLiteral */ || node.kind === 7 /* StringLiteral */); + ts.Debug.assert(node.kind === 63 /* Identifier */ || node.kind === 6 /* NumericLiteral */ || node.kind === 7 /* StringLiteral */); return getReferencesForNode(node, program.getSourceFiles(), findInStrings, findInComments); } function getReferencesForNode(node, sourceFiles, findInStrings, findInComments) { @@ -34727,10 +33754,10 @@ var ts; return getLabelReferencesInNode(node.parent, node); } } - if (node.kind === 87 /* ThisKeyword */) { + if (node.kind === 91 /* ThisKeyword */) { return getReferencesForThisKeyword(node, sourceFiles); } - if (node.kind === 85 /* SuperKeyword */) { + if (node.kind === 89 /* SuperKeyword */) { return getReferencesForSuperKeyword(node); } var symbol = typeInfoResolver.getSymbolInfo(node); @@ -34760,7 +33787,7 @@ var ts; } return result; function getNormalizedSymbolName(symbolName, declarations) { - var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 144 /* FunctionExpression */ ? d : undefined; }); + var functionExpression = ts.forEach(declarations, function (d) { return d.kind === 149 /* FunctionExpression */ ? d : undefined; }); if (functionExpression && functionExpression.name) { var name = functionExpression.name.text; } @@ -34775,10 +33802,10 @@ var ts; return name; } function getSymbolScope(symbol) { - if (symbol.getFlags() && (4 /* Property */ | 4096 /* Method */)) { + if (symbol.getFlags() && (4 /* Property */ | 8192 /* Method */)) { var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (d.flags & 32 /* Private */) ? d : undefined; }); if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 177 /* ClassDeclaration */); + return ts.getAncestor(privateDeclaration, 184 /* ClassDeclaration */); } } if (symbol.parent) { @@ -34792,7 +33819,7 @@ var ts; if (scope && scope !== container) { return undefined; } - if (container.kind === 186 /* SourceFile */ && !ts.isExternalModule(container)) { + if (container.kind === 193 /* SourceFile */ && !ts.isExternalModule(container)) { return undefined; } scope = container; @@ -34814,7 +33841,7 @@ var ts; if (position > end) break; var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), ts.ScriptTarget.Latest)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), ts.ScriptTarget.Latest))) { + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 2 /* Latest */)) && (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 2 /* Latest */))) { positions.push(position); } position = text.indexOf(symbolName, position + symbolNameLength + 1); @@ -34841,7 +33868,7 @@ var ts; function isValidReferencePosition(node, searchSymbolName) { if (node) { switch (node.kind) { - case 59 /* Identifier */: + case 63 /* Identifier */: return node.getWidth() === searchSymbolName.length; case 7 /* StringLiteral */: if (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) { @@ -34912,11 +33939,11 @@ var ts; } var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 120 /* Property */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 124 /* Property */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; @@ -34929,7 +33956,7 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 85 /* SuperKeyword */) { + if (!node || node.kind !== 89 /* SuperKeyword */) { return; } var container = ts.getSuperContainer(node); @@ -34943,26 +33970,26 @@ var ts; var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); var staticFlag = 128 /* Static */; switch (searchSpaceNode.kind) { - case 120 /* Property */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: + case 124 /* Property */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: staticFlag &= searchSpaceNode.flags; searchSpaceNode = searchSpaceNode.parent; break; - case 186 /* SourceFile */: + case 193 /* SourceFile */: if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: break; default: return undefined; } var result = []; - if (searchSpaceNode.kind === 186 /* SourceFile */) { + if (searchSpaceNode.kind === 193 /* SourceFile */) { ts.forEach(sourceFiles, function (sourceFile) { var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, result); @@ -34978,24 +34005,24 @@ var ts; ts.forEach(possiblePositions, function (position) { cancellationToken.throwIfCancellationRequested(); var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 87 /* ThisKeyword */) { + if (!node || node.kind !== 91 /* ThisKeyword */) { return; } var container = ts.getThisContainer(node, false); switch (searchSpaceNode.kind) { - case 144 /* FunctionExpression */: - case 175 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: if (searchSpaceNode.symbol === container.symbol) { result.push(getReferenceEntryFromNode(node)); } break; - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (container.flags & 128 /* Static */) === staticFlag) { result.push(getReferenceEntryFromNode(node)); } break; - case 186 /* SourceFile */: - if (container.kind === 186 /* SourceFile */ && !ts.isExternalModule(container)) { + case 193 /* SourceFile */: + if (container.kind === 193 /* SourceFile */ && !ts.isExternalModule(container)) { result.push(getReferenceEntryFromNode(node)); } break; @@ -35023,11 +34050,11 @@ var ts; function getPropertySymbolsFromBaseTypes(symbol, propertyName, result) { if (symbol && symbol.flags & (32 /* Class */ | 64 /* Interface */)) { ts.forEach(symbol.getDeclarations(), function (declaration) { - if (declaration.kind === 177 /* ClassDeclaration */) { + if (declaration.kind === 184 /* ClassDeclaration */) { getPropertySymbolFromTypeReference(declaration.baseType); ts.forEach(declaration.implementedTypes, getPropertySymbolFromTypeReference); } - else if (declaration.kind === 178 /* InterfaceDeclaration */) { + else if (declaration.kind === 185 /* InterfaceDeclaration */) { ts.forEach(declaration.baseTypes, getPropertySymbolFromTypeReference); } }); @@ -35128,17 +34155,17 @@ var ts; }; } function isWriteAccess(node) { - if (node.kind === 59 /* Identifier */ && ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { + if (node.kind === 63 /* Identifier */ && ts.isDeclarationOrFunctionExpressionOrCatchVariableName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 147 /* PostfixOperator */ || parent.kind === 146 /* PrefixOperator */) { + if (parent.kind === 152 /* PostfixOperator */ || parent.kind === 151 /* PrefixOperator */) { return true; } - else if (parent.kind === 148 /* BinaryExpression */ && parent.left === node) { + else if (parent.kind === 153 /* BinaryExpression */ && parent.left === node) { var operator = parent.operator; - return ts.SyntaxKind.FirstAssignment <= operator && operator <= ts.SyntaxKind.LastAssignment; + return 51 /* FirstAssignment */ <= operator && operator <= 62 /* LastAssignment */; } } return false; @@ -35250,40 +34277,40 @@ var ts; } function getMeaningFromDeclaration(node) { switch (node.kind) { - case 119 /* Parameter */: - case 174 /* VariableDeclaration */: - case 120 /* Property */: - case 137 /* PropertyAssignment */: - case 185 /* EnumMember */: - case 121 /* Method */: - case 122 /* Constructor */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 175 /* FunctionDeclaration */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: - case 171 /* CatchBlock */: + case 123 /* Parameter */: + case 181 /* VariableDeclaration */: + case 124 /* Property */: + case 141 /* PropertyAssignment */: + case 192 /* EnumMember */: + case 125 /* Method */: + case 126 /* Constructor */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 182 /* FunctionDeclaration */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: + case 178 /* CatchBlock */: return 1 /* Value */; - case 118 /* TypeParameter */: - case 178 /* InterfaceDeclaration */: - case 179 /* TypeAliasDeclaration */: - case 130 /* TypeLiteral */: + case 122 /* TypeParameter */: + case 185 /* InterfaceDeclaration */: + case 186 /* TypeAliasDeclaration */: + case 134 /* TypeLiteral */: return 2 /* Type */; - case 177 /* ClassDeclaration */: - case 180 /* EnumDeclaration */: + case 184 /* ClassDeclaration */: + case 187 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: if (node.name.kind === 7 /* StringLiteral */) { return 4 /* Namespace */ | 1 /* Value */; } - else if (ts.isInstantiated(node)) { + else if (ts.getModuleInstanceState(node) === 1 /* Instantiated */) { return 4 /* Namespace */ | 1 /* Value */; } else { return 4 /* Namespace */; } break; - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.Debug.fail("Unknown declaration type"); @@ -35292,33 +34319,33 @@ var ts; if (isRightSideOfQualifiedName(node)) { node = node.parent; } - return node.parent.kind === 128 /* TypeReference */; + return node.parent.kind === 132 /* TypeReference */; } function isNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 117 /* QualifiedName */) { - while (root.parent && root.parent.kind === 117 /* QualifiedName */) + if (root.parent.kind === 121 /* QualifiedName */) { + while (root.parent && root.parent.kind === 121 /* QualifiedName */) root = root.parent; isLastClause = root.right === node; } - return root.parent.kind === 128 /* TypeReference */ && !isLastClause; + return root.parent.kind === 132 /* TypeReference */ && !isLastClause; } function isInRightSideOfImport(node) { - while (node.parent.kind === 117 /* QualifiedName */) { + while (node.parent.kind === 121 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 183 /* ImportDeclaration */ && node.parent.entityName === node; + return node.parent.kind === 190 /* ImportDeclaration */ && node.parent.entityName === node; } function getMeaningFromRightHandSideOfImport(node) { - ts.Debug.assert(node.kind === 59 /* Identifier */); - if (node.parent.kind === 117 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 183 /* ImportDeclaration */) { + ts.Debug.assert(node.kind === 63 /* Identifier */); + if (node.parent.kind === 121 /* QualifiedName */ && node.parent.right === node && node.parent.parent.kind === 190 /* ImportDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function getMeaningFromLocation(node) { - if (node.parent.kind === 184 /* ExportAssignment */) { + if (node.parent.kind === 191 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -35407,15 +34434,15 @@ var ts; return; } switch (node.kind) { - case 138 /* PropertyAccess */: - case 117 /* QualifiedName */: + case 142 /* PropertyAccess */: + case 121 /* QualifiedName */: case 7 /* StringLiteral */: - case 74 /* FalseKeyword */: - case 89 /* TrueKeyword */: - case 83 /* NullKeyword */: - case 85 /* SuperKeyword */: - case 87 /* ThisKeyword */: - case 59 /* Identifier */: + case 78 /* FalseKeyword */: + case 93 /* TrueKeyword */: + case 87 /* NullKeyword */: + case 89 /* SuperKeyword */: + case 91 /* ThisKeyword */: + case 63 /* Identifier */: break; default: return; @@ -35426,7 +34453,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 181 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { + if (nodeForStartPos.parent.parent.kind === 188 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } else { @@ -35459,18 +34486,18 @@ var ts; if (flags & 32 /* Class */) { return ClassificationTypeNames.className; } - else if (flags & 128 /* Enum */) { + else if (flags & 384 /* Enum */) { return ClassificationTypeNames.enumName; } else if (meaningAtPosition & 2 /* Type */) { if (flags & 64 /* Interface */) { return ClassificationTypeNames.interfaceName; } - else if (flags & 524288 /* TypeParameter */) { + else if (flags & 1048576 /* TypeParameter */) { return ClassificationTypeNames.typeParameterName; } } - else if (flags & ts.SymbolFlags.Module) { + else if (flags & 1536 /* Module */) { if (meaningAtPosition & 4 /* Namespace */ || (meaningAtPosition & 1 /* Value */ && hasValueSideModule(symbol))) { return ClassificationTypeNames.moduleName; } @@ -35478,13 +34505,13 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 181 /* ModuleDeclaration */ && ts.isInstantiated(declaration); + return declaration.kind === 188 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) == 1 /* Instantiated */; }); } } function processNode(node) { if (node && span.intersectsWith(node.getStart(), node.getWidth())) { - if (node.kind === 59 /* Identifier */ && node.getWidth() > 0) { + if (node.kind === 63 /* Identifier */ && node.getWidth() > 0) { var symbol = typeInfoResolver.getSymbolInfo(node); if (symbol) { var type = classifySymbol(symbol, getMeaningFromLocation(node)); @@ -35533,13 +34560,13 @@ var ts; if (ts.isKeyword(tokenKind)) { return ClassificationTypeNames.keyword; } - if (tokenKind === 19 /* LessThanToken */ || tokenKind === 20 /* GreaterThanToken */) { + if (tokenKind === 23 /* LessThanToken */ || tokenKind === 24 /* GreaterThanToken */) { if (ts.getTypeArgumentOrTypeParameterList(token.parent)) { return ClassificationTypeNames.punctuation; } } if (ts.isPunctuation(token)) { - if (token.parent.kind === 148 /* BinaryExpression */ || token.parent.kind === 174 /* VariableDeclaration */ || token.parent.kind === 146 /* PrefixOperator */ || token.parent.kind === 147 /* PostfixOperator */ || token.parent.kind === 149 /* ConditionalExpression */) { + if (token.parent.kind === 153 /* BinaryExpression */ || token.parent.kind === 181 /* VariableDeclaration */ || token.parent.kind === 151 /* PrefixOperator */ || token.parent.kind === 152 /* PostfixOperator */ || token.parent.kind === 154 /* ConditionalExpression */) { return ClassificationTypeNames.operator; } else { @@ -35555,29 +34582,32 @@ var ts; else if (tokenKind === 8 /* RegularExpressionLiteral */) { return ClassificationTypeNames.stringLiteral; } - else if (tokenKind === 59 /* Identifier */) { + else if (ts.isTemplateLiteralKind(tokenKind)) { + return ClassificationTypeNames.stringLiteral; + } + else if (tokenKind === 63 /* Identifier */) { switch (token.parent.kind) { - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.className; } return; - case 118 /* TypeParameter */: + case 122 /* TypeParameter */: if (token.parent.name === token) { return ClassificationTypeNames.typeParameterName; } return; - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.interfaceName; } return; - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.enumName; } return; - case 181 /* ModuleDeclaration */: + case 188 /* ModuleDeclaration */: if (token.parent.name === token) { return ClassificationTypeNames.moduleName; } @@ -35635,22 +34665,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 9 /* OpenBraceToken */: - return 10 /* CloseBraceToken */; - case 11 /* OpenParenToken */: - return 12 /* CloseParenToken */; - case 13 /* OpenBracketToken */: - return 14 /* CloseBracketToken */; - case 19 /* LessThanToken */: - return 20 /* GreaterThanToken */; - case 10 /* CloseBraceToken */: - return 9 /* OpenBraceToken */; - case 12 /* CloseParenToken */: - return 11 /* OpenParenToken */; - case 14 /* CloseBracketToken */: - return 13 /* OpenBracketToken */; - case 20 /* GreaterThanToken */: - return 19 /* LessThanToken */; + case 13 /* OpenBraceToken */: return 14 /* CloseBraceToken */; + case 15 /* OpenParenToken */: return 16 /* CloseParenToken */; + case 17 /* OpenBracketToken */: return 18 /* CloseBracketToken */; + case 23 /* LessThanToken */: return 24 /* GreaterThanToken */; + case 14 /* CloseBraceToken */: return 13 /* OpenBraceToken */; + case 16 /* CloseParenToken */: return 15 /* OpenParenToken */; + case 18 /* CloseBracketToken */: return 17 /* OpenBracketToken */; + case 24 /* GreaterThanToken */: return 23 /* LessThanToken */; } return undefined; } @@ -35703,8 +34725,9 @@ var ts; return []; } function getTodoComments(filename, descriptors) { + synchronizeHostData(); filename = TypeScript.switchToForwardSlashes(filename); - var sourceFile = getCurrentSourceFile(filename); + var sourceFile = getSourceFile(filename); cancellationToken.throwIfCancellationRequested(); var fileContents = sourceFile.text; cancellationToken.throwIfCancellationRequested(); @@ -35728,7 +34751,7 @@ var ts; descriptor = descriptors[i]; } } - ts.Debug.assert(descriptor); + ts.Debug.assert(descriptor !== undefined); if (isLetterOrDigit(fileContents.charCodeAt(matchPosition + descriptor.text.length))) { continue; } @@ -35776,7 +34799,7 @@ var ts; fileName = TypeScript.switchToForwardSlashes(fileName); var sourceFile = getSourceFile(fileName); var node = ts.getTouchingWord(sourceFile, position); - if (node && node.kind === 59 /* Identifier */) { + if (node && node.kind === 63 /* Identifier */) { var symbol = typeInfoResolver.getSymbolInfo(node); if (symbol && symbol.getDeclarations() && symbol.getDeclarations().length > 0) { var kind = getSymbolKind(symbol, typeInfoResolver); @@ -35844,32 +34867,32 @@ var ts; } ts.createLanguageService = createLanguageService; function createClassifier(host) { - var scanner = ts.createScanner(ts.ScriptTarget.Latest, false); + var scanner = ts.createScanner(2 /* Latest */, false); var noRegexTable = []; - noRegexTable[59 /* Identifier */] = true; + noRegexTable[63 /* Identifier */] = true; noRegexTable[7 /* StringLiteral */] = true; noRegexTable[6 /* NumericLiteral */] = true; noRegexTable[8 /* RegularExpressionLiteral */] = true; - noRegexTable[87 /* ThisKeyword */] = true; - noRegexTable[33 /* PlusPlusToken */] = true; - noRegexTable[34 /* MinusMinusToken */] = true; - noRegexTable[12 /* CloseParenToken */] = true; - noRegexTable[14 /* CloseBracketToken */] = true; - noRegexTable[10 /* CloseBraceToken */] = true; - noRegexTable[89 /* TrueKeyword */] = true; - noRegexTable[74 /* FalseKeyword */] = true; + noRegexTable[91 /* ThisKeyword */] = true; + noRegexTable[37 /* PlusPlusToken */] = true; + noRegexTable[38 /* MinusMinusToken */] = true; + noRegexTable[16 /* CloseParenToken */] = true; + noRegexTable[18 /* CloseBracketToken */] = true; + noRegexTable[14 /* CloseBraceToken */] = true; + noRegexTable[93 /* TrueKeyword */] = true; + noRegexTable[78 /* FalseKeyword */] = true; function isAccessibilityModifier(kind) { switch (kind) { - case 102 /* PublicKeyword */: - case 100 /* PrivateKeyword */: - case 101 /* ProtectedKeyword */: + case 106 /* PublicKeyword */: + case 104 /* PrivateKeyword */: + case 105 /* ProtectedKeyword */: return true; } return false; } function canFollow(keyword1, keyword2) { if (isAccessibilityModifier(keyword1)) { - if (keyword2 === 109 /* GetKeyword */ || keyword2 === 113 /* SetKeyword */ || keyword2 === 107 /* ConstructorKeyword */ || keyword2 === 103 /* StaticKeyword */) { + if (keyword2 === 113 /* GetKeyword */ || keyword2 === 117 /* SetKeyword */ || keyword2 === 111 /* ConstructorKeyword */ || keyword2 === 107 /* StaticKeyword */) { return true; } return false; @@ -35904,26 +34927,26 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 31 /* SlashToken */ || token === 51 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if ((token === 35 /* SlashToken */ || token === 55 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { if (scanner.reScanSlashToken() === 8 /* RegularExpressionLiteral */) { token = 8 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 15 /* DotToken */ && isKeyword(token)) { - token = 59 /* Identifier */; + else if (lastNonTriviaToken === 19 /* DotToken */ && isKeyword(token)) { + token = 63 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 59 /* Identifier */; + token = 63 /* Identifier */; } - else if (lastNonTriviaToken === 59 /* Identifier */ && token === 19 /* LessThanToken */) { + else if (lastNonTriviaToken === 63 /* Identifier */ && token === 23 /* LessThanToken */) { angleBracketStack++; } - else if (token === 20 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 24 /* GreaterThanToken */ && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 105 /* AnyKeyword */ || token === 114 /* StringKeyword */ || token === 112 /* NumberKeyword */ || token === 106 /* BooleanKeyword */) { + else if (token === 109 /* AnyKeyword */ || token === 118 /* StringKeyword */ || token === 116 /* NumberKeyword */ || token === 110 /* BooleanKeyword */) { if (angleBracketStack > 0) { - token = 59 /* Identifier */; + token = 63 /* Identifier */; } } lastNonTriviaToken = token; @@ -35962,62 +34985,61 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 30 /* AsteriskToken */: - case 31 /* SlashToken */: - case 32 /* PercentToken */: - case 28 /* PlusToken */: - case 29 /* MinusToken */: - case 35 /* LessThanLessThanToken */: - case 36 /* GreaterThanGreaterThanToken */: - case 37 /* GreaterThanGreaterThanGreaterThanToken */: - case 19 /* LessThanToken */: - case 20 /* GreaterThanToken */: - case 21 /* LessThanEqualsToken */: - case 22 /* GreaterThanEqualsToken */: - case 81 /* InstanceOfKeyword */: - case 80 /* InKeyword */: - case 23 /* EqualsEqualsToken */: - case 24 /* ExclamationEqualsToken */: - case 25 /* EqualsEqualsEqualsToken */: - case 26 /* ExclamationEqualsEqualsToken */: - case 38 /* AmpersandToken */: - case 40 /* CaretToken */: - case 39 /* BarToken */: - case 43 /* AmpersandAmpersandToken */: - case 44 /* BarBarToken */: - case 57 /* BarEqualsToken */: - case 56 /* AmpersandEqualsToken */: - case 58 /* CaretEqualsToken */: - case 53 /* LessThanLessThanEqualsToken */: - case 54 /* GreaterThanGreaterThanEqualsToken */: - case 55 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* PlusEqualsToken */: - case 49 /* MinusEqualsToken */: - case 50 /* AsteriskEqualsToken */: - case 51 /* SlashEqualsToken */: - case 52 /* PercentEqualsToken */: - case 47 /* EqualsToken */: - case 18 /* CommaToken */: + case 34 /* AsteriskToken */: + case 35 /* SlashToken */: + case 36 /* PercentToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: + case 39 /* LessThanLessThanToken */: + case 40 /* GreaterThanGreaterThanToken */: + case 41 /* GreaterThanGreaterThanGreaterThanToken */: + case 23 /* LessThanToken */: + case 24 /* GreaterThanToken */: + case 25 /* LessThanEqualsToken */: + case 26 /* GreaterThanEqualsToken */: + case 85 /* InstanceOfKeyword */: + case 84 /* InKeyword */: + case 27 /* EqualsEqualsToken */: + case 28 /* ExclamationEqualsToken */: + case 29 /* EqualsEqualsEqualsToken */: + case 30 /* ExclamationEqualsEqualsToken */: + case 42 /* AmpersandToken */: + case 44 /* CaretToken */: + case 43 /* BarToken */: + case 47 /* AmpersandAmpersandToken */: + case 48 /* BarBarToken */: + case 61 /* BarEqualsToken */: + case 60 /* AmpersandEqualsToken */: + case 62 /* CaretEqualsToken */: + case 57 /* LessThanLessThanEqualsToken */: + case 58 /* GreaterThanGreaterThanEqualsToken */: + case 59 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 52 /* PlusEqualsToken */: + case 53 /* MinusEqualsToken */: + case 54 /* AsteriskEqualsToken */: + case 55 /* SlashEqualsToken */: + case 56 /* PercentEqualsToken */: + case 51 /* EqualsToken */: + case 22 /* CommaToken */: return true; - default: - return false; + default: return false; } } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 28 /* PlusToken */: - case 29 /* MinusToken */: - case 42 /* TildeToken */: - case 41 /* ExclamationToken */: - case 33 /* PlusPlusToken */: - case 34 /* MinusMinusToken */: + case 32 /* PlusToken */: + case 33 /* MinusToken */: + case 46 /* TildeToken */: + case 45 /* ExclamationToken */: + case 37 /* PlusPlusToken */: + case 38 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= ts.SyntaxKind.FirstKeyword && token <= ts.SyntaxKind.LastKeyword; + return token >= 64 /* FirstKeyword */ && token <= 119 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -36026,7 +35048,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 2 /* Operator */; } - else if (token >= ts.SyntaxKind.FirstPunctuation && token <= ts.SyntaxKind.LastPunctuation) { + else if (token >= 13 /* FirstPunctuation */ && token <= 62 /* LastPunctuation */) { return 0 /* Punctuation */; } switch (token) { @@ -36041,7 +35063,7 @@ var ts; return 3 /* Comment */; case 5 /* WhitespaceTrivia */: return 4 /* Whitespace */; - case 59 /* Identifier */: + case 63 /* Identifier */: default: return 5 /* Identifier */; } @@ -36056,7 +35078,7 @@ var ts; getNodeConstructor: function (kind) { function Node() { } - var proto = kind === 186 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); + var proto = kind === 193 /* SourceFile */ ? new SourceFileObject() : new NodeObject(); proto.kind = kind; proto.pos = 0; proto.end = 0; @@ -36110,120 +35132,120 @@ var ts; function spanInNode(node) { if (node) { if (ts.isExpression(node)) { - if (node.parent.kind === 156 /* DoStatement */) { + if (node.parent.kind === 163 /* DoStatement */) { return spanInPreviousNode(node); } - if (node.parent.kind === 158 /* ForStatement */) { + if (node.parent.kind === 165 /* ForStatement */) { return textSpan(node); } - if (node.parent.kind === 148 /* BinaryExpression */ && node.parent.operator === 18 /* CommaToken */) { + if (node.parent.kind === 153 /* BinaryExpression */ && node.parent.operator === 22 /* CommaToken */) { return textSpan(node); } - if (node.parent.kind == 145 /* ArrowFunction */ && node.parent.body == node) { + if (node.parent.kind == 150 /* ArrowFunction */ && node.parent.body == node) { return textSpan(node); } } switch (node.kind) { - case 152 /* VariableStatement */: + case 159 /* VariableStatement */: return spanInVariableDeclaration(node.declarations[0]); - case 174 /* VariableDeclaration */: - case 120 /* Property */: + case 181 /* VariableDeclaration */: + case 124 /* Property */: return spanInVariableDeclaration(node); - case 119 /* Parameter */: + case 123 /* Parameter */: return spanInParameterDeclaration(node); - case 175 /* FunctionDeclaration */: - case 121 /* Method */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 122 /* Constructor */: - case 144 /* FunctionExpression */: - case 145 /* ArrowFunction */: + case 182 /* FunctionDeclaration */: + case 125 /* Method */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 126 /* Constructor */: + case 149 /* FunctionExpression */: + case 150 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 176 /* FunctionBlock */: + case 183 /* FunctionBlock */: return spanInFunctionBlock(node); - case 151 /* Block */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: - case 182 /* ModuleBlock */: + case 158 /* Block */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: + case 189 /* ModuleBlock */: return spanInBlock(node); - case 154 /* ExpressionStatement */: + case 161 /* ExpressionStatement */: return textSpan(node.expression); - case 162 /* ReturnStatement */: + case 169 /* ReturnStatement */: return textSpan(node.getChildAt(0), node.expression); - case 157 /* WhileStatement */: + case 164 /* WhileStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 156 /* DoStatement */: + case 163 /* DoStatement */: return spanInNode(node.statement); - case 173 /* DebuggerStatement */: + case 180 /* DebuggerStatement */: return textSpan(node.getChildAt(0)); - case 155 /* IfStatement */: + case 162 /* IfStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 167 /* LabeledStatement */: + case 174 /* LabeledStatement */: return spanInNode(node.statement); - case 161 /* BreakStatement */: - case 160 /* ContinueStatement */: + case 168 /* BreakStatement */: + case 167 /* ContinueStatement */: return textSpan(node.getChildAt(0), node.label); - case 158 /* ForStatement */: + case 165 /* ForStatement */: return spanInForStatement(node); - case 159 /* ForInStatement */: + case 166 /* ForInStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return textSpan(node, ts.findNextToken(node.expression, node)); - case 165 /* CaseClause */: - case 166 /* DefaultClause */: + case 172 /* CaseClause */: + case 173 /* DefaultClause */: return spanInNode(node.statements[0]); - case 169 /* TryStatement */: + case 176 /* TryStatement */: return spanInBlock(node.tryBlock); - case 168 /* ThrowStatement */: + case 175 /* ThrowStatement */: return textSpan(node, node.expression); - case 184 /* ExportAssignment */: + case 191 /* ExportAssignment */: return textSpan(node, node.exportName); - case 183 /* ImportDeclaration */: + case 190 /* ImportDeclaration */: return textSpan(node, node.entityName || node.externalModuleName); - case 181 /* ModuleDeclaration */: - if (!ts.isInstantiated(node)) { + case 188 /* ModuleDeclaration */: + if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 177 /* ClassDeclaration */: - case 180 /* EnumDeclaration */: - case 185 /* EnumMember */: - case 140 /* CallExpression */: - case 141 /* NewExpression */: + case 184 /* ClassDeclaration */: + case 187 /* EnumDeclaration */: + case 192 /* EnumMember */: + case 144 /* CallExpression */: + case 145 /* NewExpression */: return textSpan(node); - case 163 /* WithStatement */: + case 170 /* WithStatement */: return spanInNode(node.statement); - case 178 /* InterfaceDeclaration */: + case 185 /* InterfaceDeclaration */: return undefined; - case 17 /* SemicolonToken */: + case 21 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 18 /* CommaToken */: + case 22 /* CommaToken */: return spanInPreviousNode(node); - case 9 /* OpenBraceToken */: + case 13 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 10 /* CloseBraceToken */: + case 14 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 11 /* OpenParenToken */: + case 15 /* OpenParenToken */: return spanInOpenParenToken(node); - case 12 /* CloseParenToken */: + case 16 /* CloseParenToken */: return spanInCloseParenToken(node); - case 46 /* ColonToken */: + case 50 /* ColonToken */: return spanInColonToken(node); - case 20 /* GreaterThanToken */: - case 19 /* LessThanToken */: + case 24 /* GreaterThanToken */: + case 23 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); - case 94 /* WhileKeyword */: + case 98 /* WhileKeyword */: return spanInWhileKeyword(node); - case 70 /* ElseKeyword */: - case 62 /* CatchKeyword */: - case 75 /* FinallyKeyword */: + case 74 /* ElseKeyword */: + case 66 /* CatchKeyword */: + case 79 /* FinallyKeyword */: return spanInNextNode(node); default: - if (node.parent.kind === 137 /* PropertyAssignment */ && node.parent.name === node) { + if (node.parent.kind === 141 /* PropertyAssignment */ && node.parent.name === node) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 142 /* TypeAssertion */ && node.parent.type === node) { + if (node.parent.kind === 147 /* TypeAssertion */ && node.parent.type === node) { return spanInNode(node.parent.operand); } if (ts.isAnyFunction(node.parent) && node.parent.type === node) { @@ -36233,11 +35255,11 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.kind === 159 /* ForInStatement */) { + if (variableDeclaration.parent.kind === 166 /* ForInStatement */) { return spanInNode(variableDeclaration.parent); } - var isParentVariableStatement = variableDeclaration.parent.kind === 152 /* VariableStatement */; - var isDeclarationOfForStatement = variableDeclaration.parent.kind === 158 /* ForStatement */ && ts.contains(variableDeclaration.parent.declarations, variableDeclaration); + var isParentVariableStatement = variableDeclaration.parent.kind === 159 /* VariableStatement */; + var isDeclarationOfForStatement = variableDeclaration.parent.kind === 165 /* ForStatement */ && ts.contains(variableDeclaration.parent.declarations, variableDeclaration); var declarations = isParentVariableStatement ? variableDeclaration.parent.declarations : isDeclarationOfForStatement ? variableDeclaration.parent.declarations : undefined; if (variableDeclaration.initializer || (variableDeclaration.flags & 1 /* Export */)) { if (declarations && declarations[0] === variableDeclaration) { @@ -36277,7 +35299,7 @@ var ts; } } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { - return !!(functionDeclaration.flags & 1 /* Export */) || (functionDeclaration.parent.kind === 177 /* ClassDeclaration */ && functionDeclaration.kind !== 122 /* Constructor */); + return !!(functionDeclaration.flags & 1 /* Export */) || (functionDeclaration.parent.kind === 184 /* ClassDeclaration */ && functionDeclaration.kind !== 126 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -36297,15 +35319,15 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 181 /* ModuleDeclaration */: - if (!ts.isInstantiated(block.parent)) { + case 188 /* ModuleDeclaration */: + if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } - case 157 /* WhileStatement */: - case 155 /* IfStatement */: - case 159 /* ForInStatement */: + case 164 /* WhileStatement */: + case 162 /* IfStatement */: + case 166 /* ForInStatement */: return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); - case 158 /* ForStatement */: + case 165 /* ForStatement */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); @@ -36326,34 +35348,34 @@ var ts; } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 180 /* EnumDeclaration */: + case 187 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 177 /* ClassDeclaration */: + case 184 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: return spanInNodeIfStartsOnSameLine(node.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 182 /* ModuleBlock */: - if (!ts.isInstantiated(node.parent.parent)) { + case 189 /* ModuleBlock */: + if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 176 /* FunctionBlock */: - case 180 /* EnumDeclaration */: - case 177 /* ClassDeclaration */: + case 183 /* FunctionBlock */: + case 187 /* EnumDeclaration */: + case 184 /* ClassDeclaration */: return textSpan(node); - case 151 /* Block */: - case 170 /* TryBlock */: - case 171 /* CatchBlock */: - case 172 /* FinallyBlock */: + case 158 /* Block */: + case 177 /* TryBlock */: + case 178 /* CatchBlock */: + case 179 /* FinallyBlock */: return spanInNode(node.parent.statements[node.parent.statements.length - 1]); ; - case 164 /* SwitchStatement */: + case 171 /* SwitchStatement */: var switchStatement = node.parent; var lastClause = switchStatement.clauses[switchStatement.clauses.length - 1]; if (lastClause) { @@ -36365,23 +35387,23 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 156 /* DoStatement */) { + if (node.parent.kind === 163 /* DoStatement */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 144 /* FunctionExpression */: - case 175 /* FunctionDeclaration */: - case 145 /* ArrowFunction */: - case 121 /* Method */: - case 123 /* GetAccessor */: - case 124 /* SetAccessor */: - case 122 /* Constructor */: - case 157 /* WhileStatement */: - case 156 /* DoStatement */: - case 158 /* ForStatement */: + case 149 /* FunctionExpression */: + case 182 /* FunctionDeclaration */: + case 150 /* ArrowFunction */: + case 125 /* Method */: + case 127 /* GetAccessor */: + case 128 /* SetAccessor */: + case 126 /* Constructor */: + case 164 /* WhileStatement */: + case 163 /* DoStatement */: + case 165 /* ForStatement */: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -36389,19 +35411,19 @@ var ts; return spanInNode(node.parent); } function spanInColonToken(node) { - if (ts.isAnyFunction(node.parent) || node.parent.kind === 137 /* PropertyAssignment */) { + if (ts.isAnyFunction(node.parent) || node.parent.kind === 141 /* PropertyAssignment */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 142 /* TypeAssertion */) { + if (node.parent.kind === 147 /* TypeAssertion */) { return spanInNode(node.parent.operand); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 156 /* DoStatement */) { + if (node.parent.kind === 163 /* DoStatement */) { return textSpan(node, ts.findNextToken(node.parent.expression, node.parent)); } return spanInNode(node.parent); @@ -36452,20 +35474,20 @@ var TypeScript; var lineChar = { line: -1, character: -1 }; var lineMap = text.lineMap(); var start = new Date().getTime(); - while (token.kind() !== 10 /* EndOfFileToken */) { - if (token.kind() === 49 /* ImportKeyword */) { + while (token.kind() !== 8 /* EndOfFileToken */) { + if (token.kind() === 51 /* ImportKeyword */) { var importToken = token; token = scanner.scan(false); if (TypeScript.SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { token = scanner.scan(false); - if (token.kind() === 107 /* EqualsToken */) { + if (token.kind() === 109 /* EqualsToken */) { token = scanner.scan(false); - if (token.kind() === 65 /* ModuleKeyword */ || token.kind() === 66 /* RequireKeyword */) { + if (token.kind() === 67 /* ModuleKeyword */ || token.kind() === 68 /* RequireKeyword */) { token = scanner.scan(false); - if (token.kind() === 72 /* OpenParenToken */) { + if (token.kind() === 74 /* OpenParenToken */) { token = scanner.scan(false); lineMap.fillLineAndCharacterFromPosition(TypeScript.start(importToken, text), lineChar); - if (token.kind() === 14 /* StringLiteral */) { + if (token.kind() === 12 /* StringLiteral */) { var ref = { line: lineChar.line, character: lineChar.character, @@ -36495,7 +35517,7 @@ var TypeScript; var lineMap = text.lineMap(); for (var i = 0, n = leadingTrivia.count(); i < n; i++) { var trivia = leadingTrivia.syntaxTriviaAt(i); - if (trivia.kind() === 7 /* SingleLineCommentTrivia */) { + if (trivia.kind() === 5 /* SingleLineCommentTrivia */) { var triviaText = trivia.fullText(); var referencedCode = getFileReferenceFromReferencePath(fileName, text, position, triviaText, diagnostics); if (referencedCode) { @@ -36518,7 +35540,7 @@ var TypeScript; function preProcessFile(fileName, sourceText, readImportFiles) { if (readImportFiles === void 0) { readImportFiles = true; } var text = TypeScript.SimpleText.fromScriptSnapshot(sourceText); - var scanner = TypeScript.Scanner.createScanner(ts.ScriptTarget.Latest, text, reportDiagnostic); + var scanner = TypeScript.Scanner.createScanner(2 /* Latest */, text, reportDiagnostic); var firstToken = scanner.scan(false); var importedFiles = []; if (readImportFiles) { @@ -36536,72 +35558,44 @@ var TypeScript; var debugObjectHost = this; var ts; (function (ts) { - (function (LanguageVersion) { - LanguageVersion[LanguageVersion["EcmaScript3"] = 0] = "EcmaScript3"; - LanguageVersion[LanguageVersion["EcmaScript5"] = 1] = "EcmaScript5"; - LanguageVersion[LanguageVersion["EcmaScript6"] = 2] = "EcmaScript6"; - })(ts.LanguageVersion || (ts.LanguageVersion = {})); - var LanguageVersion = ts.LanguageVersion; - (function (ModuleGenTarget) { - ModuleGenTarget[ModuleGenTarget["Unspecified"] = 0] = "Unspecified"; - ModuleGenTarget[ModuleGenTarget["Synchronous"] = 1] = "Synchronous"; - ModuleGenTarget[ModuleGenTarget["Asynchronous"] = 2] = "Asynchronous"; - })(ts.ModuleGenTarget || (ts.ModuleGenTarget = {})); - var ModuleGenTarget = ts.ModuleGenTarget; function languageVersionToScriptTarget(languageVersion) { if (typeof languageVersion === "undefined") return undefined; switch (languageVersion) { - case 0 /* EcmaScript3 */: - return 0 /* ES3 */; - case 1 /* EcmaScript5 */: - return 1 /* ES5 */; - case 2 /* EcmaScript6 */: - return 2 /* ES6 */; - default: - throw Error("unsupported LanguageVersion value: " + languageVersion); + case 0 /* EcmaScript3 */: return 0 /* ES3 */; + case 1 /* EcmaScript5 */: return 1 /* ES5 */; + case 2 /* EcmaScript6 */: return 2 /* ES6 */; + default: throw Error("unsupported LanguageVersion value: " + languageVersion); } } function moduleGenTargetToModuleKind(moduleGenTarget) { if (typeof moduleGenTarget === "undefined") return undefined; switch (moduleGenTarget) { - case 2 /* Asynchronous */: - return 2 /* AMD */; - case 1 /* Synchronous */: - return 1 /* CommonJS */; - case 0 /* Unspecified */: - return 0 /* None */; - default: - throw Error("unsupported ModuleGenTarget value: " + moduleGenTarget); + case 2 /* Asynchronous */: return 2 /* AMD */; + case 1 /* Synchronous */: return 1 /* CommonJS */; + case 0 /* Unspecified */: return 0 /* None */; + default: throw Error("unsupported ModuleGenTarget value: " + moduleGenTarget); } } function scriptTargetTolanguageVersion(scriptTarget) { if (typeof scriptTarget === "undefined") return undefined; switch (scriptTarget) { - case 0 /* ES3 */: - return 0 /* EcmaScript3 */; - case 1 /* ES5 */: - return 1 /* EcmaScript5 */; - case 2 /* ES6 */: - return 2 /* EcmaScript6 */; - default: - throw Error("unsupported ScriptTarget value: " + scriptTarget); + case 0 /* ES3 */: return 0 /* EcmaScript3 */; + case 1 /* ES5 */: return 1 /* EcmaScript5 */; + case 2 /* ES6 */: return 2 /* EcmaScript6 */; + default: throw Error("unsupported ScriptTarget value: " + scriptTarget); } } function moduleKindToModuleGenTarget(moduleKind) { if (typeof moduleKind === "undefined") return undefined; switch (moduleKind) { - case 2 /* AMD */: - return 2 /* Asynchronous */; - case 1 /* CommonJS */: - return 1 /* Synchronous */; - case 0 /* None */: - return 0 /* Unspecified */; - default: - throw Error("unsupported ModuleKind value: " + moduleKind); + case 2 /* AMD */: return 2 /* Asynchronous */; + case 1 /* CommonJS */: return 1 /* Synchronous */; + case 0 /* None */: return 0 /* Unspecified */; + default: throw Error("unsupported ModuleKind value: " + moduleKind); } } function compilationSettingsToCompilerOptions(settings) { diff --git a/doc/TypeScript Language Specification (Change Markup).docx b/doc/TypeScript Language Specification (Change Markup).docx index bb4be4fac1c..7846303e15b 100644 Binary files a/doc/TypeScript Language Specification (Change Markup).docx and b/doc/TypeScript Language Specification (Change Markup).docx differ diff --git a/doc/TypeScript Language Specification (Change Markup).pdf b/doc/TypeScript Language Specification (Change Markup).pdf index 0cffd20b7c7..ea7cede20f8 100644 Binary files a/doc/TypeScript Language Specification (Change Markup).pdf and b/doc/TypeScript Language Specification (Change Markup).pdf differ diff --git a/doc/TypeScript Language Specification.docx b/doc/TypeScript Language Specification.docx index 3d2014252f2..c7b95764525 100644 Binary files a/doc/TypeScript Language Specification.docx and b/doc/TypeScript Language Specification.docx differ diff --git a/doc/TypeScript Language Specification.pdf b/doc/TypeScript Language Specification.pdf index 203269c3f24..9a165b56df6 100644 Binary files a/doc/TypeScript Language Specification.pdf and b/doc/TypeScript Language Specification.pdf differ diff --git a/doc/spec.md b/doc/spec.md index 158c431c229..62d27e0a808 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -45,40 +45,42 @@ TypeScript is a trademark of Microsoft Corporation. * [3.3.1 Named Type References](#3.3.1) * [3.3.2 Array Types](#3.3.2) * [3.3.3 Tuple Types](#3.3.3) - * [3.3.4 Union Types](#3.3.4) - * [3.3.5 Function Types](#3.3.5) - * [3.3.6 Constructor Types](#3.3.6) - * [3.3.7 Members](#3.3.7) - * [3.4 Type Parameters](#3.4) - * [3.4.1 Type Parameter Lists](#3.4.1) - * [3.4.2 Type Argument Lists](#3.4.2) - * [3.5 Named Types](#3.5) - * [3.5.1 Instance Types](#3.5.1) - * [3.6 Specifying Types](#3.6) - * [3.6.1 Predefined Types](#3.6.1) - * [3.6.2 Type References](#3.6.2) - * [3.6.3 Object Type Literals](#3.6.3) - * [3.6.4 Array Type Literals](#3.6.4) - * [3.6.5 Tuple Type Literals](#3.6.5) - * [3.6.6 Union Type Literals](#3.6.6) - * [3.6.7 Function Type Literals](#3.6.7) - * [3.6.8 Constructor Type Literals](#3.6.8) - * [3.6.9 Type Queries](#3.6.9) - * [3.7 Specifying Members](#3.7) - * [3.7.1 Property Signatures](#3.7.1) - * [3.7.2 Call Signatures](#3.7.2) - * [3.7.3 Construct Signatures](#3.7.3) - * [3.7.4 Index Signatures](#3.7.4) - * [3.7.5 Method Signatures](#3.7.5) - * [3.8 Type Relationships](#3.8) - * [3.8.1 Apparent Type](#3.8.1) - * [3.8.2 Type and Member Identity](#3.8.2) - * [3.8.3 Subtypes and Supertypes](#3.8.3) - * [3.8.4 Assignment Compatibility](#3.8.4) - * [3.8.5 Contextual Signature Instantiation](#3.8.5) - * [3.8.6 Type Inference](#3.8.6) - * [3.8.7 Recursive Types](#3.8.7) - * [3.9 Widened Types](#3.9) + * [3.3.4 Function Types](#3.3.4) + * [3.3.5 Constructor Types](#3.3.5) + * [3.3.6 Members](#3.3.6) + * [3.4 Union Types](#3.4) + * [3.4.1 Contextual Union Types](#3.4.1) + * [3.5 Type Parameters](#3.5) + * [3.5.1 Type Parameter Lists](#3.5.1) + * [3.5.2 Type Argument Lists](#3.5.2) + * [3.6 Named Types](#3.6) + * [3.6.1 Instance Types](#3.6.1) + * [3.7 Specifying Types](#3.7) + * [3.7.1 Predefined Types](#3.7.1) + * [3.7.2 Type References](#3.7.2) + * [3.7.3 Object Type Literals](#3.7.3) + * [3.7.4 Array Type Literals](#3.7.4) + * [3.7.5 Tuple Type Literals](#3.7.5) + * [3.7.6 Union Type Literals](#3.7.6) + * [3.7.7 Function Type Literals](#3.7.7) + * [3.7.8 Constructor Type Literals](#3.7.8) + * [3.7.9 Type Queries](#3.7.9) + * [3.8 Specifying Members](#3.8) + * [3.8.1 Property Signatures](#3.8.1) + * [3.8.2 Call Signatures](#3.8.2) + * [3.8.3 Construct Signatures](#3.8.3) + * [3.8.4 Index Signatures](#3.8.4) + * [3.8.5 Method Signatures](#3.8.5) + * [3.9 Type Aliases](#3.9) + * [3.10 Type Relationships](#3.10) + * [3.10.1 Apparent Members](#3.10.1) + * [3.10.2 Type and Member Identity](#3.10.2) + * [3.10.3 Subtypes and Supertypes](#3.10.3) + * [3.10.4 Assignment Compatibility](#3.10.4) + * [3.10.5 Contextual Signature Instantiation](#3.10.5) + * [3.10.6 Type Inference](#3.10.6) + * [3.10.7 Recursive Types](#3.10.7) + * [3.11 Widened Types](#3.11) * [4 Expressions](#4) * [4.1 Values and References](#4.1) * [4.2 The this Keyword](#4.2) @@ -306,7 +308,7 @@ In this example, the second parameter to 'vote' has the function type which means the second parameter is a function returning type 'any' that has a single parameter of type 'string' named 'result'. -Section [3.7.2](#3.7.2) provides additional information about function types. +Section [3.8.2](#3.8.2) provides additional information about function types. ## 1.3 Object Types @@ -418,7 +420,7 @@ getX({ x: 0, y: 0, color: "red" }); // Extra fields Ok getX({ x: 0 }); // Error: supplied parameter does not match ``` -See section [3.8](#3.8) for more information about type comparisons. +See section [0](#0) for more information about type comparisons. ## 1.5 Contextual Typing @@ -614,7 +616,7 @@ In the following screen shot, a programming tool combines information from overl / -Section [3.7.2.4](#3.7.2.4) provides details on how to use string literals in function signatures. +Section [3.8.2.4](#3.8.2.4) provides details on how to use string literals in function signatures. ## 1.9 Generic Types and Functions @@ -678,7 +680,7 @@ class List { } ``` -Section [3.5](#3.5) provides further information about generic types. +Section [3.6](#3.6) provides further information about generic types. ## 1.10 Modules @@ -870,9 +872,9 @@ The ***scope*** of a name is the region of program text within which it is possi Scopes may overlap, for example through nesting of modules and functions. When the scopes of two entities with the same name overlap, the entity with the innermost declaration takes precedence and access to the outer entity is either not possible or only possible by qualifying its name. -When an identifier is resolved as a *TypeName* (section [3.6.2](#3.6.2)), only classes, interfaces, enums, and type parameters are considered and other entities in scope are ignored. +When an identifier is resolved as a *TypeName* (section [3.7.2](#3.7.2)), only classes, interfaces, enums, and type parameters are considered and other entities in scope are ignored. -When an identifier is resolved as a *ModuleName* (section [3.6.2](#3.6.2)), only modules are considered and other entities in scope are ignored. +When an identifier is resolved as a *ModuleName* (section [3.7.2](#3.7.2)), only modules are considered and other entities in scope are ignored. When an identifier is resolved as a *PrimaryExpression* (section [4.3](#4.3)), only instantiated modules (section [10.1](#10.1)), classes, enums, functions, variables, and parameters are considered and other entities in scope are ignored. @@ -901,11 +903,13 @@ module M { TypeScript adds optional static types to JavaScript. Types are used to place static constraints on program entities such as functions, variables, and properties so that compilers and development tools can offer better verification and assistance during software development. TypeScript's *static* compile-time type system closely models the *dynamic* run-time type system of JavaScript, allowing programmers to accurately express the type relationships that are expected to exist when their programs run and have those assumptions pre-validated by the TypeScript compiler. TypeScript's type analysis occurs entirely at compile-time and adds no run-time overhead to program execution. -All types in TypeScript are subtypes of a single top type called the Any type. The `any` keyword references this type. The Any type is the one type that can represent *any* JavaScript value with no constraints. All other types are categorized as ***primitive types***, ***object types***, or ***type parameters***. These types introduce various static constraints on their values. +All types in TypeScript are subtypes of a single top type called the Any type. The `any` keyword references this type. The Any type is the one type that can represent *any* JavaScript value with no constraints. All other types are categorized as ***primitive types***, ***object types***, ***union types***, or ***type parameters***. These types introduce various static constraints on their values. The primitive types are the Number, Boolean, String, Void, Null, and Undefined types along with user defined enum types. The `number`, `boolean`, `string`, and `void` keywords reference the Number, Boolean, String, and Void primitive types respectively. The Void type exists purely to indicate the absence of a value, such as in a function with no return value. It is not possible to explicitly reference the Null and Undefined types—only *values* of those types can be referenced, using the `null` and `undefined` literals. -The object types are all class, interface, array, and literal types. Class and interface types are introduced through class and interface declarations and are referenced by the name given to them in their declarations. Class and interface types may be ***generic types*** which have one or more type parameters. Literal types are written as object, array, function, or constructor type literals and are used to compose new types from other types. +The object types are all class, interface, array, tuple, function, and constructor types. Class and interface types are introduced through class and interface declarations and are referenced by the name given to them in their declarations. Class and interface types may be ***generic types*** which have one or more type parameters. + +Union types represent values that can have one of multiple types. Declarations of modules, classes, properties, functions, variables and other language entities associate types with those entities. The mechanism by which a type is formed and associated with a language entity depends on the particular kind of entity. For example, a module declaration associates the module with an anonymous type containing a set of properties corresponding to the exported variables and functions in the module, and a function declaration associates the function with an anonymous type containing a call signature corresponding to the parameters and return type of the function. Types can be associated with variables through explicit ***type annotations***, such as @@ -951,7 +955,7 @@ The Number primitive type corresponds to the similarly named JavaScript primitiv The `number` keyword references the Number primitive type and numeric literals may be used to write values of the Number primitive type. -For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the Number primitive type behaves as an object type with the same properties as the global interface type 'Number'. +For purposes of determining type relationships (section [0](#0)) and accessing properties (section [4.10](#4.10)), the Number primitive type behaves as an object type with the same properties as the global interface type 'Number'. Some examples: @@ -968,7 +972,7 @@ The Boolean primitive type corresponds to the similarly named JavaScript primiti The `boolean` keyword references the Boolean primitive type and the `true` and `false` literals reference the two Boolean truth values. -For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the Boolean primitive type behaves as an object type with the same properties as the global interface type 'Boolean'. +For purposes of determining type relationships (section [0](#0)) and accessing properties (section [4.10](#4.10)), the Boolean primitive type behaves as an object type with the same properties as the global interface type 'Boolean'. Some examples: @@ -984,7 +988,7 @@ The String primitive type corresponds to the similarly named JavaScript primitiv The `string` keyword references the String primitive type and string literals may be used to write values of the String primitive type. -For purposes of determining type relationships (section [3.8](#3.8)) and accessing properties (section [4.10](#4.10)), the String primitive type behaves as an object type with the same properties as the global interface type 'String'. +For purposes of determining type relationships (section [0](#0)) and accessing properties (section [4.10](#4.10)), the String primitive type behaves as an object type with the same properties as the global interface type 'String'. Some examples: @@ -1009,7 +1013,7 @@ The Null type corresponds to the similarly named JavaScript primitive type and i The `null` literal references the one and only value of the Null type. It is not possible to directly reference the Null type itself. -The Null type is a subtype of all types, except the Undefined type. This means that `null` is considered a valid value for all primitive types, object types, and type parameters, including even the Number and Boolean primitive types. +The Null type is a subtype of all types, except the Undefined type. This means that `null` is considered a valid value for all primitive types, object types, union types, and type parameters, including even the Number and Boolean primitive types. Some examples: @@ -1025,7 +1029,7 @@ The Undefined type corresponds to the similarly named JavaScript primitive type The `undefined` literal denotes the value given to all uninitialized variables and is the one and only value of the Undefined type. It is not possible to directly reference the Undefined type itself. -The undefined type is a subtype of all types. This means that `undefined` is considered a valid value for all primitive types, object types, and type parameters. +The undefined type is a subtype of all types. This means that `undefined` is considered a valid value for all primitive types, object types, union types, and type parameters. Some examples: @@ -1037,13 +1041,13 @@ var e: Undefined; // Error, can't reference Undefined type ### 3.2.7 Enum Types -Enum types are distinct user defined subtypes of the Number primitive type. Enum types are declared using enum declarations (section [9.1](#9.1)) and referenced using type references (section [3.6.2](#3.6.2)). +Enum types are distinct user defined subtypes of the Number primitive type. Enum types are declared using enum declarations (section [9.1](#9.1)) and referenced using type references (section [3.7.2](#3.7.2)). Enum types are assignable to the Number primitive type, and vice versa, but different enum types are not assignable to each other. ### 3.2.8 String Literal Types -Specialized signatures (section [3.7.2.4](#3.7.2.4)) permit string literals to be used as types in parameter type annotations. String literal types are permitted only in that context and nowhere else. +Specialized signatures (section [3.8.2.4](#3.8.2.4)) permit string literals to be used as types in parameter type annotations. String literal types are permitted only in that context and nowhere else. All string literal types are subtypes of the String primitive type. @@ -1053,12 +1057,11 @@ Object types are composed from properties, call signatures, construct signatures Class and interface type references, array types, tuple types, union types, function types, and constructor types are all classified as object types. Multiple constructs in the TypeScript language create object types, including: -* Object type literals (section [3.6.3](#3.6.3)). -* Array type literals (section [3.6.4](#3.6.4)). -* Tuple type literals (section [3.6.5](#3.6.5)). -* Union type literals (section [3.6.6](#3.6.6)). -* Function type literals (section [3.6.7](#3.6.7)). -* Constructor type literals (section [3.6.8](#3.6.8)). +* Object type literals (section [3.7.3](#3.7.3)). +* Array type literals (section [3.7.4](#3.7.4)). +* Tuple type literals (section [3.7.5](#3.7.5)). +* Function type literals (section [3.7.7](#3.7.7)). +* Constructor type literals (section [3.7.8](#3.7.8)). * Object literals (section [4.5](#4.5)). * Array literals (section [4.6](#4.6)). * Function expressions (section [4.9](#4.9)) and function declarations ([6.1](#6.1)). @@ -1067,11 +1070,11 @@ Class and interface type references, array types, tuple types, union types, func ### 3.3.1 Named Type References -Type references (section [3.6.2](#3.6.2)) to class and interface types are classified as object types. Type references to generic class and interface types include type arguments that are substituted for the type parameters of the class or interface to produce an actual object type. +Type references (section [3.7.2](#3.7.2)) to class and interface types are classified as object types. Type references to generic class and interface types include type arguments that are substituted for the type parameters of the class or interface to produce an actual object type. ### 3.3.2 Array Types -***Array types*** represent JavaScript arrays with a common element type. Array types are named type references created from the generic interface type 'Array' in the global module with the array element type as a type argument. Array type literals (section [3.6.4](#3.6.4)) provide a shorthand notation for creating such references. +***Array types*** represent JavaScript arrays with a common element type. Array types are named type references created from the generic interface type 'Array' in the global module with the array element type as a type argument. Array type literals (section [3.7.4](#3.7.4)) provide a shorthand notation for creating such references. The declaration of the 'Array' interface includes a property 'length' and a numeric index signature for the element type, along with other members: @@ -1091,7 +1094,7 @@ var a: string[] = ["hello", "world"]; ### 3.3.3 Tuple Types -***Tuple types*** represent JavaScript arrays with individually tracked element types. Tuple types are written using tuple type literals (section [3.6.5](#3.6.5)). A tuple type combines a set of numerically named properties with the members of an array type. Specifically, a tuple type +***Tuple types*** represent JavaScript arrays with individually tracked element types. Tuple types are written using tuple type literals (section [3.7.5](#3.7.5)). A tuple type combines a set of numerically named properties with the members of an array type. Specifically, a tuple type ```TypeScript [ T0, T1, ..., Tn ] @@ -1108,11 +1111,9 @@ combines the set of properties } ``` -with the members of an array type whose element type is the union type (section [3.3.4](#3.3.4)) of the tuple element types. +with the members of an array type whose element type is the union type (section [3.4](#3.4)) of the tuple element types. -Array literals (section [4.6](#4.6)) may be used to create values of tuple types. - -An example: +Array literals (section [4.6](#4.6)) may be used to create values of tuple types. For example: ```TypeScript var t: [number, string] = [3, "three"]; @@ -1122,9 +1123,41 @@ var i: number; var x = t[i]; // Type of x is number | string ``` -### 3.3.4 Union Types +Named tuple types can be created by declaring interfaces that derive from Array<T> and introduce numerically named properties. For example: -***Union types*** represent values that may have one of several disjoint representations. A value of a union type *A* | *B* is a value that is *either* of type *A* or type *B*. Union types are written using union type literals (section [3.6.6](#3.6.6)). +```TypeScript +interface KeyValuePair extends Array { 0: K; 1: V; } + +var x: KeyValuePair = [10, "ten"]; +``` + +### 3.3.4 Function Types + +An object type containing one or more call signatures is said to be a ***function type***. Function types may be written using function type literals (section [3.7.7](#3.7.7)) or by including call signatures in object type literals. + +### 3.3.5 Constructor Types + +An object type containing one or more construct signatures is said to be a ***constructor type***. Constructor types may be written using constructor type literals (section [3.7.8](#3.7.8)) or by including construct signatures in object type literals. + +### 3.3.6 Members + +Every object type is composed from zero or more of the following kinds of members: + +* ***Properties***, which define the names and types of the properties of objects of the given type. Property names are unique within their type. +* ***Call signatures***, which define the possible parameter lists and return types associated with applying call operations to objects of the given type. +* ***Construct signatures***, which define the possible parameter lists and return types associated with applying the `new` operator to objects of the given type. +* ***Index signatures***, which define type constraints for properties in the given type. An object type can have at most one string index signature and one numeric index signature. + +Properties are either ***public***, ***private***, or ***protected*** and are either ***required*** or ***optional***: + +* Properties in a class declaration may be designated public, private, or protected, while properties declared in other contexts are always considered public. Private members are only accessible within their declaring class, as described in section [8.2.2](#8.2.2), and private properties match only themselves in subtype and assignment compatibility checks, as described in section [0](#0). Protected members are only accessible within their declaring class and classes derived from it, as described in section [8.2.2](#8.2.2), and protected properties match only themselves and overrides in subtype and assignment compatibility checks, as described in section [0](#0). +* Properties in an object type literal or interface declaration may be designated required or optional, while properties declared in other contexts are always considered required. Properties that are optional in the target type of an assignment may be omitted from source objects, as described in section [3.10.4](#3.10.4). + +Call and construct signatures may be ***specialized*** (section [3.8.2.4](#3.8.2.4)) by including parameters with string literal types. Specialized signatures are used to express patterns where specific string values for some parameters cause the types of other parameters or the function result to become further specialized. + +## 3.4 Union Types + +***Union types*** represent values that may have one of several disjoint representations. A value of a union type *A* | *B* is a value that is *either* of type *A* or type *B*. Union types are written using union type literals (section [3.7.6](#3.7.6)). A union type encompasses an unordered set of unrelated types (that is, types that aren't subtypes of each other). The following rules govern union types: @@ -1144,22 +1177,6 @@ Similarly, union types have the following assignability relationships: * A union type *U* is assignable to a type *T* if each type in *U* is assignable to *T*. * A type *T* is assignable to a union type *U* if *T* is assignable to any type in *U*. -For purposes of property access (section [4.10](#4.10)) and function calls ([4.12](#4.12)), a union type *U* has those members that are present in every one of its constituent types, with types that are unions of the respective members in the constituent types. Specifically: - -* If each type in *U* has a property *P*, *U* has a property *P* of a union type of the types of *P* from each type in *U*. -* If each type in *U* has call signatures and the sets of call signatures are identical ignoring return types, *U* has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in *U*. -* If each type in *U* has construct signatures and the sets of construct signatures are identical ignoring return types, *U* has the same set of construct signatures, but with return types that are unions of the return types of the respective construct signatures from each type in *U*. -* If each type in *U* has a string index signature, *U* has a string index signature of a union type of the types of the string index signatures from each type in *U*. -* If each type in *U* has a numeric index signature, *U* has a numeric index signature of a union type of the types of the numeric index signatures from each type in *U*. - -When used as a contextual type (section [4.19](#4.19)), a union type *U* has those members that are present in any of its constituent types, with types that are unions of the respective members in the constituent types. Specifically: - -* Let *S* be the set of types in *U* that has a property *P*. If *S* is not empty, *U* has a property *P* of a union type of the types of *P* from each type in *S*. -* Let *S* be the set of types in *U* that have call signatures. If *S* is not empty and the sets of call signatures of the types in *S* are identical ignoring return types, *U* has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in *S*. -* Let *S* be the set of types in *U* that have construct signatures. If *S* is not empty and the sets of construct signatures of the types in *S* are identical ignoring return types, *U* has the same set of construct signatures, but with return types that are unions of the return types of the respective construct signatures from each type in *S*. -* Let *S* be the set of types in *U* that has a string index signature. If *S* is not empty, *U* has a string index signature of a union type of the types of the string index signatures from each type in *S*. -* Let *S* be the set of types in *U* that has a numeric index signature. If *S* is not empty, *U* has a numeric index signature of a union type of the types of the numeric index signatures from each type in *S*. - The || and conditional operators (section [4.15.7](#4.15.7) and [4.16](#4.16)) may produce values of union types, and array literals (section [4.6](#4.6)) may produce array values that have union types as their element types. Type guards (section [4.20](#4.20)) may be used to narrow a union type to a more specific type. In particular, type guards are useful for narrowing union type values to a non-union type values. @@ -1182,7 +1199,7 @@ it is possible to assign 'x' a value of type string, number, or the union type s var n = typeof x === "string" ? x.length : x; // Type of n is number ``` -The following example illustrates the merging of member types that occurs when union types are created from object types. +For purposes of property access and function calls, the apparent members (section [3.10.1](#3.10.1)) of a union type *U* are those that are present in every one of its constituent types, with types that are unions of the respective apparent members in the constituent types. The following example illustrates the merging of member types that occurs when union types are created from object types. ```TypeScript interface A { @@ -1204,37 +1221,23 @@ var c = x.c; // Error, no property c in union type Note that 'x.a' has a union type because the type of 'a' is different in 'A' and 'B', whereas 'x.b' simply has type number because that is the type of 'b' in both 'A' and 'B'. Also note that there is no property 'x.c' because only 'A' has a property 'c'. -### 3.3.5 Function Types +### 3.4.1 Contextual Union Types -An object type containing one or more call signatures is said to be a ***function type***. Function types may be written using function type literals (section [3.6.7](#3.6.7)) or by including call signatures in object type literals. +When used as a contextual type (section [4.19](#4.19)), a union type *U* has those members that are present in any of its constituent types, with types that are unions of the respective members in the constituent types. Specifically: -### 3.3.6 Constructor Types +* Let *S* be the set of types in *U* that has a property *P*. If *S* is not empty, *U* has a property *P* of a union type of the types of *P* from each type in *S*. +* Let *S* be the set of types in *U* that have call signatures. If *S* is not empty and the sets of call signatures of the types in *S* are identical ignoring return types, *U* has the same set of call signatures, but with return types that are unions of the return types of the respective call signatures from each type in *S*. +* Let *S* be the set of types in *U* that have construct signatures. If *S* is not empty and the sets of construct signatures of the types in *S* are identical ignoring return types, *U* has the same set of construct signatures, but with return types that are unions of the return types of the respective construct signatures from each type in *S*. +* Let *S* be the set of types in *U* that has a string index signature. If *S* is not empty, *U* has a string index signature of a union type of the types of the string index signatures from each type in *S*. +* Let *S* be the set of types in *U* that has a numeric index signature. If *S* is not empty, *U* has a numeric index signature of a union type of the types of the numeric index signatures from each type in *S*. -An object type containing one or more construct signatures is said to be a ***constructor type***. Constructor types may be written using constructor type literals (section [3.6.8](#3.6.8)) or by including construct signatures in object type literals. - -### 3.3.7 Members - -Every object type is composed from zero or more of the following kinds of members: - -* ***Properties***, which define the names and types of the properties of objects of the given type. Property names are unique within their type. -* ***Call signatures***, which define the possible parameter lists and return types associated with applying call operations to objects of the given type. -* ***Construct signatures***, which define the possible parameter lists and return types associated with applying the `new` operator to objects of the given type. -* ***Index signatures***, which define type constraints for properties in the given type. An object type can have at most one string index signature and one numeric index signature. - -Properties are either ***public***, ***private***, or ***protected*** and are either ***required*** or ***optional***: - -* Properties in a class declaration may be designated public, private, or protected, while properties declared in other contexts are always considered public. Private members are only accessible within their declaring class, as described in section [8.2.2](#8.2.2), and private properties match only themselves in subtype and assignment compatibility checks, as described in section [3.8](#3.8). Protected members are only accessible within their declaring class and classes derived from it, as described in section [8.2.2](#8.2.2), and protected properties match only themselves and overrides in subtype and assignment compatibility checks, as described in section [3.8](#3.8). -* Properties in an object type literal or interface declaration may be designated required or optional, while properties declared in other contexts are always considered required. Properties that are optional in the target type of an assignment may be omitted from source objects, as described in section [3.8.4](#3.8.4). - -Call and construct signatures may be ***specialized*** (section [3.7.2.4](#3.7.2.4)) by including parameters with string literal types. Specialized signatures are used to express patterns where specific string values for some parameters cause the types of other parameters or the function result to become further specialized. - -## 3.4 Type Parameters +## 3.5 Type Parameters A type parameter represents an actual type that the parameter is bound to in a generic type reference or a generic function call. Type parameters have constraints that establish upper bounds for their actual type arguments. Since a type parameter represents a multitude of different type arguments, type parameters have certain restrictions compared to other types. In particular, a type parameter cannot be used as a base class or interface. -### 3.4.1 Type Parameter Lists +### 3.5.1 Type Parameter Lists Class, interface, and function declarations may optionally include lists of type parameters enclosed in < and > brackets. Type parameters are also permitted in call signatures of object, function, and constructor type literals. @@ -1273,11 +1276,11 @@ interface G { the base constraint of 'T' is the empty object type, and the base constraint of 'U' and 'V' is 'Function'. -For purposes of determining type relationships (section [3.8](#3.8)), type parameters appear to be subtypes of their base constraint. Likewise, in property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)), type parameters appear to have the members of their base constraint, but no other members. +For purposes of determining type relationships (section [0](#0)), type parameters appear to be subtypes of their base constraint. Likewise, in property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)), type parameters appear to have the members of their base constraint, but no other members. -### 3.4.2 Type Argument Lists +### 3.5.2 Type Argument Lists -A type reference (section [3.6.2](#3.6.2)) to a generic type must include a list of type arguments enclosed in angle brackets and separated by commas. Similarly, a call (section [4.12](#4.12)) to a generic function may explicitly include a type argument list instead of relying on type inference. +A type reference (section [3.7.2](#3.7.2)) to a generic type must include a list of type arguments enclosed in angle brackets and separated by commas. Similarly, a call (section [4.12](#4.12)) to a generic function may explicitly include a type argument list instead of relying on type inference.   *TypeArguments:*    `<` *TypeArgumentList* `>` @@ -1289,7 +1292,7 @@ A type reference (section [3.6.2](#3.6.2)) to a generic type must include a list   *TypeArgument:*    *Type* -Type arguments correspond one-to-one with type parameters of the generic type or function being referenced. A type argument list is required to specify exactly one type argument for each corresponding type parameter, and each type argument is required to ***satisfy*** the constraint of its corresponding type parameter. A type argument satisfies a type parameter constraint if the type argument is assignable to (section [3.8.4](#3.8.4)) the constraint type once type arguments are substituted for type parameters. +Type arguments correspond one-to-one with type parameters of the generic type or function being referenced. A type argument list is required to specify exactly one type argument for each corresponding type parameter, and each type argument is required to ***satisfy*** the constraint of its corresponding type parameter. A type argument satisfies a type parameter constraint if the type argument is assignable to (section [3.10.4](#3.10.4)) the constraint type once type arguments are substituted for type parameters. Given the declaration @@ -1301,13 +1304,13 @@ a type reference of the form 'G<A, B>' places no requirements on 'A' but requ The process of substituting type arguments for type parameters in a generic type or generic signature is known as ***instantiating*** the generic type or signature. Instantiation of a generic type or signature can fail if the supplied type arguments do not satisfy the constraints of their corresponding type parameters. -## 3.5 Named Types +## 3.6 Named Types -Class, interface, and enum types are ***named types*** that are introduced through class declarations (section [8.1](#8.1)), interface declarations (section [7.1](#7.1)), and enum declarations ([9.1](#9.1)). Class and interface types may have type parameters and are then called ***generic types***. Conversely, named types without type parameters are called ***non-generic types***. +Classes, interfaces, enums, and type aliases are ***named types*** that are introduced through class declarations (section [8.1](#8.1)), interface declarations (section [7.1](#7.1)), enum declarations ([9.1](#9.1)), and type alias declarations (section [3.9](#3.9)). Class and interface types may have type parameters and are then called ***generic types***. Conversely, named types without type parameters are called ***non-generic types***. Interface declarations only introduce named types, whereas class declarations introduce named types *and* constructor functions that create instances of implementations of those named types. The named types introduced by class and interface declarations have only minor differences (classes can't declare optional members and interfaces can't declare private or protected members) and are in most contexts interchangeable. In particular, class declarations with only public members introduce named types that function exactly like those created by interface declarations. -Named types are referenced through ***type references*** (section [3.6.2](#3.6.2)) that specify a type name and, if applicable, the type arguments to be substituted for the type parameters of the named type. +Named types are referenced through ***type references*** (section [3.7.2](#3.7.2)) that specify a type name and, if applicable, the type arguments to be substituted for the type parameters of the named type. Named types are technically not types—only *references* to named types are. This distinction is particularly evident with generic types: Generic types are "templates" from which multiple *actual* types can be created by writing type references that supply type arguments to substitute in place of the generic type's type parameters. This substitution process is known as ***instantiating*** a generic type. Only once a generic type is instantiated does it denote an actual type. @@ -1329,9 +1332,9 @@ is indistinguishable from the type { first: string; second: Entity; } ``` -### 3.5.1 Instance Types +### 3.6.1 Instance Types -Each named type has an associated actual type known as the ***instance type***. For a non-generic type, the instance type is simply a type reference to the non-generic type. For a generic type, the instance type is an instantiation of the generic type where each of the type arguments is the corresponding type parameter. Since the instance type uses the type parameters it can be used only where the type parameters are in scope—that is, inside the declaration of the generic type. Within the constructor and instance member functions of a class, the type of `this` is the instance type of the class. +Each class and interface has an associated actual type known as the ***instance type***. For a non-generic class or interface, the instance type is simply a type reference to the class or interface. For a generic class or interface, the instance type is an instantiation of the generic type where each of the type arguments is the corresponding type parameter. Since the instance type uses the type parameters it can be used only where the type parameters are in scope—that is, inside the declaration of the class or interface. Within the constructor and instance member functions of a class, the type of `this` is the instance type of the class. The following example illustrates the concept of an instance type: @@ -1344,7 +1347,7 @@ class G { // Introduce type parameter T } ``` -## 3.6 Specifying Types +## 3.7 Specifying Types Types are specified either by referencing their keyword or name, or by writing object type literals, array type literals, tuple type literals, function type literals, constructor type literals, or type queries. @@ -1378,7 +1381,7 @@ Parentheses are required around union, function, or constructor types when they The different forms of type notations are described in the following sections. -### 3.6.1 Predefined Types +### 3.7.1 Predefined Types The `any`, `number`, `boolean`, `string`, and `void` keywords reference the Any type and the Number, Boolean, String, and Void primitive types respectively. @@ -1391,7 +1394,7 @@ The `any`, `number`, `boolean`, `string`, and `void` keywords reference the Any The predefined type keywords are reserved and cannot be used as names of user defined types. -### 3.6.2 Type References +### 3.7.2 Type References A type reference references a named type or type parameter through its name and, in the case of a generic type, supplies a type argument list. @@ -1406,7 +1409,7 @@ A type reference references a named type or type parameter through its name and,    *Identifier*    *ModuleName* `.` *Identifier* -A *TypeReference* consists of a *TypeName* that a references a named type or type parameter. A reference to a generic type must be followed by a list of *TypeArguments* (section [3.4.2](#3.4.2)). +A *TypeReference* consists of a *TypeName* that a references a named type or type parameter. A reference to a generic type must be followed by a list of *TypeArguments* (section [3.5.2](#3.5.2)). Resolution of a *TypeName* consisting of a single identifier is described in section [2.4](#2.4). @@ -1416,7 +1419,7 @@ Resolution of a *ModuleName* consisting of a single identifier is described in s Resolution of a *ModuleName* of the form *M.N*, where *M* is a *ModuleName* and *N* is an *Identifier*, proceeds by first resolving the module name *M*. If the resolution of *M* is successful and the resulting module contains an exported module member *N*, then *M.N* refers to that member. Otherwise, *M.N* is undefined. -A type reference to a generic type is required to specify exactly one type argument for each type parameter of the referenced generic type, and each type argument must be assignable to (section [3.8.4](#3.8.4)) the constraint of the corresponding type parameter or otherwise an error occurs. An example: +A type reference to a generic type is required to specify exactly one type argument for each type parameter of the referenced generic type, and each type argument must be assignable to (section [3.10.4](#3.10.4)) the constraint of the corresponding type parameter or otherwise an error occurs. An example: ```TypeScript interface A { a: string; } @@ -1441,7 +1444,7 @@ var v7: G; // Error, no arguments A type argument is simply a *Type* and may itself be a type reference to a generic type, as demonstrated by 'v4' in the example above. -As described in section [3.5](#3.5), a type reference to a generic type *G* designates a type wherein all occurrences of *G*'s type parameters have been replaced with the actual type arguments supplied in the type reference. For example, the declaration of 'v1' above is equivalent to: +As described in section [3.6](#3.6), a type reference to a generic type *G* designates a type wherein all occurrences of *G*'s type parameters have been replaced with the actual type arguments supplied in the type reference. For example, the declaration of 'v1' above is equivalent to: ```TypeScript var v1: { @@ -1450,7 +1453,7 @@ var v1: { }; ``` -### 3.6.3 Object Type Literals +### 3.7.3 Object Type Literals An object type literal defines an object type by specifying the set of members that are statically considered to be present in instances of the type. Object type literals can be given names using interface declarations but are otherwise anonymous. @@ -1471,9 +1474,9 @@ An object type literal defines an object type by specifying the set of members t    *IndexSignature*    *MethodSignature* -The members of an object type literal are specified as a combination of property, call, construct, index, and method signatures. Object type members are described in section [3.7](#3.7). +The members of an object type literal are specified as a combination of property, call, construct, index, and method signatures. Object type members are described in section [3.8](#3.8). -### 3.6.4 Array Type Literals +### 3.7.4 Array Type Literals An array type literal is written as an element type followed by an open and close square bracket. @@ -1496,7 +1499,7 @@ Array Array<() => string> ``` -### 3.6.5 Tuple Type Literals +### 3.7.5 Tuple Type Literals A tuple type literal is written as a sequence of element types, separated by commas and enclosed in square brackets. @@ -1512,14 +1515,14 @@ A tuple type literal is written as a sequence of element types, separated by com A tuple type literal references a tuple type (section [3.3.3](#3.3.3)). -### 3.6.6 Union Type Literals +### 3.7.6 Union Type Literals A union type literal is written as a sequence of types separated by vertical bars.   *UnionType:*    *PrimaryOrUnionType* `|` *PrimaryType* -A union typle literal references a union type (section [3.3.4](#3.3.4)). +A union typle literal references a union type (section [3.4](#3.4)). When function or constructor types are included in union types they must be enclosed in parentheses. For example: @@ -1533,7 +1536,7 @@ Alternatively, function or constructor types in union types can be written using { (x: string): string } | { (x: number): number } ``` -### 3.6.7 Function Type Literals +### 3.7.7 Function Type Literals A function type literal specifies the type parameters, regular parameters, and return type of a call signature. @@ -1554,7 +1557,7 @@ is exactly equivalent to the object type literal Note that function types with multiple call or construct signatures cannot be written as function type literals but must instead be written as object type literals. -### 3.6.8 Constructor Type Literals +### 3.7.8 Constructor Type Literals A constructor type literal specifies the type parameters, regular parameters, and return type of a construct signature. @@ -1575,7 +1578,7 @@ is exactly equivalent to the object type literal Note that constructor types with multiple construct signatures cannot be written as constructor type literals but must instead be written as object type literals. -### 3.6.9 Type Queries +### 3.7.9 Type Queries A type query obtains the type of an expression. @@ -1586,7 +1589,7 @@ A type query obtains the type of an expression.    *Identifier*    *TypeQueryExpression* `.` *IdentifierName* -A type query consists of the keyword `typeof` followed by an expression. The expression is restricted to a single identifier or a sequence of identifiers separated by periods. The expression is processed as an identifier expression (section [4.3](#4.3)) or property access expression (section [4.10](#4.10)), the widened type (section [3.9](#3.9)) of which becomes the result. Similar to other static typing constructs, type queries are erased from the generated JavaScript code and add no run-time overhead. +A type query consists of the keyword `typeof` followed by an expression. The expression is restricted to a single identifier or a sequence of identifiers separated by periods. The expression is processed as an identifier expression (section [4.3](#4.3)) or property access expression (section [4.10](#4.10)), the widened type (section [3.11](#3.11)) of which becomes the result. Similar to other static typing constructs, type queries are erased from the generated JavaScript code and add no run-time overhead. Type queries are useful for capturing anonymous types that are generated by various constructs such as object literals, function declarations, and module declarations. For example: @@ -1615,11 +1618,11 @@ var h: () => typeof h; Here, 'g' and 'g.x' have the same recursive type, and likewise 'h' and 'h()' have the same recursive type. -## 3.7 Specifying Members +## 3.8 Specifying Members -The members of an object type literal (section [3.6.3](#3.6.3)) are specified as a combination of property, call, construct, index, and method signatures. +The members of an object type literal (section [3.7.3](#3.7.3)) are specified as a combination of property, call, construct, index, and method signatures. -### 3.7.1 Property Signatures +### 3.8.1 Property Signatures A property signature declares the name and type of a property member. @@ -1637,26 +1640,26 @@ The *PropertyName* of a property signature must be unique within its containing If a property signature omits a *TypeAnnotation*, the Any type is assumed. -### 3.7.2 Call Signatures +### 3.8.2 Call Signatures A call signature defines the type parameters, parameter list, and return type associated with applying a call operation (section [4.12](#4.12)) to an instance of the containing type. A type may ***overload*** call operations by defining multiple different call signatures.   *CallSignature:*    *TypeParametersopt* `(` *ParameterListopt* `)` *TypeAnnotationopt* -A call signature that includes *TypeParameters* (section [3.4.1](#3.4.1)) is called a ***generic call signature***. Conversely, a call signature with no *TypeParameters* is called a non-generic call signature. +A call signature that includes *TypeParameters* (section [3.5.1](#3.5.1)) is called a ***generic call signature***. Conversely, a call signature with no *TypeParameters* is called a non-generic call signature. -As well as being members of object type literals, call signatures occur in method signatures (section [3.7.5](#3.7.5)), function expressions (section [4.9](#4.9)), and function declarations (section [6.1](#6.1)). +As well as being members of object type literals, call signatures occur in method signatures (section [3.8.5](#3.8.5)), function expressions (section [4.9](#4.9)), and function declarations (section [6.1](#6.1)). An object type containing call signatures is said to be a ***function type***. -#### 3.7.2.1 Type Parameters +#### 3.8.2.1 Type Parameters -Type parameters (section [3.4.1](#3.4.1)) in call signatures provide a mechanism for expressing the relationships of parameter and return types in call operations. For example, a signature might introduce a type parameter and use it as both a parameter type and a return type, in effect describing a function that returns a value of the same type as its argument. +Type parameters (section [3.5.1](#3.5.1)) in call signatures provide a mechanism for expressing the relationships of parameter and return types in call operations. For example, a signature might introduce a type parameter and use it as both a parameter type and a return type, in effect describing a function that returns a value of the same type as its argument. Type parameters may be referenced in parameter types and return type annotations, but not in type parameter constraints, of the call signature in which they are introduced. -Type arguments (section [3.4.2](#3.4.2)) for call signature type parameters may be explicitly specified in a call operation or may, when possible, be inferred (section [4.12.2](#4.12.2)) from the types of the regular arguments in the call. An ***instantiation*** of a generic call signature for a particular set of type arguments is the call signature formed by replacing each type parameter with its corresponding type argument. +Type arguments (section [3.5.2](#3.5.2)) for call signature type parameters may be explicitly specified in a call operation or may, when possible, be inferred (section [4.12.2](#4.12.2)) from the types of the regular arguments in the call. An ***instantiation*** of a generic call signature for a particular set of type arguments is the call signature formed by replacing each type parameter with its corresponding type argument. Some examples of call signatures with type parameters follow below. @@ -1684,7 +1687,7 @@ A function taking an array of one type and a function argument, returning an arr (a: T[], f: (x: T) => U): U[] ``` -#### 3.7.2.2 Parameter List +#### 3.8.2.2 Parameter List A signature's parameter list consists of zero or more required parameters, followed by zero or more optional parameters, finally followed by an optional rest parameter. @@ -1730,11 +1733,11 @@ A parameter with a type annotation is considered to be of that type. A type anno A parameter with no type annotation or initializer is considered to be of type `any`, unless it is a rest parameter, in which case it is considered to be of type `any[]`. -When a parameter type annotation specifies a string literal type, the containing signature is a specialized signature (section [3.7.2.4](#3.7.2.4)). Specialized signatures are not permitted in conjunction with a function body, i.e. the *FunctionExpression*, *FunctionImplementation*, *MemberFunctionImplementation*, and *ConstructorImplementation* grammar productions do not permit parameters with string literal types. +When a parameter type annotation specifies a string literal type, the containing signature is a specialized signature (section [3.8.2.4](#3.8.2.4)). Specialized signatures are not permitted in conjunction with a function body, i.e. the *FunctionExpression*, *FunctionImplementation*, *MemberFunctionImplementation*, and *ConstructorImplementation* grammar productions do not permit parameters with string literal types. A parameter can be marked optional by following its name with a question mark (`?`) or by including an initializer. The form that includes an initializer is permitted only in conjunction with a function body, i.e. only in a *FunctionExpression*, *FunctionImplementation*, *MemberFunctionImplementation*, or *ConstructorImplementation* grammar production. -#### 3.7.2.3 Return Type +#### 3.8.2.3 Return Type If present, a call signature's return type annotation specifies the type of the value computed and returned by a call operation. A `void` return type annotation is used to indicate that a function has no return value. @@ -1742,7 +1745,7 @@ When a call signature with no return type annotation occurs in a context without When a call signature with no return type annotation occurs in a context that has a function body (specifically, a function implementation, a member function implementation, or a member accessor declaration), the return type is inferred from the function body as described in section [6.3](#6.3). -#### 3.7.2.4 Specialized Signatures +#### 3.8.2.4 Specialized Signatures When a parameter type annotation specifies a string literal type (section [3.2.8](#3.2.8)), the containing signature is considered a specialized signature. Specialized signatures are used to express patterns where specific string values for some parameters cause the types of other parameters or the function result to become further specialized. For example, the declaration @@ -1761,7 +1764,7 @@ When writing overloaded declarations such as the one above it is important to li Every specialized call or construct signature in an object type must be assignable to at least one non-specialized call or construct signature in the same object type (where a call signature *A* is considered assignable to another call signature *B* if an object type containing only *A* would be assignable to an object type containing only *B*). For example, the 'createElement' property in the example above is of a type that contains three specialized signatures, all of which are assignable to the non-specialized signature in the type. -### 3.7.3 Construct Signatures +### 3.8.3 Construct Signatures A construct signature defines the parameter list and return type associated with applying the `new` operator (section [4.11](#4.11)) to an instance of the containing type. A type may overload `new` operations by defining multiple construct signatures with different parameter lists. @@ -1772,7 +1775,7 @@ The type parameters, parameter list, and return type of a construct signature ar A type containing construct signatures is said to be a ***constructor type***. -### 3.7.4 Index Signatures +### 3.8.4 Index Signatures An index signature defines a type constraint for properties in the containing type. @@ -1791,7 +1794,7 @@ An object type can contain at most one string index signature and one numeric in Index signatures affect the determination of the type that results from applying a bracket notation property access to an instance of the containing type, as described in section [4.10](#4.10). -### 3.7.5 Method Signatures +### 3.8.5 Method Signatures A method signature is shorthand for declaring a property of a function type. @@ -1855,27 +1858,92 @@ the properties 'func1', 'func2', and 'func3' are all of the same type, namely an the properties 'func4' and 'func5' are of the same type, namely an object type with two call signatures taking and returning number and string respectively. -## 3.8 Type Relationships +## 3.9 Type Aliases + +A type alias declaration introduces a ***type alias*** in the containing module. + +  *TypeAliasDeclaration:* +   `type` *Identifier* `=` *Type* `;` + +A type alias serves as an alias for the type specified in the type alias declaration. Unlike an interface declaration, which always introduces a named object type, a type alias declaration can introduce a name for any kind of type, including primitive types and union types. + +Type aliases are referenced using type references ([3.7.2](#3.7.2)). Writing a reference to a type alias has ***exactly*** the same effect as writing the aliased type itself. + +The *Identifier* of a type alias declaration may not be one of the predefined type names (section [3.7.1](#3.7.1)). + +It is an error for the type specified in a type alias to depend on that type alias. Types have the following dependencies: + +* A type alias *directly depends on* the type it aliases. +* A type reference *directly depends on* the referenced type and each of the type arguments, if any. +* A union type *directly depends on* each of the constituent types. +* An array type *directly depends on* its element type. +* A tuple type *directly depends on* each of its element types. +* A type query *directly depends on* the type of the referenced entity. + +Given this definition, the complete set of types upon which a type depends is the transitive closure of the *directly depends on* relationship. Note that object type literals, function type literals, and constructor type literals do not depend on types referenced within them and are therefore permitted to circularly reference themselves through type aliases. + +Some examples of type alias declarations: + +```TypeScript +type StringOrNumber = string | number; +type Text = string | { text: string }; +type Coordinates = [number, number]; +type NameLookup = Dictionary; +type Callback = (data: string) => void; +type RecFunc = () => RecFunc; +type ObjectStatics = typeof Object; +``` + +Interface types have many similarities to type aliases for object type literals, but since interface types offer more capabilities they are generally preferred to type aliases. For example, the interface type + +```TypeScript +interface Point { + x: number; + y: number; +} +``` + +could be written as the type alias + +```TypeScript +type Point = { + x: number; + y: number; +}; +``` + +However, doing so means the following capabilities are lost: + +* An interface can be named in an extends or implements clause, but a type alias for an object type literal cannot. +* An interface can have multiple merged declarations, but a type alias for an object type literal cannot. +* An interface can have type parameters, but a type alias for an object type literal cannot. +* An interface is referenced by its name in error messages and tooling, but a type alias is always expanded to its structural representation. + +## 3.10 Type Relationships Types in TypeScript have identity, subtype, supertype, and assignment compatibility relationships as defined in the following sections. -For purposes of determining type relationships, all object types appear to have the members of the 'Object' interface unless those members are hidden by members with the same name in the object types, and object types with one or more call or construct signatures appear to have the members of the 'Function' interface unless those members are hidden by members with the same name in the object types. Apparent types (section [3.8.1](#3.8.1)) that are object types appear to have these extra members as well. +### 3.10.1 Apparent Members -### 3.8.1 Apparent Type +The ***apparent members*** of a type are the members observed in subtype, supertype, and assignment compatibility relationships, as well as in the type checking of property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)). The apparent members of a type are determined as follows: -In certain contexts a type appears to have the characteristics of a related type called the type's ***apparent type***. Specifically, a type's apparent type is used when determining subtype, supertype, and assignment compatibility relationships, as well as in the type checking of property accesses (section [4.10](#4.10)), `new` operations (section [4.11](#4.11)), and function calls (section [4.12](#4.12)). +* The apparent members of the primitive types Number, Boolean, and String are the apparent members of the global interface types 'Number', 'Boolean', and 'String' respectively. +* The apparent members of an enum type are the apparent members of the global interface type 'Number'. +* The apparent members of a type parameter are the apparent members of the base constraint (section [3.5.1](#3.5.1)) of that type parameter. +* The apparent members of an object type *T* are the combination of the following: + * The declared and/or inherited members of *T*. + * The properties of the global interface type 'Object' that aren't hidden by properties with the same name in *T*. + * If *T* has one or more call or construct signatures, the properties of the global interface type 'Function' that aren't hidden by properties with the same name in *T*. +* The apparent members of a union type *U* are determined as follows: + * If each type in *U* has an apparent property *P*, *U* has an apparent property *P* of a union type of the types of *P* from each type in *U*. + * If each type in *U* has apparent call signatures and the sets of apparent call signatures are identical ignoring return types, *U* has the same set of call signatures, but with return types that are unions of the return types of the respective apparent call signatures from each type in *U*. + * If each type in *U* has apparent construct signatures and the sets of apparent construct signatures are identical ignoring return types, *U* has the same set of construct signatures, but with return types that are unions of the return types of the respective apparent construct signatures from each type in *U*. + * If each type in *U* has an apparent string index signature, *U* has a string index signature of a union type of the types of the apparent string index signatures from each type in *U*. + * If each type in *U* has an apparent numeric index signature, *U* has a numeric index signature of a union type of the types of the apparent numeric index signatures from each type in *U*. -The apparent type of a type *T* is defined as follows: +If a type is not one of the above, it is considered to have no apparent members. -* If *T* is the primitive type Number, Boolean, or String, the apparent type of *T* is the augmented form (as defined below) of the global interface type 'Number', 'Boolean', or 'String'. -* if *T* is an enum type, the apparent type of *T* is the augmented form of the global interface type 'Number'. -* If *T* is an object type, the apparent type of *T* is the augmented form of *T*. -* If *T* is a type parameter, the apparent type of *T* is the apparent type of *T*'s base constraint (section [3.4.1](#3.4.1)). -* Otherwise, the apparent type of *T* is *T* itself. - -The augmented form of an object type *T* adds to *T* those properties of the global interface type 'Object' that aren't hidden by properties in *T*. Furthermore, if *T* has one or more call or construct signatures, the augmented form of *T* adds to *T* the properties of the global interface type 'Function' that aren't hidden by properties in *T*. Properties in *T* hide 'Object' or 'Function' interface properties with the same name. - -In effect, a type's apparent type is a subtype of the 'Object' or 'Function' interface unless the type defines members that are incompatible with those of the 'Object' or 'Function' interface—which, for example, occurs if the type defines a property with the same name as a property in the 'Object' or 'Function' interface but with a type that isn't a subtype of that in the 'Object' or 'Function' interface. +In effect, a type's apparent members make it a subtype of the 'Object' or 'Function' interface unless the type defines members that are incompatible with those of the 'Object' or 'Function' interface—which, for example, occurs if the type defines a property with the same name as a property in the 'Object' or 'Function' interface but with a type that isn't a subtype of that in the 'Object' or 'Function' interface. Some examples: @@ -1885,9 +1953,9 @@ var f: Function = (x: number) => x * x; // Ok var err: Object = { toString: 0 }; // Error ``` -The last assignment is an error because the apparent type of the object literal has a 'toString' method that isn't compatible with that of 'Object'. +The last assignment is an error because the object literal has a 'toString' method that isn't compatible with that of 'Object'. -### 3.8.2 Type and Member Identity +### 3.10.2 Type and Member Identity Two types are considered ***identical*** when @@ -1895,7 +1963,7 @@ Two types are considered ***identical*** when * they are the same primitive type, * they are the same type parameter, * they are union types with identical sets of constituent types, or -* they are non-union object types with identical sets of members. +* they are object types with identical sets of members. Two members are considered identical when @@ -1924,9 +1992,9 @@ var b: C; the variables 'a' and 'b' are of identical types because the two type references to 'C' create types with a private member 'x' that originates in the same declaration, and because the two private 'x' members have types with identical sets of members once the type arguments 'X' and 'Y' are substituted. -### 3.8.3 Subtypes and Supertypes +### 3.10.3 Subtypes and Supertypes -*S* is a ***subtype*** of a type *T*, and *T* is a ***supertype*** of *S*, if one of the following is true, where *S*' denotes the apparent type (section [3.8.1](#3.8.1)) of *S*: +*S* is a ***subtype*** of a type *T*, and *T* is a ***supertype*** of *S*, if one of the following is true: * *S* and *T* are identical types. * *T* is the Any type. @@ -1937,32 +2005,31 @@ the variables 'a' and 'b' are of identical types because the two type references * *S* and *T* are type parameters, and *S* is directly or indirectly constrained to *T*. * *S* is a union type and each constituent type of *S* is a subtype of *T*. * *T* is a union type and *S* is a subtype of at least one constituent type of *T*. -* *S'* and *T* are object types and, for each member *M* in *T*, one of the following is true: - * *M* is a property and *S'* contains a property *N* where +* *S* is an object type, a type parameter, or the Number, Boolean, or String primitive type, *T* is an object type, and for each member *M* in *T*, one of the following is true: + * *M* is a property and *S* has an apparent property *N* where * *M* and *N* have the same name, * the type of *N* is a subtype of that of *M*, * if *M* is a required property, *N* is also a required property, and * *M* and *N* are both public, *M* and *N* are both private and originate in the same declaration, *M* and *N* are both protected and originate in the same declaration, or *M* is protected and *N* is declared in a class derived from the class in which *M* is declared. - * *M* is an optional property and *S'* contains no property of the same name as *M*. - * *M* is a non-specialized call or construct signature and *S*' contains a call or construct signature *N* where, when *M* and *N* are instantiated using type Any as the type argument for all type parameters declared by *M* and *N* (if any), + * *M* is a non-specialized call or construct signature and *S* has an apparent call or construct signature *N* where, when *M* and *N* are instantiated using type Any as the type argument for all type parameters declared by *M* and *N* (if any), * the signatures are of the same kind (call or construct), * *M* has a rest parameter or the number of non-optional parameters in *N* is less than or equal to the total number of parameters in *M*, * for parameter positions that are present in both signatures, each parameter type in *N* is a subtype or supertype of the corresponding parameter type in *M*, and * the result type of *M* is Void, or the result type of *N* is a subtype of that of *M*. - * *M* is a string index signature of type *U* and *S'* contains a string index signature of a type that is a subtype of *U*. - * *M* is a numeric index signature of type *U* and *S'* contains a string or numeric index signature of a type that is a subtype of *U*. + * *M* is a string index signature of type *U* and *S* has an apparent string index signature of a type that is a subtype of *U*. + * *M* is a numeric index signature of type *U* and *S* has an apparent string or numeric index signature of a type that is a subtype of *U*. When comparing call or construct signatures, parameter names are ignored and rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. -Note that specialized call and construct signatures (section [3.7.2.4](#3.7.2.4)) are not significant when determining subtype and supertype relationships. +Note that specialized call and construct signatures (section [3.8.2.4](#3.8.2.4)) are not significant when determining subtype and supertype relationships. Also note that type parameters are not considered object types. Thus, the only subtypes of a type parameter *T* are *T* itself and other type parameters that are directly or indirectly constrained to *T*. -### 3.8.4 Assignment Compatibility +### 3.10.4 Assignment Compatibility Types are required to be assignment compatible in certain circumstances, such as expression and variable types in assignment statements and argument and parameter types in function calls. -*S* is ***assignable to*** a type *T*, and *T* is ***assignable from*** *S*, if one of the following is true, where *S*' denotes the apparent type (section [3.8.1](#3.8.1)) of *S*: +*S* is ***assignable to*** a type *T*, and *T* is ***assignable from*** *S*, if one of the following is true: * *S* and *T* are identical types. * *S* or *T* is the Any type. @@ -1973,29 +2040,30 @@ Types are required to be assignment compatible in certain circumstances, such as * *S* and *T* are type parameters, and *S* is directly or indirectly constrained to *T*. * *S* is a union type and each constituent type of *S* is assignable to *T*. * *T* is a union type and *S* is assignable to at least one constituent type of *T*. -* *S'* and *T* are object types and, for each member *M* in *T*, one of the following is true: - * *M* is a property and *S'* contains a property *N* where +* *S* is an object type, a type parameter, or the Number, Boolean, or String primitive type, *T* is an object type, and for each member *M* in *T*, one of the following is true: + * *M* is a property and *S* has an apparent property *N* where * *M* and *N* have the same name, * the type of *N* is assignable to that of *M*, * if *M* is a required property, *N* is also a required property, and * *M* and *N* are both public, *M* and *N* are both private and originate in the same declaration, *M* and *N* are both protected and originate in the same declaration, or *M* is protected and *N* is declared in a class derived from the class in which *M* is declared. - * *M* is an optional property and *S'* contains no property of the same name as *M*. - * *M* is a non-specialized call or construct signature and *S*' contains a call or construct signature *N* where, when *M* and *N* are instantiated using type Any as the type argument for all type parameters declared by *M* and *N* (if any), + * *M* is an optional property and *S* has no apparent property of the same name as *M*. + * *M* is a non-specialized call or construct signature and *S* has an apparent call or construct signature *N* where, when *M* and *N* are instantiated using type Any as the type argument for all type parameters declared by *M* and *N* (if any), * the signatures are of the same kind (call or construct), * *M* has a rest parameter or the number of non-optional parameters in *N* is less than or equal to the total number of parameters in *M*, * for parameter positions that are present in both signatures, each parameter type in *N* is assignable to or from the corresponding parameter type in *M*, and * the result type of *M* is Void, or the result type of *N* is assignable to that of *M*. - * *M* is a string index signature of type *U* and *S'* contains a string index signature of a type that is assignable to *U*. - * *M* is a numeric index signature of type *U* and *S'* contains a string or numeric index signature of a type that is assignable to *U*. + * *M* is a string index signature of type *U* and *S* has an apparent string index signature of a type that is assignable to *U*. + * *M* is a numeric index signature of type *U* and *S* has an apparent string or numeric index signature of a type that is assignable to *U*. When comparing call or construct signatures, parameter names are ignored and rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. -Note that specialized call and construct signatures (section [3.7.2.4](#3.7.2.4)) are not significant when determining assignment compatibility. +Note that specialized call and construct signatures (section [3.8.2.4](#3.8.2.4)) are not significant when determining assignment compatibility. The assignment compatibility and subtyping rules differ only in that -* the Any type is assignable to, but not a subtype of, all types, and -* the primitive type Number is assignable to, but not a subtype of, all enum types. +* the Any type is assignable to, but not a subtype of, all types, +* the primitive type Number is assignable to, but not a subtype of, all enum types, and +* an object type without a particular property is assignable to an object type in which that property is optional. The assignment compatibility rules imply that, when assigning values or passing parameters, optional properties must either be present and of a compatible type, or not be present at all. For example: @@ -2008,14 +2076,14 @@ foo({ id: 1234, name: false }); // Error, name of wrong type foo({ name: "hello" }); // Error, id required but missing ``` -### 3.8.5 Contextual Signature Instantiation +### 3.10.5 Contextual Signature Instantiation During type argument inference in a function call (section [4.12.2](#4.12.2)) it is in certain circumstances necessary to instantiate a generic call signature of an argument expression in the context of a non-generic call signature of a parameter such that further inferences can be made. A generic call signature *A* is ***instantiated in the context of*** non-generic call signature *B* as follows: -* Using the process described in [3.8.6](#3.8.6), inferences for *A*'s type parameters are made from each parameter type in *B* to the corresponding parameter type in *A* for those parameter positions that are present in both signatures, where rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. +* Using the process described in [3.10.6](#3.10.6), inferences for *A*'s type parameters are made from each parameter type in *B* to the corresponding parameter type in *A* for those parameter positions that are present in both signatures, where rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type. * The inferred type argument for each type parameter is the union type of the set of inferences made for that type parameter. However, if the union type does not satisfy the constraint of the type parameter, the inferred type argument is instead the constraint. -### 3.8.6 Type Inference +### 3.10.6 Type Inference In certain contexts, inferences for a given set of type parameters are made *from* a type *S*, in which those type parameters do not occur, *to* another type *T*, in which those type parameters do occur. Inferences consist of a set of candidate type arguments collected for each of the type parameters. The inference process recursively relates *S* and *T* to gather as many inferences as possible: @@ -2035,7 +2103,7 @@ In certain contexts, inferences for a given set of type parameters are made *fro When comparing call or construct signatures, signatures in *S* correspond to signatures of the same kind in *T* pairwise in declaration order. If *S* and *T* have different numbers of a given kind of signature, the excess *first* signatures in declaration order of the longer list are ignored. -### 3.8.7 Recursive Types +### 3.10.7 Recursive Types Classes and interfaces can reference themselves in their internal structure, in effect creating recursive types with infinite nesting. For example, the type @@ -2069,7 +2137,7 @@ interface List { 'List<T>' has a member 'owner' of type 'List<List<T>>', which has a member 'owner' of type 'List<List<List<T>>>', which has a member 'owner' of type 'List<List<List<List<T>>>>' and so on, ad infinitum. Since type relationships are determined structurally, possibly exploring the constituent types to their full depth, in order to determine type relationships involving infinitely expanding generic types it may be necessary for the compiler to terminate the recursion at some point with the assumption that no further exploration will change the outcome. -## 3.9 Widened Types +## 3.11 Widened Types In several situations TypeScript infers types from context, alleviating the need for the programmer to explicitly specify types that appear obvious. For example @@ -2193,7 +2261,7 @@ A get accessor declaration is processed in the same manner as an ordinary functi If a get accessor is declared for a property, the return type of the get accessor becomes the type of the property. If only a set accessor is declared for a property, the parameter type (which may be type Any if no type annotation is present) of the set accessor becomes the type of the property. -When an object literal is contextually typed by a type that includes a string index signature, the resulting type of the object literal includes a string index signature with the union type of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. Likewise, when an object literal is contextually typed by a type that includes a numeric index signature, the resulting type of the object literal includes a numeric index signature with the union type of the types of the numerically named properties (section [3.7.4](#3.7.4)) declared in the object literal, or the Undefined type if the object literal declares no numerically named properties. +When an object literal is contextually typed by a type that includes a string index signature, the resulting type of the object literal includes a string index signature with the union type of the types of the properties declared in the object literal, or the Undefined type if the object literal is empty. Likewise, when an object literal is contextually typed by a type that includes a numeric index signature, the resulting type of the object literal includes a numeric index signature with the union type of the types of the numerically named properties (section [3.8.4](#3.8.4)) declared in the object literal, or the Undefined type if the object literal declares no numerically named properties. ## 4.6 Array Literals @@ -2394,8 +2462,6 @@ Furthermore, when a function expression has no return type annotation and is con A property access uses either dot notation or bracket notation. A property access expression is always classified as a reference. -A property access uses an object's apparent type (section [3.8.1](#3.8.1)) to determine its properties. Furthermore, in a property access, an object's apparent type includes the properties that originate in the 'Object' or 'Function' global interface types, as described in section [3.3](#3.3). - A dot notation property access of the form ```TypeScript @@ -2405,7 +2471,7 @@ object . name where *object* is an expression and *name* is an identifier (including, possibly, a reserved word), is used to access the property with the given name on the given object. A dot notation property access is processed as follows at compile-time: * If *object* is of type Any, any *name* is permitted and the property access is of type Any. -* Otherwise, if *name* denotes an accessible property member in the apparent type of *object*, the property access is of the type of that property. Public members are always accessible, but private and protected members of a class have restricted accessibility, as described in [8.2.2](#8.2.2). +* Otherwise, if *name* denotes an accessible apparent property (section [3.10.1](#3.10.1)) in the type of *object*, the property access is of the type of that property. Public members are always accessible, but private and protected members of a class have restricted accessibility, as described in [8.2.2](#8.2.2). * Otherwise, the property access is invalid and a compile-time error occurs. A bracket notation property access of the form @@ -2416,9 +2482,9 @@ object [ index ] where *object* and *index* are expressions, is used to access the property with the name computed by the index expression on the given object. A bracket notation property access is processed as follows at compile-time: -* If *index* is a string literal or a numeric literal and *object*'s apparent type has a property with the name given by that literal (converted to its string representation in the case of a numeric literal), the property access is of the type of that property. -* Otherwise, if *object*'s apparent type has a numeric index signature and *index* is of type Any, the Number primitive type, or an enum type, the property access is of the type of that index signature. -* Otherwise, if *object*'s apparent type has a string index signature and *index* is of type Any, the String or Number primitive type, or an enum type, the property access is of the type of that index signature. +* If *index* is a string literal or a numeric literal and *object* has an apparent property (section [3.10.1](#3.10.1)) with the name given by that literal (converted to its string representation in the case of a numeric literal), the property access is of the type of that property. +* Otherwise, if *object* has an apparent numeric index signature and *index* is of type Any, the Number primitive type, or an enum type, the property access is of the type of that index signature. +* Otherwise, if *object* has an apparent string index signature and *index* is of type Any, the String or Number primitive type, or an enum type, the property access is of the type of that index signature. * Otherwise, if *index* is of type Any, the String or Number primitive type, or an enum type, the property access is of type Any. * Otherwise, the property access is invalid and a compile-time error occurs. @@ -2455,8 +2521,8 @@ new C < ... > ( ... ) where *C* is an expression. The first form is equivalent to supplying an empty argument list. *C* must be of type Any or of an object type with one or more construct or call signatures. The operation is processed as follows at compile-time: * If *C* is of type Any, any argument list is permitted and the result of the operation is of type Any. -* If *C*'s apparent type (section [3.8.1](#3.8.1)) is an object type with one or more construct signatures, the expression is processed in the same manner as a function call, but using the construct signatures as the initial set of candidate signatures for overload resolution. The result type of the function call becomes the result type of the operation. -* If *C*'s apparent type is an object type with no construct signatures but one or more call signatures, the expression is processed as a function call. A compile-time error occurs if the result of the function call is not Void. The type of the result of the operation is Any. +* If *C* has one or more apparent construct signatures (section [3.10.1](#3.10.1)), the expression is processed in the same manner as a function call, but using the construct signatures as the initial set of candidate signatures for overload resolution. The result type of the function call becomes the result type of the operation. +* If *C* has no apparent construct signatures but one or more apparent call signatures, the expression is processed as a function call. A compile-time error occurs if the result of the function call is not Void. The type of the result of the operation is Any. ## 4.12 Function Calls @@ -2472,11 +2538,11 @@ func ( ... ) func < ... > ( ... ) ``` -where *func* is an expression of a function type or of type Any. The function expression is followed by an optional type argument list (section [3.4.2](#3.4.2)) and an argument list. +where *func* is an expression of a function type or of type Any. The function expression is followed by an optional type argument list (section [3.5.2](#3.5.2)) and an argument list. If *func* is of type Any, or of an object type that has no call or construct signatures but is a subtype of the Function interface, the call is an ***untyped function call***. In an untyped function call no type arguments are permitted, argument expressions can be of any type and number, no contextual types are provided for the argument expressions, and the result is always of type Any. -If *func*'s apparent type (section [3.8.1](#3.8.1)) is a function type, the call is a ***typed function call***. TypeScript employs ***overload resolution*** in typed function calls in order to support functions with multiple call signatures. Furthermore, TypeScript may perform ***type argument inference*** to automatically determine type arguments in generic function calls. +If *func* has apparent call signatures (section [3.10.1](#3.10.1)) the call is a ***typed function call***. TypeScript employs ***overload resolution*** in typed function calls in order to support functions with multiple call signatures. Furthermore, TypeScript may perform ***type argument inference*** to automatically determine type arguments in generic function calls. ### 4.12.1 Overload Resolution @@ -2503,7 +2569,7 @@ A signature is said to be an ***applicable signature*** with respect to an argum * the number of arguments is not less than the number of required parameters, * the number of arguments is not greater than the number of parameters, and -* for each argument expression *e* and its corresponding parameter *P,* when *e* is contextually typed (section [4.19](#4.19)) by the type of *P*, no errors ensue and the type of *e* is assignable to (section [3.8.4](#3.8.4)) the type of *P*. +* for each argument expression *e* and its corresponding parameter *P,* when *e* is contextually typed (section [4.19](#4.19)) by the type of *P*, no errors ensue and the type of *e* is assignable to (section [3.10.4](#3.10.4)) the type of *P*. ### 4.12.2 Type Argument Inference @@ -2518,13 +2584,13 @@ Type argument inference produces a set of candidate types for each type paramete In order to compute candidate types, the argument list is processed as follows: * Initially all inferred type arguments are considered ***unfixed*** with an empty set of candidate types. -* Proceeding from left to right, each argument expression *e* is ***inferentially typed*** by its corresponding parameter type *P*, possibly causing some inferred type arguments to become ***fixed***, and candidate type inferences (section [3.8.6](#3.8.6)) are made for unfixed inferred type arguments from the type computed for *e* to *P*. +* Proceeding from left to right, each argument expression *e* is ***inferentially typed*** by its corresponding parameter type *P*, possibly causing some inferred type arguments to become ***fixed***, and candidate type inferences (section [3.10.6](#3.10.6)) are made for unfixed inferred type arguments from the type computed for *e* to *P*. The process of inferentially typing an expression *e* by a type *T* is the same as that of contextually typing *e* by *T*, with the following exceptions: * Where expressions contained within *e* would be contextually typed, they are instead inferentially typed. * When a function expression is inferentially typed (section [4.9.3](#4.9.3)) and a type assigned to a parameter in that expression references type parameters for which inferences are being made, the corresponding inferred type arguments to become ***fixed*** and no further candidate inferences are made for them. -* If *e* is an expression of a function type that contains exactly one generic call signature and no other members, and *T* is a function type with exactly one non-generic call signature and no other members, then any inferences made for type parameters referenced by the parameters of *T*'s call signature are ***fixed***, and *e*'s type is changed to a function type with *e*'s call signature instantiated in the context of *T*'s call signature (section [3.8.5](#3.8.5)). +* If *e* is an expression of a function type that contains exactly one generic call signature and no other members, and *T* is a function type with exactly one non-generic call signature and no other members, then any inferences made for type parameters referenced by the parameters of *T*'s call signature are ***fixed***, and *e*'s type is changed to a function type with *e*'s call signature instantiated in the context of *T*'s call signature (section [3.10.5](#3.10.5)). An example: @@ -2696,7 +2762,7 @@ The 'void' operator takes an operand of any type and produces the value 'undefin ### 4.14.6 The typeof Operator -The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query (section [3.6.9](#3.6.9)) to produce the type of an expression. +The 'typeof' operator takes an operand of any type and produces a value of the String primitive type. In positions where a type is expected, 'typeof' can also be used in a type query (section [3.7.9](#3.7.9)) to produce the type of an expression. ```TypeScript var x = 5; @@ -2708,31 +2774,31 @@ In the example above, 'x' is of type 'number', 'y' is of type 'string' because w ## 4.15 Binary Operators -The subsections that follow specify the compile-time processing rules of the binary operators. In general, if the operands of a binary operator do not meet the stated requirements, a compile-time error occurs and the result of the operation defaults to type any in further processing. Tables that summarize the compile-time processing rules for operands of the Any type, the Boolean, Number, and String primitive types, and all object types and type parameters (the Object column in the tables) are provided. +The subsections that follow specify the compile-time processing rules of the binary operators. In general, if the operands of a binary operator do not meet the stated requirements, a compile-time error occurs and the result of the operation defaults to type any in further processing. Tables that summarize the compile-time processing rules for operands of the Any type, the Boolean, Number, and String primitive types, and all other types (the Other column in the tables) are provided. ### 4.15.1 The *, /, %, –, <<, >>, >>>, &, ^, and | operators These operators require their operands to be of type Any, the Number primitive type, or an enum type. Operands of an enum type are treated as having the primitive type Number. If one operand is the `null` or `undefined` value, it is treated as having the type of the other operand. The result is always of the Number primitive type. -||Any|Boolean|Number|String|Object| +||Any|Boolean|Number|String|Other| |:---:|:---:|:---:|:---:|:---:|:---:| |Any|Number||Number||| |Boolean|||||| |Number|Number||Number||| |String|||||| -|Object|||||| +|Other|||||| ### 4.15.2 The + operator The binary + operator requires both operands to be of the Number primitive type or an enum type, or at least one of the operands to be of type Any or the String primitive type. Operands of an enum type are treated as having the primitive type Number. If one operand is the `null` or `undefined` value, it is treated as having the type of the other operand. If both operands are of the Number primitive type, the result is of the Number primitive type. If one or both operands are of the String primitive type, the result is of the String primitive type. Otherwise, the result is of type Any. -||Any|Boolean|Number|String|Object| +||Any|Boolean|Number|String|Other| |:---:|:---:|:---:|:---:|:---:|:---:| |Any|Any|Any|Any|String|Any| |Boolean|Any|||String|| |Number|Any||Number|String|| |String|String|String|String|String|String| -|Object|Any|||String|| +|Other|Any|||String|| A value of any type can converted to the String primitive type by adding an empty string: @@ -2746,15 +2812,15 @@ The example above converts the result of 'getValue()' to a string if it isn't a ### 4.15.3 The <, >, <=, >=, ==, !=, ===, and !== operators -These operators require one operand type to be identical to or a subtype of the other operand type. The result is always of the Boolean primitive type. +These operators require one or both of the operand types to be assignable to the other. The result is always of the Boolean primitive type. -||Any|Boolean|Number|String|Object| +||Any|Boolean|Number|String|Other| |:---:|:---:|:---:|:---:|:---:|:---:| |Any|Boolean|Boolean|Boolean|Boolean|Boolean| |Boolean|Boolean|Boolean|||| |Number|Boolean||Boolean||| |String|Boolean|||Boolean|| -|Object|Boolean||||Boolean| +|Other|Boolean||||Boolean| ### 4.15.4 The instanceof operator @@ -2770,13 +2836,13 @@ The `in` operator requires the left operand to be of type Any, the String primit The && operator permits the operands to be of any type and produces a result of the same type as the second operand. -||Any|Boolean|Number|String|Object| +||Any|Boolean|Number|String|Other| |:---:|:---:|:---:|:---:|:---:|:---:| -|Any|Any|Boolean|Number|String|Object| -|Boolean|Any|Boolean|Number|String|Object| -|Number|Any|Boolean|Number|String|Object| -|String|Any|Boolean|Number|String|Object| -|Object|Any|Boolean|Number|String|Object| +|Any|Any|Boolean|Number|String|Other| +|Boolean|Any|Boolean|Number|String|Other| +|Number|Any|Boolean|Number|String|Other| +|String|Any|Boolean|Number|String|Other| +|Other|Any|Boolean|Number|String|Other| ### 4.15.7 The || operator @@ -2786,13 +2852,13 @@ If the || expression is contextually typed (section [4.19](#4.19)), the operands The type of the result is the union type of the two operand types. -||Any|Boolean|Number|String|Object| +||Any|Boolean|Number|String|Other| |:---:|:---:|:---:|:---:|:---:|:---:| |Any|Any|Any|Any|Any|Any| -|Boolean|Any|Boolean|{ }|{ }|{ }| -|Number|Any|{ }|Number|{ }|{ }| -|String|Any|{ }|{ }|String|{ }| -|Object|Any|{ }|{ }|{ }|Object| +|Boolean|Any|Boolean|N | B|S | B|B | O| +|Number|Any|N | B|Number|S | N|N | O| +|String|Any|S | B|S | N|String|S | O| +|Other|Any|B | O|N | O|S | O|Other| ## 4.16 The Conditional Operator @@ -2816,7 +2882,7 @@ An assignment of the form v = expr ``` -requires *v* to be classified as a reference (section [4.1](#4.1)). The *expr* expression is contextually typed (section [4.19](#4.19)) by the type of *v*, and the type of *expr* must be assignable to (section [3.8.4](#3.8.4)) the type of *v*, or otherwise a compile-time error occurs. The result is a value with the type of *expr*. +requires *v* to be classified as a reference (section [4.1](#4.1)). The *expr* expression is contextually typed (section [4.19](#4.19)) by the type of *v*, and the type of *expr* must be assignable to (section [3.10.4](#3.10.4)) the type of *v*, or otherwise a compile-time error occurs. The result is a value with the type of *expr*. A compound assignment of the form @@ -3038,7 +3104,7 @@ Variable statements are extended to include optional type annotations. A variable declaration introduces a variable with the given name in the containing declaration space. The type associated with a variable is determined as follows: * If the declaration includes a type annotation, the stated type becomes the type of the variable. If an initializer is present, the initializer expression is contextually typed (section [4.19](#4.19)) by the stated type and must be assignable to the stated type, or otherwise a compile-time error occurs. -* If the declaration includes an initializer but no type annotation, and if the initializer doesn't directly or indirectly reference the variable, the widened type (section [3.9](#3.9)) of the initializer expression becomes the type of the variable. If the initializer directly or indirectly references the variable, the type of the variable becomes the Any type. +* If the declaration includes an initializer but no type annotation, and if the initializer doesn't directly or indirectly reference the variable, the widened type (section [3.11](#3.11)) of the initializer expression becomes the type of the variable. If the initializer directly or indirectly references the variable, the type of the variable becomes the Any type. * If the declaration includes neither a type annotation nor an initializer, the type of the variable becomes the Any type. Multiple declarations for the same variable name in the same declaration space are permitted, provided that each declaration associates the same type with the variable. @@ -3135,7 +3201,7 @@ Use of the 'with' statement in TypeScript is an error, as is the case in ECMAScr ## 5.9 Switch Statements -In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from (section [3.8.4](#3.8.4)) the type of the 'switch' expression. +In a 'switch' statement, each 'case' expression must be of a type that is assignable to or from (section [3.10.4](#3.10.4)) the type of the 'switch' expression. ## 5.10 Throw Statements @@ -3212,8 +3278,8 @@ A function implementation without a return type annotation is said to be an ***i * If there are no return statements with expressions in *f*'s function body, the inferred return type is Void. * Otherwise, if *f*'s function body directly references *f* or references any implicitly typed functions that through this same analysis reference *f*, the inferred return type is Any. -* Otherwise, if *f* is a contextually typed function expression (section [4.9.3](#4.9.3)), the inferred return type is the union type (section [3.3.4](#3.3.4)) of the types of the return statement expressions in the function body, ignoring return statements with no expressions. -* Otherwise, the inferred return type is the first of the types of the return statement expressions in the function body that is a supertype (section [3.8.3](#3.8.3)) of each of the others, ignoring return statements with no expressions. A compile-time error occurs if no return statement expression has a type that is a supertype of each of the others. +* Otherwise, if *f* is a contextually typed function expression (section [4.9.3](#4.9.3)), the inferred return type is the union type (section [3.4](#3.4)) of the types of the return statement expressions in the function body, ignoring return statements with no expressions. +* Otherwise, the inferred return type is the first of the types of the return statement expressions in the function body that is a supertype (section [3.10.3](#3.10.3)) of each of the others, ignoring return statements with no expressions. A compile-time error occurs if no return statement expression has a type that is a supertype of each of the others. In the example @@ -3234,7 +3300,7 @@ An explicitly typed function whose return type isn't the Void or the Any type mu The type of 'this' in a function implementation is the Any type. -In the signature of a function implementation, a parameter can be marked optional by following it with an initializer. When a parameter declaration includes both a type annotation and an initializer, the initializer expression is contextually typed (section [4.19](#4.19)) by the stated type and must be assignable to the stated type, or otherwise a compile-time error occurs. When a parameter declaration has no type annotation but includes an initializer, the type of the parameter is the widened form (section [3.9](#3.9)) of the type of the initializer expression. +In the signature of a function implementation, a parameter can be marked optional by following it with an initializer. When a parameter declaration includes both a type annotation and an initializer, the initializer expression is contextually typed (section [4.19](#4.19)) by the stated type and must be assignable to the stated type, or otherwise a compile-time error occurs. When a parameter declaration has no type annotation but includes an initializer, the type of the parameter is the widened form (section [3.11](#3.11)) of the type of the initializer expression. Initializer expressions are evaluated in the scope of the function body but are not permitted to reference local variables and are only permitted to access parameters that are declared to the left of the parameter they initialize, unless the parameter reference occurs in a nested function expression. @@ -3269,7 +3335,7 @@ the local variable 'x' is in scope in the parameter initializer (thus hiding the ## 6.4 Generic Functions -A function implementation may include type parameters in its signature (section [3.7.2.1](#3.7.2.1)) and is then called a ***generic function***. Type parameters provide a mechanism for expressing relationships between parameter and return types in call operations. Type parameters have no run-time representation—they are purely a compile-time construct. +A function implementation may include type parameters in its signature (section [3.8.2.1](#3.8.2.1)) and is then called a ***generic function***. Type parameters provide a mechanism for expressing relationships between parameter and return types in call operations. Type parameters have no run-time representation—they are purely a compile-time construct. Type parameters declared in the signature of a function implementation are in scope in the signature and body of that function implementation. @@ -3287,7 +3353,7 @@ function compare(x: T, y: T): number { } ``` -Note that the 'x' and 'y' parameters are known to be subtypes of the constraint 'Comparable' and therefore have a 'compareTo' member. This is described further in section [3.4.1](#3.4.1). +Note that the 'x' and 'y' parameters are known to be subtypes of the constraint 'Comparable' and therefore have a 'compareTo' member. This is described further in section [3.5.1](#3.5.1). The type arguments of a call to a generic function may be explicitly specified in a call operation or may, when possible, be inferred (section [4.12.2](#4.12.2)) from the types of the regular arguments in the call. In the example @@ -3335,13 +3401,13 @@ Interfaces provide the ability to name and parameterize object types and to comp Interfaces have no run-time representation—they are purely a compile-time construct. Interfaces are particularly useful for documenting and validating the required shape of properties, objects passed as parameters, and objects returned from functions. -Because TypeScript has a structural type system, an interface type with a particular set of members is considered identical to, and can be substituted for, another interface type or object type literal with an identical set of members (see section [3.8.2](#3.8.2)). +Because TypeScript has a structural type system, an interface type with a particular set of members is considered identical to, and can be substituted for, another interface type or object type literal with an identical set of members (see section [3.10.2](#3.10.2)). Class declarations may reference interfaces in their implements clause to validate that they provide an implementation of the interfaces. ## 7.1 Interface Declarations -An interface declaration declares a new named type (section [3.5](#3.5)) by introducing a type name in the containing module. +An interface declaration declares a new named type (section [3.6](#3.6)) by introducing a type name in the containing module.   *InterfaceDeclaration:*    `interface` *Identifier* *TypeParametersopt* *InterfaceExtendsClauseopt* *ObjectType* @@ -3356,9 +3422,9 @@ An interface declaration declares a new named type (section [3.5](#3.5)) by intr   *ClassOrInterfaceType:*    *TypeReference* -The *Identifier* of an interface declaration may not be one of the predefined type names (section [3.6.1](#3.6.1)). +The *Identifier* of an interface declaration may not be one of the predefined type names (section [3.7.1](#3.7.1)). -An interface may optionally have type parameters (section [3.4.1](#3.4.1)) that serve as placeholders for actual types to be provided when the interface is referenced in type references. An interface with type parameters is called a ***generic interface***. The type parameters of a generic interface declaration are in scope in the entire declaration and may be referenced in the *InterfaceExtendsClause* and *ObjectType* body. +An interface may optionally have type parameters (section [3.5.1](#3.5.1)) that serve as placeholders for actual types to be provided when the interface is referenced in type references. An interface with type parameters is called a ***generic interface***. The type parameters of a generic interface declaration are in scope in the entire declaration and may be referenced in the *InterfaceExtendsClause* and *ObjectType* body. An interface can inherit from zero or more ***base types*** which are specified in the *InterfaceExtendsClause*. The base types must be type references to class or interface types. @@ -3372,9 +3438,9 @@ The following constraints must be satisfied by an interface declaration or other * An interface declaration may not, directly or indirectly, specify a base type that originates in the same declaration. In other words an interface cannot, directly or indirectly, be a base type of itself, regardless of type arguments. * An interface cannot declare a property with the same name as an inherited private or protected property. -* Inherited properties with the same name must be identical (section [3.8.2](#3.8.2)). -* All properties of the interface must satisfy the constraints implied by the index signatures of the interface as specified in section [3.7.4](#3.7.4). -* The instance type (section [3.5.1](#3.5.1)) of the declared interface must be assignable (section [3.8.4](#3.8.4)) to each of the base type references. +* Inherited properties with the same name must be identical (section [3.10.2](#3.10.2)). +* All properties of the interface must satisfy the constraints implied by the index signatures of the interface as specified in section [3.8.4](#3.8.4). +* The instance type (section [3.6.1](#3.6.1)) of the declared interface must be assignable (section [3.10.4](#3.10.4)) to each of the base type references. An interface is permitted to inherit identical members from multiple base types and will in that case only contain one occurrence of each particular member. @@ -3477,7 +3543,7 @@ class Location { } ``` -In the above example, 'SelectableControl' contains all of the members of 'Control', including the private 'state' property. Since 'state' is a private member it is only possible for descendants of 'Control' to implement 'SelectableControl'. This is because only descendants of 'Control' will have a 'state' private member that originates in the same declaration, which is a requirement for private members to be compatible (section [3.8](#3.8)). +In the above example, 'SelectableControl' contains all of the members of 'Control', including the private 'state' property. Since 'state' is a private member it is only possible for descendants of 'Control' to implement 'SelectableControl'. This is because only descendants of 'Control' will have a 'state' private member that originates in the same declaration, which is a requirement for private members to be compatible (section [0](#0)). Within the 'Control' class it is possible to access the 'state' private member through an instance of 'SelectableControl'. Effectively, a 'SelectableControl' acts like a 'Control' that is known to have a 'select' method. The 'Button' and 'TextBox' classes are subtypes of 'SelectableControl' (because they both inherit from 'Control' and have a 'select' method), but the 'Image' and 'Location' classes are not. @@ -3518,9 +3584,9 @@ Class declarations introduce named types and provide implementations of those ty A *ClassDeclaration* declares a ***class type*** and a ***constructor function***, both with the name given by *Identifier*, in the containing module. The class type is created from the instance members declared in the class body and the instance members inherited from the base class. The constructor function is created from the constructor declaration, the static member declarations in the class body, and the static members inherited from the base class. The constructor function initializes and returns an instance of the class type. -The *Identifier* of a class declaration may not be one of the predefined type names (section [3.6.1](#3.6.1)). +The *Identifier* of a class declaration may not be one of the predefined type names (section [3.7.1](#3.7.1)). -A class may optionally have type parameters (section [3.4.1](#3.4.1)) that serve as placeholders for actual types to be provided when the class is referenced in type references. A class with type parameters is called a ***generic class***. The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the *ClassHeritage* and *ClassBody*. +A class may optionally have type parameters (section [3.5.1](#3.5.1)) that serve as placeholders for actual types to be provided when the class is referenced in type references. A class with type parameters is called a ***generic class***. The type parameters of a generic class declaration are in scope in the entire declaration and may be referenced in the *ClassHeritage* and *ClassBody*. The following example introduces both a named type called 'Point' (the class type) and a member called 'Point' (the constructor function) in the containing module. @@ -3581,7 +3647,7 @@ The following constraints must be satisfied by the class heritage specification * If present, the type reference specified in the `extends` clause must denote a class type. Furthermore, the *TypeName* part of the type reference is required to be a reference to the class constructor function when evaluated as an expression. * A class declaration may not, directly or indirectly, specify a base class that originates in the same declaration. In other words a class cannot, directly or indirectly, be a base class of itself, regardless of type arguments. -* The instance type (section [3.5.1](#3.5.1)) of the declared class must be assignable (section [3.8.4](#3.8.4)) to the base type reference and each of the type references listed in the `implements` clause. +* The instance type (section [3.6.1](#3.6.1)) of the declared class must be assignable (section [3.10.4](#3.10.4)) to the base type reference and each of the type references listed in the `implements` clause. * The constructor function type created by the class declaration must be assignable to the base class constructor function type, ignoring construct signatures. The following example illustrates a situation in which the first rule above would be violated: @@ -3629,7 +3695,7 @@ The members of a class consist of the members introduced through member declarat Members are either ***instance members*** or ***static members***. -Instance members are members of the class type (section [8.2.4](#8.2.4)) and its associated instance type. Within constructors, instance member functions, and instance member accessors, the type of `this` is the instance type (section [3.5.1](#3.5.1)) of the class. +Instance members are members of the class type (section [8.2.4](#8.2.4)) and its associated instance type. Within constructors, instance member functions, and instance member accessors, the type of `this` is the instance type (section [3.6.1](#3.6.1)) of the class. Static members are declared using the `static` modifier and are members of the constructor function type (section [8.2.5](#8.2.5)). Within static member functions and static member accessors, the type of `this` is the constructor function type. @@ -3677,7 +3743,7 @@ In class 'A', the accesses to 'x' are permitted because 'x' is declared in 'A', A derived class ***inherits*** all members from its base class it doesn't ***override***. Inheritance means that a derived class implicitly contains all non-overridden members of the base class. Only public and protected property members can be overridden. -A property member in a derived class is said to override a property member in a base class when the derived class property member has the same name and kind (instance or static) as the base class property member. The type of an overriding property member must be assignable (section [3.8.4](#3.8.4)) to the type of the overridden property member, or otherwise a compile-time error occurs. +A property member in a derived class is said to override a property member in a base class when the derived class property member has the same name and kind (instance or static) as the base class property member. The type of an overriding property member must be assignable (section [3.10.4](#3.10.4)) to the type of the overridden property member, or otherwise a compile-time error occurs. Base class instance member functions can be overridden by derived class instance member functions, but not by other kinds of members. @@ -3685,11 +3751,11 @@ Base class instance member variables and accessors can be overridden by derived Base class static property members can be overridden by derived class static property members of any kind as long as the types are compatible, as described above. -An index member in a derived class is said to override an index member in a base class when the derived class index member is of the same index kind (string or numeric) as the base class index member. The type of an overriding index member must be assignable (section [3.8.4](#3.8.4)) to the type of the overridden index member, or otherwise a compile-time error occurs. +An index member in a derived class is said to override an index member in a base class when the derived class index member is of the same index kind (string or numeric) as the base class index member. The type of an overriding index member must be assignable (section [3.10.4](#3.10.4)) to the type of the overridden index member, or otherwise a compile-time error occurs. ### 8.2.4 Class Types -A class declaration declares a new named type (section [3.5](#3.5)) called a class type. Within the constructor and member functions of a class, the type of `this` is the instance type (section [3.5.1](#3.5.1)) of this class type. The class type has the following members: +A class declaration declares a new named type (section [3.6](#3.6)) called a class type. Within the constructor and member functions of a class, the type of `this` is the instance type (section [3.6.1](#3.6.1)) of this class type. The class type has the following members: * A property for each instance member variable declaration in the class body. * A property of a function type for each instance member function declaration in the class body. @@ -3698,7 +3764,7 @@ A class declaration declares a new named type (section [3.5](#3.5)) called a cla * An index signature for each instance index member declaration in the class body. * All base class instance type property or index members that are not overridden in the class. -All instance property members (including those that are private or protected) of a class must satisfy the constraints implied by the index members of the class as specified in section [3.7.4](#3.7.4). +All instance property members (including those that are private or protected) of a class must satisfy the constraints implied by the index members of the class as specified in section [3.8.4](#3.8.4). In the example @@ -4078,14 +4144,14 @@ Get and set accessors are emitted as calls to 'Object.defineProperty' in the gen ## 8.5 Index Member Declarations -An index member declaration introduces an index signature (section [3.7.4](#3.7.4)) in the class instance type. +An index member declaration introduces an index signature (section [3.8.4](#3.8.4)) in the class instance type.   *IndexMemberDeclaration:*    *IndexSignature* `;` Index member declarations have no body and cannot specify an accessibility modifier. -A class declaration can have at most one string index member declaration and one numeric index member declaration. All instance property members of a class must satisfy the constraints implied by the index members of the class as specified in section [3.7.4](#3.7.4). +A class declaration can have at most one string index member declaration and one numeric index member declaration. All instance property members of a class must satisfy the constraints implied by the index members of the class as specified in section [3.8.4](#3.8.4). It is not possible to declare index members for the static side of a class. @@ -4289,7 +4355,7 @@ An enum declaration declares an ***enum type*** and an ***enum object*** in the The enum type and enum object declared by an *EnumDeclaration* both have the name given by the *Identifier* of the declaration. The enum type is a distinct subtype of the Number primitive type. The enum object is a variable of an anonymous object type containing a set of properties, all of the enum type, corresponding to the values declared for the enum type in the body of the declaration. The enum object's type furthermore includes a numeric index signature with the signature '[x: number]: string'. -The *Identifier* of an enum declaration may not be one of the predefined type names (section [3.6.1](#3.6.1)). +The *Identifier* of an enum declaration may not be one of the predefined type names (section [3.7.1](#3.7.1)). The example @@ -4443,7 +4509,7 @@ An internal module declaration declares a namespace name and, in the case of an Internal modules are either ***instantiated*** or ***non-instantiated***. A non-instantiated module is an internal module containing only interface types and other non-instantiated modules. An instantiated module is an internal module that doesn't meet this definition. In intuitive terms, an instantiated module is one for which a module object instance is created, whereas a non-instantiated module is one for which no code is generated. -When a module identifier is referenced as a *ModuleName* (section [3.6.2](#3.6.2)) it denotes a container of module and type names, and when a module identifier is referenced as a *PrimaryExpression* (section [4.3](#4.3)) it denotes the singleton module instance. For example: +When a module identifier is referenced as a *ModuleName* (section [3.7.2](#3.7.2)) it denotes a container of module and type names, and when a module identifier is referenced as a *PrimaryExpression* (section [4.3](#4.3)) it denotes the singleton module instance. For example: ```TypeScript module M { @@ -4499,6 +4565,7 @@ The body of an internal module corresponds to a function that is executed once t    `export`*opt* *FunctionDeclaration*    `export`*opt* *ClassDeclaration*    `export`*opt* *InterfaceDeclaration* +   `export`*opt* *TypeAliasDeclaration*    `export`*opt* *EnumDeclaration*    `export`*opt* *ModuleDeclaration*    `export`*opt* *ImportDeclaration* @@ -4560,7 +4627,7 @@ When an import statement includes an export modifier, all meanings of the local An export declaration declares an externally accessible module member. An export declaration is simply a regular declaration prefixed with the keyword `export`. -Exported class, interface, and enum types can be accessed as a *TypeName* (section [3.6.2](#3.6.2)) of the form *M.T*, where *M* is a reference to the containing module and *T* is the exported type name. Likewise, as part of a *TypeName*, exported modules can be accessed as a *ModuleName* of the form *M.N*, where *M* is a reference to the containing module and *N* is the exported module. +Exported class, interface, and enum types can be accessed as a *TypeName* (section [3.7.2](#3.7.2)) of the form *M.T*, where *M* is a reference to the containing module and *T* is the exported type name. Likewise, as part of a *TypeName*, exported modules can be accessed as a *ModuleName* of the form *M.N*, where *M* is a reference to the containing module and *N* is the exported module. Exported variable, function, class, enum, module, and import alias declarations become properties on the module instance and together establish the module's ***instance type***. This unnamed type has the following members: @@ -4571,7 +4638,7 @@ Exported variable, function, class, enum, module, and import alias declarations * A property of an object type for each exported instantiated module declaration. * A property for each exported import alias that references a variable, function, class, enum, or instantiated module. -An exported member depends on a (possibly empty) set of named types (section [3.5](#3.5)). Those named types must be at least as accessible as the exported member, or otherwise an error occurs. +An exported member depends on a (possibly empty) set of named types (section [3.6](#3.6)). Those named types must be at least as accessible as the exported member, or otherwise an error occurs. The named types upon which a member depends are the named types occurring in the transitive closure of the ***directly depends on*** relationship defined as follows: @@ -4756,13 +4823,14 @@ A TypeScript ***program*** consists of one or more source files that are either    *ExportAssignment*    *AmbientExternalModuleDeclaration*    `export`*opt* *InterfaceDeclaration* +   `export`*opt* *TypeAliasDeclaration*    `export`*opt* *ImportDeclaration*    `export`*opt* *AmbientDeclaration*    `export`*opt* *ExternalImportDeclaration* When a TypeScript program is compiled, all of the program's source files are processed together. Statements and declarations in different source files can depend on each other, possibly in a circular fashion. By default, a JavaScript output file is generated for each implementation source file in a compilation, but no output is generated from declaration source files. -The source elements permitted in a TypeScript implementation source file are a superset of those supported by JavaScript. Specifically, TypeScript extends the JavaScript grammar's existing *VariableDeclaration* (section [5.1](#5.1)) and *FunctionDeclaration* (section [6.1](#6.1)) productions, and adds *InterfaceDeclaration* (section [7.1](#7.1)), *ClassDeclaration* (section [8.1](#8.1)), *EnumDeclaration* (section [9.1](#9.1)), *ModuleDeclaration* (section [10.1](#10.1)), *ImportDeclaration* (section [10.3](#10.3)), *ExternalImportDeclaration* (section [11.2.2](#11.2.2)), *ExportAssignment* (section [11.2.4](#11.2.4)), *AmbientDeclaration* (section [12.1](#12.1)), and *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) productions. +The source elements permitted in a TypeScript implementation source file are a superset of those supported by JavaScript. Specifically, TypeScript extends the JavaScript grammar's existing *VariableDeclaration* (section [5.1](#5.1)) and *FunctionDeclaration* (section [6.1](#6.1)) productions, and adds *TypeAliasDeclaration* (section [3.9](#3.9)), *InterfaceDeclaration* (section [7.1](#7.1)), *ClassDeclaration* (section [8.1](#8.1)), *EnumDeclaration* (section [9.1](#9.1)), *ModuleDeclaration* (section [10.1](#10.1)), *ImportDeclaration* (section [10.3](#10.3)), *ExternalImportDeclaration* (section [11.2.2](#11.2.2)), *ExportAssignment* (section [11.2.4](#11.2.4)), *AmbientDeclaration* (section [12.1](#12.1)), and *AmbientExternalModuleDeclaration* (section [12.2](#12.2)) productions. Declaration source files are restricted to contain declarations only. Declaration source files can be used to declare the static type information associated with existing JavaScript code in an adjunct manner. They are entirely optional but enable the TypeScript compiler and tools to provide better verification and assistance when integrating existing JavaScript code and libraries in a TypeScript application. @@ -4794,6 +4862,7 @@ External modules are written as separate source files that contain at least one * top-level exported *FunctionDeclaration*, * top-level exported *ClassDeclaration*, * top-level exported *InterfaceDeclaration*, +* top-level exported *TypeAliasDeclaration*, * top-level exported *EnumDeclaration*, * top-level exported *ModuleDeclaration*, * top-level exported *ImportDeclaration*, or @@ -5018,7 +5087,7 @@ An ambient function declaration introduces a function in the containing declarat   *AmbientFunctionDeclaration:*    `function` *Identifier* *CallSignature* `;` -Ambient functions may be overloaded by specifying multiple ambient function declarations with the same name, but it is an error to declare multiple overloads that are considered identical (section [3.8.2](#3.8.2)) or differ only in their return types. +Ambient functions may be overloaded by specifying multiple ambient function declarations with the same name, but it is an error to declare multiple overloads that are considered identical (section [3.10.2](#3.10.2)) or differ only in their return types. Ambient function declarations cannot specify a function bodies and do not permit default parameter values. @@ -5308,6 +5377,9 @@ This appendix contains a summary of the grammar found in the main document. As d   *MethodSignature:*    *PropertyName* `?`*opt* *CallSignature* +  *TypeAliasDeclaration:* +   `type` *Identifier* `=` *Type* `;` + ## A.2 Expressions   *PropertyAssignment:* *( Modified )* @@ -5515,6 +5587,7 @@ This appendix contains a summary of the grammar found in the main document. As d    `export`*opt* *FunctionDeclaration*    `export`*opt* *ClassDeclaration*    `export`*opt* *InterfaceDeclaration* +   `export`*opt* *TypeAliasDeclaration*    `export`*opt* *EnumDeclaration*    `export`*opt* *ModuleDeclaration*    `export`*opt* *ImportDeclaration* @@ -5557,6 +5630,7 @@ This appendix contains a summary of the grammar found in the main document. As d    *ExportAssignment*    *AmbientExternalModuleDeclaration*    `export`*opt* *InterfaceDeclaration* +   `export`*opt* *TypeAliasDeclaration*    `export`*opt* *ImportDeclaration*    `export`*opt* *AmbientDeclaration*    `export`*opt* *ExternalImportDeclaration* diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index f0b2d71ccad..e13d7dd07bf 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -5,25 +5,51 @@ module ts { - export function isInstantiated(node: Node): boolean { + export const enum ModuleInstanceState { + NonInstantiated = 0, + Instantiated = 1, + ConstEnumOnly = 2 + } + + export function getModuleInstanceState(node: Node): ModuleInstanceState { // A module is uninstantiated if it contains only // 1. interface declarations if (node.kind === SyntaxKind.InterfaceDeclaration) { - return false; + return ModuleInstanceState.NonInstantiated; } - // 2. non - exported import declarations + // 2. const enum declarations don't make module instantiated + else if (node.kind === SyntaxKind.EnumDeclaration && isConstEnumDeclaration(node)) { + return ModuleInstanceState.ConstEnumOnly; + } + // 3. non - exported import declarations else if (node.kind === SyntaxKind.ImportDeclaration && !(node.flags & NodeFlags.Export)) { - return false; + return ModuleInstanceState.NonInstantiated; } - // 3. other uninstantiated module declarations. - else if (node.kind === SyntaxKind.ModuleBlock && !forEachChild(node, isInstantiated)) { - return false; + // 4. other uninstantiated module declarations. + else if (node.kind === SyntaxKind.ModuleBlock) { + var state = ModuleInstanceState.NonInstantiated; + forEachChild(node, n => { + switch (getModuleInstanceState(n)) { + case ModuleInstanceState.NonInstantiated: + // child is non-instantiated - continue searching + return false; + case ModuleInstanceState.ConstEnumOnly: + // child is const enum only - record state and continue searching + state = ModuleInstanceState.ConstEnumOnly; + return false; + case ModuleInstanceState.Instantiated: + // child is instantiated - record state and stop + state = ModuleInstanceState.Instantiated; + return true; + } + }); + return state; } - else if (node.kind === SyntaxKind.ModuleDeclaration && !isInstantiated((node).body)) { - return false; + else if (node.kind === SyntaxKind.ModuleDeclaration) { + return getModuleInstanceState((node).body); } else { - return true; + return ModuleInstanceState.Instantiated; } } @@ -248,11 +274,22 @@ module ts { if (node.name.kind === SyntaxKind.StringLiteral) { bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); } - else if (isInstantiated(node)) { - bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); - } else { - bindDeclaration(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true); + var state = getModuleInstanceState(node); + if (state === ModuleInstanceState.NonInstantiated) { + bindDeclaration(node, SymbolFlags.NamespaceModule, SymbolFlags.NamespaceModuleExcludes, /*isBlockScopeContainer*/ true); + } + else { + bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true); + if (state === ModuleInstanceState.ConstEnumOnly) { + // mark value module as module that contains only enums + node.symbol.constEnumOnlyModule = true; + } + else if (node.symbol.constEnumOnlyModule) { + // const only value module was merged with instantiated module - reset flag + node.symbol.constEnumOnlyModule = false; + } + } } } @@ -364,7 +401,12 @@ module ts { bindDeclaration(node, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes, /*isBlockScopeContainer*/ false); break; case SyntaxKind.EnumDeclaration: - bindDeclaration(node, SymbolFlags.Enum, SymbolFlags.EnumExcludes, /*isBlockScopeContainer*/ false); + if (isConstEnumDeclaration(node)) { + bindDeclaration(node, SymbolFlags.ConstEnum, SymbolFlags.ConstEnumExcludes, /*isBlockScopeContainer*/ false); + } + else { + bindDeclaration(node, SymbolFlags.RegularEnum, SymbolFlags.RegularEnumExcludes, /*isBlockScopeContainer*/ false); + } break; case SyntaxKind.ModuleDeclaration: bindModuleDeclaration(node); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7b497535778..7f433bf59ab 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -187,7 +187,8 @@ module ts { if (flags & SymbolFlags.Function) result |= SymbolFlags.FunctionExcludes; if (flags & SymbolFlags.Class) result |= SymbolFlags.ClassExcludes; if (flags & SymbolFlags.Interface) result |= SymbolFlags.InterfaceExcludes; - if (flags & SymbolFlags.Enum) result |= SymbolFlags.EnumExcludes; + if (flags & SymbolFlags.RegularEnum) result |= SymbolFlags.RegularEnumExcludes; + if (flags & SymbolFlags.ConstEnum) result |= SymbolFlags.ConstEnumExcludes; if (flags & SymbolFlags.ValueModule) result |= SymbolFlags.ValueModuleExcludes; if (flags & SymbolFlags.Method) result |= SymbolFlags.MethodExcludes; if (flags & SymbolFlags.GetAccessor) result |= SymbolFlags.GetAccessorExcludes; @@ -208,6 +209,7 @@ module ts { result.declarations = symbol.declarations.slice(0); result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; + if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; if (symbol.members) result.members = cloneSymbolTable(symbol.members); if (symbol.exports) result.exports = cloneSymbolTable(symbol.exports); recordMergedSymbol(result, symbol); @@ -216,6 +218,10 @@ module ts { function extendSymbol(target: Symbol, source: Symbol) { if (!(target.flags & getExcludedSymbolFlags(source.flags))) { + if (source.flags & SymbolFlags.ValueModule && target.flags & SymbolFlags.ValueModule && target.constEnumOnlyModule && !source.constEnumOnlyModule) { + // reset flag when merging instantiated module into value module that has only const enums + target.constEnumOnlyModule = false; + } target.flags |= source.flags; if (!target.valueDeclaration && source.valueDeclaration) target.valueDeclaration = source.valueDeclaration; forEach(source.declarations, node => { @@ -310,6 +316,22 @@ module ts { // return undefined if we can't find a symbol. } + /** Returns true if node1 is defined before node 2**/ + function isDefinedBefore(node1: Node, node2: Node): boolean { + var file1 = getSourceFileOfNode(node1); + var file2 = getSourceFileOfNode(node2); + if (file1 === file2) { + return node1.pos <= node2.pos; + } + + if (!compilerOptions.out) { + return true; + } + + var sourceFiles = program.getSourceFiles(); + return sourceFiles.indexOf(file1) <= sourceFiles.indexOf(file2); + } + // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with // the given name can be found. @@ -429,18 +451,8 @@ module ts { // Block-scoped variables cannot be used before their definition var declaration = forEach(result.declarations, d => d.flags & NodeFlags.BlockScoped ? d : undefined); Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - var declarationSourceFile = getSourceFileOfNode(declaration); - var referenceSourceFile = getSourceFileOfNode(errorLocation); - if (declarationSourceFile === referenceSourceFile) { - if (declaration.pos > errorLocation.pos) { - error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, identifierToString(declaration.name)); - } - } - else if (compilerOptions.out) { - var sourceFiles = program.getSourceFiles(); - if (sourceFiles.indexOf(referenceSourceFile) < sourceFiles.indexOf(declarationSourceFile)) { - error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, identifierToString(declaration.name)); - } + if (!isDefinedBefore(declaration, errorLocation)) { + error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, identifierToString(declaration.name)); } } } @@ -1595,7 +1607,7 @@ module ts { return true; default: - Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + SyntaxKind[node.kind]); + Debug.fail("isDeclarationVisible unknown: SyntaxKind: " + node.kind); } } @@ -4452,8 +4464,8 @@ module ts { if (symbol.flags & SymbolFlags.Import) { // Mark the import as referenced so that we emit it in the final .js file. - // exception: identifiers that appear in type queries - getSymbolLinks(symbol).referenced = !isInTypeQuery(node); + // exception: identifiers that appear in type queries, const enums, modules that contain only const enums + getSymbolLinks(symbol).referenced = !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol)); } checkCollisionWithCapturedSuperVariable(node, node); @@ -5107,6 +5119,10 @@ module ts { if (objectType === unknownType) return unknownType; + if (isConstEnumObjectType(objectType) && node.index.kind !== SyntaxKind.StringLiteral) { + error(node.index, Diagnostics.Index_expression_arguments_in_const_enums_must_be_of_type_string); + } + // TypeScript 1.0 spec (April 2014): 4.10 Property Access // - If IndexExpr is a string literal or a numeric literal and ObjExpr's apparent type has a property with the name // given by that literal(converted to its string representation in the case of a numeric literal), the property access is of the type of that property. @@ -5121,6 +5137,7 @@ module ts { var name = (node.index).text; var prop = getPropertyOfType(objectType, name); if (prop) { + getNodeLinks(node).resolvedSymbol = prop; return getTypeOfSymbol(prop); } } @@ -6086,6 +6103,14 @@ module ts { return (type.flags & TypeFlags.Structured) !== 0; } + function isConstEnumObjectType(type: Type) : boolean { + return type.flags & (TypeFlags.ObjectType | TypeFlags.Anonymous) && type.symbol && isConstEnumSymbol(type.symbol); + } + + function isConstEnumSymbol(symbol: Symbol): boolean { + return (symbol.flags & SymbolFlags.ConstEnum) !== 0; + } + function checkInstanceOfExpression(node: BinaryExpression, leftType: Type, rightType: Type): Type { // TypeScript 1.0 spec (April 2014): 4.15.4 // The instanceof operator requires the left operand to be of type Any, an object type, or a type parameter type, @@ -6323,6 +6348,21 @@ module ts { } } } + + if (isConstEnumObjectType(type)) { + // enum object type for const enums are only permitted in: + // - 'left' in property access + // - 'object' in indexed access + // - target in rhs of import statement + var ok = + (node.parent.kind === SyntaxKind.PropertyAccess && (node.parent).left === node) || + (node.parent.kind === SyntaxKind.IndexedAccess && (node.parent).object === node) || + ((node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) && isInRightSideOfImportOrExportAssignment(node)); + + if (!ok) { + error(node, Diagnostics.const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment); + } + } return type; } @@ -6997,7 +7037,7 @@ module ts { case SyntaxKind.InterfaceDeclaration: return SymbolFlags.ExportType; case SyntaxKind.ModuleDeclaration: - return (d).name.kind === SyntaxKind.StringLiteral || isInstantiated(d) + return (d).name.kind === SyntaxKind.StringLiteral || getModuleInstanceState(d) !== ModuleInstanceState.NonInstantiated ? SymbolFlags.ExportNamespace | SymbolFlags.ExportValue : SymbolFlags.ExportNamespace; case SyntaxKind.ClassDeclaration: @@ -7234,7 +7274,7 @@ module ts { } // Uninstantiated modules shouldnt do this check - if (node.kind === SyntaxKind.ModuleDeclaration && !isInstantiated(node)) { + if (node.kind === SyntaxKind.ModuleDeclaration && getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) { return; } @@ -7796,26 +7836,10 @@ module ts { } function checkTypeAliasDeclaration(node: TypeAliasDeclaration) { + checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0); checkSourceElement(node.type); } - function getConstantValueForExpression(node: Expression): number { - var isNegative = false; - if (node.kind === SyntaxKind.PrefixOperator) { - var unaryExpression = node; - if (unaryExpression.operator === SyntaxKind.MinusToken || unaryExpression.operator === SyntaxKind.PlusToken) { - node = unaryExpression.operand; - isNegative = unaryExpression.operator === SyntaxKind.MinusToken; - } - } - if (node.kind === SyntaxKind.NumericLiteral) { - var literalText = (node).text; - return isNegative ? -literalText : +literalText; - } - - return undefined; - } - function computeEnumMemberValues(node: EnumDeclaration) { var nodeLinks = getNodeLinks(node); @@ -7824,6 +7848,7 @@ module ts { var enumType = getDeclaredTypeOfSymbol(enumSymbol); var autoValue = 0; var ambient = isInAmbientContext(node); + var enumIsConst = isConstEnumDeclaration(node); forEach(node.members, member => { if(isNumericName(member.name.text)) { @@ -7831,16 +7856,30 @@ module ts { } var initializer = member.initializer; if (initializer) { - autoValue = getConstantValueForExpression(initializer); - if (autoValue === undefined && !ambient) { - // Only here do we need to check that the initializer is assignable to the enum type. - // If it is a constant value (not undefined), it is syntactically constrained to be a number. - // Also, we do not need to check this for ambients because there is already - // a syntax error if it is not a constant. + autoValue = getConstantValueForEnumMemberInitializer(initializer, enumIsConst); + if (autoValue === undefined) { + if (enumIsConst) { + error(initializer, Diagnostics.In_const_enum_declarations_member_initializer_must_be_constant_expression); + } + else if (!ambient) { + // Only here do we need to check that the initializer is assignable to the enum type. + // If it is a constant value (not undefined), it is syntactically constrained to be a number. + // Also, we do not need to check this for ambients because there is already + // a syntax error if it is not a constant. checkTypeAssignableTo(checkExpression(initializer), enumType, initializer, /*headMessage*/ undefined); + } } + else if (enumIsConst) { + if (isNaN(autoValue)) { + error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN); + } + else if (!isFinite(autoValue)) { + error(initializer, Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value); + } + } + } - else if (ambient) { + else if (ambient && !enumIsConst) { autoValue = undefined; } @@ -7851,6 +7890,110 @@ module ts { nodeLinks.flags |= NodeCheckFlags.EnumValuesComputed; } + + function getConstantValueForEnumMemberInitializer(initializer: Expression, enumIsConst: boolean): number { + return evalConstant(initializer); + + function evalConstant(e: Node): number { + switch (e.kind) { + case SyntaxKind.PrefixOperator: + var value = evalConstant((e).operand); + if (value === undefined) { + return undefined; + } + switch ((e).operator) { + case SyntaxKind.PlusToken: return value; + case SyntaxKind.MinusToken: return -value; + case SyntaxKind.TildeToken: return enumIsConst ? ~value : undefined; + } + return undefined; + case SyntaxKind.BinaryExpression: + if (!enumIsConst) { + return undefined; + } + + var left = evalConstant((e).left); + if (left === undefined) { + return undefined; + } + var right = evalConstant((e).right); + if (right === undefined) { + return undefined; + } + switch ((e).operator) { + case SyntaxKind.BarToken: return left | right; + case SyntaxKind.AmpersandToken: return left & right; + case SyntaxKind.GreaterThanGreaterThanToken: return left >> right; + case SyntaxKind.GreaterThanGreaterThanGreaterThanToken: return left >>> right; + case SyntaxKind.LessThanLessThanToken: return left << right; + case SyntaxKind.CaretToken: return left ^ right; + case SyntaxKind.AsteriskToken: return left * right; + case SyntaxKind.SlashToken: return left / right; + case SyntaxKind.PlusToken: return left + right; + case SyntaxKind.MinusToken: return left - right; + case SyntaxKind.PercentToken: return left % right; + } + return undefined; + case SyntaxKind.NumericLiteral: + return +(e).text; + case SyntaxKind.ParenExpression: + return enumIsConst ? evalConstant((e).expression) : undefined; + case SyntaxKind.Identifier: + case SyntaxKind.IndexedAccess: + case SyntaxKind.PropertyAccess: + if (!enumIsConst) { + return undefined; + } + + var member = initializer.parent; + var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); + var enumType: Type; + var propertyName: string; + + if (e.kind === SyntaxKind.Identifier) { + // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. + // instead pick current enum type and later try to fetch member from the type + enumType = currentType; + propertyName = (e).text; + } + else { + if (e.kind === SyntaxKind.IndexedAccess) { + if ((e).index.kind !== SyntaxKind.StringLiteral) { + return undefined; + } + var enumType = getTypeOfNode((e).object); + propertyName = ((e).index).text; + } + else { + var enumType = getTypeOfNode((e).left); + propertyName = (e).right.text; + } + if (enumType !== currentType) { + return undefined; + } + } + + if (propertyName === undefined) { + return undefined; + } + var property = getPropertyOfObjectType(enumType, propertyName); + if (!property || !(property.flags & SymbolFlags.EnumMember)) { + return undefined; + } + var propertyDecl = property.valueDeclaration; + // self references are illegal + if (member === propertyDecl) { + return undefined; + } + + // illegal case: forward reference + if (!isDefinedBefore(propertyDecl, member)) { + return undefined; + } + return getNodeLinks(propertyDecl).enumMemberValue; + } + } + } } function checkEnumDeclaration(node: EnumDeclaration) { @@ -7874,6 +8017,16 @@ module ts { var enumSymbol = getSymbolOfNode(node); var firstDeclaration = getDeclarationOfKind(enumSymbol, node.kind); if (node === firstDeclaration) { + if (enumSymbol.declarations.length > 1) { + var enumIsConst = isConstEnumDeclaration(node); + // check that const is placed\omitted on all enum declarations + forEach(enumSymbol.declarations, decl => { + if (isConstEnumDeclaration(decl) !== enumIsConst) { + error(decl.name, Diagnostics.Enum_declarations_must_all_be_const_or_non_const); + } + }); + } + var seenEnumMissingInitialInitializer = false; forEach(enumSymbol.declarations, declaration => { // return true if we hit a violation of the rule, false otherwise @@ -8707,17 +8860,16 @@ module ts { function getExportAssignmentName(node: SourceFile): string { var symbol = getExportAssignmentSymbol(getSymbolOfNode(node)); - return symbol && symbolIsValue(symbol) ? symbolToString(symbol): undefined; + return symbol && symbolIsValue(symbol) && !isConstEnumSymbol(symbol) ? symbolToString(symbol): undefined; } - function isTopLevelValueImportedViaEntityName(node: ImportDeclaration): boolean { + function isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean { if (node.parent.kind !== SyntaxKind.SourceFile || !node.entityName) { // parent is not source file or it is not reference to internal module return false; } var symbol = getSymbolOfNode(node); - var target = resolveImport(symbol); - return target !== unknownSymbol && ((target.flags & SymbolFlags.Value) !== 0); + return isImportResolvedToValue(getSymbolOfNode(node)); } function hasSemanticErrors() { @@ -8729,6 +8881,16 @@ module ts { return forEach(getDiagnostics(sourceFile), d => d.isEarly); } + function isImportResolvedToValue(symbol: Symbol): boolean { + var target = resolveImport(symbol); + // const enums and modules that contain only const enums are not considered values from the emit perespective + return target !== unknownSymbol && target.flags & SymbolFlags.Value && !isConstEnumOrConstEnumOnlyModule(target); + } + + function isConstEnumOrConstEnumOnlyModule(s: Symbol): boolean { + return isConstEnumSymbol(s) || s.constEnumOnlyModule; + } + function isReferencedImportDeclaration(node: ImportDeclaration): boolean { var symbol = getSymbolOfNode(node); if (getSymbolLinks(symbol).referenced) { @@ -8737,10 +8899,7 @@ module ts { // logic below will answer 'true' for exported import declaration in a nested module that itself is not exported. // As a consequence this might cause emitting extra. if (node.flags & NodeFlags.Export) { - var target = resolveImport(symbol); - if (target !== unknownSymbol && target.flags & SymbolFlags.Value) { - return true; - } + return isImportResolvedToValue(symbol); } return false; } @@ -8775,7 +8934,7 @@ module ts { return getNodeLinks(node).enumMemberValue; } - function getConstantValue(node: PropertyAccess): number { + function getConstantValue(node: PropertyAccess | IndexedAccess): number { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol && (symbol.flags & SymbolFlags.EnumMember)) { var declaration = symbol.valueDeclaration; @@ -8810,7 +8969,7 @@ module ts { isReferencedImportDeclaration: isReferencedImportDeclaration, getNodeCheckFlags: getNodeCheckFlags, getEnumMemberValue: getEnumMemberValue, - isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName, + isTopLevelValueImportWithEntityName: isTopLevelValueImportWithEntityName, hasSemanticErrors: hasSemanticErrors, hasEarlyErrors: hasEarlyErrors, isDeclarationVisible: isDeclarationVisible, diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 63c555f1951..fed7c991b2e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -24,7 +24,7 @@ module ts { type: "boolean", }, { - name: "emitBOM", + name: "emitBOM", type: "boolean" }, { @@ -102,7 +102,7 @@ module ts { { name: "target", shortName: "t", - type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5 , "es6": ScriptTarget.ES6 }, + type: { "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6 }, description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental, paramType: Diagnostics.VERSION, error: Diagnostics.Argument_for_target_option_must_be_es3_es5_or_es6 @@ -118,6 +118,11 @@ module ts { shortName: "w", type: "boolean", description: Diagnostics.Watch_input_files, + }, + { + name: "preserveConstEnums", + type: "boolean", + description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code } ]; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 8056dc0d449..e512688fee2 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -9,7 +9,7 @@ module ts { // x | y is False if both x and y are False. // x | y is Maybe if either x or y is Maybe, but neither x or y is True. // x | y is True if either x or y is True. - export enum Ternary { + export const enum Ternary { False = 0, Maybe = 1, True = -1 @@ -19,7 +19,7 @@ module ts { [index: string]: T; } - export enum Comparison { + export const enum Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 @@ -648,7 +648,7 @@ module ts { getSignatureConstructor: () => Signature } - export enum AssertionLevel { + export const enum AssertionLevel { None = 0, Normal = 1, Aggressive = 2, diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 7ab19bd5074..0492ebeef45 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -120,9 +120,8 @@ module ts { const_declarations_must_be_initialized: { code: 1155, category: DiagnosticCategory.Error, key: "'const' declarations must be initialized" }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: DiagnosticCategory.Error, key: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: DiagnosticCategory.Error, key: "'let' declarations can only be declared inside a block." }, - Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead: { code: 1158, category: DiagnosticCategory.Error, key: "Aliased type cannot be an object type literal. Use an interface declaration instead." }, - Invalid_template_literal_expected: { code: 1159, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" }, - Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1160, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, + Invalid_template_literal_expected: { code: 1158, category: DiagnosticCategory.Error, key: "Invalid template literal; expected '}'" }, + Tagged_templates_are_only_available_when_targeting_ECMAScript_6_and_higher: { code: 1159, category: DiagnosticCategory.Error, key: "Tagged templates are only available when targeting ECMAScript 6 and higher." }, Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." }, @@ -270,6 +269,7 @@ module ts { The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly: { code: 2453, category: DiagnosticCategory.Error, key: "The type argument for type parameter '{0}' cannot be inferred from the usage. Consider specifying the type arguments explicitly." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: DiagnosticCategory.Error, key: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: DiagnosticCategory.Error, key: "Type alias '{0}' circularly references itself." }, + Type_alias_name_cannot_be_0: { code: 2457, category: DiagnosticCategory.Error, key: "Type alias name cannot be '{0}'" }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_name_1_from_private_module_2: { code: 4001, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using name '{1}' from private module '{2}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, @@ -352,6 +352,12 @@ module ts { Exported_type_alias_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named: { code: 4079, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using name '{1}' from external module {2} but cannot be named." }, Exported_type_alias_0_has_or_is_using_name_1_from_private_module_2: { code: 4080, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using name '{1}' from private module '{2}'." }, Exported_type_alias_0_has_or_is_using_private_name_1: { code: 4081, category: DiagnosticCategory.Error, key: "Exported type alias '{0}' has or is using private name '{1}'." }, + Enum_declarations_must_all_be_const_or_non_const: { code: 4082, category: DiagnosticCategory.Error, key: "Enum declarations must all be const or non-const." }, + In_const_enum_declarations_member_initializer_must_be_constant_expression: { code: 4083, category: DiagnosticCategory.Error, key: "In 'const' enum declarations member initializer must be constant expression.", isEarly: true }, + const_enums_can_only_be_used_in_property_or_index_access_expressions_or_the_right_hand_side_of_an_import_declaration_or_export_assignment: { code: 4084, category: DiagnosticCategory.Error, key: "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment." }, + Index_expression_arguments_in_const_enums_must_be_of_type_string: { code: 4085, category: DiagnosticCategory.Error, key: "Index expression arguments in 'const' enums must be of type 'string'." }, + const_enum_member_initializer_was_evaluated_to_a_non_finite_value: { code: 4086, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to a non-finite value." }, + const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN: { code: 4087, category: DiagnosticCategory.Error, key: "'const' enum member initializer was evaluated to disallowed value 'NaN'." }, The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." }, Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." }, Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" }, @@ -366,6 +372,7 @@ module ts { Specifies_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations: { code: 6004, category: DiagnosticCategory.Message, key: "Specifies the location where debugger should locate TypeScript files instead of source locations." }, Watch_input_files: { code: 6005, category: DiagnosticCategory.Message, key: "Watch input files." }, Redirect_output_structure_to_the_directory: { code: 6006, category: DiagnosticCategory.Message, key: "Redirect output structure to the directory." }, + Do_not_erase_const_enum_declarations_in_generated_code: { code: 6007, category: DiagnosticCategory.Message, key: "Do not erase const enum declarations in generated code." }, Do_not_emit_comments_to_output: { code: 6009, category: DiagnosticCategory.Message, key: "Do not emit comments to output." }, Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES6_experimental: { code: 6015, category: DiagnosticCategory.Message, key: "Specify ECMAScript target version: 'ES3' (default), 'ES5', or 'ES6' (experimental)" }, Specify_module_code_generation_Colon_commonjs_or_amd: { code: 6016, category: DiagnosticCategory.Message, key: "Specify module code generation: 'commonjs' or 'amd'" }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3e380ea5a67..7e2f2e2f0d2 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -471,17 +471,13 @@ "category": "Error", "code": 1157 }, - "Aliased type cannot be an object type literal. Use an interface declaration instead.": { + "Invalid template literal; expected '}'": { "category": "Error", "code": 1158 }, - "Invalid template literal; expected '}'": { - "category": "Error", - "code": 1159 - }, "Tagged templates are only available when targeting ECMAScript 6 and higher.": { "category": "Error", - "code": 1160 + "code": 1159 }, "Duplicate identifier '{0}'.": { @@ -1080,6 +1076,10 @@ "category": "Error", "code": 2456 }, + "Type alias name cannot be '{0}'": { + "category": "Error", + "code": 2457 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -1409,13 +1409,35 @@ "category": "Error", "code": 4081 }, - - + "Enum declarations must all be const or non-const.": { + "category": "Error", + "code": 4082 + }, + "In 'const' enum declarations member initializer must be constant expression.": { + "category": "Error", + "code": 4083, + "isEarly": true + }, + "'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.": { + "category": "Error", + "code": 4084 + }, + "Index expression arguments in 'const' enums must be of type 'string'.": { + "category": "Error", + "code": 4085 + }, + "'const' enum member initializer was evaluated to a non-finite value.": { + "category": "Error", + "code": 4086 + }, + "'const' enum member initializer was evaluated to disallowed value 'NaN'.": { + "category": "Error", + "code": 4087 + }, "The current host does not support the '{0}' option.": { "category": "Error", "code": 5001 }, - "Cannot find the common subdirectory path for the input files.": { "category": "Error", "code": 5009 @@ -1468,6 +1490,10 @@ "category": "Message", "code": 6006 }, + "Do not erase const enum declarations in generated code.": { + "category": "Message", + "code": 6007 + }, "Do not emit comments to output.": { "category": "Message", "code": 6009 diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 782d22a0bf4..1e6f2ed604e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1031,19 +1031,29 @@ module ts { emitTrailingComments(node); } - function emitPropertyAccess(node: PropertyAccess) { + function tryEmitConstantValue(node: PropertyAccess | IndexedAccess): boolean { var constantValue = resolver.getConstantValue(node); if (constantValue !== undefined) { - write(constantValue.toString() + " /* " + identifierToString(node.right) + " */"); + var propertyName = node.kind === SyntaxKind.PropertyAccess ? identifierToString((node).right) : getTextOfNode((node).index); + write(constantValue.toString() + " /* " + propertyName + " */"); + return true; } - else { - emit(node.left); - write("."); - emit(node.right); + return false; + } + + function emitPropertyAccess(node: PropertyAccess) { + if (tryEmitConstantValue(node)) { + return; } + emit(node.left); + write("."); + emit(node.right); } function emitIndexedAccess(node: IndexedAccess) { + if (tryEmitConstantValue(node)) { + return; + } emit(node.object); write("["); emit(node.index); @@ -1341,6 +1351,10 @@ module ts { emitToken(SyntaxKind.CloseBraceToken, node.clauses.end); } + function isOnSameLine(node1: Node, node2: Node) { + return getLineOfLocalPosition(skipTrivia(currentSourceFile.text, node1.pos)) === getLineOfLocalPosition(skipTrivia(currentSourceFile.text, node2.pos)); + } + function emitCaseOrDefaultClause(node: CaseOrDefaultClause) { if (node.kind === SyntaxKind.CaseClause) { write("case "); @@ -1350,9 +1364,16 @@ module ts { else { write("default:"); } - increaseIndent(); - emitLines(node.statements); - decreaseIndent(); + + if (node.statements.length === 1 && isOnSameLine(node, node.statements[0])) { + write(" "); + emit(node.statements[0]); + } + else { + increaseIndent(); + emitLines(node.statements); + decreaseIndent(); + } } function emitThrowStatement(node: ThrowStatement) { @@ -1876,6 +1897,11 @@ module ts { } function emitEnumDeclaration(node: EnumDeclaration) { + // const enums are completely erased during compilation. + var isConstEnum = isConstEnumDeclaration(node); + if (isConstEnum && !compilerOptions.preserveConstEnums) { + return; + } emitLeadingComments(node); if (!(node.flags & NodeFlags.Export)) { emitStart(node); @@ -1893,7 +1919,7 @@ module ts { write(") {"); increaseIndent(); scopeEmitStart(node); - emitEnumMemberDeclarations(); + emitEnumMemberDeclarations(isConstEnum); decreaseIndent(); writeLine(); emitToken(SyntaxKind.CloseBraceToken, node.members.end); @@ -1916,7 +1942,7 @@ module ts { } emitTrailingComments(node); - function emitEnumMemberDeclarations() { + function emitEnumMemberDeclarations(isConstEnum: boolean) { forEach(node.members, member => { writeLine(); emitLeadingComments(member); @@ -1927,7 +1953,7 @@ module ts { write("["); emitQuotedIdentifier(member.name); write("] = "); - if (member.initializer) { + if (member.initializer && !isConstEnum) { emit(member.initializer); } else { @@ -1950,7 +1976,7 @@ module ts { } function emitModuleDeclaration(node: ModuleDeclaration) { - if (!isInstantiated(node)) { + if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) { return emitPinnedOrTripleSlashComments(node); } emitLeadingComments(node); @@ -2002,7 +2028,7 @@ module ts { // preserve old compiler's behavior: emit 'var' for import declaration (even if we do not consider them referenced) when // - current file is not external module // - import declaration is top level and target is value imported by entity name - emitImportDeclaration = !isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportedViaEntityName(node); + emitImportDeclaration = !isExternalModule(currentSourceFile) && resolver.isTopLevelValueImportWithEntityName(node); } if (emitImportDeclaration) { @@ -2722,6 +2748,9 @@ module ts { if (resolver.isDeclarationVisible(node)) { emitJsDocComments(node); emitDeclarationFlags(node); + if (isConstEnumDeclaration(node)) { + write("const ") + } write("enum "); emitSourceTextOfNode(node.name); write(" {"); @@ -2801,7 +2830,7 @@ module ts { break; default: - Debug.fail("This is unknown parent for type parameter: " + SyntaxKind[node.parent.kind]); + Debug.fail("This is unknown parent for type parameter: " + node.parent.kind); } return { @@ -3197,7 +3226,7 @@ module ts { break; default: - Debug.fail("This is unknown kind for signature: " + SyntaxKind[node.kind]); + Debug.fail("This is unknown kind for signature: " + node.kind); } return { @@ -3282,7 +3311,7 @@ module ts { break; default: - Debug.fail("This is unknown parent for parameter: " + SyntaxKind[node.parent.kind]); + Debug.fail("This is unknown parent for parameter: " + node.parent.kind); } return { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 0c5af3660a2..5da1952ab27 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -115,6 +115,10 @@ module ts { return (file.flags & NodeFlags.DeclarationFile) !== 0; } + export function isConstEnumDeclaration(node: EnumDeclaration): boolean { + return (node.flags & NodeFlags.Const) !== 0; + } + export function isPrologueDirective(node: Node): boolean { return node.kind === SyntaxKind.ExpressionStatement && (node).expression.kind === SyntaxKind.StringLiteral; } @@ -662,7 +666,7 @@ module ts { return undefined; } - enum ParsingContext { + const enum ParsingContext { SourceElements, // Elements in source file ModuleElements, // Elements in module declaration BlockStatements, // Statements in block @@ -683,7 +687,7 @@ module ts { Count // Number of parsing contexts } - enum Tristate { + const enum Tristate { False, True, Unknown @@ -711,13 +715,13 @@ module ts { } }; - enum LookAheadMode { + const enum LookAheadMode { NotLookingAhead, NoErrorYet, Error } - enum ModifierContext { + const enum ModifierContext { SourceElements, // Top level elements in a source file ModuleElements, // Elements in module declaration ClassMembers, // Members in class declaration @@ -726,7 +730,7 @@ module ts { // Tracks whether we nested (directly or indirectly) in a certain control block. // Used for validating break and continue statements. - enum ControlBlockContext { + const enum ControlBlockContext { NotNested, Nested, CrossingFunctionBoundary @@ -2730,7 +2734,7 @@ module ts { currentKind = SetAccesor; } else { - Debug.fail("Unexpected syntax kind:" + SyntaxKind[p.kind]); + Debug.fail("Unexpected syntax kind:" + p.kind); } if (!hasProperty(seen, p.name.text)) { @@ -3246,7 +3250,6 @@ module ts { case SyntaxKind.OpenBraceToken: case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: - case SyntaxKind.ConstKeyword: case SyntaxKind.FunctionKeyword: case SyntaxKind.IfKeyword: case SyntaxKind.DoKeyword: @@ -3265,6 +3268,12 @@ module ts { case SyntaxKind.CatchKeyword: case SyntaxKind.FinallyKeyword: return true; + case SyntaxKind.ConstKeyword: + // const keyword can precede enum keyword when defining constant enums + // 'const enum' do not start statement. + // In ES 6 'enum' is a future reserved keyword, so it should not be used as identifier + var isConstEnum = lookAhead(() => nextToken() === SyntaxKind.EnumKeyword); + return !isConstEnum; case SyntaxKind.InterfaceKeyword: case SyntaxKind.ClassKeyword: case SyntaxKind.ModuleKeyword: @@ -3275,6 +3284,7 @@ module ts { if (isDeclarationStart()) { return false; } + case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: @@ -3296,6 +3306,7 @@ module ts { case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: case SyntaxKind.ConstKeyword: + // const here should always be parsed as const declaration because of check in 'isStatement' return parseVariableStatement(allowLetAndConstDeclarations); case SyntaxKind.FunctionKeyword: return parseFunctionDeclaration(); @@ -3856,17 +3867,11 @@ module ts { parseExpected(SyntaxKind.EqualsToken); node.type = parseType(); parseSemicolon(); - var n = node.type; - while (n.kind === SyntaxKind.ParenType) { - n = (n).type; - } - if (n.kind === SyntaxKind.TypeLiteral && (n.pos !== (n).members.pos || n.end !== (n).members.end)) { - grammarErrorOnNode(node.type, Diagnostics.Aliased_type_cannot_be_an_object_type_literal_Use_an_interface_declaration_instead); - } return finishNode(node); } function parseAndCheckEnumDeclaration(pos: number, flags: NodeFlags): EnumDeclaration { + var enumIsConst = flags & NodeFlags.Const; function isIntegerLiteral(expression: Expression): boolean { function isInteger(literalExpression: LiteralExpression): boolean { // Allows for scientific notation since literalExpression.text was formed by @@ -3901,22 +3906,29 @@ module ts { node.name = parsePropertyName(); node.initializer = parseInitializer(/*inParameter*/ false); - if (inAmbientContext) { - if (node.initializer && !isIntegerLiteral(node.initializer) && errorCountBeforeEnumMember === file.syntacticErrors.length) { - grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers); + // skip checks below for const enums - they allow arbitrary initializers as long as they can be evaluated to constant expressions. + // since all values are known in compile time - it is not necessary to check that constant enum section precedes computed enum members. + if (!enumIsConst) { + if (inAmbientContext) { + if (node.initializer && !isIntegerLiteral(node.initializer) && errorCountBeforeEnumMember === file.syntacticErrors.length) { + grammarErrorOnNode(node.name, Diagnostics.Ambient_enum_elements_can_only_have_integer_literal_initializers); + } + } + else if (node.initializer) { + inConstantEnumMemberSection = isIntegerLiteral(node.initializer); + } + else if (!inConstantEnumMemberSection && errorCountBeforeEnumMember === file.syntacticErrors.length) { + grammarErrorOnNode(node.name, Diagnostics.Enum_member_must_have_initializer); } - } - else if (node.initializer) { - inConstantEnumMemberSection = isIntegerLiteral(node.initializer); - } - else if (!inConstantEnumMemberSection && errorCountBeforeEnumMember === file.syntacticErrors.length) { - grammarErrorOnNode(node.name, Diagnostics.Enum_member_must_have_initializer); } return finishNode(node); } var node = createNode(SyntaxKind.EnumDeclaration, pos); node.flags = flags; + if (enumIsConst) { + parseExpected(SyntaxKind.ConstKeyword); + } parseExpected(SyntaxKind.EnumKeyword); node.name = parseIdentifier(); if (parseExpected(SyntaxKind.OpenBraceToken)) { @@ -4073,9 +4085,17 @@ module ts { switch (token) { case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: - case SyntaxKind.ConstKeyword: result = parseVariableStatement(/*allowLetAndConstDeclarations*/ true, pos, flags); break; + case SyntaxKind.ConstKeyword: + var isConstEnum = lookAhead(() => nextToken() === SyntaxKind.EnumKeyword); + if (isConstEnum) { + result = parseAndCheckEnumDeclaration(pos, flags | NodeFlags.Const); + } + else { + result = parseVariableStatement(/*allowLetAndConstDeclarations*/ true, pos, flags); + } + break; case SyntaxKind.FunctionKeyword: result = parseFunctionDeclaration(pos, flags); break; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ead84957731..90b0697697e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -9,7 +9,7 @@ module ts { } // token > SyntaxKind.Identifer => token is a keyword - export enum SyntaxKind { + export const enum SyntaxKind { Unknown, EndOfFileToken, SingleLineCommentTrivia, @@ -249,7 +249,7 @@ module ts { LastTemplateToken = TemplateTail } - export enum NodeFlags { + export const enum NodeFlags { Export = 0x00000001, // Declarations Ambient = 0x00000002, // Declarations QuestionMark = 0x00000004, // Parameter/Property/Method @@ -722,7 +722,7 @@ module ts { trackSymbol(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): void; } - export enum TypeFormatFlags { + export const enum TypeFormatFlags { None = 0x00000000, WriteArrayAsGenericType = 0x00000001, // Write Array instead T[] UseTypeOfFunction = 0x00000002, // Write typeof instead of function type literal @@ -733,7 +733,7 @@ module ts { InElementType = 0x00000040, // Writing an array or union element type } - export enum SymbolFormatFlags { + export const enum SymbolFormatFlags { None = 0x00000000, WriteTypeParametersOrArguments = 0x00000001, // Write symbols's type argument if it is instantiated symbol // eg. class C { p: T } <-- Show p as C.p here @@ -744,7 +744,7 @@ module ts { // When this flag is specified m.c will be used to refer to the class instead of alias symbol x } - export enum SymbolAccessibility { + export const enum SymbolAccessibility { Accessible, NotAccessible, CannotBeNamed @@ -763,7 +763,7 @@ module ts { getExpressionNamePrefix(node: Identifier): string; getExportAssignmentName(node: SourceFile): string; isReferencedImportDeclaration(node: ImportDeclaration): boolean; - isTopLevelValueImportedViaEntityName(node: ImportDeclaration): boolean; + isTopLevelValueImportWithEntityName(node: ImportDeclaration): boolean; getNodeCheckFlags(node: Node): NodeCheckFlags; getEnumMemberValue(node: EnumMember): number; hasSemanticErrors(): boolean; @@ -774,11 +774,11 @@ module ts { isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessiblityResult; isImportDeclarationEntityNameReferenceDeclarationVisibile(entityName: EntityName): SymbolAccessiblityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant - getConstantValue(node: PropertyAccess): number; + getConstantValue(node: PropertyAccess | IndexedAccess): number; hasEarlyErrors(sourceFile?: SourceFile): boolean; } - export enum SymbolFlags { + export const enum SymbolFlags { FunctionScopedVariable = 0x00000001, // Variable (var) or parameter BlockScopedVariable = 0x00000002, // A block-scoped variable (let or const) Property = 0x00000004, // Property or enum member @@ -786,32 +786,34 @@ module ts { Function = 0x00000010, // Function Class = 0x00000020, // Class Interface = 0x00000040, // Interface - Enum = 0x00000080, // Enum - ValueModule = 0x00000100, // Instantiated module - NamespaceModule = 0x00000200, // Uninstantiated module - TypeLiteral = 0x00000400, // Type Literal - ObjectLiteral = 0x00000800, // Object Literal - Method = 0x00001000, // Method - Constructor = 0x00002000, // Constructor - GetAccessor = 0x00004000, // Get accessor - SetAccessor = 0x00008000, // Set accessor - CallSignature = 0x00010000, // Call signature - ConstructSignature = 0x00020000, // Construct signature - IndexSignature = 0x00040000, // Index signature - TypeParameter = 0x00080000, // Type parameter - TypeAlias = 0x00100000, // Type alias + ConstEnum = 0x00000080, // Const enum + RegularEnum = 0x00000100, // Enum + ValueModule = 0x00000200, // Instantiated module + NamespaceModule = 0x00000400, // Uninstantiated module + TypeLiteral = 0x00000800, // Type Literal + ObjectLiteral = 0x00001000, // Object Literal + Method = 0x00002000, // Method + Constructor = 0x00004000, // Constructor + GetAccessor = 0x00008000, // Get accessor + SetAccessor = 0x00010000, // Set accessor + CallSignature = 0x00020000, // Call signature + ConstructSignature = 0x00040000, // Construct signature + IndexSignature = 0x00080000, // Index signature + TypeParameter = 0x00100000, // Type parameter + TypeAlias = 0x00200000, // Type alias // Export markers (see comment in declareModuleMember in binder) - ExportValue = 0x00200000, // Exported value marker - ExportType = 0x00400000, // Exported type marker - ExportNamespace = 0x00800000, // Exported namespace marker - Import = 0x01000000, // Import - Instantiated = 0x02000000, // Instantiated symbol - Merged = 0x04000000, // Merged symbol (created during program binding) - Transient = 0x08000000, // Transient symbol (created during type check) - Prototype = 0x10000000, // Prototype property (no source representation) - UnionProperty = 0x20000000, // Property in union type + ExportValue = 0x00400000, // Exported value marker + ExportType = 0x00800000, // Exported type marker + ExportNamespace = 0x01000000, // Exported namespace marker + Import = 0x02000000, // Import + Instantiated = 0x04000000, // Instantiated symbol + Merged = 0x08000000, // Merged symbol (created during program binding) + Transient = 0x10000000, // Transient symbol (created during type check) + Prototype = 0x20000000, // Prototype property (no source representation) + UnionProperty = 0x40000000, // Property in union type + Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor, Type = Class | Interface | Enum | TypeLiteral | ObjectLiteral | TypeParameter | TypeAlias, @@ -834,8 +836,9 @@ module ts { FunctionExcludes = Value & ~(Function | ValueModule), ClassExcludes = (Value | Type) & ~ValueModule, InterfaceExcludes = Type & ~Interface, - EnumExcludes = (Value | Type) & ~(Enum | ValueModule), - ValueModuleExcludes = Value & ~(Function | Class | Enum | ValueModule), + RegularEnumExcludes = (Value | Type) & ~(RegularEnum | ValueModule), // regular enums merge only with regular enums and modules + ConstEnumExcludes = (Value | Type) & ~ConstEnum, // const enums merge only with const enums + ValueModuleExcludes = Value & ~(Function | Class | RegularEnum | ValueModule), NamespaceModuleExcludes = 0, MethodExcludes = Value & ~Method, GetAccessorExcludes = Value & ~SetAccessor, @@ -867,7 +870,8 @@ module ts { members?: SymbolTable; // Class, interface or literal instance members exports?: SymbolTable; // Module exports exportSymbol?: Symbol; // Exported symbol associated with this symbol - valueDeclaration?: Declaration // First value declaration of the symbol + valueDeclaration?: Declaration // First value declaration of the symbol, + constEnumOnlyModule?: boolean // For modules - if true - module contains only const enums or other modules with only const enums. } export interface SymbolLinks { @@ -886,7 +890,7 @@ module ts { [index: string]: Symbol; } - export enum NodeCheckFlags { + export const enum NodeCheckFlags { TypeChecked = 0x00000001, // Node has been type checked LexicalThis = 0x00000002, // Lexical 'this' reference CaptureThis = 0x00000004, // Lexical 'this' used in body @@ -911,7 +915,7 @@ module ts { assignmentChecks?: Map; // Cache of assignment checks } - export enum TypeFlags { + export const enum TypeFlags { Any = 0x00000001, String = 0x00000002, Number = 0x00000004, @@ -1008,7 +1012,7 @@ module ts { mapper?: TypeMapper; // Instantiation mapper } - export enum SignatureKind { + export const enum SignatureKind { Call, Construct, } @@ -1028,7 +1032,7 @@ module ts { isolatedSignatureType?: ObjectType; // A manufactured type that just contains the signature for purposes of signature comparison } - export enum IndexKind { + export const enum IndexKind { String, Number, } @@ -1104,10 +1108,11 @@ module ts { target?: ScriptTarget; version?: boolean; watch?: boolean; + preserveConstEnums?: boolean; [option: string]: string | number | boolean; } - export enum ModuleKind { + export const enum ModuleKind { None, CommonJS, AMD, @@ -1122,7 +1127,7 @@ module ts { } - export enum ScriptTarget { + export const enum ScriptTarget { ES3, ES5, ES6, @@ -1144,7 +1149,7 @@ module ts { error?: DiagnosticMessage; // The error given when the argument does not fit a customized 'type'. } - export enum CharacterCodes { + export const enum CharacterCodes { nullCharacter = 0, maxAsciiCharacter = 0x7F, diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 6e211892437..f23647024f9 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -3,7 +3,7 @@ /// /// -enum CompilerTestType { +const enum CompilerTestType { Conformance, Regressions, Test262 diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 33f435ce76b..268a54f8e63 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2368,7 +2368,7 @@ module FourSlash { }; } - enum State { + const enum State { none, inSlashStarMarker, inObjectMarker diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 60c5da5a1a6..14e2c9b42d4 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -30,7 +30,7 @@ module Utils { var global = Function("return this").call(null); // Setup some globals based on the current environment - export enum ExecutionEnvironment { + export const enum ExecutionEnvironment { Node, Browser, CScript @@ -757,7 +757,6 @@ module Harness { case 'codepage': case 'createFileLog': case 'filename': - case 'propagateenumconstants': case 'removecomments': case 'watch': case 'allowautomaticsemicoloninsertion': @@ -772,7 +771,9 @@ module Harness { case 'errortruncation': options.noErrorTruncation = setting.value === 'false'; break; - + case 'preserveconstenums': + options.preserveConstEnums = setting.value === 'true'; + break; default: throw new Error('Unsupported compiler setting ' + setting.flag); } @@ -1147,7 +1148,7 @@ module Harness { var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines // List of allowed metadata names - var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames"]; + var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums"]; function extractCompilerSettings(content: string): CompilerSetting[] { diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index 6f7a7c335a0..ed8d37c9c7e 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -1,7 +1,7 @@ interface TypeWriterResult { line: number; column: number; - syntaxKind: string; + syntaxKind: number; sourceText: string; type: string; } @@ -84,7 +84,7 @@ class TypeWriterWalker { this.results.push({ line: lineAndCharacter.line - 1, column: lineAndCharacter.character, - syntaxKind: ts.SyntaxKind[node.kind], + syntaxKind: node.kind, sourceText: sourceText, type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.WriteOwnNameForAnyLike) }); diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 3a72ee9bfa6..3a82e71c677 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -178,7 +178,7 @@ module ts.BreakpointResolver { case SyntaxKind.ModuleDeclaration: // span on complete module if it is instantiated - if (!isInstantiated(node)) { + if (getModuleInstanceState(node) !== ModuleInstanceState.Instantiated) { return undefined; } @@ -350,7 +350,7 @@ module ts.BreakpointResolver { function spanInBlock(block: Block): TypeScript.TextSpan { switch (block.parent.kind) { case SyntaxKind.ModuleDeclaration: - if (!isInstantiated(block.parent)) { + if (getModuleInstanceState(block.parent) !== ModuleInstanceState.Instantiated) { return undefined; } @@ -407,7 +407,7 @@ module ts.BreakpointResolver { switch (node.parent.kind) { case SyntaxKind.ModuleBlock: // If this is not instantiated module block no bp span - if (!isInstantiated(node.parent.parent)) { + if (getModuleInstanceState(node.parent.parent) !== ModuleInstanceState.Instantiated) { return undefined; } diff --git a/src/services/compiler/precompile.ts b/src/services/compiler/precompile.ts index 08a919a65b5..3396cb4f2a2 100644 --- a/src/services/compiler/precompile.ts +++ b/src/services/compiler/precompile.ts @@ -99,26 +99,26 @@ module TypeScript { var start = new Date().getTime(); // Look for: // import foo = module("foo") - while (token.kind() !== SyntaxKind.EndOfFileToken) { - if (token.kind() === SyntaxKind.ImportKeyword) { + while (token.kind !== SyntaxKind.EndOfFileToken) { + if (token.kind === SyntaxKind.ImportKeyword) { var importToken = token; token = scanner.scan(/*allowRegularExpression:*/ false); if (SyntaxFacts.isIdentifierNameOrAnyKeyword(token)) { token = scanner.scan(/*allowRegularExpression:*/ false); - if (token.kind() === SyntaxKind.EqualsToken) { + if (token.kind === SyntaxKind.EqualsToken) { token = scanner.scan(/*allowRegularExpression:*/ false); - if (token.kind() === SyntaxKind.ModuleKeyword || token.kind() === SyntaxKind.RequireKeyword) { + if (token.kind === SyntaxKind.ModuleKeyword || token.kind === SyntaxKind.RequireKeyword) { token = scanner.scan(/*allowRegularExpression:*/ false); - if (token.kind() === SyntaxKind.OpenParenToken) { + if (token.kind === SyntaxKind.OpenParenToken) { token = scanner.scan(/*allowRegularExpression:*/ false); lineMap.fillLineAndCharacterFromPosition(TypeScript.start(importToken, text), lineChar); - if (token.kind() === SyntaxKind.StringLiteral) { + if (token.kind === SyntaxKind.StringLiteral) { var ref = { line: lineChar.line, character: lineChar.character, diff --git a/src/services/formatting/formatter.ts b/src/services/formatting/formatter.ts index a98d969c059..92417168eac 100644 --- a/src/services/formatting/formatter.ts +++ b/src/services/formatting/formatter.ts @@ -78,7 +78,7 @@ module TypeScript.Services.Formatting { } // Push the token - var currentTokenSpan = new TokenSpan(token.kind(), position, width(token)); + var currentTokenSpan = new TokenSpan(token.kind, position, width(token)); if (!this.parent().hasSkippedOrMissingTokenChild()) { if (this.previousTokenSpan) { // Note that formatPair calls TrimWhitespaceInLineRange in between the 2 tokens diff --git a/src/services/formatting/formattingManager.ts b/src/services/formatting/formattingManager.ts index 727c97cce30..b83281fb9ec 100644 --- a/src/services/formatting/formattingManager.ts +++ b/src/services/formatting/formattingManager.ts @@ -42,12 +42,12 @@ module TypeScript.Services.Formatting { var sourceUnit = this.syntaxTree.sourceUnit(); var semicolonPositionedToken = findToken(sourceUnit, caretPosition - 1); - if (semicolonPositionedToken.kind() === SyntaxKind.SemicolonToken) { + if (semicolonPositionedToken.kind === SyntaxKind.SemicolonToken) { // Find the outer most parent that this semicolon terminates var current: ISyntaxElement = semicolonPositionedToken; while (current.parent !== null && end(current.parent) === end(semicolonPositionedToken) && - current.parent.kind() !== SyntaxKind.List) { + current.parent.kind !== SyntaxKind.List) { current = current.parent; } @@ -65,12 +65,12 @@ module TypeScript.Services.Formatting { var sourceUnit = this.syntaxTree.sourceUnit(); var closeBracePositionedToken = findToken(sourceUnit, caretPosition - 1); - if (closeBracePositionedToken.kind() === SyntaxKind.CloseBraceToken) { + if (closeBracePositionedToken.kind === SyntaxKind.CloseBraceToken) { // Find the outer most parent that this closing brace terminates var current: ISyntaxElement = closeBracePositionedToken; while (current.parent !== null && end(current.parent) === end(closeBracePositionedToken) && - current.parent.kind() !== SyntaxKind.List) { + current.parent.kind !== SyntaxKind.List) { current = current.parent; } diff --git a/src/services/formatting/indentationNodeContext.ts b/src/services/formatting/indentationNodeContext.ts index 398d4998eed..7aa10d2f9b9 100644 --- a/src/services/formatting/indentationNodeContext.ts +++ b/src/services/formatting/indentationNodeContext.ts @@ -66,7 +66,7 @@ module TypeScript.Services.Formatting { } public kind(): SyntaxKind { - return this._node.kind(); + return this._node.kind; } public hasSkippedOrMissingTokenChild(): boolean { diff --git a/src/services/formatting/indentationTrackingWalker.ts b/src/services/formatting/indentationTrackingWalker.ts index 2863b2e4fcc..9ed998858c5 100644 --- a/src/services/formatting/indentationTrackingWalker.ts +++ b/src/services/formatting/indentationTrackingWalker.ts @@ -99,11 +99,11 @@ module TypeScript.Services.Formatting { } public walk(element: ISyntaxElement) { - if (element && !isShared(element)) { + if (element) { if (isToken(element)) { this.visitToken(element); } - else if (element.kind() === SyntaxKind.List || element.kind() === SyntaxKind.SeparatedList) { + else if (element.kind === SyntaxKind.List) { for (var i = 0, n = childCount(element); i < n; i++) { this.walk(childAt(element, i)); } @@ -148,9 +148,9 @@ module TypeScript.Services.Formatting { // } // Also in a do-while statement, the while should be indented like the parent. if (firstToken(this._parent.node()) === token || - token.kind() === SyntaxKind.OpenBraceToken || token.kind() === SyntaxKind.CloseBraceToken || - token.kind() === SyntaxKind.OpenBracketToken || token.kind() === SyntaxKind.CloseBracketToken || - (token.kind() === SyntaxKind.WhileKeyword && this._parent.node().kind() == SyntaxKind.DoStatement)) { + token.kind === SyntaxKind.OpenBraceToken || token.kind === SyntaxKind.CloseBraceToken || + token.kind === SyntaxKind.OpenBracketToken || token.kind === SyntaxKind.CloseBracketToken || + (token.kind === SyntaxKind.WhileKeyword && this._parent.node().kind == SyntaxKind.DoStatement)) { return this._parent.indentationAmount(); } @@ -161,7 +161,7 @@ module TypeScript.Services.Formatting { // If this is token terminating an indentation scope, leading comments should be indented to follow the children // indentation level and not the node - if (token.kind() === SyntaxKind.CloseBraceToken || token.kind() === SyntaxKind.CloseBracketToken) { + if (token.kind === SyntaxKind.CloseBraceToken || token.kind === SyntaxKind.CloseBracketToken) { return (this._parent.indentationAmount() + this._parent.childIndentationAmountDelta()); } return this._parent.indentationAmount(); @@ -213,7 +213,7 @@ module TypeScript.Services.Formatting { var indentationAmountDelta: number; var parentNode = parent.node(); - switch (node.kind()) { + switch (node.kind) { default: // General case // This node should follow the child indentation set by its parent diff --git a/src/services/formatting/multipleTokenIndenter.ts b/src/services/formatting/multipleTokenIndenter.ts index 23181571427..9297db96635 100644 --- a/src/services/formatting/multipleTokenIndenter.ts +++ b/src/services/formatting/multipleTokenIndenter.ts @@ -119,7 +119,7 @@ module TypeScript.Services.Formatting { } - if (token.kind() !== SyntaxKind.EndOfFileToken && indentNextTokenOrTrivia) { + if (token.kind !== SyntaxKind.EndOfFileToken && indentNextTokenOrTrivia) { // If the last trivia item was a new line, or no trivia items were encounterd record the // indentation edit at the token position if (indentationString.length > 0) { diff --git a/src/services/resources/diagnosticCode.generated.ts b/src/services/resources/diagnosticCode.generated.ts index 26df20b428d..838879b55bc 100644 --- a/src/services/resources/diagnosticCode.generated.ts +++ b/src/services/resources/diagnosticCode.generated.ts @@ -13,7 +13,6 @@ module TypeScript { Automatic_semicolon_insertion_not_allowed: "Automatic semicolon insertion not allowed.", Unexpected_token_0_expected: "Unexpected token; '{0}' expected.", Trailing_comma_not_allowed: "Trailing comma not allowed.", - AsteriskSlash_expected: "'*/' expected.", public_or_private_modifier_must_precede_static: "'public' or 'private' modifier must precede 'static'.", Unexpected_token: "Unexpected token.", Catch_clause_parameter_cannot_have_a_type_annotation: "Catch clause parameter cannot have a type annotation.", @@ -95,6 +94,7 @@ module TypeScript { return_statement_must_be_contained_within_a_function_body: "'return' statement must be contained within a function body.", Expression_expected: "Expression expected.", Type_expected: "Type expected.", + Template_literal_cannot_be_used_as_an_element_name: "Template literal cannot be used as an element name.", Duplicate_identifier_0: "Duplicate identifier '{0}'.", The_name_0_does_not_exist_in_the_current_scope: "The name '{0}' does not exist in the current scope.", The_name_0_does_not_refer_to_a_value: "The name '{0}' does not refer to a value.", diff --git a/src/services/resources/diagnosticInformationMap.generated.ts b/src/services/resources/diagnosticInformationMap.generated.ts index 8d3bc73486e..6bf01f5873a 100644 --- a/src/services/resources/diagnosticInformationMap.generated.ts +++ b/src/services/resources/diagnosticInformationMap.generated.ts @@ -96,6 +96,7 @@ module TypeScript { "'return' statement must be contained within a function body.": { "code": 1108, "category": DiagnosticCategory.Error }, "Expression expected.": { "code": 1109, "category": DiagnosticCategory.Error }, "Type expected.": { "code": 1110, "category": DiagnosticCategory.Error }, + "Template literal cannot be used as an element name.": { "code": 1111, "category": DiagnosticCategory.Error }, "Duplicate identifier '{0}'.": { "code": 2000, "category": DiagnosticCategory.Error }, "The name '{0}' does not exist in the current scope.": { "code": 2001, "category": DiagnosticCategory.Error }, "The name '{0}' does not refer to a value.": { "code": 2002, "category": DiagnosticCategory.Error }, diff --git a/src/services/resources/diagnosticMessages.json b/src/services/resources/diagnosticMessages.json index bbca8b3f9ce..95e7f109edf 100644 --- a/src/services/resources/diagnosticMessages.json +++ b/src/services/resources/diagnosticMessages.json @@ -47,10 +47,6 @@ "category": "Error", "code": 1009 }, - "'*/' expected.": { - "category": "Error", - "code": 1010 - }, "'public' or 'private' modifier must precede 'static'.": { "category": "Error", "code": 1011 @@ -375,6 +371,10 @@ "category": "Error", "code": 1110 }, + "Template literal cannot be used as an element name.": { + "category": "Error", + "code": 1111 + }, "Duplicate identifier '{0}'.": { "category": "Error", "code": 2000 diff --git a/src/services/services.ts b/src/services/services.ts index d208eb87e96..a5e9b9de10a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1065,7 +1065,7 @@ module ts { emitOutputStatus: EmitReturnStatus; } - export enum OutputFileType { + export const enum OutputFileType { JavaScript, SourceMap, Declaration @@ -1077,7 +1077,7 @@ module ts { text: string; } - export enum EndOfLineState { + export const enum EndOfLineState { Start, InMultiLineCommentTrivia, InSingleQuoteStringLiteral, @@ -1780,7 +1780,7 @@ module ts { var buckets: Map> = {}; function getKeyFromCompilationSettings(settings: CompilerOptions): string { - return "_" + ScriptTarget[settings.target]; // + "|" + settings.propagateEnumConstantoString() + return "_" + settings.target; // + "|" + settings.propagateEnumConstantoString() } function getBucketForCompilationSettings(settings: CompilerOptions, createIfMissing: boolean): Map { @@ -2028,7 +2028,7 @@ module ts { } } - enum SemanticMeaning { + const enum SemanticMeaning { None = 0x0, Value = 0x1, Type = 0x2, @@ -2036,7 +2036,7 @@ module ts { All = Value | Type | Namespace } - enum BreakContinueSearchType { + const enum BreakContinueSearchType { None = 0x0, Unlabeled = 0x1, Labeled = 0x2, @@ -2335,24 +2335,35 @@ module ts { filename = TypeScript.switchToForwardSlashes(filename); + var syntacticStart = new Date().getTime(); var sourceFile = getSourceFile(filename); + var start = new Date().getTime(); var currentToken = getTokenAtPosition(sourceFile, position); + host.log("getCompletionsAtPosition: Get current token: " + (new Date().getTime() - start)); + var start = new Date().getTime(); // Completion not allowed inside comments, bail out if this is the case - if (isInsideComment(sourceFile, currentToken, position)) { + var insideComment = isInsideComment(sourceFile, currentToken, position); + host.log("getCompletionsAtPosition: Is inside comment: " + (new Date().getTime() - start)); + + if (insideComment) { host.log("Returning an empty list because completion was inside a comment."); return undefined; } // The decision to provide completion depends on the previous token, so find it // Note: previousToken can be undefined if we are the beginning of the file + var start = new Date().getTime(); var previousToken = findPrecedingToken(position, sourceFile); + host.log("getCompletionsAtPosition: Get previous token 1: " + (new Date().getTime() - start)); // The caret is at the end of an identifier; this is a partial identifier that we want to complete: e.g. a.toS| // Skip this partial identifier to the previous token if (previousToken && position <= previousToken.end && previousToken.kind === SyntaxKind.Identifier) { + var start = new Date().getTime(); previousToken = findPrecedingToken(previousToken.pos, sourceFile); + host.log("getCompletionsAtPosition: Get previous token 2: " + (new Date().getTime() - start)); } // Check if this is a valid completion location @@ -2383,8 +2394,10 @@ module ts { symbols: {}, typeChecker: typeInfoResolver }; + host.log("getCompletionsAtPosition: Syntactic work: " + (new Date().getTime() - syntacticStart)); // Populate the completion list + var semanticStart = new Date().getTime(); if (isRightOfDot) { // Right of dot member completion list var symbols: Symbol[] = []; @@ -2454,6 +2467,7 @@ module ts { if (!isMemberCompletion) { Array.prototype.push.apply(activeCompletionSession.entries, keywordCompletions); } + host.log("getCompletionsAtPosition: Semantic work: " + (new Date().getTime() - semanticStart)); return { isMemberCompletion: isMemberCompletion, @@ -2461,6 +2475,7 @@ module ts { }; function getCompletionEntriesFromSymbols(symbols: Symbol[], session: CompletionSession): void { + var start = new Date().getTime(); forEach(symbols, symbol => { var entry = createCompletionEntry(symbol, session.typeChecker); if (entry && !lookUp(session.symbols, entry.name)) { @@ -2468,12 +2483,16 @@ module ts { session.symbols[entry.name] = symbol; } }); + host.log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - semanticStart)); } function isCompletionListBlocker(previousToken: Node): boolean { - return isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || + var start = new Date().getTime(); + var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) || isIdentifierDefinitionLocation(previousToken) || isRightOfIllegalDot(previousToken); + host.log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - semanticStart)); + return result; } function isInStringOrRegularExpressionOrTemplateLiteral(previousToken: Node): boolean { @@ -4572,7 +4591,7 @@ module ts { if ((node).name.kind === SyntaxKind.StringLiteral) { return SemanticMeaning.Namespace | SemanticMeaning.Value; } - else if (isInstantiated(node)) { + else if (getModuleInstanceState(node) === ModuleInstanceState.Instantiated) { return SemanticMeaning.Namespace | SemanticMeaning.Value; } else { @@ -4849,7 +4868,7 @@ module ts { */ function hasValueSideModule(symbol: Symbol): boolean { return forEach(symbol.declarations, declaration => { - return declaration.kind === SyntaxKind.ModuleDeclaration && isInstantiated(declaration); + return declaration.kind === SyntaxKind.ModuleDeclaration && getModuleInstanceState(declaration) == ModuleInstanceState.Instantiated; }); } } @@ -5135,9 +5154,17 @@ module ts { } function getTodoComments(filename: string, descriptors: TodoCommentDescriptor[]): TodoComment[] { + // Note: while getting todo comments seems like a syntactic operation, we actually + // treat it as a semantic operation here. This is because we expect our host to call + // this on every single file. If we treat this syntactically, then that will cause + // us to populate and throw away the tree in our syntax tree cache for each file. By + // treating this as a semantic operation, we can access any tree without throwing + // anything away. + synchronizeHostData(); + filename = TypeScript.switchToForwardSlashes(filename); - var sourceFile = getCurrentSourceFile(filename); + var sourceFile = getSourceFile(filename); cancellationToken.throwIfCancellationRequested(); diff --git a/src/services/shims.ts b/src/services/shims.ts index a6bf421b095..b93c699be73 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -171,13 +171,13 @@ module ts { } /// TODO: delete this, it is only needed until the VS interface is updated - export enum LanguageVersion { + export const enum LanguageVersion { EcmaScript3 = 0, EcmaScript5 = 1, EcmaScript6 = 2, } - export enum ModuleGenTarget { + export const enum ModuleGenTarget { Unspecified = 0, Synchronous = 1, Asynchronous = 2, diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index f0b4ddc5ef7..41f64c1b8db 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -244,7 +244,7 @@ module ts.SignatureHelp { // If the node is not a subspan of its parent, this is a big problem. // There have been crashes that might be caused by this violation. if (n.pos < n.parent.pos || n.end > n.parent.end) { - Debug.fail("Node of kind " + SyntaxKind[n.kind] + " is not a subspan of its parent of kind " + SyntaxKind[n.parent.kind]); + Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); } var argumentInfo = getImmediatelyContainingArgumentInfo(n); diff --git a/src/services/syntax/SyntaxGenerator.js b/src/services/syntax/SyntaxGenerator.js new file mode 100644 index 00000000000..0da69eec942 --- /dev/null +++ b/src/services/syntax/SyntaxGenerator.js @@ -0,0 +1,2304 @@ +var sys = (function () { + function getWScriptSystem() { + var fso = new ActiveXObject("Scripting.FileSystemObject"); + var fileStream = new ActiveXObject("ADODB.Stream"); + fileStream.Type = 2; + var binaryStream = new ActiveXObject("ADODB.Stream"); + binaryStream.Type = 1; + var args = []; + for (var i = 0; i < WScript.Arguments.length; i++) { + args[i] = WScript.Arguments.Item(i); + } + function readFile(fileName, encoding) { + if (!fso.FileExists(fileName)) { + return undefined; + } + fileStream.Open(); + try { + if (encoding) { + fileStream.Charset = encoding; + fileStream.LoadFromFile(fileName); + } + else { + fileStream.Charset = "x-ansi"; + fileStream.LoadFromFile(fileName); + var bom = fileStream.ReadText(2) || ""; + fileStream.Position = 0; + fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; + } + return fileStream.ReadText(); + } + catch (e) { + throw e; + } + finally { + fileStream.Close(); + } + } + function writeFile(fileName, data, writeByteOrderMark) { + fileStream.Open(); + binaryStream.Open(); + try { + fileStream.Charset = "utf-8"; + fileStream.WriteText(data); + if (writeByteOrderMark) { + fileStream.Position = 0; + } + else { + fileStream.Position = 3; + } + fileStream.CopyTo(binaryStream); + binaryStream.SaveToFile(fileName, 2); + } + finally { + binaryStream.Close(); + fileStream.Close(); + } + } + return { + args: args, + newLine: "\r\n", + useCaseSensitiveFileNames: false, + write: function (s) { + WScript.StdOut.Write(s); + }, + readFile: readFile, + writeFile: writeFile, + resolvePath: function (path) { + return fso.GetAbsolutePathName(path); + }, + fileExists: function (path) { + return fso.FileExists(path); + }, + directoryExists: function (path) { + return fso.FolderExists(path); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + fso.CreateFolder(directoryName); + } + }, + getExecutingFilePath: function () { + return WScript.ScriptFullName; + }, + getCurrentDirectory: function () { + return new ActiveXObject("WScript.Shell").CurrentDirectory; + }, + exit: function (exitCode) { + try { + WScript.Quit(exitCode); + } + catch (e) { + } + } + }; + } + function getNodeSystem() { + var _fs = require("fs"); + var _path = require("path"); + var _os = require('os'); + var platform = _os.platform(); + var useCaseSensitiveFileNames = platform !== "win32" && platform !== "win64" && platform !== "darwin"; + function readFile(fileName, encoding) { + if (!_fs.existsSync(fileName)) { + return undefined; + } + var buffer = _fs.readFileSync(fileName); + var len = buffer.length; + if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { + len &= ~1; + for (var i = 0; i < len; i += 2) { + var temp = buffer[i]; + buffer[i] = buffer[i + 1]; + buffer[i + 1] = temp; + } + return buffer.toString("utf16le", 2); + } + if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) { + return buffer.toString("utf16le", 2); + } + if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) { + return buffer.toString("utf8", 3); + } + return buffer.toString("utf8"); + } + function writeFile(fileName, data, writeByteOrderMark) { + if (writeByteOrderMark) { + data = '\uFEFF' + data; + } + _fs.writeFileSync(fileName, data, "utf8"); + } + return { + args: process.argv.slice(2), + newLine: _os.EOL, + useCaseSensitiveFileNames: useCaseSensitiveFileNames, + write: function (s) { + _fs.writeSync(1, s); + }, + readFile: readFile, + writeFile: writeFile, + watchFile: function (fileName, callback) { + _fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged); + return { + close: function () { + _fs.unwatchFile(fileName, fileChanged); + } + }; + function fileChanged(curr, prev) { + if (+curr.mtime <= +prev.mtime) { + return; + } + callback(fileName); + } + ; + }, + resolvePath: function (path) { + return _path.resolve(path); + }, + fileExists: function (path) { + return _fs.existsSync(path); + }, + directoryExists: function (path) { + return _fs.existsSync(path) && _fs.statSync(path).isDirectory(); + }, + createDirectory: function (directoryName) { + if (!this.directoryExists(directoryName)) { + _fs.mkdirSync(directoryName); + } + }, + getExecutingFilePath: function () { + return process.mainModule.filename; + }, + getCurrentDirectory: function () { + return process.cwd(); + }, + getMemoryUsage: function () { + if (global.gc) { + global.gc(); + } + return process.memoryUsage().heapUsed; + }, + exit: function (exitCode) { + process.exit(exitCode); + } + }; + } + if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { + return getWScriptSystem(); + } + else if (typeof module !== "undefined" && module.exports) { + return getNodeSystem(); + } + else { + return undefined; + } +})(); +var TypeScript; +(function (TypeScript) { + var Errors = (function () { + function Errors() { + } + Errors.argument = function (argument, message) { + return new Error("Invalid argument: " + argument + ". " + message); + }; + Errors.argumentOutOfRange = function (argument) { + return new Error("Argument out of range: " + argument); + }; + Errors.argumentNull = function (argument) { + return new Error("Argument null: " + argument); + }; + Errors.abstract = function () { + return new Error("Operation not implemented properly by subclass."); + }; + Errors.notYetImplemented = function () { + return new Error("Not yet implemented."); + }; + Errors.invalidOperation = function (message) { + return new Error("Invalid operation: " + message); + }; + return Errors; + })(); + TypeScript.Errors = Errors; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var ArrayUtilities = (function () { + function ArrayUtilities() { + } + ArrayUtilities.sequenceEquals = function (array1, array2, equals) { + if (array1 === array2) { + return true; + } + if (!array1 || !array2) { + return false; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0, n = array1.length; i < n; i++) { + if (!equals(array1[i], array2[i])) { + return false; + } + } + return true; + }; + ArrayUtilities.contains = function (array, value) { + for (var i = 0; i < array.length; i++) { + if (array[i] === value) { + return true; + } + } + return false; + }; + ArrayUtilities.distinct = function (array, equalsFn) { + var result = []; + for (var i = 0, n = array.length; i < n; i++) { + var current = array[i]; + for (var j = 0; j < result.length; j++) { + if (equalsFn(result[j], current)) { + break; + } + } + if (j === result.length) { + result.push(current); + } + } + return result; + }; + ArrayUtilities.last = function (array) { + if (array.length === 0) { + throw TypeScript.Errors.argumentOutOfRange('array'); + } + return array[array.length - 1]; + }; + ArrayUtilities.lastOrDefault = function (array, predicate) { + for (var i = array.length - 1; i >= 0; i--) { + var v = array[i]; + if (predicate(v, i)) { + return v; + } + } + return undefined; + }; + ArrayUtilities.firstOrDefault = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (func(value, i)) { + return value; + } + } + return undefined; + }; + ArrayUtilities.first = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + var value = array[i]; + if (!func || func(value, i)) { + return value; + } + } + throw TypeScript.Errors.invalidOperation(); + }; + ArrayUtilities.sum = function (array, func) { + var result = 0; + for (var i = 0, n = array.length; i < n; i++) { + result += func(array[i]); + } + return result; + }; + ArrayUtilities.select = function (values, func) { + var result = new Array(values.length); + for (var i = 0; i < values.length; i++) { + result[i] = func(values[i]); + } + return result; + }; + ArrayUtilities.where = function (values, func) { + var result = new Array(); + for (var i = 0; i < values.length; i++) { + if (func(values[i])) { + result.push(values[i]); + } + } + return result; + }; + ArrayUtilities.any = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (func(array[i])) { + return true; + } + } + return false; + }; + ArrayUtilities.all = function (array, func) { + for (var i = 0, n = array.length; i < n; i++) { + if (!func(array[i])) { + return false; + } + } + return true; + }; + ArrayUtilities.binarySearch = function (array, value) { + var low = 0; + var high = array.length - 1; + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midValue = array[middle]; + if (midValue === value) { + return middle; + } + else if (midValue > value) { + high = middle - 1; + } + else { + low = middle + 1; + } + } + return ~low; + }; + ArrayUtilities.createArray = function (length, defaultValue) { + var result = new Array(length); + for (var i = 0; i < length; i++) { + result[i] = defaultValue; + } + return result; + }; + ArrayUtilities.grow = function (array, length, defaultValue) { + var count = length - array.length; + for (var i = 0; i < count; i++) { + array.push(defaultValue); + } + }; + ArrayUtilities.copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) { + for (var i = 0; i < length; i++) { + destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i]; + } + }; + ArrayUtilities.indexOf = function (array, predicate) { + for (var i = 0, n = array.length; i < n; i++) { + if (predicate(array[i])) { + return i; + } + } + return -1; + }; + return ArrayUtilities; + })(); + TypeScript.ArrayUtilities = ArrayUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var StringUtilities = (function () { + function StringUtilities() { + } + StringUtilities.isString = function (value) { + return Object.prototype.toString.apply(value, []) === '[object String]'; + }; + StringUtilities.endsWith = function (string, value) { + return string.substring(string.length - value.length, string.length) === value; + }; + StringUtilities.startsWith = function (string, value) { + return string.substr(0, value.length) === value; + }; + StringUtilities.repeat = function (value, count) { + return Array(count + 1).join(value); + }; + return StringUtilities; + })(); + TypeScript.StringUtilities = StringUtilities; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["None"] = 0] = "None"; + SyntaxKind[SyntaxKind["List"] = 1] = "List"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 2] = "WhitespaceTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 3] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 4] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 5] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["SkippedTokenTrivia"] = 6] = "SkippedTokenTrivia"; + SyntaxKind[SyntaxKind["ErrorToken"] = 7] = "ErrorToken"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 8] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["IdentifierName"] = 9] = "IdentifierName"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 10] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 12] = "StringLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateToken"] = 13] = "NoSubstitutionTemplateToken"; + SyntaxKind[SyntaxKind["TemplateStartToken"] = 14] = "TemplateStartToken"; + SyntaxKind[SyntaxKind["TemplateMiddleToken"] = 15] = "TemplateMiddleToken"; + SyntaxKind[SyntaxKind["TemplateEndToken"] = 16] = "TemplateEndToken"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 17] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 18] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 19] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 20] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 21] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 22] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 23] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 24] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 25] = "ElseKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 26] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 27] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 28] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 29] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 30] = "IfKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 31] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 32] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 33] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 34] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 35] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 36] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 37] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 38] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 39] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 40] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 41] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 42] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 43] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 44] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 45] = "WithKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 46] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 47] = "ConstKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 48] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 49] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 50] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 51] = "ImportKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 52] = "SuperKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 53] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 54] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 55] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 56] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 57] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 58] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 59] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 60] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 61] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 62] = "AnyKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 63] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 64] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 65] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 66] = "GetKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 67] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 68] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 69] = "NumberKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 70] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 71] = "StringKeyword"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 72] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 73] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 74] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 75] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 76] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 77] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 78] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 79] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 80] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 81] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 82] = "LessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 83] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 84] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 85] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 86] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 87] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 88] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 89] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 90] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 91] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 92] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 93] = "AsteriskToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 94] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 95] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 96] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 97] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 98] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 99] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 100] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 101] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 102] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 103] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 104] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 105] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 106] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 107] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 108] = "ColonToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 109] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 110] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 111] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 112] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 113] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 114] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 115] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 116] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 117] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 118] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 119] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 120] = "SlashToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 121] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["SourceUnit"] = 122] = "SourceUnit"; + SyntaxKind[SyntaxKind["QualifiedName"] = 123] = "QualifiedName"; + SyntaxKind[SyntaxKind["ObjectType"] = 124] = "ObjectType"; + SyntaxKind[SyntaxKind["FunctionType"] = 125] = "FunctionType"; + SyntaxKind[SyntaxKind["ArrayType"] = 126] = "ArrayType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 127] = "ConstructorType"; + SyntaxKind[SyntaxKind["GenericType"] = 128] = "GenericType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 129] = "TypeQuery"; + SyntaxKind[SyntaxKind["TupleType"] = 130] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 131] = "UnionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 132] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 133] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 134] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 135] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 136] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 137] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 138] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 139] = "ExportAssignment"; + SyntaxKind[SyntaxKind["MemberFunctionDeclaration"] = 140] = "MemberFunctionDeclaration"; + SyntaxKind[SyntaxKind["MemberVariableDeclaration"] = 141] = "MemberVariableDeclaration"; + SyntaxKind[SyntaxKind["ConstructorDeclaration"] = 142] = "ConstructorDeclaration"; + SyntaxKind[SyntaxKind["IndexMemberDeclaration"] = 143] = "IndexMemberDeclaration"; + SyntaxKind[SyntaxKind["GetAccessor"] = 144] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 145] = "SetAccessor"; + SyntaxKind[SyntaxKind["PropertySignature"] = 146] = "PropertySignature"; + SyntaxKind[SyntaxKind["CallSignature"] = 147] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 148] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 149] = "IndexSignature"; + SyntaxKind[SyntaxKind["MethodSignature"] = 150] = "MethodSignature"; + SyntaxKind[SyntaxKind["Block"] = 151] = "Block"; + SyntaxKind[SyntaxKind["IfStatement"] = 152] = "IfStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 153] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 154] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 155] = "ReturnStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 156] = "SwitchStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 157] = "BreakStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 158] = "ContinueStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 159] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 160] = "ForInStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 161] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 162] = "ThrowStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 163] = "WhileStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 164] = "TryStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 165] = "LabeledStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 166] = "DoStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 167] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 168] = "WithStatement"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 169] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 170] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 171] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 172] = "VoidExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 173] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 174] = "BinaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 175] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["MemberAccessExpression"] = 176] = "MemberAccessExpression"; + SyntaxKind[SyntaxKind["InvocationExpression"] = 177] = "InvocationExpression"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 178] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 179] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectCreationExpression"] = 180] = "ObjectCreationExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 181] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["ParenthesizedArrowFunctionExpression"] = 182] = "ParenthesizedArrowFunctionExpression"; + SyntaxKind[SyntaxKind["SimpleArrowFunctionExpression"] = 183] = "SimpleArrowFunctionExpression"; + SyntaxKind[SyntaxKind["CastExpression"] = 184] = "CastExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 185] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 186] = "FunctionExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 187] = "OmittedExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 188] = "TemplateExpression"; + SyntaxKind[SyntaxKind["TemplateAccessExpression"] = 189] = "TemplateAccessExpression"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 190] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarator"] = 191] = "VariableDeclarator"; + SyntaxKind[SyntaxKind["ArgumentList"] = 192] = "ArgumentList"; + SyntaxKind[SyntaxKind["ParameterList"] = 193] = "ParameterList"; + SyntaxKind[SyntaxKind["TypeArgumentList"] = 194] = "TypeArgumentList"; + SyntaxKind[SyntaxKind["TypeParameterList"] = 195] = "TypeParameterList"; + SyntaxKind[SyntaxKind["HeritageClause"] = 196] = "HeritageClause"; + SyntaxKind[SyntaxKind["EqualsValueClause"] = 197] = "EqualsValueClause"; + SyntaxKind[SyntaxKind["CaseSwitchClause"] = 198] = "CaseSwitchClause"; + SyntaxKind[SyntaxKind["DefaultSwitchClause"] = 199] = "DefaultSwitchClause"; + SyntaxKind[SyntaxKind["ElseClause"] = 200] = "ElseClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 201] = "CatchClause"; + SyntaxKind[SyntaxKind["FinallyClause"] = 202] = "FinallyClause"; + SyntaxKind[SyntaxKind["TemplateClause"] = 203] = "TemplateClause"; + SyntaxKind[SyntaxKind["TypeParameter"] = 204] = "TypeParameter"; + SyntaxKind[SyntaxKind["Constraint"] = 205] = "Constraint"; + SyntaxKind[SyntaxKind["SimplePropertyAssignment"] = 206] = "SimplePropertyAssignment"; + SyntaxKind[SyntaxKind["FunctionPropertyAssignment"] = 207] = "FunctionPropertyAssignment"; + SyntaxKind[SyntaxKind["Parameter"] = 208] = "Parameter"; + SyntaxKind[SyntaxKind["EnumElement"] = 209] = "EnumElement"; + SyntaxKind[SyntaxKind["TypeAnnotation"] = 210] = "TypeAnnotation"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 211] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ModuleNameModuleReference"] = 212] = "ModuleNameModuleReference"; + SyntaxKind[SyntaxKind["FirstStandardKeyword"] = SyntaxKind.BreakKeyword] = "FirstStandardKeyword"; + SyntaxKind[SyntaxKind["LastStandardKeyword"] = SyntaxKind.WithKeyword] = "LastStandardKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedKeyword"] = SyntaxKind.ClassKeyword] = "FirstFutureReservedKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedKeyword"] = SyntaxKind.SuperKeyword] = "LastFutureReservedKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedStrictKeyword"] = SyntaxKind.ImplementsKeyword] = "FirstFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["LastFutureReservedStrictKeyword"] = SyntaxKind.YieldKeyword] = "LastFutureReservedStrictKeyword"; + SyntaxKind[SyntaxKind["FirstTypeScriptKeyword"] = SyntaxKind.AnyKeyword] = "FirstTypeScriptKeyword"; + SyntaxKind[SyntaxKind["LastTypeScriptKeyword"] = SyntaxKind.StringKeyword] = "LastTypeScriptKeyword"; + SyntaxKind[SyntaxKind["FirstKeyword"] = SyntaxKind.FirstStandardKeyword] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = SyntaxKind.LastTypeScriptKeyword] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstToken"] = SyntaxKind.ErrorToken] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = SyntaxKind.SlashEqualsToken] = "LastToken"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = SyntaxKind.OpenBraceToken] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = SyntaxKind.SlashEqualsToken] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstFixedWidth"] = SyntaxKind.FirstKeyword] = "FirstFixedWidth"; + SyntaxKind[SyntaxKind["LastFixedWidth"] = SyntaxKind.LastPunctuation] = "LastFixedWidth"; + SyntaxKind[SyntaxKind["FirstTrivia"] = SyntaxKind.WhitespaceTrivia] = "FirstTrivia"; + SyntaxKind[SyntaxKind["LastTrivia"] = SyntaxKind.SkippedTokenTrivia] = "LastTrivia"; + SyntaxKind[SyntaxKind["FirstNode"] = SyntaxKind.SourceUnit] = "FirstNode"; + SyntaxKind[SyntaxKind["LastNode"] = SyntaxKind.ModuleNameModuleReference] = "LastNode"; + })(TypeScript.SyntaxKind || (TypeScript.SyntaxKind = {})); + var SyntaxKind = TypeScript.SyntaxKind; +})(TypeScript || (TypeScript = {})); +var TypeScript; +(function (TypeScript) { + var SyntaxFacts; + (function (SyntaxFacts) { + var textToKeywordKind = { + "any": 62 /* AnyKeyword */, + "boolean": 63 /* BooleanKeyword */, + "break": 17 /* BreakKeyword */, + "case": 18 /* CaseKeyword */, + "catch": 19 /* CatchKeyword */, + "class": 46 /* ClassKeyword */, + "continue": 20 /* ContinueKeyword */, + "const": 47 /* ConstKeyword */, + "constructor": 64 /* ConstructorKeyword */, + "debugger": 21 /* DebuggerKeyword */, + "declare": 65 /* DeclareKeyword */, + "default": 22 /* DefaultKeyword */, + "delete": 23 /* DeleteKeyword */, + "do": 24 /* DoKeyword */, + "else": 25 /* ElseKeyword */, + "enum": 48 /* EnumKeyword */, + "export": 49 /* ExportKeyword */, + "extends": 50 /* ExtendsKeyword */, + "false": 26 /* FalseKeyword */, + "finally": 27 /* FinallyKeyword */, + "for": 28 /* ForKeyword */, + "function": 29 /* FunctionKeyword */, + "get": 66 /* GetKeyword */, + "if": 30 /* IfKeyword */, + "implements": 53 /* ImplementsKeyword */, + "import": 51 /* ImportKeyword */, + "in": 31 /* InKeyword */, + "instanceof": 32 /* InstanceOfKeyword */, + "interface": 54 /* InterfaceKeyword */, + "let": 55 /* LetKeyword */, + "module": 67 /* ModuleKeyword */, + "new": 33 /* NewKeyword */, + "null": 34 /* NullKeyword */, + "number": 69 /* NumberKeyword */, + "package": 56 /* PackageKeyword */, + "private": 57 /* PrivateKeyword */, + "protected": 58 /* ProtectedKeyword */, + "public": 59 /* PublicKeyword */, + "require": 68 /* RequireKeyword */, + "return": 35 /* ReturnKeyword */, + "set": 70 /* SetKeyword */, + "static": 60 /* StaticKeyword */, + "string": 71 /* StringKeyword */, + "super": 52 /* SuperKeyword */, + "switch": 36 /* SwitchKeyword */, + "this": 37 /* ThisKeyword */, + "throw": 38 /* ThrowKeyword */, + "true": 39 /* TrueKeyword */, + "try": 40 /* TryKeyword */, + "typeof": 41 /* TypeOfKeyword */, + "var": 42 /* VarKeyword */, + "void": 43 /* VoidKeyword */, + "while": 44 /* WhileKeyword */, + "with": 45 /* WithKeyword */, + "yield": 61 /* YieldKeyword */, + "{": 72 /* OpenBraceToken */, + "}": 73 /* CloseBraceToken */, + "(": 74 /* OpenParenToken */, + ")": 75 /* CloseParenToken */, + "[": 76 /* OpenBracketToken */, + "]": 77 /* CloseBracketToken */, + ".": 78 /* DotToken */, + "...": 79 /* DotDotDotToken */, + ";": 80 /* SemicolonToken */, + ",": 81 /* CommaToken */, + "<": 82 /* LessThanToken */, + ">": 83 /* GreaterThanToken */, + "<=": 84 /* LessThanEqualsToken */, + ">=": 85 /* GreaterThanEqualsToken */, + "==": 86 /* EqualsEqualsToken */, + "=>": 87 /* EqualsGreaterThanToken */, + "!=": 88 /* ExclamationEqualsToken */, + "===": 89 /* EqualsEqualsEqualsToken */, + "!==": 90 /* ExclamationEqualsEqualsToken */, + "+": 91 /* PlusToken */, + "-": 92 /* MinusToken */, + "*": 93 /* AsteriskToken */, + "%": 94 /* PercentToken */, + "++": 95 /* PlusPlusToken */, + "--": 96 /* MinusMinusToken */, + "<<": 97 /* LessThanLessThanToken */, + ">>": 98 /* GreaterThanGreaterThanToken */, + ">>>": 99 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 100 /* AmpersandToken */, + "|": 101 /* BarToken */, + "^": 102 /* CaretToken */, + "!": 103 /* ExclamationToken */, + "~": 104 /* TildeToken */, + "&&": 105 /* AmpersandAmpersandToken */, + "||": 106 /* BarBarToken */, + "?": 107 /* QuestionToken */, + ":": 108 /* ColonToken */, + "=": 109 /* EqualsToken */, + "+=": 110 /* PlusEqualsToken */, + "-=": 111 /* MinusEqualsToken */, + "*=": 112 /* AsteriskEqualsToken */, + "%=": 113 /* PercentEqualsToken */, + "<<=": 114 /* LessThanLessThanEqualsToken */, + ">>=": 115 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 117 /* AmpersandEqualsToken */, + "|=": 118 /* BarEqualsToken */, + "^=": 119 /* CaretEqualsToken */, + "/": 120 /* SlashToken */, + "/=": 121 /* SlashEqualsToken */ + }; + var kindToText = new Array(); + for (var name in textToKeywordKind) { + if (textToKeywordKind.hasOwnProperty(name)) { + kindToText[textToKeywordKind[name]] = name; + } + } + kindToText[64 /* ConstructorKeyword */] = "constructor"; + function getTokenKind(text) { + if (textToKeywordKind.hasOwnProperty(text)) { + return textToKeywordKind[text]; + } + return 0 /* None */; + } + SyntaxFacts.getTokenKind = getTokenKind; + function getText(kind) { + var result = kindToText[kind]; + return result; + } + SyntaxFacts.getText = getText; + function isAnyKeyword(kind) { + return kind >= TypeScript.SyntaxKind.FirstKeyword && kind <= TypeScript.SyntaxKind.LastKeyword; + } + SyntaxFacts.isAnyKeyword = isAnyKeyword; + function isAnyPunctuation(kind) { + return kind >= TypeScript.SyntaxKind.FirstPunctuation && kind <= TypeScript.SyntaxKind.LastPunctuation; + } + SyntaxFacts.isAnyPunctuation = isAnyPunctuation; + function isPrefixUnaryExpressionOperatorToken(tokenKind) { + switch (tokenKind) { + case 91 /* PlusToken */: + case 92 /* MinusToken */: + case 104 /* TildeToken */: + case 103 /* ExclamationToken */: + case 95 /* PlusPlusToken */: + case 96 /* MinusMinusToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isPrefixUnaryExpressionOperatorToken = isPrefixUnaryExpressionOperatorToken; + function isBinaryExpressionOperatorToken(tokenKind) { + switch (tokenKind) { + case 93 /* AsteriskToken */: + case 120 /* SlashToken */: + case 94 /* PercentToken */: + case 91 /* PlusToken */: + case 92 /* MinusToken */: + case 97 /* LessThanLessThanToken */: + case 98 /* GreaterThanGreaterThanToken */: + case 99 /* GreaterThanGreaterThanGreaterThanToken */: + case 82 /* LessThanToken */: + case 83 /* GreaterThanToken */: + case 84 /* LessThanEqualsToken */: + case 85 /* GreaterThanEqualsToken */: + case 32 /* InstanceOfKeyword */: + case 31 /* InKeyword */: + case 86 /* EqualsEqualsToken */: + case 88 /* ExclamationEqualsToken */: + case 89 /* EqualsEqualsEqualsToken */: + case 90 /* ExclamationEqualsEqualsToken */: + case 100 /* AmpersandToken */: + case 102 /* CaretToken */: + case 101 /* BarToken */: + case 105 /* AmpersandAmpersandToken */: + case 106 /* BarBarToken */: + case 118 /* BarEqualsToken */: + case 117 /* AmpersandEqualsToken */: + case 119 /* CaretEqualsToken */: + case 114 /* LessThanLessThanEqualsToken */: + case 115 /* GreaterThanGreaterThanEqualsToken */: + case 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 110 /* PlusEqualsToken */: + case 111 /* MinusEqualsToken */: + case 112 /* AsteriskEqualsToken */: + case 121 /* SlashEqualsToken */: + case 113 /* PercentEqualsToken */: + case 109 /* EqualsToken */: + case 81 /* CommaToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isBinaryExpressionOperatorToken = isBinaryExpressionOperatorToken; + function isAssignmentOperatorToken(tokenKind) { + switch (tokenKind) { + case 118 /* BarEqualsToken */: + case 117 /* AmpersandEqualsToken */: + case 119 /* CaretEqualsToken */: + case 114 /* LessThanLessThanEqualsToken */: + case 115 /* GreaterThanGreaterThanEqualsToken */: + case 116 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 110 /* PlusEqualsToken */: + case 111 /* MinusEqualsToken */: + case 112 /* AsteriskEqualsToken */: + case 121 /* SlashEqualsToken */: + case 113 /* PercentEqualsToken */: + case 109 /* EqualsToken */: + return true; + default: + return false; + } + } + SyntaxFacts.isAssignmentOperatorToken = isAssignmentOperatorToken; + function isType(kind) { + switch (kind) { + case 126 /* ArrayType */: + case 62 /* AnyKeyword */: + case 69 /* NumberKeyword */: + case 63 /* BooleanKeyword */: + case 71 /* StringKeyword */: + case 43 /* VoidKeyword */: + case 125 /* FunctionType */: + case 124 /* ObjectType */: + case 127 /* ConstructorType */: + case 129 /* TypeQuery */: + case 128 /* GenericType */: + case 123 /* QualifiedName */: + case 9 /* IdentifierName */: + return true; + } + return false; + } + SyntaxFacts.isType = isType; + })(SyntaxFacts = TypeScript.SyntaxFacts || (TypeScript.SyntaxFacts = {})); +})(TypeScript || (TypeScript = {})); +var forPrettyPrinter = false; +var interfaces = { + IMemberDeclarationSyntax: 'IClassElementSyntax', + IStatementSyntax: 'IModuleElementSyntax', + INameSyntax: 'ITypeSyntax', + IUnaryExpressionSyntax: 'IExpressionSyntax', + IPostfixExpressionSyntax: 'IUnaryExpressionSyntax', + ILeftHandSideExpressionSyntax: 'IPostfixExpressionSyntax', + IMemberExpressionSyntax: 'ILeftHandSideExpressionSyntax', + ICallExpressionSyntax: 'ILeftHandSideExpressionSyntax', + IPrimaryExpressionSyntax: 'IMemberExpressionSyntax' +}; +var definitions = [ + { + name: 'SourceUnitSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'moduleElements', isList: true, elementType: 'IModuleElementSyntax' }, + { name: 'endOfFileToken', isToken: true } + ] + }, + { + name: 'ExternalModuleReferenceSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IModuleReferenceSyntax'], + children: [ + { name: 'requireKeyword', isToken: true, tokenKinds: ['RequireKeyword'], excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'stringLiteral', isToken: true, tokenKinds: ['StringLiteral'] }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'ModuleNameModuleReferenceSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IModuleReferenceSyntax'], + children: [ + { name: 'moduleName', type: 'INameSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'ImportDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IModuleElementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'importKeyword', isToken: true, excludeFromAST: true }, + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'equalsToken', isToken: true, excludeFromAST: true }, + { name: 'moduleReference', type: 'IModuleReferenceSyntax' }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'ExportAssignmentSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IModuleElementSyntax'], + children: [ + { name: 'exportKeyword', isToken: true, excludeFromAST: true }, + { name: 'equalsToken', isToken: true, excludeFromAST: true }, + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'ClassDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IModuleElementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'classKeyword', isToken: true, excludeFromAST: true }, + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true }, + { name: 'heritageClauses', isList: true, elementType: 'HeritageClauseSyntax' }, + { name: 'openBraceToken', isToken: true, excludeFromAST: true }, + { name: 'classElements', isList: true, elementType: 'IClassElementSyntax' }, + { name: 'closeBraceToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'InterfaceDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IModuleElementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'interfaceKeyword', isToken: true, excludeFromAST: true }, + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true }, + { name: 'heritageClauses', isList: true, elementType: 'HeritageClauseSyntax' }, + { name: 'body', type: 'ObjectTypeSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'HeritageClauseSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'extendsOrImplementsKeyword', isToken: true }, + { name: 'typeNames', isSeparatedList: true, requiresAtLeastOneItem: true, elementType: 'INameSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'ModuleDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IModuleElementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'moduleKeyword', isToken: true, excludeFromAST: true }, + { name: 'name', type: 'INameSyntax', isOptional: true }, + { name: 'stringLiteral', isToken: true, isOptional: true, tokenKinds: ['StringLiteral'] }, + { name: 'openBraceToken', isToken: true, excludeFromAST: true }, + { name: 'moduleElements', isList: true, elementType: 'IModuleElementSyntax' }, + { name: 'closeBraceToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'FunctionDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true }, + { name: 'functionKeyword', isToken: true, excludeFromAST: true }, + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'callSignature', type: 'CallSignatureSyntax' }, + { name: 'block', type: 'BlockSyntax', isOptional: true }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + }, + { + name: 'VariableStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true }, + { name: 'variableDeclaration', type: 'VariableDeclarationSyntax' }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + }, + { + name: 'VariableDeclarationSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'varKeyword', isToken: true }, + { name: 'variableDeclarators', isSeparatedList: true, requiresAtLeastOneItem: true, elementType: 'VariableDeclaratorSyntax' } + ] + }, + { + name: 'VariableDeclaratorSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'propertyName', isToken: true }, + { name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecific: true }, + { name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true } + ] + }, + { + name: 'EqualsValueClauseSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'equalsToken', isToken: true, excludeFromAST: true }, + { name: 'value', type: 'IExpressionSyntax' } + ] + }, + { + name: 'PrefixUnaryExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IUnaryExpressionSyntax'], + children: [ + { name: 'operatorToken', isToken: true }, + { name: 'operand', type: 'IUnaryExpressionSyntax' } + ] + }, + { + name: 'ArrayLiteralExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPrimaryExpressionSyntax'], + children: [ + { name: 'openBracketToken', isToken: true, excludeFromAST: true }, + { name: 'expressions', isSeparatedList: true, elementType: 'IExpressionSyntax' }, + { name: 'closeBracketToken', isToken: true, excludeFromAST: true } + ] + }, + { + name: 'OmittedExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IExpressionSyntax'], + children: [] + }, + { + name: 'ParenthesizedExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPrimaryExpressionSyntax'], + children: [ + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IExpressionSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true } + ] + }, + { + name: 'SimpleArrowFunctionExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IUnaryExpressionSyntax'], + children: [ + { name: 'parameter', type: 'ParameterSyntax' }, + { name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true }, + { name: 'block', type: 'BlockSyntax', isOptional: true }, + { name: 'expression', type: 'IExpressionSyntax', isOptional: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'ParenthesizedArrowFunctionExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IUnaryExpressionSyntax'], + children: [ + { name: 'callSignature', type: 'CallSignatureSyntax' }, + { name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true }, + { name: 'block', type: 'BlockSyntax', isOptional: true }, + { name: 'expression', type: 'IExpressionSyntax', isOptional: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'QualifiedNameSyntax', + baseType: 'ISyntaxNode', + interfaces: ['INameSyntax'], + children: [ + { name: 'left', type: 'INameSyntax' }, + { name: 'dotToken', isToken: true, excludeFromAST: true }, + { name: 'right', isToken: true, tokenKinds: ['IdentifierName'] } + ], + isTypeScriptSpecific: true + }, + { + name: 'TypeArgumentListSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'lessThanToken', isToken: true }, + { name: 'typeArguments', isSeparatedList: true, elementType: 'ITypeSyntax' }, + { name: 'greaterThanToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'ConstructorTypeSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'newKeyword', isToken: true, excludeFromAST: true }, + { name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true }, + { name: 'parameterList', type: 'ParameterListSyntax' }, + { name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true }, + { name: 'type', type: 'ITypeSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'FunctionTypeSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true }, + { name: 'parameterList', type: 'ParameterListSyntax' }, + { name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true }, + { name: 'type', type: 'ITypeSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'ObjectTypeSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'openBraceToken', isToken: true, excludeFromAST: true }, + { name: 'typeMembers', isSeparatedList: true, elementType: 'ITypeMemberSyntax' }, + { name: 'closeBraceToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'ArrayTypeSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'type', type: 'ITypeSyntax' }, + { name: 'openBracketToken', isToken: true, excludeFromAST: true }, + { name: 'closeBracketToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'GenericTypeSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'name', type: 'INameSyntax' }, + { name: 'typeArgumentList', type: 'TypeArgumentListSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'TypeQuerySyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'typeOfKeyword', isToken: true, excludeFromAST: true }, + { name: 'name', type: 'INameSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'TupleTypeSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'openBracketToken', isToken: true, excludeFromAST: true }, + { name: 'types', isSeparatedList: true, elementType: 'ITypeSyntax' }, + { name: 'closeBracketToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'UnionTypeSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'left', type: 'ITypeSyntax' }, + { name: 'barToken', isToken: true, excludeFromAST: true }, + { name: 'right', type: 'ITypeSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'ParenthesizedTypeSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeSyntax'], + children: [ + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'type', type: 'ITypeSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'TypeAnnotationSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'colonToken', isToken: true, excludeFromAST: true }, + { name: 'type', type: 'ITypeSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'BlockSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'openBraceToken', isToken: true }, + { name: 'statements', isList: true, elementType: 'IStatementSyntax' }, + { name: 'closeBraceToken', isToken: true, excludeFromAST: true } + ] + }, + { + name: 'ParameterSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'dotDotDotToken', isToken: true, isOptional: true, isTypeScriptSpecific: true }, + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'questionToken', isToken: true, isOptional: true, isTypeScriptSpecific: true }, + { name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecific: true }, + { name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true, isTypeScriptSpecific: true } + ] + }, + { + name: 'MemberAccessExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IMemberExpressionSyntax', 'ICallExpressionSyntax'], + children: [ + { name: 'expression', type: 'ILeftHandSideExpressionSyntax' }, + { name: 'dotToken', isToken: true, excludeFromAST: true }, + { name: 'name', isToken: true, tokenKinds: ['IdentifierName'] } + ] + }, + { + name: 'PostfixUnaryExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPostfixExpressionSyntax'], + children: [ + { name: 'operand', type: 'ILeftHandSideExpressionSyntax' }, + { name: 'operatorToken', isToken: true } + ] + }, + { + name: 'ElementAccessExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IMemberExpressionSyntax', 'ICallExpressionSyntax'], + children: [ + { name: 'expression', type: 'ILeftHandSideExpressionSyntax' }, + { name: 'openBracketToken', isToken: true, excludeFromAST: true }, + { name: 'argumentExpression', type: 'IExpressionSyntax' }, + { name: 'closeBracketToken', isToken: true, excludeFromAST: true } + ] + }, + { + name: 'TemplateAccessExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IMemberExpressionSyntax', 'ICallExpressionSyntax'], + children: [ + { name: 'expression', type: 'ILeftHandSideExpressionSyntax' }, + { name: 'templateExpression', type: 'IPrimaryExpressionSyntax' } + ] + }, + { + name: 'TemplateExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPrimaryExpressionSyntax'], + children: [ + { name: 'templateStartToken', isToken: true, excludeFromAST: true }, + { name: 'templateClauses', isList: true, elementType: 'TemplateClauseSyntax' } + ] + }, + { + name: 'TemplateClauseSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'expression', type: 'IExpressionSyntax' }, + { name: 'templateMiddleOrEndToken', isToken: true, elementType: 'TemplateSpanSyntax' } + ] + }, + { + name: 'InvocationExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ICallExpressionSyntax'], + children: [ + { name: 'expression', type: 'ILeftHandSideExpressionSyntax' }, + { name: 'argumentList', type: 'ArgumentListSyntax' } + ] + }, + { + name: 'ArgumentListSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'typeArgumentList', type: 'TypeArgumentListSyntax', isOptional: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'arguments', isSeparatedList: true, elementType: 'IExpressionSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true } + ] + }, + { + name: 'BinaryExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IExpressionSyntax'], + children: [ + { name: 'left', type: 'IExpressionSyntax' }, + { name: 'operatorToken', isToken: true }, + { name: 'right', type: 'IExpressionSyntax' } + ] + }, + { + name: 'ConditionalExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IExpressionSyntax'], + children: [ + { name: 'condition', type: 'IExpressionSyntax' }, + { name: 'questionToken', isToken: true, excludeFromAST: true }, + { name: 'whenTrue', type: 'IExpressionSyntax' }, + { name: 'colonToken', isToken: true, excludeFromAST: true }, + { name: 'whenFalse', type: 'IExpressionSyntax' } + ] + }, + { + name: 'ConstructSignatureSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeMemberSyntax'], + children: [ + { name: 'newKeyword', isToken: true, excludeFromAST: true }, + { name: 'callSignature', type: 'CallSignatureSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'MethodSignatureSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeMemberSyntax'], + children: [ + { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'questionToken', isToken: true, isOptional: true, itTypeScriptSpecific: true }, + { name: 'callSignature', type: 'CallSignatureSyntax' } + ] + }, + { + name: 'IndexSignatureSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeMemberSyntax'], + children: [ + { name: 'openBracketToken', isToken: true }, + { name: 'parameters', isSeparatedList: true, elementType: 'ParameterSyntax' }, + { name: 'closeBracketToken', isToken: true }, + { name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'PropertySignatureSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeMemberSyntax'], + children: [ + { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'questionToken', isToken: true, isOptional: true }, + { name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'CallSignatureSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ITypeMemberSyntax'], + children: [ + { name: 'typeParameterList', type: 'TypeParameterListSyntax', isOptional: true, isTypeScriptSpecific: true }, + { name: 'parameterList', type: 'ParameterListSyntax' }, + { name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecific: true } + ] + }, + { + name: 'ParameterListSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'parameters', isSeparatedList: true, elementType: 'ParameterSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true } + ] + }, + { + name: 'TypeParameterListSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'lessThanToken', isToken: true }, + { name: 'typeParameters', isSeparatedList: true, elementType: 'TypeParameterSyntax' }, + { name: 'greaterThanToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'TypeParameterSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'constraint', type: 'ConstraintSyntax', isOptional: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'ConstraintSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'extendsKeyword', isToken: true, excludeFromAST: true }, + { name: 'typeOrExpression', type: 'ISyntaxNodeOrToken' } + ], + isTypeScriptSpecific: true + }, + { + name: 'ElseClauseSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'elseKeyword', isToken: true, excludeFromAST: true }, + { name: 'statement', type: 'IStatementSyntax' } + ] + }, + { + name: 'IfStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'ifKeyword', isToken: true, excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'condition', type: 'IExpressionSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true }, + { name: 'statement', type: 'IStatementSyntax' }, + { name: 'elseClause', type: 'ElseClauseSyntax', isOptional: true } + ] + }, + { + name: 'ExpressionStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'expression', type: 'IExpressionSyntax' }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + }, + { + name: 'ConstructorDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IClassElementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'constructorKeyword', isToken: true }, + { name: 'callSignature', type: 'CallSignatureSyntax' }, + { name: 'block', type: 'BlockSyntax', isOptional: true }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'MemberFunctionDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IMemberDeclarationSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'callSignature', type: 'CallSignatureSyntax' }, + { name: 'block', type: 'BlockSyntax', isOptional: true }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'GetAccessorSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IMemberDeclarationSyntax', 'IPropertyAssignmentSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true }, + { name: 'getKeyword', isToken: true, excludeFromAST: true }, + { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'callSignature', type: 'CallSignatureSyntax' }, + { name: 'block', type: 'BlockSyntax' } + ] + }, + { + name: 'SetAccessorSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IMemberDeclarationSyntax', 'IPropertyAssignmentSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken', isTypeScriptSpecific: true }, + { name: 'setKeyword', isToken: true, excludeFromAST: true }, + { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'callSignature', type: 'CallSignatureSyntax' }, + { name: 'block', type: 'BlockSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'MemberVariableDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IMemberDeclarationSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'variableDeclarator', type: 'VariableDeclaratorSyntax' }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'IndexMemberDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IClassElementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'indexSignature', type: 'IndexSignatureSyntax' }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'ThrowStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'throwKeyword', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IExpressionSyntax' }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + }, + { + name: 'ReturnStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'returnKeyword', isToken: true }, + { name: 'expression', type: 'IExpressionSyntax', isOptional: true }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + }, + { + name: 'ObjectCreationExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPrimaryExpressionSyntax'], + children: [ + { name: 'newKeyword', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IMemberExpressionSyntax' }, + { name: 'argumentList', type: 'ArgumentListSyntax', isOptional: true } + ] + }, + { + name: 'SwitchStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'switchKeyword', isToken: true, excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IExpressionSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true }, + { name: 'openBraceToken', isToken: true, excludeFromAST: true }, + { name: 'switchClauses', isList: true, elementType: 'ISwitchClauseSyntax' }, + { name: 'closeBraceToken', isToken: true, excludeFromAST: true } + ] + }, + { + name: 'CaseSwitchClauseSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ISwitchClauseSyntax'], + children: [ + { name: 'caseKeyword', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IExpressionSyntax' }, + { name: 'colonToken', isToken: true, excludeFromAST: true }, + { name: 'statements', isList: true, elementType: 'IStatementSyntax' } + ] + }, + { + name: 'DefaultSwitchClauseSyntax', + baseType: 'ISyntaxNode', + interfaces: ['ISwitchClauseSyntax'], + children: [ + { name: 'defaultKeyword', isToken: true, excludeFromAST: true }, + { name: 'colonToken', isToken: true, excludeFromAST: true }, + { name: 'statements', isList: true, elementType: 'IStatementSyntax' } + ] + }, + { + name: 'BreakStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'breakKeyword', isToken: true }, + { name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + }, + { + name: 'ContinueStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'continueKeyword', isToken: true }, + { name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + }, + { + name: 'ForStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'forKeyword', isToken: true, excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'variableDeclaration', type: 'VariableDeclarationSyntax', isOptional: true }, + { name: 'initializer', type: 'IExpressionSyntax', isOptional: true }, + { name: 'firstSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true }, + { name: 'condition', type: 'IExpressionSyntax', isOptional: true }, + { name: 'secondSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true }, + { name: 'incrementor', type: 'IExpressionSyntax', isOptional: true }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true }, + { name: 'statement', type: 'IStatementSyntax' } + ] + }, + { + name: 'ForInStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'forKeyword', isToken: true, excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'variableDeclaration', type: 'VariableDeclarationSyntax', isOptional: true }, + { name: 'left', type: 'IExpressionSyntax', isOptional: true }, + { name: 'inKeyword', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IExpressionSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true }, + { name: 'statement', type: 'IStatementSyntax' } + ] + }, + { + name: 'WhileStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'whileKeyword', isToken: true, excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'condition', type: 'IExpressionSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true }, + { name: 'statement', type: 'IStatementSyntax' } + ] + }, + { + name: 'WithStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'withKeyword', isToken: true, excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'condition', type: 'IExpressionSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true }, + { name: 'statement', type: 'IStatementSyntax' } + ] + }, + { + name: 'EnumDeclarationSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IModuleElementSyntax'], + children: [ + { name: 'modifiers', isList: true, elementType: 'ISyntaxToken' }, + { name: 'enumKeyword', isToken: true, excludeFromAST: true }, + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'openBraceToken', isToken: true, excludeFromAST: true }, + { name: 'enumElements', isSeparatedList: true, elementType: 'EnumElementSyntax' }, + { name: 'closeBraceToken', isToken: true, excludeFromAST: true } + ], + isTypeScriptSpecific: true + }, + { + name: 'EnumElementSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true } + ] + }, + { + name: 'CastExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IUnaryExpressionSyntax'], + children: [ + { name: 'lessThanToken', isToken: true, excludeFromAST: true }, + { name: 'type', type: 'ITypeSyntax' }, + { name: 'greaterThanToken', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IUnaryExpressionSyntax' } + ], + isTypeScriptSpecific: true + }, + { + name: 'ObjectLiteralExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPrimaryExpressionSyntax'], + children: [ + { name: 'openBraceToken', isToken: true, excludeFromAST: true }, + { name: 'propertyAssignments', isSeparatedList: true, elementType: 'IPropertyAssignmentSyntax' }, + { name: 'closeBraceToken', isToken: true, excludeFromAST: true } + ] + }, + { + name: 'SimplePropertyAssignmentSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPropertyAssignmentSyntax'], + children: [ + { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'colonToken', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IExpressionSyntax' } + ] + }, + { + name: 'FunctionPropertyAssignmentSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPropertyAssignmentSyntax'], + children: [ + { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'callSignature', type: 'CallSignatureSyntax' }, + { name: 'block', type: 'BlockSyntax' } + ] + }, + { + name: 'FunctionExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPrimaryExpressionSyntax'], + children: [ + { name: 'functionKeyword', isToken: true, excludeFromAST: true }, + { name: 'identifier', isToken: true, isOptional: true, tokenKinds: ['IdentifierName'] }, + { name: 'callSignature', type: 'CallSignatureSyntax' }, + { name: 'block', type: 'BlockSyntax' } + ] + }, + { + name: 'EmptyStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'semicolonToken', isToken: true } + ] + }, + { + name: 'TryStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'tryKeyword', isToken: true, excludeFromAST: true }, + { name: 'block', type: 'BlockSyntax' }, + { name: 'catchClause', type: 'CatchClauseSyntax', isOptional: true }, + { name: 'finallyClause', type: 'FinallyClauseSyntax', isOptional: true } + ] + }, + { + name: 'CatchClauseSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'catchKeyword', isToken: true, excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecified: true }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true }, + { name: 'block', type: 'BlockSyntax' } + ] + }, + { + name: 'FinallyClauseSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'finallyKeyword', isToken: true, excludeFromAST: true }, + { name: 'block', type: 'BlockSyntax' } + ] + }, + { + name: 'LabeledStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] }, + { name: 'colonToken', isToken: true, excludeFromAST: true }, + { name: 'statement', type: 'IStatementSyntax' } + ] + }, + { + name: 'DoStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'doKeyword', isToken: true, excludeFromAST: true }, + { name: 'statement', type: 'IStatementSyntax' }, + { name: 'whileKeyword', isToken: true, excludeFromAST: true }, + { name: 'openParenToken', isToken: true, excludeFromAST: true }, + { name: 'condition', type: 'IExpressionSyntax' }, + { name: 'closeParenToken', isToken: true, excludeFromAST: true }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + }, + { + name: 'TypeOfExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IUnaryExpressionSyntax'], + children: [ + { name: 'typeOfKeyword', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IUnaryExpressionSyntax' } + ] + }, + { + name: 'DeleteExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IUnaryExpressionSyntax'], + children: [ + { name: 'deleteKeyword', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IUnaryExpressionSyntax' } + ] + }, + { + name: 'VoidExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IUnaryExpressionSyntax'], + children: [ + { name: 'voidKeyword', isToken: true, excludeFromAST: true }, + { name: 'expression', type: 'IUnaryExpressionSyntax' } + ] + }, + { + name: 'DebuggerStatementSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IStatementSyntax'], + children: [ + { name: 'debuggerKeyword', isToken: true }, + { name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true } + ] + } +]; +function firstKind(definition) { + var kindName = getNameWithoutSuffix(definition); + return TypeScript.SyntaxKind[kindName]; +} +definitions.sort(function (d1, d2) { return firstKind(d1) - firstKind(d2); }); +function getStringWithoutSuffix(definition) { + if (TypeScript.StringUtilities.endsWith(definition, "Syntax")) { + return definition.substring(0, definition.length - "Syntax".length); + } + return definition; +} +function getNameWithoutSuffix(definition) { + return getStringWithoutSuffix(definition.name); +} +function getType(child) { + if (child.isToken) { + return "ISyntaxToken"; + } + else if (child.isSeparatedList) { + return "ISeparatedSyntaxList<" + child.elementType + ">"; + } + else if (child.isList) { + return child.elementType + "[]"; + } + else { + return child.type; + } +} +function camelCase(value) { + return value.substr(0, 1).toLowerCase() + value.substr(1); +} +function getSafeName(child) { + if (child.name === "arguments") { + return "_" + child.name; + } + return child.name; +} +function generateBrands(definition, accessibility) { + var properties = ""; + var types = []; + if (definition.interfaces) { + var ifaces = definition.interfaces.slice(0); + var i; + for (i = 0; i < ifaces.length; i++) { + var current = ifaces[i]; + while (current !== undefined) { + if (!TypeScript.ArrayUtilities.contains(ifaces, current)) { + ifaces.push(current); + } + current = interfaces[current]; + } + } + for (i = 0; i < ifaces.length; i++) { + var type = ifaces[i]; + type = getStringWithoutSuffix(type); + if (isInterface(type)) { + type = "_" + type.substr(1, 1).toLowerCase() + type.substr(2) + "Brand"; + } + types.push(type); + } + } + types.push("_syntaxNodeOrTokenBrand"); + if (types.length > 0) { + properties += " "; + for (var i = 0; i < types.length; i++) { + if (accessibility) { + properties += " public "; + } + properties += types[i] + ": any;"; + } + properties += "\r\n"; + } + return properties; +} +function generateConstructorFunction(definition) { + var result = " export var " + definition.name + ": " + getNameWithoutSuffix(definition) + "Constructor = function(data: number"; + for (var i = 0; i < definition.children.length; i++) { + var child = definition.children[i]; + result += ", "; + result += getSafeName(child); + result += ": " + getType(child); + } + result += ") {\r\n"; + result += " if (data) { this.__data = data; }\r\n"; + if (definition.children.length) { + result += " "; + for (var i = 0; i < definition.children.length; i++) { + if (i) { + result += ", "; + } + var child = definition.children[i]; + result += "this." + child.name + " = " + getSafeName(child); + } + result += ";\r\n"; + } + if (definition.children.length > 0) { + result += " "; + for (var i = 0; i < definition.children.length; i++) { + if (i) { + result += ", "; + } + var child = definition.children[i]; + if (child.isOptional) { + result += getSafeName(child) + " && (" + getSafeName(child) + ".parent = this)"; + } + else { + result += getSafeName(child) + ".parent = this"; + } + } + result += ";\r\n"; + } + result += " };\r\n"; + result += " " + definition.name + ".prototype.kind = SyntaxKind." + getNameWithoutSuffix(definition) + ";\r\n"; + return result; +} +function generateSyntaxInterfaces() { + var result = "///\r\n\r\n"; + result += "module TypeScript {\r\n"; + for (var i = 0; i < definitions.length; i++) { + var definition = definitions[i]; + if (i > 0) { + result += "\r\n"; + } + result += generateSyntaxInterface(definition); + } + result += "}"; + return result; +} +function generateSyntaxInterface(definition) { + var result = " export interface " + definition.name + " extends ISyntaxNode"; + if (definition.interfaces) { + result += ", "; + result += definition.interfaces.join(", "); + } + result += " {\r\n"; + if (definition.name === "SourceUnitSyntax") { + result += " syntaxTree: SyntaxTree;\r\n"; + } + for (var i = 0; i < definition.children.length; i++) { + var child = definition.children[i]; + result += " " + child.name + ": " + getType(child) + ";\r\n"; + } + result += " }\r\n"; + result += " export interface " + getNameWithoutSuffix(definition) + "Constructor {"; + result += " new (data: number"; + for (var i = 0; i < definition.children.length; i++) { + var child = definition.children[i]; + result += ", "; + result += getSafeName(child); + result += ": " + getType(child); + } + result += "): " + definition.name; + result += " }\r\n"; + return result; +} +function generateNodes() { + var result = "///\r\n\r\n"; + result += "module TypeScript"; + result += " {\r\n"; + for (var i = 0; i < definitions.length; i++) { + var definition = definitions[i]; + if (i) { + result += "\r\n"; + } + result += generateConstructorFunction(definition); + } + result += "}"; + return result; +} +function isInterface(name) { + return name.substr(0, 1) === "I" && name.substr(1, 1).toUpperCase() === name.substr(1, 1); +} +function generateWalker() { + var result = ""; + result += "///\r\n" + "\r\n" + "module TypeScript {\r\n" + " export class SyntaxWalker implements ISyntaxVisitor {\r\n" + " public visitToken(token: ISyntaxToken): void {\r\n" + " }\r\n" + "\r\n" + " private visitOptionalToken(token: ISyntaxToken): void {\r\n" + " if (token === undefined) {\r\n" + " return;\r\n" + " }\r\n" + "\r\n" + " this.visitToken(token);\r\n" + " }\r\n" + "\r\n" + " public visitList(list: ISyntaxNodeOrToken[]): void {\r\n" + " for (var i = 0, n = list.length; i < n; i++) {\r\n" + " visitNodeOrToken(this, list[i]);\r\n" + " }\r\n" + " }\r\n"; + for (var i = 0; i < definitions.length; i++) { + var definition = definitions[i]; + result += "\r\n"; + result += " public visit" + getNameWithoutSuffix(definition) + "(node: " + definition.name + "): void {\r\n"; + for (var j = 0; j < definition.children.length; j++) { + var child = definition.children[j]; + if (child.isToken) { + if (child.isOptional) { + result += " this.visitOptionalToken(node." + child.name + ");\r\n"; + } + else { + result += " this.visitToken(node." + child.name + ");\r\n"; + } + } + else if (child.isList || child.isSeparatedList) { + result += " this.visitList(node." + child.name + ");\r\n"; + } + else if (child.isToken) { + if (child.isOptional) { + result += " this.visitOptionalToken(node." + child.name + ");\r\n"; + } + else { + result += " this.visitToken(node." + child.name + ");\r\n"; + } + } + else { + result += " visitNodeOrToken(this, node." + child.name + ");\r\n"; + } + } + result += " }\r\n"; + } + result += " }"; + result += "\r\n}"; + return result; +} +function firstEnumName(e, value) { + for (var name in e) { + if (e[name] === value) { + return name; + } + } +} +function groupBy(array, func) { + var result = {}; + for (var i = 0, n = array.length; i < n; i++) { + var v = array[i]; + var k = func(v); + var list = result[k] || []; + list.push(v); + result[k] = list; + } + return result; +} +function generateKeywordCondition(keywords, currentCharacter, indent) { + var length = keywords[0].text.length; + var result = ""; + var index; + if (keywords.length === 1) { + var keyword = keywords[0]; + if (currentCharacter === length) { + return " return SyntaxKind." + firstEnumName(TypeScript.SyntaxKind, keyword.kind) + ";\r\n"; + } + var keywordText = keywords[0].text; + result = " return ("; + for (var i = currentCharacter; i < length; i++) { + if (i > currentCharacter) { + result += " && "; + } + index = i === 0 ? "start" : ("start + " + i); + result += "str.charCodeAt(" + index + ") === CharacterCodes." + keywordText.substr(i, 1); + } + result += ") ? SyntaxKind." + firstEnumName(TypeScript.SyntaxKind, keyword.kind) + " : SyntaxKind.IdentifierName;\r\n"; + } + else { + result += " // " + TypeScript.ArrayUtilities.select(keywords, function (k) { return k.text; }).join(", ") + "\r\n"; + index = currentCharacter === 0 ? "start" : ("start + " + currentCharacter); + result += indent + "switch(str.charCodeAt(" + index + ")) {\r\n"; + var groupedKeywords = groupBy(keywords, function (k) { return k.text.substr(currentCharacter, 1); }); + for (var c in groupedKeywords) { + if (groupedKeywords.hasOwnProperty(c)) { + result += indent + " case CharacterCodes." + c + ":"; + result += generateKeywordCondition(groupedKeywords[c], currentCharacter + 1, indent + " "); + } + } + result += indent + " default: return SyntaxKind.IdentifierName;\r\n"; + result += indent + "}\r\n"; + } + return result; +} +function min(array, func) { + var min = func(array[0]); + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next < min) { + min = next; + } + } + return min; +} +function max(array, func) { + var max = func(array[0]); + for (var i = 1; i < array.length; i++) { + var next = func(array[i]); + if (next > max) { + max = next; + } + } + return max; +} +function generateUtilities() { + var result = ""; + result += " var fixedWidthArray = ["; + for (var i = 0; i <= TypeScript.SyntaxKind.LastFixedWidth; i++) { + if (i) { + result += ", "; + } + if (i < TypeScript.SyntaxKind.FirstFixedWidth) { + result += "0"; + } + else { + result += TypeScript.SyntaxFacts.getText(i).length; + } + } + result += "];\r\n"; + result += " function fixedWidthTokenLength(kind: SyntaxKind) {\r\n"; + result += " return fixedWidthArray[kind];\r\n"; + result += " }\r\n"; + return result; +} +function generateScannerUtilities() { + var result = "///\r\n" + "\r\n" + "module TypeScript {\r\n" + " export module ScannerUtilities {\r\n"; + var i; + var keywords = []; + for (i = TypeScript.SyntaxKind.FirstKeyword; i <= TypeScript.SyntaxKind.LastKeyword; i++) { + keywords.push({ kind: i, text: TypeScript.SyntaxFacts.getText(i) }); + } + keywords.sort(function (a, b) { return a.text.localeCompare(b.text); }); + result += " export function identifierKind(str: string, start: number, length: number): SyntaxKind {\r\n"; + var minTokenLength = min(keywords, function (k) { return k.text.length; }); + var maxTokenLength = max(keywords, function (k) { return k.text.length; }); + result += " switch (length) {\r\n"; + for (i = minTokenLength; i <= maxTokenLength; i++) { + var keywordsOfLengthI = TypeScript.ArrayUtilities.where(keywords, function (k) { return k.text.length === i; }); + if (keywordsOfLengthI.length > 0) { + result += " case " + i + ":"; + result += generateKeywordCondition(keywordsOfLengthI, 0, " "); + } + } + result += " default: return SyntaxKind.IdentifierName;\r\n"; + result += " }\r\n"; + result += " }\r\n"; + result += " }\r\n"; + result += "}"; + return result; +} +function syntaxKindName(kind) { + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === kind) { + return name; + } + } + throw new Error(); +} +function generateVisitor() { + var result = ""; + result += "///\r\n\r\n"; + result += "module TypeScript {\r\n"; + result += " export function visitNodeOrToken(visitor: ISyntaxVisitor, element: ISyntaxNodeOrToken): any {\r\n"; + result += " if (element === undefined) { return undefined; }\r\n"; + result += " switch (element.kind) {\r\n"; + for (var i = 0; i < definitions.length; i++) { + var definition = definitions[i]; + result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ": "; + result += "return visitor.visit" + getNameWithoutSuffix(definition) + "(<" + definition.name + ">element);\r\n"; + } + result += " default: return visitor.visitToken(element);\r\n"; + result += " }\r\n"; + result += " }\r\n\r\n"; + result += " export interface ISyntaxVisitor {\r\n"; + result += " visitToken(token: ISyntaxToken): any;\r\n"; + for (var i = 0; i < definitions.length; i++) { + var definition = definitions[i]; + result += " visit" + getNameWithoutSuffix(definition) + "(node: " + definition.name + "): any;\r\n"; + } + result += " }"; + result += "\r\n}"; + return result; +} +function generateServicesUtilities() { + var result = ""; + result += "module TypeScript {\r\n"; + result += " var childCountArray = ["; + for (var i = 0, n = TypeScript.SyntaxKind.LastNode; i <= n; i++) { + if (i) { + result += ", "; + } + if (i <= TypeScript.SyntaxKind.LastToken) { + result += "0"; + } + else { + var definition = TypeScript.ArrayUtilities.first(definitions, function (d) { return firstKind(d) === i; }); + result += definition.children.length; + } + } + result += "];\r\n\r\n"; + result += " export function childCount(element: ISyntaxElement): number {\r\n"; + result += " if (isList(element)) { return (element).length; }\r\n"; + result += " return childCountArray[element.kind];\r\n"; + result += " }\r\n\r\n"; + result += " var childAtArray: ((nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement)[] = [\r\n "; + for (var i = 0; i < TypeScript.SyntaxKind.FirstNode; i++) { + if (i) { + result += ", "; + } + result += "undefined"; + } + for (var i = 0; i < definitions.length; i++) { + var definition = definitions[i]; + result += ",\r\n"; + result += " (node: " + definition.name + ", index: number): ISyntaxElement => {\r\n"; + if (definition.children.length) { + result += " switch (index) {\r\n"; + for (var j = 0; j < definition.children.length; j++) { + result += " case " + j + ": return node." + definition.children[j].name + ";\r\n"; + } + result += " }\r\n"; + } + else { + result += " throw Errors.invalidOperation();\r\n"; + } + result += " }"; + } + result += "\r\n ];\r\n"; + result += " export function childAt(element: ISyntaxElement, index: number): ISyntaxElement {\r\n"; + result += " if (isList(element)) { return (element)[index]; }\r\n"; + result += " return childAtArray[element.kind](element, index);\r\n"; + result += " }\r\n\r\n"; + result += " export function getChildAtFunction(element: ISyntaxNodeOrToken): (nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement {\r\n"; + result += " return childAtArray[element.kind];\r\n"; + result += " }\r\n"; + result += "}"; + return result; +} +var syntaxNodesConcrete = generateNodes(); +var syntaxInterfaces = generateSyntaxInterfaces(); +var walker = generateWalker(); +var scannerUtilities = generateScannerUtilities(); +var visitor = generateVisitor(); +var servicesUtilities = generateServicesUtilities(); +var utilities = generateUtilities(); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxNodes.concrete.generated.ts", syntaxNodesConcrete, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxInterfaces.generated.ts", syntaxInterfaces, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxWalker.generated.ts", walker, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\scannerUtilities.generated.ts", scannerUtilities, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxVisitor.generated.ts", visitor, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxUtilities.generated.ts", servicesUtilities, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\utilities.generated.ts", utilities, false); diff --git a/src/services/syntax/defaultSyntaxVisitor.generated.ts b/src/services/syntax/defaultSyntaxVisitor.generated.ts deleted file mode 100644 index ceaa8a4fcf3..00000000000 --- a/src/services/syntax/defaultSyntaxVisitor.generated.ts +++ /dev/null @@ -1,365 +0,0 @@ -/// - -module TypeScript { - export class SyntaxVisitor implements ISyntaxVisitor { - public defaultVisit(node: ISyntaxNodeOrToken): any { - return undefined; - } - - public visitToken(token: ISyntaxToken): any { - return this.defaultVisit(token); - } - - public visitSourceUnit(node: SourceUnitSyntax): any { - return this.defaultVisit(node); - } - - public visitQualifiedName(node: QualifiedNameSyntax): any { - return this.defaultVisit(node); - } - - public visitObjectType(node: ObjectTypeSyntax): any { - return this.defaultVisit(node); - } - - public visitFunctionType(node: FunctionTypeSyntax): any { - return this.defaultVisit(node); - } - - public visitArrayType(node: ArrayTypeSyntax): any { - return this.defaultVisit(node); - } - - public visitConstructorType(node: ConstructorTypeSyntax): any { - return this.defaultVisit(node); - } - - public visitGenericType(node: GenericTypeSyntax): any { - return this.defaultVisit(node); - } - - public visitTypeQuery(node: TypeQuerySyntax): any { - return this.defaultVisit(node); - } - - public visitTupleType(node: TupleTypeSyntax): any { - return this.defaultVisit(node); - } - - public visitUnionType(node: UnionTypeSyntax): any { - return this.defaultVisit(node); - } - - public visitParenthesizedType(node: ParenthesizedTypeSyntax): any { - return this.defaultVisit(node); - } - - public visitInterfaceDeclaration(node: InterfaceDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitFunctionDeclaration(node: FunctionDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitModuleDeclaration(node: ModuleDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitClassDeclaration(node: ClassDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitEnumDeclaration(node: EnumDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitImportDeclaration(node: ImportDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitExportAssignment(node: ExportAssignmentSyntax): any { - return this.defaultVisit(node); - } - - public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitConstructorDeclaration(node: ConstructorDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitGetAccessor(node: GetAccessorSyntax): any { - return this.defaultVisit(node); - } - - public visitSetAccessor(node: SetAccessorSyntax): any { - return this.defaultVisit(node); - } - - public visitPropertySignature(node: PropertySignatureSyntax): any { - return this.defaultVisit(node); - } - - public visitCallSignature(node: CallSignatureSyntax): any { - return this.defaultVisit(node); - } - - public visitConstructSignature(node: ConstructSignatureSyntax): any { - return this.defaultVisit(node); - } - - public visitIndexSignature(node: IndexSignatureSyntax): any { - return this.defaultVisit(node); - } - - public visitMethodSignature(node: MethodSignatureSyntax): any { - return this.defaultVisit(node); - } - - public visitBlock(node: BlockSyntax): any { - return this.defaultVisit(node); - } - - public visitIfStatement(node: IfStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitVariableStatement(node: VariableStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitExpressionStatement(node: ExpressionStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitReturnStatement(node: ReturnStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitSwitchStatement(node: SwitchStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitBreakStatement(node: BreakStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitContinueStatement(node: ContinueStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitForStatement(node: ForStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitForInStatement(node: ForInStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitEmptyStatement(node: EmptyStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitThrowStatement(node: ThrowStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitWhileStatement(node: WhileStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitTryStatement(node: TryStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitLabeledStatement(node: LabeledStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitDoStatement(node: DoStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitDebuggerStatement(node: DebuggerStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitWithStatement(node: WithStatementSyntax): any { - return this.defaultVisit(node); - } - - public visitPrefixUnaryExpression(node: PrefixUnaryExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitDeleteExpression(node: DeleteExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitTypeOfExpression(node: TypeOfExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitVoidExpression(node: VoidExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitConditionalExpression(node: ConditionalExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitBinaryExpression(node: BinaryExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitPostfixUnaryExpression(node: PostfixUnaryExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitMemberAccessExpression(node: MemberAccessExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitInvocationExpression(node: InvocationExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitArrayLiteralExpression(node: ArrayLiteralExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitObjectLiteralExpression(node: ObjectLiteralExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitObjectCreationExpression(node: ObjectCreationExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitParenthesizedExpression(node: ParenthesizedExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitSimpleArrowFunctionExpression(node: SimpleArrowFunctionExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitCastExpression(node: CastExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitElementAccessExpression(node: ElementAccessExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitFunctionExpression(node: FunctionExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitOmittedExpression(node: OmittedExpressionSyntax): any { - return this.defaultVisit(node); - } - - public visitVariableDeclaration(node: VariableDeclarationSyntax): any { - return this.defaultVisit(node); - } - - public visitVariableDeclarator(node: VariableDeclaratorSyntax): any { - return this.defaultVisit(node); - } - - public visitArgumentList(node: ArgumentListSyntax): any { - return this.defaultVisit(node); - } - - public visitParameterList(node: ParameterListSyntax): any { - return this.defaultVisit(node); - } - - public visitTypeArgumentList(node: TypeArgumentListSyntax): any { - return this.defaultVisit(node); - } - - public visitTypeParameterList(node: TypeParameterListSyntax): any { - return this.defaultVisit(node); - } - - public visitHeritageClause(node: HeritageClauseSyntax): any { - return this.defaultVisit(node); - } - - public visitEqualsValueClause(node: EqualsValueClauseSyntax): any { - return this.defaultVisit(node); - } - - public visitCaseSwitchClause(node: CaseSwitchClauseSyntax): any { - return this.defaultVisit(node); - } - - public visitDefaultSwitchClause(node: DefaultSwitchClauseSyntax): any { - return this.defaultVisit(node); - } - - public visitElseClause(node: ElseClauseSyntax): any { - return this.defaultVisit(node); - } - - public visitCatchClause(node: CatchClauseSyntax): any { - return this.defaultVisit(node); - } - - public visitFinallyClause(node: FinallyClauseSyntax): any { - return this.defaultVisit(node); - } - - public visitTypeParameter(node: TypeParameterSyntax): any { - return this.defaultVisit(node); - } - - public visitConstraint(node: ConstraintSyntax): any { - return this.defaultVisit(node); - } - - public visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): any { - return this.defaultVisit(node); - } - - public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): any { - return this.defaultVisit(node); - } - - public visitParameter(node: ParameterSyntax): any { - return this.defaultVisit(node); - } - - public visitEnumElement(node: EnumElementSyntax): any { - return this.defaultVisit(node); - } - - public visitTypeAnnotation(node: TypeAnnotationSyntax): any { - return this.defaultVisit(node); - } - - public visitExternalModuleReference(node: ExternalModuleReferenceSyntax): any { - return this.defaultVisit(node); - } - - public visitModuleNameModuleReference(node: ModuleNameModuleReferenceSyntax): any { - return this.defaultVisit(node); - } - } -} \ No newline at end of file diff --git a/src/services/syntax/incrementalParser.ts b/src/services/syntax/incrementalParser.ts index 6c6d81c0fef..c0d1d4aa0ed 100644 --- a/src/services/syntax/incrementalParser.ts +++ b/src/services/syntax/incrementalParser.ts @@ -235,7 +235,7 @@ module TypeScript.IncrementalParser { !_oldSourceUnitCursor.isFinished(); } - function updateTokens(nodeOrToken: ISyntaxNodeOrToken): void { + function updateTokenPosition(token: ISyntaxToken): void { // If we got a node or token, and we're past the range of edited text, then walk its // constituent tokens, making sure all their positions are correct. We don't need to // do this for the tokens before the edited range (since their positions couldn't have @@ -243,16 +243,48 @@ module TypeScript.IncrementalParser { // edited range, as their positions will be correct when the underlying parser source // creates them. - var position = absolutePosition(); - var tokenWasMoved = isPastChangeRange() && fullStart(nodeOrToken) !== position; - - if (tokenWasMoved) { - setTokenFullStartWalker.position = position; - - visitNodeOrToken(setTokenFullStartWalker, nodeOrToken); + if (isPastChangeRange()) { + token.setFullStart(absolutePosition()); } } + function updateNodePosition(node: ISyntaxNode): void { + // If we got a node or token, and we're past the range of edited text, then walk its + // constituent tokens, making sure all their positions are correct. We don't need to + // do this for the tokens before the edited range (since their positions couldn't have + // been affected by the edit), and we don't need to do this for the tokens in the + // edited range, as their positions will be correct when the underlying parser source + // creates them. + + if (isPastChangeRange()) { + var position = absolutePosition(); + + var tokens = getTokens(node); + + for (var i = 0, n = tokens.length; i < n; i++) { + var token = tokens[i]; + token.setFullStart(position); + + position += token.fullWidth(); + } + } + } + + function getTokens(node: ISyntaxNode): ISyntaxToken[] { + var tokens = node.__cachedTokens; + if (!tokens) { + tokens = []; + tokenCollectorWalker.tokens = tokens; + + visitNodeOrToken(tokenCollectorWalker, node); + + node.__cachedTokens = tokens; + tokenCollectorWalker.tokens = undefined; + } + + return tokens; + } + function currentNode(): ISyntaxNode { if (canReadFromOldSourceUnit()) { // Try to read a node. If we can't then our caller will call back in and just try @@ -260,7 +292,7 @@ module TypeScript.IncrementalParser { var node = tryGetNodeFromOldSourceUnit(); if (node) { // Make sure the positions for the tokens in this node are correct. - updateTokens(node); + updateNodePosition(node); return node; } } @@ -274,7 +306,7 @@ module TypeScript.IncrementalParser { var token = tryGetTokenFromOldSourceUnit(); if (token) { // Make sure the token's position/text is correct. - updateTokens(token); + updateTokenPosition(token); return token; } } @@ -702,6 +734,10 @@ module TypeScript.IncrementalParser { return isNode(element) ? element : undefined; } + function isEmptyList(element: ISyntaxElement) { + return isList(element) && (element).length === 0; + } + function moveToFirstChild() { var nodeOrToken = currentNodeOrToken(); if (nodeOrToken === undefined) { @@ -721,7 +757,7 @@ module TypeScript.IncrementalParser { // next sibling of the empty node. for (var i = 0, n = childCount(nodeOrToken); i < n; i++) { var child = childAt(nodeOrToken, i); - if (child && !isShared(child)) { + if (child && !isEmptyList(child)) { // Great, we found a real child. Push that. pushElement(child, /*indexInParent:*/ i); @@ -749,14 +785,13 @@ module TypeScript.IncrementalParser { for (var i = currentPiece.indexInParent + 1, n = childCount(parent); i < n; i++) { var sibling = childAt(parent, i); - if (sibling && !isShared(sibling)) { + if (sibling && !isEmptyList(sibling)) { // We found a good sibling that we can move to. Just reuse our existing piece // so we don't have to push/pop. currentPiece.element = sibling; currentPiece.indexInParent = i; - // The sibling might have been a list. Move to it's first child. it must have - // one since this was a non-shared element. + // The sibling might have been a list. Move to it's first child. moveToFirstChildIfList(); return; } @@ -777,7 +812,7 @@ module TypeScript.IncrementalParser { function moveToFirstChildIfList(): void { var element = pieces[currentPieceIndex].element; - if (isList(element) || isSeparatedList(element)) { + if (isList(element)) { // We cannot ever get an empty list in our piece path. Empty lists are 'shared' and // we make sure to filter that out before pushing any children. // Debug.assert(childCount(element) > 0); @@ -841,21 +876,17 @@ module TypeScript.IncrementalParser { // A simple walker we use to hit all the tokens of a node and update their positions when they // are reused in a different location because of an incremental parse. - class SetTokenFullStartWalker extends SyntaxWalker { - public position: number; + class TokenCollectorWalker extends SyntaxWalker { + public tokens: ISyntaxToken[] = []; public visitToken(token: ISyntaxToken): void { - var position = this.position; - token.setFullStart(position); - - this.position = position + token.fullWidth(); + this.tokens.push(token); } } - var setTokenFullStartWalker = new SetTokenFullStartWalker(); + var tokenCollectorWalker = new TokenCollectorWalker(); export function parse(oldSyntaxTree: SyntaxTree, textChangeRange: TextChangeRange, newText: ISimpleText): SyntaxTree { - Debug.assert(oldSyntaxTree.isConcrete(), "Can only incrementally parse a concrete syntax tree."); if (textChangeRange.isUnchanged()) { return oldSyntaxTree; } diff --git a/src/services/syntax/parser.ts b/src/services/syntax/parser.ts index 74387549d9c..eb23de608a6 100644 --- a/src/services/syntax/parser.ts +++ b/src/services/syntax/parser.ts @@ -1,10 +1,6 @@ /// module TypeScript.Parser { - // The factory used to produce parse tree nodes. Injected normally by the - // TypeScript.Syntax.Abstract or TypeScript.Syntax.Conrete modules. - export var syntaxFactory: Syntax.ISyntaxFactory; - // Interface that represents the source that the parser pulls tokens from. Essentially, this // is the interface that the parser needs an underlying scanner to provide. This allows us to // separate out "what" the parser does with the tokens it retrieves versus "how" it obtains @@ -135,12 +131,6 @@ module TypeScript.Parser { return result; } - function returnZeroLengthArray(array: any[]) { - if (array.length === 0) { - returnArray(array); - } - } - function returnArray(array: any[]) { array.length = 0; arrayPool[arrayPoolCount] = array; @@ -226,7 +216,7 @@ module TypeScript.Parser { var allDiagnostics = source.tokenDiagnostics().concat(diagnostics); allDiagnostics.sort((a: Diagnostic, b: Diagnostic) => a.start() - b.start()); - return new SyntaxTree(syntaxFactory.isConcrete, sourceUnit, isDeclaration, allDiagnostics, fileName, source.text, languageVersion); + return new SyntaxTree(sourceUnit, isDeclaration, allDiagnostics, fileName, source.text, languageVersion); } function getRewindPoint(): IParserRewindPoint { @@ -300,7 +290,7 @@ module TypeScript.Parser { //we should keep it simple so that it can be inlined. function eatToken(kind: SyntaxKind): ISyntaxToken { var token = currentToken(); - if (token.kind() === kind) { + if (token.kind === kind) { return consumeToken(token); } @@ -311,7 +301,7 @@ module TypeScript.Parser { // Eats the token if it is there. Otherwise does nothing. Will not report errors. function tryEatToken(kind: SyntaxKind): ISyntaxToken { var _currentToken = currentToken(); - if (_currentToken.kind() === kind) { + if (_currentToken.kind === kind) { return consumeToken(_currentToken); } @@ -323,7 +313,7 @@ module TypeScript.Parser { // on the state of the parser. For example, 'yield' is an identifier *unless* the parser // is in strict mode. function isIdentifier(token: ISyntaxToken): boolean { - var tokenKind = token.kind(); + var tokenKind = token.kind; if (tokenKind === SyntaxKind.IdentifierName) { return true; @@ -352,7 +342,7 @@ module TypeScript.Parser { var token = currentToken(); // If we have an identifier name, then consume and return it. - var tokenKind = token.kind(); + var tokenKind = token.kind; if (tokenKind === SyntaxKind.IdentifierName) { return consumeToken(token); } @@ -378,7 +368,7 @@ module TypeScript.Parser { if (isIdentifier(token)) { consumeToken(token); - if (token.kind() === SyntaxKind.IdentifierName) { + if (token.kind === SyntaxKind.IdentifierName) { return token; } @@ -408,7 +398,7 @@ module TypeScript.Parser { var token = currentToken(); // An automatic semicolon is always allowed if we're at the end of the file. - var tokenKind = token.kind(); + var tokenKind = token.kind; if (tokenKind === SyntaxKind.EndOfFileToken) { return true; } @@ -433,7 +423,7 @@ module TypeScript.Parser { function canEatExplicitOrAutomaticSemicolon(allowWithoutNewline: boolean): boolean { var token = currentToken(); - if (token.kind() === SyntaxKind.SemicolonToken) { + if (token.kind === SyntaxKind.SemicolonToken) { return true; } @@ -444,7 +434,7 @@ module TypeScript.Parser { var token = currentToken(); // If we see a semicolon, then we can definitely eat it. - if (token.kind() === SyntaxKind.SemicolonToken) { + if (token.kind === SyntaxKind.SemicolonToken) { return consumeToken(token); } @@ -469,7 +459,7 @@ module TypeScript.Parser { return Syntax.emptyToken(expectedKind); } - function getExpectedTokenDiagnostic(expectedKind: SyntaxKind, actual: ISyntaxToken, diagnosticCode: string): Diagnostic { + function getExpectedTokenDiagnostic(expectedKind: SyntaxKind, actual?: ISyntaxToken, diagnosticCode?: string): Diagnostic { var token = currentToken(); var args: any[] = undefined; @@ -484,9 +474,9 @@ module TypeScript.Parser { // They wanted an identifier. // If the user supplied a keyword, give them a specialized message. - if (actual && SyntaxFacts.isAnyKeyword(actual.kind())) { + if (actual && SyntaxFacts.isAnyKeyword(actual.kind)) { diagnosticCode = DiagnosticCode.Identifier_expected_0_is_a_keyword; - args = [SyntaxFacts.getText(actual.kind())]; + args = [SyntaxFacts.getText(actual.kind)]; } else { // Otherwise just report that an identifier was expected. @@ -557,12 +547,14 @@ module TypeScript.Parser { // when next requested. while (true) { // Parent must be a list or a node. All of those have a 'data' element. - Debug.assert(isNode(parent) || isList(parent) || isSeparatedList(parent)); - var dataElement = <{ data: number }>parent; - if (dataElement.data) { - dataElement.data &= SyntaxConstants.NodeParsedInStrictModeMask + Debug.assert(isNode(parent) || isList(parent)); + var dataElement = parent; + if (dataElement.__data) { + dataElement.__data &= SyntaxConstants.NodeParsedInStrictModeMask } + dataElement.__cachedTokens = undefined; + if (parent === node) { break; } @@ -592,20 +584,6 @@ module TypeScript.Parser { } } } - else if (isSeparatedList(parent)) { - var list2 = parent; - for (var i = 0, n = childCount(list2); i < n; i++) { - if (childAt(list2, i) === oldToken) { - if (i % 2 === 0) { - list2[i / 2] = newToken; - } - else { - list2.separators[(i - 1) / 2] = newToken; - } - return; - } - } - } throw Errors.invalidOperation(); } @@ -630,7 +608,7 @@ module TypeScript.Parser { } function addSkippedTokensBeforeToken(token: ISyntaxToken, skippedTokens: ISyntaxToken[]): ISyntaxToken { - // Debug.assert(token.fullWidth() > 0 || token.kind() === SyntaxKind.EndOfFileToken); + // Debug.assert(token.fullWidth() > 0 || token.kind === SyntaxKind.EndOfFileToken); // Debug.assert(skippedTokens.length > 0); var leadingTrivia: ISyntaxTrivia[] = []; @@ -717,8 +695,8 @@ module TypeScript.Parser { var moduleElements = parseSyntaxList(ListParsingState.SourceUnit_ModuleElements, skippedTokens, updateStrictModeState); setStrictMode(savedIsInStrictMode); - - var sourceUnit = new syntaxFactory.SourceUnitSyntax(parseNodeData, moduleElements, currentToken()); + + var sourceUnit = new SourceUnitSyntax(parseNodeData, moduleElements, currentToken()); sourceUnit = addSkippedTokensBeforeNode(sourceUnit, skippedTokens); @@ -733,12 +711,16 @@ module TypeScript.Parser { return sourceUnit; } + function isDirectivePrologueElement(node: ISyntaxNodeOrToken): boolean { + return node.kind === SyntaxKind.ExpressionStatement && + (node).expression.kind === SyntaxKind.StringLiteral; + } + function updateStrictModeState(items: any[]): void { if (!isInStrictMode) { // Check if all the items are directive prologue elements. - for (var i = 0; i < items.length; i++) { - var item = items[i]; - if (!SyntaxFacts.isDirectivePrologueElement(item)) { + for (var i = 0, n = items.length; i < n; i++) { + if (!isDirectivePrologueElement(items[i])) { return; } } @@ -770,7 +752,7 @@ module TypeScript.Parser { if (_modifierCount) { // if we have modifiers, then these are definitely TS constructs and we can // immediately start parsing them. - switch (peekToken(_modifierCount).kind()) { + switch (peekToken(_modifierCount).kind) { case SyntaxKind.ImportKeyword: return parseImportDeclaration(); case SyntaxKind.ModuleKeyword: return parseModuleDeclaration(); case SyntaxKind.InterfaceKeyword: return parseInterfaceDeclaration(); @@ -786,10 +768,10 @@ module TypeScript.Parser { // consuming these, we only parse them out if we can see enough context to 'prove' that // they really do start the module element var nextToken = peekToken(1); - var currentTokenKind = _currentToken.kind(); + var currentTokenKind = _currentToken.kind; switch (currentTokenKind) { case SyntaxKind.ModuleKeyword: - if (isIdentifier(nextToken) || nextToken.kind() === SyntaxKind.StringLiteral) { + if (isIdentifier(nextToken) || nextToken.kind === SyntaxKind.StringLiteral) { return parseModuleDeclaration(); } break; @@ -821,7 +803,7 @@ module TypeScript.Parser { case SyntaxKind.ExportKeyword: // 'export' could be a modifier on a statement (like export var ...). So we // only want to parse out an export assignment here if we actually see the equals. - if (nextToken.kind() === SyntaxKind.EqualsToken) { + if (nextToken.kind === SyntaxKind.EqualsToken) { return parseExportAssignment(); } break; @@ -831,12 +813,12 @@ module TypeScript.Parser { } function parseImportDeclaration(): ImportDeclarationSyntax { - return new syntaxFactory.ImportDeclarationSyntax(parseNodeData, + return new ImportDeclarationSyntax(parseNodeData, parseModifiers(), eatToken(SyntaxKind.ImportKeyword), eatIdentifierToken(), eatToken(SyntaxKind.EqualsToken), parseModuleReference(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseExportAssignment(): ExportAssignmentSyntax { - return new syntaxFactory.ExportAssignmentSyntax(parseNodeData, + return new ExportAssignmentSyntax(parseNodeData, eatToken(SyntaxKind.ExportKeyword), eatToken(SyntaxKind.EqualsToken), eatIdentifierToken(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -845,22 +827,22 @@ module TypeScript.Parser { } function isExternalModuleReference(): boolean { - return currentToken().kind() === SyntaxKind.RequireKeyword && - peekToken(1).kind() === SyntaxKind.OpenParenToken; + return currentToken().kind === SyntaxKind.RequireKeyword && + peekToken(1).kind === SyntaxKind.OpenParenToken; } function parseExternalModuleReference(): ExternalModuleReferenceSyntax { - return new syntaxFactory.ExternalModuleReferenceSyntax(parseNodeData, + return new ExternalModuleReferenceSyntax(parseNodeData, eatToken(SyntaxKind.RequireKeyword), eatToken(SyntaxKind.OpenParenToken), eatToken(SyntaxKind.StringLiteral), eatToken(SyntaxKind.CloseParenToken)); } function parseModuleNameModuleReference(): ModuleNameModuleReferenceSyntax { - return new syntaxFactory.ModuleNameModuleReferenceSyntax(parseNodeData, parseName(/*allowIdentifierNames:*/ false)); + return new ModuleNameModuleReferenceSyntax(parseNodeData, parseName(/*allowIdentifierNames:*/ false)); } function tryParseTypeArgumentList(inExpression: boolean): TypeArgumentListSyntax { var _currentToken = currentToken(); - if (_currentToken.kind() !== SyntaxKind.LessThanToken) { + if (_currentToken.kind !== SyntaxKind.LessThanToken) { return undefined; } @@ -873,7 +855,7 @@ module TypeScript.Parser { var typeArguments = parseSeparatedSyntaxList(ListParsingState.TypeArgumentList_Types, skippedTokens); lessThanToken = addSkippedTokensAfterToken(lessThanToken, skippedTokens); - return new syntaxFactory.TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, eatToken(SyntaxKind.GreaterThanToken)); + return new TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, eatToken(SyntaxKind.GreaterThanToken)); } // If we're in an expression, then we only want to consume this as a type argument list @@ -893,14 +875,14 @@ module TypeScript.Parser { // We're in a context where '<' could be the start of a type argument list, or part // of an arithmetic expression. We'll presume it's the latter unless we see the '>' // and a following token that guarantees that it's supposed to be a type argument list. - if (greaterThanToken.fullWidth() === 0 || !canFollowTypeArgumentListInExpression(currentToken().kind())) { + if (greaterThanToken.fullWidth() === 0 || !canFollowTypeArgumentListInExpression(currentToken().kind)) { rewind(rewindPoint); releaseRewindPoint(rewindPoint); return undefined; } else { releaseRewindPoint(rewindPoint); - return new syntaxFactory.TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, greaterThanToken); + return new TypeArgumentListSyntax(parseNodeData, lessThanToken, typeArguments, greaterThanToken); } } @@ -965,7 +947,7 @@ module TypeScript.Parser { // the code would be implicitly: "name.keyword; identifierNameOrKeyword". // In the first case though, ASI will not take effect because there is not a // line terminator after the keyword. - if (SyntaxFacts.isAnyKeyword(_currentToken.kind()) && + if (SyntaxFacts.isAnyKeyword(_currentToken.kind) && previousTokenHasTrailingNewLine(_currentToken)) { var token1 = peekToken(1); @@ -989,11 +971,11 @@ module TypeScript.Parser { // Call eatIdentifierName to convert the token to an identifier if it is as keyword. var current: INameSyntax = eatIdentifierToken(); - while (shouldContinue && currentToken().kind() === SyntaxKind.DotToken) { + while (shouldContinue && currentToken().kind === SyntaxKind.DotToken) { var dotToken = consumeToken(currentToken()); var identifierName = eatRightSideOfName(allowIdentifierNames); - current = new syntaxFactory.QualifiedNameSyntax(parseNodeData, current, dotToken, identifierName); + current = new QualifiedNameSyntax(parseNodeData, current, dotToken, identifierName); shouldContinue = identifierName.fullWidth() > 0; } @@ -1006,7 +988,7 @@ module TypeScript.Parser { var identifier = eatIdentifierToken(); var openBraceToken = eatToken(SyntaxKind.OpenBraceToken); - var enumElements = Syntax.emptySeparatedList(); + var enumElements: ISeparatedSyntaxList; if (openBraceToken.fullWidth() > 0) { var skippedTokens: ISyntaxToken[] = getArray(); @@ -1014,12 +996,12 @@ module TypeScript.Parser { openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } - return new syntaxFactory.EnumDeclarationSyntax(parseNodeData, modifiers, enumKeyword, identifier, openBraceToken, enumElements, eatToken(SyntaxKind.CloseBraceToken)); + return new EnumDeclarationSyntax(parseNodeData, modifiers, enumKeyword, identifier, openBraceToken, enumElements || [], eatToken(SyntaxKind.CloseBraceToken)); } function isEnumElement(inErrorRecovery: boolean): boolean { var node = currentNode(); - if (node && node.kind() === SyntaxKind.EnumElement) { + if (node && node.kind === SyntaxKind.EnumElement) { return true; } @@ -1032,7 +1014,7 @@ module TypeScript.Parser { function tryParseEnumElement(inErrorRecovery: boolean): EnumElementSyntax { var node = currentNode(); - if (node && node.kind() === SyntaxKind.EnumElement) { + if (node && node.kind === SyntaxKind.EnumElement) { consumeNode(node); return node; } @@ -1041,7 +1023,7 @@ module TypeScript.Parser { return undefined; } - return new syntaxFactory.EnumElementSyntax(parseNodeData, eatPropertyName(), tryParseEnumElementEqualsValueClause()); + return new EnumElementSyntax(parseNodeData, eatPropertyName(), tryParseEnumElementEqualsValueClause()); } function isModifierKind(kind: SyntaxKind): boolean { @@ -1059,13 +1041,13 @@ module TypeScript.Parser { } function isModifier(token: ISyntaxToken, index: number): boolean { - if (isModifierKind(token.kind())) { + if (isModifierKind(token.kind)) { // These are modifiers only if we see an actual keyword, identifier, string literal // or number following. // Note: we also allow [ for error conditions. // [ is for: static [a: number] var nextToken = peekToken(index + 1); - var nextTokenKind = nextToken.kind(); + var nextTokenKind = nextToken.kind; switch (nextTokenKind) { case SyntaxKind.IdentifierName: @@ -1103,17 +1085,11 @@ module TypeScript.Parser { break; } - var result = Syntax.list(tokens); - - // If the tokens array is greater than one, then we can't return it. It will have been - // copied directly into the syntax list. - returnZeroLengthArray(tokens); - - return result; + return Syntax.list(tokens); } function parseHeritageClauses(): HeritageClauseSyntax[] { - var heritageClauses = Syntax.emptyList(); + var heritageClauses: HeritageClauseSyntax[]; if (isHeritageClause()) { // NOTE: we can pass "undefined" for the skipped tokens here as we know we can't get @@ -1122,7 +1098,7 @@ module TypeScript.Parser { heritageClauses = parseSyntaxList(ListParsingState.ClassOrInterfaceDeclaration_HeritageClauses, undefined); } - return heritageClauses; + return heritageClauses || []; } function tryParseHeritageClauseTypeName(): ITypeSyntax { @@ -1136,7 +1112,7 @@ module TypeScript.Parser { var typeParameterList = tryParseTypeParameterList(/*requireCompleteTypeParameterList:*/ false); var heritageClauses = parseHeritageClauses(); var openBraceToken = eatToken(SyntaxKind.OpenBraceToken); - var classElements = Syntax.emptyList(); + var classElements: IClassElementSyntax[]; if (openBraceToken.fullWidth() > 0) { var skippedTokens: ISyntaxToken[] = getArray(); @@ -1144,12 +1120,12 @@ module TypeScript.Parser { openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); }; - return new syntaxFactory.ClassDeclarationSyntax(parseNodeData, - modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements, eatToken(SyntaxKind.CloseBraceToken)); + return new ClassDeclarationSyntax(parseNodeData, + modifiers, classKeyword, identifier, typeParameterList, heritageClauses, openBraceToken, classElements || [], eatToken(SyntaxKind.CloseBraceToken)); } function isAccessor(modifierCount: number, inErrorRecovery: boolean): boolean { - var tokenKind = peekToken(modifierCount).kind(); + var tokenKind = peekToken(modifierCount).kind; if (tokenKind !== SyntaxKind.GetKeyword && tokenKind !== SyntaxKind.SetKeyword) { return false; @@ -1161,7 +1137,7 @@ module TypeScript.Parser { function parseAccessor(checkForStrictMode: boolean): ISyntaxNode { var modifiers = parseModifiers(); var _currenToken = currentToken(); - var tokenKind = _currenToken.kind(); + var tokenKind = _currenToken.kind; if (tokenKind === SyntaxKind.GetKeyword) { return parseGetMemberAccessorDeclaration(modifiers, _currenToken, checkForStrictMode); @@ -1175,14 +1151,14 @@ module TypeScript.Parser { } function parseGetMemberAccessorDeclaration(modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, checkForStrictMode: boolean): GetAccessorSyntax { - return new syntaxFactory.GetAccessorSyntax(parseNodeData, + return new GetAccessorSyntax(parseNodeData, modifiers, consumeToken(getKeyword), eatPropertyName(), parseCallSignature(/*requireCompleteTypeParameterList:*/ false), parseBlock(/*parseStatementsEvenWithNoOpenBrace:*/ false, checkForStrictMode)); } function parseSetMemberAccessorDeclaration(modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, checkForStrictMode: boolean): SetAccessorSyntax { - return new syntaxFactory.SetAccessorSyntax(parseNodeData, + return new SetAccessorSyntax(parseNodeData, modifiers, consumeToken(setKeyword), eatPropertyName(), parseCallSignature(/*requireCompleteTypeParameterList:*/ false), parseBlock(/*parseStatementsEvenWithNoOpenBrace:*/ false, checkForStrictMode)); @@ -1236,7 +1212,7 @@ module TypeScript.Parser { // assume this is a constructor. That means, if a user writes "public constructor;" // it won't be viewed as a member. As a workaround, they can simply write: // public 'constructor'; - return peekToken(modifierCount).kind() === SyntaxKind.ConstructorKeyword; + return peekToken(modifierCount).kind === SyntaxKind.ConstructorKeyword; } function parseConstructorDeclaration(): ConstructorDeclarationSyntax { @@ -1254,7 +1230,7 @@ module TypeScript.Parser { semicolonToken = eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false); } - return new syntaxFactory.ConstructorDeclarationSyntax(parseNodeData, modifiers, constructorKeyword, callSignature, block, semicolonToken); + return new ConstructorDeclarationSyntax(parseNodeData, modifiers, constructorKeyword, callSignature, block, semicolonToken); } function isMemberFunctionDeclaration(modifierCount: number, inErrorRecovery: boolean): boolean { @@ -1280,7 +1256,7 @@ module TypeScript.Parser { semicolon = eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false); } - return new syntaxFactory.MemberFunctionDeclarationSyntax(parseNodeData, modifiers, propertyName, callSignature, block, semicolon); + return new MemberFunctionDeclarationSyntax(parseNodeData, modifiers, propertyName, callSignature, block, semicolon); } function isDefinitelyMemberVariablePropertyName(index: number): boolean { @@ -1292,9 +1268,9 @@ module TypeScript.Parser { // public } // public // public - if (SyntaxFacts.isAnyKeyword(peekToken(index).kind())) { + if (SyntaxFacts.isAnyKeyword(peekToken(index).kind)) { var nextToken = peekToken(index + 1); - switch (nextToken.kind()) { + switch (nextToken.kind) { case SyntaxKind.SemicolonToken: case SyntaxKind.EqualsToken: case SyntaxKind.ColonToken: @@ -1316,7 +1292,7 @@ module TypeScript.Parser { } function parseMemberVariableDeclaration(): MemberVariableDeclarationSyntax { - return new syntaxFactory.MemberVariableDeclarationSyntax(parseNodeData, + return new MemberVariableDeclarationSyntax(parseNodeData, parseModifiers(), tryParseVariableDeclarator(/*allowIn:*/ true, /*allowPropertyName:*/ true), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -1326,14 +1302,14 @@ module TypeScript.Parser { } function parseIndexMemberDeclaration(): IndexMemberDeclarationSyntax { - return new syntaxFactory.IndexMemberDeclarationSyntax(parseNodeData, + return new IndexMemberDeclarationSyntax(parseNodeData, parseModifiers(), parseIndexSignature(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewLine:*/ false)); } function tryAddUnexpectedEqualsGreaterThanToken(callSignature: CallSignatureSyntax): boolean { var token0 = currentToken(); - var hasEqualsGreaterThanToken = token0.kind() === SyntaxKind.EqualsGreaterThanToken; + var hasEqualsGreaterThanToken = token0.kind === SyntaxKind.EqualsGreaterThanToken; if (hasEqualsGreaterThanToken) { // We can only do this if the call signature actually contains a final token that we // could add the => to. @@ -1349,11 +1325,7 @@ module TypeScript.Parser { consumeToken(token0); - // Note: we only do this if we're creating a concrete syntax tree (which contains - // everything, including skipped tokens, in it). - if (syntaxFactory.isConcrete) { - addSkippedTokenAfterNode(callSignature, token0); - } + addSkippedTokenAfterNode(callSignature, token0); return true; } } @@ -1363,7 +1335,7 @@ module TypeScript.Parser { } function isFunctionDeclaration(modifierCount: number): boolean { - return peekToken(modifierCount).kind() === SyntaxKind.FunctionKeyword; + return peekToken(modifierCount).kind === SyntaxKind.FunctionKeyword; } function parseFunctionDeclaration(): FunctionDeclarationSyntax { @@ -1387,7 +1359,7 @@ module TypeScript.Parser { semicolonToken = eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false); } - return new syntaxFactory.FunctionDeclarationSyntax(parseNodeData, modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); + return new FunctionDeclarationSyntax(parseNodeData, modifiers, functionKeyword, identifier, callSignature, block, semicolonToken); } function parseModuleDeclaration(): ModuleDeclarationSyntax { @@ -1397,7 +1369,7 @@ module TypeScript.Parser { var moduleName: INameSyntax = undefined; var stringLiteral: ISyntaxToken = undefined; - if (currentToken().kind() === SyntaxKind.StringLiteral) { + if (currentToken().kind === SyntaxKind.StringLiteral) { stringLiteral = eatToken(SyntaxKind.StringLiteral); } else { @@ -1406,19 +1378,19 @@ module TypeScript.Parser { var openBraceToken = eatToken(SyntaxKind.OpenBraceToken); - var moduleElements = Syntax.emptyList(); + var moduleElements: IModuleElementSyntax[]; if (openBraceToken.fullWidth() > 0) { var skippedTokens: ISyntaxToken[] = getArray(); moduleElements = parseSyntaxList(ListParsingState.ModuleDeclaration_ModuleElements, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } - return new syntaxFactory.ModuleDeclarationSyntax(parseNodeData, - modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements, eatToken(SyntaxKind.CloseBraceToken)); + return new ModuleDeclarationSyntax(parseNodeData, + modifiers, moduleKeyword, moduleName, stringLiteral, openBraceToken, moduleElements || [], eatToken(SyntaxKind.CloseBraceToken)); } function parseInterfaceDeclaration(): InterfaceDeclarationSyntax { - return new syntaxFactory.InterfaceDeclarationSyntax(parseNodeData, + return new InterfaceDeclarationSyntax(parseNodeData, parseModifiers(), eatToken(SyntaxKind.InterfaceKeyword), eatIdentifierToken(), tryParseTypeParameterList(/*requireCompleteTypeParameterList:*/ false), parseHeritageClauses(), parseObjectType()); } @@ -1426,27 +1398,27 @@ module TypeScript.Parser { function parseObjectType(): ObjectTypeSyntax { var openBraceToken = eatToken(SyntaxKind.OpenBraceToken); - var typeMembers = Syntax.emptySeparatedList(); + var typeMembers: ISeparatedSyntaxList; if (openBraceToken.fullWidth() > 0) { var skippedTokens: ISyntaxToken[] = getArray(); typeMembers = parseSeparatedSyntaxList(ListParsingState.ObjectType_TypeMembers, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } - return new syntaxFactory.ObjectTypeSyntax(parseNodeData, openBraceToken, typeMembers, eatToken(SyntaxKind.CloseBraceToken)); + return new ObjectTypeSyntax(parseNodeData, openBraceToken, typeMembers || [], eatToken(SyntaxKind.CloseBraceToken)); } function parseTupleType(currentToken: ISyntaxToken): TupleTypeSyntax { var openBracket = consumeToken(currentToken); - var types = Syntax.emptySeparatedList(); + var types: ISeparatedSyntaxList; if (openBracket.fullWidth() > 0) { var skippedTokens: ISyntaxToken[] = getArray(); types = parseSeparatedSyntaxList(ListParsingState.TupleType_Types, skippedTokens); openBracket = addSkippedTokensAfterToken(openBracket, skippedTokens); } - return new syntaxFactory.TupleTypeSyntax(parseNodeData, openBracket, types, eatToken(SyntaxKind.CloseBracketToken)); + return new TupleTypeSyntax(parseNodeData, openBracket, types || [], eatToken(SyntaxKind.CloseBracketToken)); } function isTypeMember(inErrorRecovery: boolean): boolean { @@ -1491,7 +1463,7 @@ module TypeScript.Parser { } function parseConstructSignature(): ConstructSignatureSyntax { - return new syntaxFactory.ConstructSignatureSyntax(parseNodeData, eatToken(SyntaxKind.NewKeyword), parseCallSignature(/*requireCompleteTypeParameterList:*/ false)); + return new ConstructSignatureSyntax(parseNodeData, eatToken(SyntaxKind.NewKeyword), parseCallSignature(/*requireCompleteTypeParameterList:*/ false)); } function parseIndexSignature(): IndexSignatureSyntax { @@ -1501,27 +1473,27 @@ module TypeScript.Parser { var parameters = parseSeparatedSyntaxList(ListParsingState.IndexSignature_Parameters, skippedTokens); openBracketToken = addSkippedTokensAfterToken(openBracketToken, skippedTokens); - return new syntaxFactory.IndexSignatureSyntax(parseNodeData, + return new IndexSignatureSyntax(parseNodeData, openBracketToken, parameters, eatToken(SyntaxKind.CloseBracketToken), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false)); } function parseMethodSignature(): MethodSignatureSyntax { - return new syntaxFactory.MethodSignatureSyntax(parseNodeData, + return new MethodSignatureSyntax(parseNodeData, eatPropertyName(), tryEatToken(SyntaxKind.QuestionToken), parseCallSignature(/*requireCompleteTypeParameterList:*/ false)); } function parsePropertySignature(): PropertySignatureSyntax { - return new syntaxFactory.PropertySignatureSyntax(parseNodeData, + return new PropertySignatureSyntax(parseNodeData, eatPropertyName(), tryEatToken(SyntaxKind.QuestionToken), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false)); } function isCallSignature(peekIndex: number): boolean { - var tokenKind = peekToken(peekIndex).kind(); + var tokenKind = peekToken(peekIndex).kind; return tokenKind === SyntaxKind.OpenParenToken || tokenKind === SyntaxKind.LessThanToken; } function isConstructSignature(): boolean { - if (currentToken().kind() !== SyntaxKind.NewKeyword) { + if (currentToken().kind !== SyntaxKind.NewKeyword) { return false; } @@ -1529,7 +1501,7 @@ module TypeScript.Parser { } function isIndexSignature(peekIndex: number): boolean { - return peekToken(peekIndex).kind() === SyntaxKind.OpenBracketToken; + return peekToken(peekIndex).kind === SyntaxKind.OpenBracketToken; } function isMethodSignature(inErrorRecovery: boolean): boolean { @@ -1540,7 +1512,7 @@ module TypeScript.Parser { } // id?( - if (peekToken(1).kind() === SyntaxKind.QuestionToken && + if (peekToken(1).kind === SyntaxKind.QuestionToken && isCallSignature(2)) { return true; } @@ -1578,12 +1550,12 @@ module TypeScript.Parser { } function isHeritageClause(): boolean { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; return tokenKind === SyntaxKind.ExtendsKeyword || tokenKind === SyntaxKind.ImplementsKeyword; } function isNotHeritageClauseTypeName(): boolean { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind === SyntaxKind.ImplementsKeyword || tokenKind === SyntaxKind.ExtendsKeyword) { @@ -1605,7 +1577,7 @@ module TypeScript.Parser { function tryParseHeritageClause(): HeritageClauseSyntax { var extendsOrImplementsKeyword = currentToken(); - var tokenKind = extendsOrImplementsKeyword.kind(); + var tokenKind = extendsOrImplementsKeyword.kind; if (tokenKind !== SyntaxKind.ExtendsKeyword && tokenKind !== SyntaxKind.ImplementsKeyword) { return undefined; } @@ -1616,15 +1588,13 @@ module TypeScript.Parser { var typeNames = parseSeparatedSyntaxList(ListParsingState.HeritageClause_TypeNameList, skippedTokens); extendsOrImplementsKeyword = addSkippedTokensAfterToken(extendsOrImplementsKeyword, skippedTokens); - return new syntaxFactory.HeritageClauseSyntax(parseNodeData, extendsOrImplementsKeyword, typeNames); + return new HeritageClauseSyntax(parseNodeData, extendsOrImplementsKeyword, typeNames); } - function isInterfaceEnumClassModuleImportOrExport(modifierCount: number): boolean { - var _currentToken = currentToken(); - + function isInterfaceEnumClassModuleImportOrExport(modifierCount: number, _currentToken?: ISyntaxToken): boolean { if (modifierCount) { // Any of these keywords following a modifier is definitely a TS construct. - switch (peekToken(modifierCount).kind()) { + switch (peekToken(modifierCount).kind) { case SyntaxKind.ImportKeyword: case SyntaxKind.ModuleKeyword: case SyntaxKind.InterfaceKeyword: @@ -1634,6 +1604,8 @@ module TypeScript.Parser { } } + _currentToken = _currentToken || currentToken(); + // no modifiers. While certain of these keywords are javascript keywords as well, it // is possible to run into them in some circumstances in error recovery where we don't // want to consider them the start of the module element construct. For example, they @@ -1641,27 +1613,18 @@ module TypeScript.Parser { // make sure it really is the start of a module element. var nextToken = peekToken(1); - switch (_currentToken.kind()) { + switch (_currentToken.kind) { case SyntaxKind.ModuleKeyword: - if (isIdentifier(nextToken) || nextToken.kind() === SyntaxKind.StringLiteral) { - return true; - } - break; + return isIdentifier(nextToken) || nextToken.kind === SyntaxKind.StringLiteral; case SyntaxKind.ImportKeyword: case SyntaxKind.ClassKeyword: case SyntaxKind.EnumKeyword: case SyntaxKind.InterfaceKeyword: - if (isIdentifier(nextToken)) { - return true; - } - break; + return isIdentifier(nextToken); case SyntaxKind.ExportKeyword: - if (nextToken.kind() === SyntaxKind.EqualsToken) { - return true; - } - break; + return nextToken.kind === SyntaxKind.EqualsToken; } return false; @@ -1673,7 +1636,7 @@ module TypeScript.Parser { } var _currentToken = currentToken(); - var currentTokenKind = _currentToken.kind(); + var currentTokenKind = _currentToken.kind; switch (currentTokenKind) { // ERROR RECOVERY case SyntaxKind.PublicKeyword: @@ -1714,7 +1677,7 @@ module TypeScript.Parser { // do not want to consume. This can happen when the user does not terminate their // existing block properly. We don't want to accidently consume these as expression // below. - if (isInterfaceEnumClassModuleImportOrExport(modifierCount)) { + if (isInterfaceEnumClassModuleImportOrExport(modifierCount, _currentToken)) { return false; } @@ -1738,7 +1701,7 @@ module TypeScript.Parser { } var _currentToken = currentToken(); - var currentTokenKind = _currentToken.kind(); + var currentTokenKind = _currentToken.kind; return tryParseStatementWorker(_currentToken, currentTokenKind, modifierCount(), inErrorRecovery); } @@ -1780,7 +1743,7 @@ module TypeScript.Parser { // do not want to consume. This can happen when the user does not terminate their // existing block properly. We don't want to accidently consume these as expression // below. - if (isInterfaceEnumClassModuleImportOrExport(modifierCount)) { + if (isInterfaceEnumClassModuleImportOrExport(modifierCount, _currentToken)) { return undefined; } else if (isVariableStatement(modifierCount)) { @@ -1804,7 +1767,7 @@ module TypeScript.Parser { } function parseDebuggerStatement(debuggerKeyword: ISyntaxToken): DebuggerStatementSyntax { - return new syntaxFactory.DebuggerStatementSyntax(parseNodeData, consumeToken(debuggerKeyword), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); + return new DebuggerStatementSyntax(parseNodeData, consumeToken(debuggerKeyword), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseDoStatement(doKeyword: ISyntaxToken): DoStatementSyntax { @@ -1812,17 +1775,17 @@ module TypeScript.Parser { // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - return new syntaxFactory.DoStatementSyntax(parseNodeData, + return new DoStatementSyntax(parseNodeData, consumeToken(doKeyword), parseStatement(/*inErrorRecovery:*/ false), eatToken(SyntaxKind.WhileKeyword), eatToken(SyntaxKind.OpenParenToken), parseExpression(/*allowIn:*/ true), eatToken(SyntaxKind.CloseParenToken), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ true)); } function isLabeledStatement(currentToken: ISyntaxToken): boolean { - return isIdentifier(currentToken) && peekToken(1).kind() === SyntaxKind.ColonToken; + return isIdentifier(currentToken) && peekToken(1).kind === SyntaxKind.ColonToken; } function parseLabeledStatement(identifierToken: ISyntaxToken): LabeledStatementSyntax { - return new syntaxFactory.LabeledStatementSyntax(parseNodeData, + return new LabeledStatementSyntax(parseNodeData, consumeToken(identifierToken), eatToken(SyntaxKind.ColonToken), parseStatement(/*inErrorRecovery:*/ false)); } @@ -1835,18 +1798,18 @@ module TypeScript.Parser { listParsingState = savedListParsingState; var catchClause: CatchClauseSyntax = undefined; - if (currentToken().kind() === SyntaxKind.CatchKeyword) { + if (currentToken().kind === SyntaxKind.CatchKeyword) { catchClause = parseCatchClause(); } // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. var finallyClause: FinallyClauseSyntax = undefined; - if (!catchClause || currentToken().kind() === SyntaxKind.FinallyKeyword) { + if (!catchClause || currentToken().kind === SyntaxKind.FinallyKeyword) { finallyClause = parseFinallyClause(); } - return new syntaxFactory.TryStatementSyntax(parseNodeData, tryKeyword, block, catchClause, finallyClause); + return new TryStatementSyntax(parseNodeData, tryKeyword, block, catchClause, finallyClause); } function parseCatchClauseBlock(): BlockSyntax { @@ -1859,23 +1822,23 @@ module TypeScript.Parser { } function parseCatchClause(): CatchClauseSyntax { - return new syntaxFactory.CatchClauseSyntax(parseNodeData, + return new CatchClauseSyntax(parseNodeData, eatToken(SyntaxKind.CatchKeyword), eatToken(SyntaxKind.OpenParenToken), eatIdentifierToken(), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false), eatToken(SyntaxKind.CloseParenToken), parseCatchClauseBlock()); } function parseFinallyClause(): FinallyClauseSyntax { - return new syntaxFactory.FinallyClauseSyntax(parseNodeData, + return new FinallyClauseSyntax(parseNodeData, eatToken(SyntaxKind.FinallyKeyword), parseBlock(/*parseStatementsEvenWithNoOpenBrace:*/ false, /*checkForStrictMode:*/ false)); } function parseWithStatement(withKeyword: ISyntaxToken): WithStatementSyntax { - return new syntaxFactory.WithStatementSyntax(parseNodeData, + return new WithStatementSyntax(parseNodeData, consumeToken(withKeyword), eatToken(SyntaxKind.OpenParenToken), parseExpression(/*allowIn:*/ true), eatToken(SyntaxKind.CloseParenToken), parseStatement(/*inErrorRecovery:*/ false)); } function parseWhileStatement(whileKeyword: ISyntaxToken): WhileStatementSyntax { - return new syntaxFactory.WhileStatementSyntax(parseNodeData, + return new WhileStatementSyntax(parseNodeData, consumeToken(whileKeyword), eatToken(SyntaxKind.OpenParenToken), parseExpression(/*allowIn:*/ true), eatToken(SyntaxKind.CloseParenToken), parseStatement(/*inErrorRecovery:*/ false)); } @@ -1890,11 +1853,11 @@ module TypeScript.Parser { return false; } - return currentToken.kind() === SyntaxKind.SemicolonToken; + return currentToken.kind === SyntaxKind.SemicolonToken; } function parseEmptyStatement(semicolonToken: ISyntaxToken): EmptyStatementSyntax { - return new syntaxFactory.EmptyStatementSyntax(parseNodeData, consumeToken(semicolonToken)); + return new EmptyStatementSyntax(parseNodeData, consumeToken(semicolonToken)); } function parseForOrForInStatement(forKeyword: ISyntaxToken): IStatementSyntax { @@ -1904,7 +1867,7 @@ module TypeScript.Parser { var openParenToken = eatToken(SyntaxKind.OpenParenToken); var _currentToken = currentToken(); - var tokenKind = _currentToken.kind(); + var tokenKind = _currentToken.kind; if (tokenKind === SyntaxKind.VarKeyword) { // for ( var VariableDeclarationListNoIn; Expressionopt ; Expressionopt ) Statement // for ( var VariableDeclarationNoIn in Expression ) Statement @@ -1922,14 +1885,14 @@ module TypeScript.Parser { } function parseForOrForInStatementWithVariableDeclaration(forKeyword: ISyntaxToken, openParenToken: ISyntaxToken): IStatementSyntax { - // Debug.assert(forKeyword.kind === SyntaxKind.ForKeyword && openParenToken.kind() === SyntaxKind.OpenParenToken); - // Debug.assert(currentToken().kind() === SyntaxKind.VarKeyword); + // Debug.assert(forKeyword.kind === SyntaxKind.ForKeyword && openParenToken.kind === SyntaxKind.OpenParenToken); + // Debug.assert(currentToken().kind === SyntaxKind.VarKeyword); // for ( var VariableDeclarationListNoIn; Expressionopt ; Expressionopt ) Statement // for ( var VariableDeclarationNoIn in Expression ) Statement var variableDeclaration = parseVariableDeclaration(/*allowIn:*/ false); - return currentToken().kind() === SyntaxKind.InKeyword + return currentToken().kind === SyntaxKind.InKeyword ? parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, undefined) : parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, variableDeclaration, undefined); } @@ -1937,33 +1900,33 @@ module TypeScript.Parser { function parseForInStatementWithVariableDeclarationOrInitializer(forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax): ForInStatementSyntax { // for ( var VariableDeclarationNoIn in Expression ) Statement - return new syntaxFactory.ForInStatementSyntax(parseNodeData, + return new ForInStatementSyntax(parseNodeData, forKeyword, openParenToken, variableDeclaration, initializer, eatToken(SyntaxKind.InKeyword), parseExpression(/*allowIn:*/ true), eatToken(SyntaxKind.CloseParenToken), parseStatement(/*inErrorRecovery:*/ false)); } function parseForOrForInStatementWithInitializer(forKeyword: ISyntaxToken, openParenToken: ISyntaxToken): IStatementSyntax { - // Debug.assert(forKeyword.kind() === SyntaxKind.ForKeyword && openParenToken.kind() === SyntaxKind.OpenParenToken); + // Debug.assert(forKeyword.kind === SyntaxKind.ForKeyword && openParenToken.kind === SyntaxKind.OpenParenToken); // for ( ExpressionNoInopt; Expressionopt ; Expressionopt ) Statement // for ( LeftHandSideExpression in Expression ) Statement var initializer = parseExpression(/*allowIn:*/ false); - return currentToken().kind() === SyntaxKind.InKeyword + return currentToken().kind === SyntaxKind.InKeyword ? parseForInStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, undefined, initializer) : parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, undefined, initializer); } function parseForStatementWithNoVariableDeclarationOrInitializer(forKeyword: ISyntaxToken, openParenToken: ISyntaxToken): ForStatementSyntax { - // Debug.assert(forKeyword.kind() === SyntaxKind.ForKeyword && openParenToken.kind() === SyntaxKind.OpenParenToken); - // Debug.assert(currentToken().kind() === SyntaxKind.SemicolonToken); + // Debug.assert(forKeyword.kind === SyntaxKind.ForKeyword && openParenToken.kind === SyntaxKind.OpenParenToken); + // Debug.assert(currentToken().kind === SyntaxKind.SemicolonToken); // for ( ; Expressionopt ; Expressionopt ) Statement return parseForStatementWithVariableDeclarationOrInitializer(forKeyword, openParenToken, /*variableDeclaration:*/ undefined, /*initializer:*/ undefined); } function tryParseForStatementCondition(): IExpressionSyntax { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind !== SyntaxKind.SemicolonToken && tokenKind !== SyntaxKind.CloseParenToken && tokenKind !== SyntaxKind.EndOfFileToken) { @@ -1974,7 +1937,7 @@ module TypeScript.Parser { } function tryParseForStatementIncrementor(): IExpressionSyntax { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind !== SyntaxKind.CloseParenToken && tokenKind !== SyntaxKind.EndOfFileToken) { return parseExpression(/*allowIn:*/ true); @@ -1988,7 +1951,7 @@ module TypeScript.Parser { // a semicolon is never inserted automatically if the semicolon would then ... become // one of the two semicolons in the header of a for statement - return new syntaxFactory.ForStatementSyntax(parseNodeData, + return new ForStatementSyntax(parseNodeData, forKeyword, openParenToken, variableDeclaration, initializer, eatToken(SyntaxKind.SemicolonToken), tryParseForStatementCondition(), eatToken(SyntaxKind.SemicolonToken), tryParseForStatementIncrementor(), @@ -2009,12 +1972,12 @@ module TypeScript.Parser { } function parseBreakStatement(breakKeyword: ISyntaxToken): BreakStatementSyntax { - return new syntaxFactory.BreakStatementSyntax(parseNodeData, + return new BreakStatementSyntax(parseNodeData, consumeToken(breakKeyword), tryEatBreakOrContinueLabel(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseContinueStatement(continueKeyword: ISyntaxToken): ContinueStatementSyntax { - return new syntaxFactory.ContinueStatementSyntax(parseNodeData, + return new ContinueStatementSyntax(parseNodeData, consumeToken(continueKeyword), tryEatBreakOrContinueLabel(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -2027,14 +1990,14 @@ module TypeScript.Parser { var closeParenToken = eatToken(SyntaxKind.CloseParenToken); var openBraceToken = eatToken(SyntaxKind.OpenBraceToken); - var switchClauses = Syntax.emptyList(); + var switchClauses: ISwitchClauseSyntax[]; if (openBraceToken.fullWidth() > 0) { var skippedTokens: ISyntaxToken[] = getArray(); switchClauses = parseSyntaxList(ListParsingState.SwitchStatement_SwitchClauses, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); } - return new syntaxFactory.SwitchStatementSyntax(parseNodeData, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses, eatToken(SyntaxKind.CloseBraceToken)); + return new SwitchStatementSyntax(parseNodeData, switchKeyword, openParenToken, expression, closeParenToken, openBraceToken, switchClauses || [], eatToken(SyntaxKind.CloseBraceToken)); } function isSwitchClause(): boolean { @@ -2042,7 +2005,7 @@ module TypeScript.Parser { return true; } - var currentTokenKind = currentToken().kind(); + var currentTokenKind = currentToken().kind; return currentTokenKind === SyntaxKind.CaseKeyword || currentTokenKind === SyntaxKind.DefaultKeyword; } @@ -2055,7 +2018,7 @@ module TypeScript.Parser { } var _currentToken = currentToken(); - var kind = _currentToken.kind(); + var kind = _currentToken.kind; if (kind === SyntaxKind.CaseKeyword) { return parseCaseSwitchClause(_currentToken); } @@ -2073,7 +2036,7 @@ module TypeScript.Parser { consumeToken(caseKeyword); var expression = parseExpression(/*allowIn:*/ true); var colonToken = eatToken(SyntaxKind.ColonToken); - var statements = Syntax.emptyList(); + var statements: IStatementSyntax[]; // TODO: allow parsing of the list evne if there's no colon. However, we have to make // sure we add any skipped tokens to the right previous node or token. @@ -2083,7 +2046,7 @@ module TypeScript.Parser { colonToken = addSkippedTokensAfterToken(colonToken, skippedTokens); } - return new syntaxFactory.CaseSwitchClauseSyntax(parseNodeData, caseKeyword, expression, colonToken, statements); + return new CaseSwitchClauseSyntax(parseNodeData, caseKeyword, expression, colonToken, statements || []); } function parseDefaultSwitchClause(defaultKeyword: ISyntaxToken): DefaultSwitchClauseSyntax { @@ -2091,7 +2054,7 @@ module TypeScript.Parser { consumeToken(defaultKeyword); var colonToken = eatToken(SyntaxKind.ColonToken); - var statements = Syntax.emptyList(); + var statements: IStatementSyntax[]; // TODO: Allow parsing without a colon here. However, ensure that we attach any skipped // tokens to the defaultKeyword. @@ -2101,7 +2064,7 @@ module TypeScript.Parser { colonToken = addSkippedTokensAfterToken(colonToken, skippedTokens); } - return new syntaxFactory.DefaultSwitchClauseSyntax(parseNodeData, defaultKeyword, colonToken, statements); + return new DefaultSwitchClauseSyntax(parseNodeData, defaultKeyword, colonToken, statements || []); } function parseThrowStatementExpression(): IExpressionSyntax { @@ -2114,7 +2077,7 @@ module TypeScript.Parser { } function parseThrowStatement(throwKeyword: ISyntaxToken): ThrowStatementSyntax { - return new syntaxFactory.ThrowStatementSyntax(parseNodeData, + return new ThrowStatementSyntax(parseNodeData, consumeToken(throwKeyword), parseThrowStatementExpression(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } @@ -2123,38 +2086,42 @@ module TypeScript.Parser { } function parseReturnStatement(returnKeyword: ISyntaxToken): ReturnStatementSyntax { - return new syntaxFactory.ReturnStatementSyntax(parseNodeData, + return new ReturnStatementSyntax(parseNodeData, consumeToken(returnKeyword), tryParseReturnStatementExpression(), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function isExpressionStatement(currentToken: ISyntaxToken): boolean { // As per the gramar, neither { nor 'function' can start an expression statement. - var tokenKind = currentToken.kind(); + var tokenKind = currentToken.kind; return tokenKind !== SyntaxKind.OpenBraceToken && tokenKind !== SyntaxKind.FunctionKeyword && isExpression(currentToken); } function isAssignmentOrOmittedExpression(): boolean { var _currentToken = currentToken(); - return _currentToken.kind() === SyntaxKind.CommaToken || isExpression(_currentToken); + return _currentToken.kind === SyntaxKind.CommaToken || isExpression(_currentToken); } function tryParseAssignmentOrOmittedExpression(): IExpressionSyntax { // Debug.assert(isAssignmentOrOmittedExpression()); - if (currentToken().kind() === SyntaxKind.CommaToken) { - return new syntaxFactory.OmittedExpressionSyntax(parseNodeData); + if (currentToken().kind === SyntaxKind.CommaToken) { + return new OmittedExpressionSyntax(parseNodeData); } return tryParseAssignmentExpressionOrHigher(/*force:*/ false, /*allowIn:*/ true); } function isExpression(currentToken: ISyntaxToken): boolean { - switch (currentToken.kind()) { + switch (currentToken.kind) { // Literals case SyntaxKind.NumericLiteral: case SyntaxKind.StringLiteral: case SyntaxKind.RegularExpressionLiteral: + // Templates + case SyntaxKind.NoSubstitutionTemplateToken: + case SyntaxKind.TemplateStartToken: + // For array literals. case SyntaxKind.OpenBracketToken: @@ -2216,34 +2183,34 @@ module TypeScript.Parser { } function parseExpressionStatement(): ExpressionStatementSyntax { - return new syntaxFactory.ExpressionStatementSyntax(parseNodeData, parseExpression(/*allowIn:*/ true), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); + return new ExpressionStatementSyntax(parseNodeData, parseExpression(/*allowIn:*/ true), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseIfStatement(ifKeyword: ISyntaxToken): IfStatementSyntax { - return new syntaxFactory.IfStatementSyntax(parseNodeData, + return new IfStatementSyntax(parseNodeData, consumeToken(ifKeyword), eatToken(SyntaxKind.OpenParenToken), parseExpression(/*allowIn:*/ true), eatToken(SyntaxKind.CloseParenToken), parseStatement(/*inErrorRecovery:*/ false), parseOptionalElseClause()); } function parseOptionalElseClause(): ElseClauseSyntax { - return currentToken().kind() === SyntaxKind.ElseKeyword ? parseElseClause() : undefined; + return currentToken().kind === SyntaxKind.ElseKeyword ? parseElseClause() : undefined; } function parseElseClause(): ElseClauseSyntax { - return new syntaxFactory.ElseClauseSyntax(parseNodeData, eatToken(SyntaxKind.ElseKeyword), parseStatement(/*inErrorRecovery:*/ false)); + return new ElseClauseSyntax(parseNodeData, eatToken(SyntaxKind.ElseKeyword), parseStatement(/*inErrorRecovery:*/ false)); } function isVariableStatement(modifierCount: number): boolean { - return peekToken(modifierCount).kind() === SyntaxKind.VarKeyword; + return peekToken(modifierCount).kind === SyntaxKind.VarKeyword; } function parseVariableStatement(): VariableStatementSyntax { - return new syntaxFactory.VariableStatementSyntax(parseNodeData, + return new VariableStatementSyntax(parseNodeData, parseModifiers(), parseVariableDeclaration(/*allowIn:*/ true), eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false)); } function parseVariableDeclaration(allowIn: boolean): VariableDeclarationSyntax { - // Debug.assert(currentToken().kind() === SyntaxKind.VarKeyword); + // Debug.assert(currentToken().kind === SyntaxKind.VarKeyword); var varKeyword = eatToken(SyntaxKind.VarKeyword); // Debug.assert(varKeyword.fullWidth() > 0); @@ -2256,12 +2223,12 @@ module TypeScript.Parser { var variableDeclarators = parseSeparatedSyntaxList(listParsingState, skippedTokens); varKeyword = addSkippedTokensAfterToken(varKeyword, skippedTokens); - return new syntaxFactory.VariableDeclarationSyntax(parseNodeData, varKeyword, variableDeclarators); + return new VariableDeclarationSyntax(parseNodeData, varKeyword, variableDeclarators); } function isVariableDeclarator(): boolean { var node = currentNode(); - if (node && node.kind() === SyntaxKind.VariableDeclarator) { + if (node && node.kind === SyntaxKind.VariableDeclarator) { return true; } @@ -2269,7 +2236,7 @@ module TypeScript.Parser { } function canReuseVariableDeclaratorNode(node: ISyntaxNode) { - if (!node || node.kind() !== SyntaxKind.VariableDeclarator) { + if (!node || node.kind !== SyntaxKind.VariableDeclarator) { return false; } @@ -2324,12 +2291,12 @@ module TypeScript.Parser { } } - return new syntaxFactory.VariableDeclaratorSyntax(parseNodeData, propertyName, typeAnnotation, equalsValueClause); + return new VariableDeclaratorSyntax(parseNodeData, propertyName, typeAnnotation, equalsValueClause); } function isEqualsValueClause(inParameter: boolean): boolean { var token0 = currentToken(); - if (token0.kind() === SyntaxKind.EqualsToken) { + if (token0.kind === SyntaxKind.EqualsToken) { return true; } @@ -2337,7 +2304,7 @@ module TypeScript.Parser { // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. if (!previousTokenHasTrailingNewLine(token0)) { - var tokenKind = token0.kind(); + var tokenKind = token0.kind; // The 'isExpression' call below returns true for "=>". That's because it smartly // assumes that there is just a missing identifier and the user wanted a lambda. @@ -2365,7 +2332,7 @@ module TypeScript.Parser { } function parseEqualsValueClause(allowIn: boolean): EqualsValueClauseSyntax { - return new syntaxFactory.EqualsValueClauseSyntax(parseNodeData, + return new EqualsValueClauseSyntax(parseNodeData, eatToken(SyntaxKind.EqualsToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, allowIn)); } @@ -2377,11 +2344,11 @@ module TypeScript.Parser { var leftOperand = tryParseAssignmentExpressionOrHigher(/*force:*/ true, allowIn); while (true) { var _currentToken = currentToken(); - if (_currentToken.kind() !== SyntaxKind.CommaToken) { + if (_currentToken.kind !== SyntaxKind.CommaToken) { break; } - leftOperand = new syntaxFactory.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(_currentToken), + leftOperand = new BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(_currentToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, allowIn)); } @@ -2444,8 +2411,8 @@ module TypeScript.Parser { var operatorToken = currentOperatorToken(); // Check for recursive assignment expressions. - if (SyntaxFacts.isAssignmentOperatorToken(operatorToken.kind())) { - return new syntaxFactory.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), + if (SyntaxFacts.isAssignmentOperatorToken(operatorToken.kind)) { + return new BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, allowIn)); } } @@ -2461,7 +2428,7 @@ module TypeScript.Parser { } function tryParseUnaryExpressionOrHigher(_currentToken: ISyntaxToken, force: boolean): IUnaryExpressionSyntax { - var currentTokenKind = _currentToken.kind(); + var currentTokenKind = _currentToken.kind; switch (currentTokenKind) { case SyntaxKind.PlusToken: @@ -2470,7 +2437,7 @@ module TypeScript.Parser { case SyntaxKind.ExclamationToken: case SyntaxKind.PlusPlusToken: case SyntaxKind.MinusMinusToken: - return new syntaxFactory.PrefixUnaryExpressionSyntax(parseNodeData, consumeToken(_currentToken), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); + return new PrefixUnaryExpressionSyntax(parseNodeData, consumeToken(_currentToken), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); case SyntaxKind.TypeOfKeyword: return parseTypeOfExpression(_currentToken); case SyntaxKind.VoidKeyword: return parseVoidExpression(_currentToken); case SyntaxKind.DeleteKeyword: return parseDeleteExpression(_currentToken); @@ -2503,14 +2470,14 @@ module TypeScript.Parser { var _currentToken = currentToken(); // Now check for conditional expression. - if (_currentToken.kind() !== SyntaxKind.QuestionToken) { + if (_currentToken.kind !== SyntaxKind.QuestionToken) { return leftOperand; } // Note: we explicitly do *not* pass 'allowIn' to the whenTrue part. An 'in' expression is always // allowed in the 'true' part of a conditional expression. - return new syntaxFactory.ConditionalExpressionSyntax(parseNodeData, + return new ConditionalExpressionSyntax(parseNodeData, leftOperand, consumeToken(_currentToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, /*allowIn:*/ true), eatToken(SyntaxKind.ColonToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, allowIn)); } @@ -2521,7 +2488,7 @@ module TypeScript.Parser { // currentOperatorToken versus currentToken here so that we merge token sequences // like > and = into >= var operatorToken = currentOperatorToken(); - var tokenKind = operatorToken.kind(); + var tokenKind = operatorToken.kind; // Only proceed if we see binary expression token. However we don't parse // assignment expressions or comma expressions here. Those are taken care of @@ -2551,7 +2518,7 @@ module TypeScript.Parser { // Precedence is okay, so we'll "take" this operator. // Now skip the operator token we're on. - leftOperand = new syntaxFactory.BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), + leftOperand = new BinaryExpressionSyntax(parseNodeData, leftOperand, consumeToken(operatorToken), tryParseBinaryExpressionOrHigher(currentToken(), /*force:*/ true, newPrecedence, allowIn)); } @@ -2563,7 +2530,7 @@ module TypeScript.Parser { // If we see a > we need to see if we can actually merge this contextually into a // >> >>> >= >>= >>>= token. - if (token0.kind() === SyntaxKind.GreaterThanToken) { + if (token0.kind === SyntaxKind.GreaterThanToken) { return currentContextualToken(); // var kind = token0.kind; //Debug.assert(kind() === SyntaxKind.GreaterThanToken || kind() === SyntaxKind.GreaterThanGreaterThanToken || @@ -2633,11 +2600,11 @@ module TypeScript.Parser { function parseCallExpressionRest(expression: ILeftHandSideExpressionSyntax): ILeftHandSideExpressionSyntax { while (true) { var _currentToken = currentToken(); - var currentTokenKind = _currentToken.kind(); + var currentTokenKind = _currentToken.kind; switch (currentTokenKind) { case SyntaxKind.OpenParenToken: - expression = new syntaxFactory.InvocationExpressionSyntax(parseNodeData, expression, parseArgumentList(/*typeArgumentList:*/ undefined)); + expression = new InvocationExpressionSyntax(parseNodeData, expression, parseArgumentList(/*typeArgumentList:*/ undefined)); continue; case SyntaxKind.LessThanToken: @@ -2650,7 +2617,7 @@ module TypeScript.Parser { break; } - expression = new syntaxFactory.InvocationExpressionSyntax(parseNodeData, expression, argumentList); + expression = new InvocationExpressionSyntax(parseNodeData, expression, argumentList); continue; case SyntaxKind.OpenBracketToken: @@ -2658,7 +2625,12 @@ module TypeScript.Parser { continue; case SyntaxKind.DotToken: - expression = new syntaxFactory.MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + expression = new MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + continue; + + case SyntaxKind.NoSubstitutionTemplateToken: + case SyntaxKind.TemplateStartToken: + expression = new TemplateAccessExpressionSyntax(parseNodeData, expression, parseTemplateExpression(_currentToken)); continue; } @@ -2669,7 +2641,7 @@ module TypeScript.Parser { function parseMemberExpressionRest(expression: IMemberExpressionSyntax, inObjectCreation: boolean): IMemberExpressionSyntax { while (true) { var _currentToken = currentToken(); - var currentTokenKind = _currentToken.kind(); + var currentTokenKind = _currentToken.kind; switch (currentTokenKind) { case SyntaxKind.OpenBracketToken: @@ -2677,7 +2649,12 @@ module TypeScript.Parser { continue; case SyntaxKind.DotToken: - expression = new syntaxFactory.MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + expression = new MemberAccessExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken), eatIdentifierNameToken()); + continue; + + case SyntaxKind.NoSubstitutionTemplateToken: + case SyntaxKind.TemplateStartToken: + expression = new TemplateAccessExpressionSyntax(parseNodeData, expression, parseTemplateExpression(_currentToken)); continue; } @@ -2718,7 +2695,7 @@ module TypeScript.Parser { // CallExpression productions. var expression: ILeftHandSideExpressionSyntax = undefined; - if (_currentToken.kind() === SyntaxKind.SuperKeyword) { + if (_currentToken.kind === SyntaxKind.SuperKeyword) { expression = parseSuperExpression(_currentToken); } else { @@ -2738,10 +2715,10 @@ module TypeScript.Parser { // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var currentTokenKind = currentToken().kind(); + var currentTokenKind = currentToken().kind; return currentTokenKind === SyntaxKind.OpenParenToken || currentTokenKind === SyntaxKind.DotToken ? expression - : new syntaxFactory.MemberAccessExpressionSyntax(parseNodeData, expression, eatToken(SyntaxKind.DotToken), eatIdentifierNameToken()); + : new MemberAccessExpressionSyntax(parseNodeData, expression, eatToken(SyntaxKind.DotToken), eatIdentifierNameToken()); } function tryParsePostfixExpressionOrHigher(_currentToken: ISyntaxToken, force: boolean): IPostfixExpressionSyntax { @@ -2751,7 +2728,7 @@ module TypeScript.Parser { } var _currentToken = currentToken(); - var currentTokenKind = _currentToken.kind(); + var currentTokenKind = _currentToken.kind; switch (currentTokenKind) { case SyntaxKind.PlusPlusToken: @@ -2762,21 +2739,21 @@ module TypeScript.Parser { break; } - return new syntaxFactory.PostfixUnaryExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken)); + return new PostfixUnaryExpressionSyntax(parseNodeData, expression, consumeToken(_currentToken)); } return expression; } function tryParseGenericArgumentList(): ArgumentListSyntax { - // Debug.assert(currentToken().kind() === SyntaxKind.LessThanToken); + // Debug.assert(currentToken().kind === SyntaxKind.LessThanToken); // If we have a '<', then only parse this as a arugment list if the type arguments // are complete and we have an open paren. if we don't, rewind and return nothing. var rewindPoint = getRewindPoint(); var typeArgumentList = tryParseTypeArgumentList(/*inExpression:*/ true); var token0 = currentToken(); - var tokenKind = token0.kind(); + var tokenKind = token0.kind; var isOpenParen = tokenKind === SyntaxKind.OpenParenToken; var isDot = tokenKind === SyntaxKind.DotToken; @@ -2804,8 +2781,8 @@ module TypeScript.Parser { DiagnosticCode.A_parameter_list_must_follow_a_generic_type_argument_list_expected, undefined); addDiagnostic(diagnostic); - return new syntaxFactory.ArgumentListSyntax(parseNodeData, typeArgumentList, - Syntax.emptyToken(SyntaxKind.OpenParenToken), Syntax.emptySeparatedList(), Syntax.emptyToken(SyntaxKind.CloseParenToken)); + return new ArgumentListSyntax(parseNodeData, typeArgumentList, + Syntax.emptyToken(SyntaxKind.OpenParenToken), [], Syntax.emptyToken(SyntaxKind.CloseParenToken)); } else { return parseArgumentList(typeArgumentList); @@ -2814,7 +2791,7 @@ module TypeScript.Parser { } function tryParseArgumentList(): ArgumentListSyntax { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind === SyntaxKind.LessThanToken) { return tryParseGenericArgumentList(); } @@ -2830,7 +2807,7 @@ module TypeScript.Parser { var openParenToken = eatToken(SyntaxKind.OpenParenToken); // Don't use the name 'arguments' it prevents V8 from optimizing this method. - var _arguments = Syntax.emptySeparatedList(); + var _arguments: ISeparatedSyntaxList; if (openParenToken.fullWidth() > 0) { var skippedTokens: ISyntaxToken[] = getArray(); @@ -2838,7 +2815,7 @@ module TypeScript.Parser { openParenToken = addSkippedTokensAfterToken(openParenToken, skippedTokens); } - return new syntaxFactory.ArgumentListSyntax(parseNodeData, typeArgumentList, openParenToken, _arguments, eatToken(SyntaxKind.CloseParenToken)); + return new ArgumentListSyntax(parseNodeData, typeArgumentList, openParenToken, _arguments || [], eatToken(SyntaxKind.CloseParenToken)); } function tryParseArgumentListExpression(): IExpressionSyntax { @@ -2849,14 +2826,14 @@ module TypeScript.Parser { // after the open paren, we still want to force parsing an expression (which will // cause a missing identiifer to be created), so that we will then consume the // comma and the following list items). - var force = currentToken().kind() === SyntaxKind.CommaToken; + var force = currentToken().kind === SyntaxKind.CommaToken; return tryParseAssignmentExpressionOrHigher(force, /*allowIn:*/ true); } function parseElementAccessArgumentExpression(openBracketToken: ISyntaxToken, inObjectCreation: boolean) { // It's not uncommon for a user to write: "new Type[]". Check for that common pattern // and report a better error message. - if (inObjectCreation && currentToken().kind() === SyntaxKind.CloseBracketToken) { + if (inObjectCreation && currentToken().kind === SyntaxKind.CloseBracketToken) { var errorStart = start(openBracketToken, source.text); var errorEnd = end(currentToken(), source.text); var diagnostic = new Diagnostic(fileName, source.text.lineMap(), errorStart, errorEnd - errorStart, @@ -2871,8 +2848,8 @@ module TypeScript.Parser { } function parseElementAccessExpression(expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, inObjectCreation: boolean): ElementAccessExpressionSyntax { - // Debug.assert(currentToken().kind() === SyntaxKind.OpenBracketToken); - return new syntaxFactory.ElementAccessExpressionSyntax(parseNodeData, expression, consumeToken(openBracketToken), + // Debug.assert(currentToken().kind === SyntaxKind.OpenBracketToken); + return new ElementAccessExpressionSyntax(parseNodeData, expression, consumeToken(openBracketToken), parseElementAccessArgumentExpression(openBracketToken, inObjectCreation), eatToken(SyntaxKind.CloseBracketToken)); } @@ -2881,7 +2858,7 @@ module TypeScript.Parser { return eatIdentifierToken(); } - var currentTokenKind = _currentToken.kind(); + var currentTokenKind = _currentToken.kind; switch (currentTokenKind) { case SyntaxKind.ThisKeyword: case SyntaxKind.TrueKeyword: @@ -2892,11 +2869,15 @@ module TypeScript.Parser { case SyntaxKind.StringLiteral: return consumeToken(_currentToken); - case SyntaxKind.FunctionKeyword: return parseFunctionExpression(_currentToken); - case SyntaxKind.OpenBracketToken: return parseArrayLiteralExpression(_currentToken); - case SyntaxKind.OpenBraceToken: return parseObjectLiteralExpression(_currentToken); - case SyntaxKind.OpenParenToken: return parseParenthesizedExpression(_currentToken); - case SyntaxKind.NewKeyword: return parseObjectCreationExpression(_currentToken); + case SyntaxKind.FunctionKeyword: return parseFunctionExpression(_currentToken); + case SyntaxKind.OpenBracketToken: return parseArrayLiteralExpression(_currentToken); + case SyntaxKind.OpenBraceToken: return parseObjectLiteralExpression(_currentToken); + case SyntaxKind.OpenParenToken: return parseParenthesizedExpression(_currentToken); + case SyntaxKind.NewKeyword: return parseObjectCreationExpression(_currentToken); + + case SyntaxKind.NoSubstitutionTemplateToken: + case SyntaxKind.TemplateStartToken: + return parseTemplateExpression(_currentToken); case SyntaxKind.SlashToken: case SyntaxKind.SlashEqualsToken: @@ -2924,7 +2905,7 @@ module TypeScript.Parser { // contexts. // var currentToken = this.currentToken(); - // Debug.assert(SyntaxFacts.isAnyDivideToken(currentToken.kind())); + // Debug.assert(SyntaxFacts.isAnyDivideToken(currentToken.kind)); // Ok, from our quick lexical check, this could be a place where a regular expression could // go. Now we have to do a bunch of work. Ask the source to retrive the token at the @@ -2933,9 +2914,9 @@ module TypeScript.Parser { // Note: we *must* have gotten a /, /= or regular expression. Or else something went *very* // wrong with our logic above. - // Debug.assert(SyntaxFacts.isAnyDivideOrRegularExpressionToken(currentToken.kind())); + // Debug.assert(SyntaxFacts.isAnyDivideOrRegularExpressionToken(currentToken.kind)); - var tokenKind = currentToken.kind(); + var tokenKind = currentToken.kind; if (tokenKind === SyntaxKind.SlashToken || tokenKind === SyntaxKind.SlashEqualsToken) { // Still came back as a / or /=. This is not a regular expression literal. return undefined; @@ -2951,19 +2932,19 @@ module TypeScript.Parser { } function parseTypeOfExpression(typeOfKeyword: ISyntaxToken): TypeOfExpressionSyntax { - return new syntaxFactory.TypeOfExpressionSyntax(parseNodeData, consumeToken(typeOfKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); + return new TypeOfExpressionSyntax(parseNodeData, consumeToken(typeOfKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); } function parseDeleteExpression(deleteKeyword: ISyntaxToken): DeleteExpressionSyntax { - return new syntaxFactory.DeleteExpressionSyntax(parseNodeData, consumeToken(deleteKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); + return new DeleteExpressionSyntax(parseNodeData, consumeToken(deleteKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); } function parseVoidExpression(voidKeyword: ISyntaxToken): VoidExpressionSyntax { - return new syntaxFactory.VoidExpressionSyntax(parseNodeData, consumeToken(voidKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); + return new VoidExpressionSyntax(parseNodeData, consumeToken(voidKeyword), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); } function parseFunctionExpression(functionKeyword: ISyntaxToken): FunctionExpressionSyntax { - return new syntaxFactory.FunctionExpressionSyntax(parseNodeData, + return new FunctionExpressionSyntax(parseNodeData, consumeToken(functionKeyword), eatOptionalIdentifierToken(), parseCallSignature(/*requireCompleteTypeParameterList:*/ false), parseBlock(/*parseStatementsEvenWithNoOpenBrace:*/ false, /*checkForStrictMode:*/ true)); @@ -2979,22 +2960,59 @@ module TypeScript.Parser { // See comment in tryParseMemberExpressionOrHigher for a more complete explanation of // this decision. - return new syntaxFactory.ObjectCreationExpressionSyntax(parseNodeData, + return new ObjectCreationExpressionSyntax(parseNodeData, consumeToken(newKeyword), tryParseMemberExpressionOrHigher(currentToken(), /*force:*/ true, /*inObjectCreation:*/ true), tryParseArgumentList()); } + function parseTemplateExpression(startToken: ISyntaxToken): IPrimaryExpressionSyntax { + consumeToken(startToken); + + if (startToken.kind === SyntaxKind.NoSubstitutionTemplateToken) { + return startToken; + } + + var templateClauses: TemplateClauseSyntax[] = getArray(); + + do { + // Keep consuming template spans as long as the last one we keep getting template + // middle pieces. + templateClauses.push(parseTemplateClause()); + } + while (templateClauses[templateClauses.length - 1].templateMiddleOrEndToken.kind === SyntaxKind.TemplateMiddleToken); + + return new TemplateExpressionSyntax(parseNodeData, startToken, Syntax.list(templateClauses)); + } + + function parseTemplateClause(): TemplateClauseSyntax { + var expression = parseExpression(/*allowIn:*/ true); + var token = currentToken(); + + if (token.kind === SyntaxKind.CloseBraceToken) { + token = currentContextualToken(); + Debug.assert(token.kind === SyntaxKind.TemplateMiddleToken || token.kind === SyntaxKind.TemplateEndToken); + consumeToken(token); + } + else { + var diagnostic = getExpectedTokenDiagnostic(SyntaxKind.CloseBraceToken); + addDiagnostic(diagnostic); + token = Syntax.emptyToken(SyntaxKind.TemplateEndToken); + } + + return new TemplateClauseSyntax(parseNodeData, expression, token); + } + function parseCastExpression(lessThanToken: ISyntaxToken): CastExpressionSyntax { - return new syntaxFactory.CastExpressionSyntax(parseNodeData, + return new CastExpressionSyntax(parseNodeData, consumeToken(lessThanToken), parseType(), eatToken(SyntaxKind.GreaterThanToken), tryParseUnaryExpressionOrHigher(currentToken(), /*force:*/ true)); } function parseParenthesizedExpression(openParenToken: ISyntaxToken): ParenthesizedExpressionSyntax { - return new syntaxFactory.ParenthesizedExpressionSyntax(parseNodeData, + return new ParenthesizedExpressionSyntax(parseNodeData, consumeToken(openParenToken), parseExpression(/*allowIn:*/ true), eatToken(SyntaxKind.CloseParenToken)); } function tryParseParenthesizedArrowFunctionExpression(): ParenthesizedArrowFunctionExpressionSyntax { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind !== SyntaxKind.OpenParenToken && tokenKind !== SyntaxKind.LessThanToken) { return undefined; } @@ -3034,11 +3052,11 @@ module TypeScript.Parser { function tryParseParenthesizedArrowFunctionExpressionWorker(requireArrow: boolean): ParenthesizedArrowFunctionExpressionSyntax { var _currentToken = currentToken(); - // Debug.assert(currentToken.kind() === SyntaxKind.OpenParenToken || currentToken.kind() === SyntaxKind.LessThanToken); + // Debug.assert(currentToken.kind === SyntaxKind.OpenParenToken || currentToken.kind === SyntaxKind.LessThanToken); var callSignature = parseCallSignature(/*requireCompleteTypeParameterList:*/ true); - if (requireArrow && currentToken().kind() !== SyntaxKind.EqualsGreaterThanToken) { + if (requireArrow && currentToken().kind !== SyntaxKind.EqualsGreaterThanToken) { return undefined; } @@ -3050,7 +3068,7 @@ module TypeScript.Parser { expression = tryParseAssignmentExpressionOrHigher(/*force:*/ true, /*allowIn:*/ true); } - return new syntaxFactory.ParenthesizedArrowFunctionExpressionSyntax(parseNodeData, callSignature, equalsGreaterThanToken, block, expression); + return new ParenthesizedArrowFunctionExpressionSyntax(parseNodeData, callSignature, equalsGreaterThanToken, block, expression); } function tryParseArrowFunctionBlock(): BlockSyntax { @@ -3086,12 +3104,12 @@ module TypeScript.Parser { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function as that's likely what // the user intended to write. - if (_currentToken.kind() === SyntaxKind.EqualsGreaterThanToken) { + if (_currentToken.kind === SyntaxKind.EqualsGreaterThanToken) { return true; } return isIdentifier(_currentToken) && - peekToken(1).kind() === SyntaxKind.EqualsGreaterThanToken; + peekToken(1).kind === SyntaxKind.EqualsGreaterThanToken; } function parseSimpleArrowFunctionExpression(): SimpleArrowFunctionExpressionSyntax { @@ -3106,23 +3124,23 @@ module TypeScript.Parser { expression = tryParseAssignmentExpressionOrHigher(/*force:*/ true, /*allowIn:*/ true); } - return new syntaxFactory.SimpleArrowFunctionExpressionSyntax(parseNodeData, parameter, equalsGreaterThanToken, block, expression); + return new SimpleArrowFunctionExpressionSyntax(parseNodeData, parameter, equalsGreaterThanToken, block, expression); } function isBlock(): boolean { - return currentToken().kind() === SyntaxKind.OpenBraceToken; + return currentToken().kind === SyntaxKind.OpenBraceToken; } function isDefinitelyArrowFunctionExpression(): boolean { var token0 = currentToken(); - if (token0.kind() !== SyntaxKind.OpenParenToken) { + if (token0.kind !== SyntaxKind.OpenParenToken) { // If it didn't start with an (, then it could be generic. That's too complicated // and we can't say it's 'definitely' an arrow function. return false; } var token1 = peekToken(1); - var token1Kind = token1.kind(); + var token1Kind = token1.kind; var token2: ISyntaxToken; @@ -3135,7 +3153,7 @@ module TypeScript.Parser { // "():" or "() =>" or "() {}". Note: the last one is illegal. However it // most likely is a missing => and not a parenthesized expression. token2 = peekToken(2); - var token2Kind = token2.kind(); + var token2Kind = token2.kind; return token2Kind === SyntaxKind.ColonToken || token2Kind === SyntaxKind.EqualsGreaterThanToken || token2Kind === SyntaxKind.OpenBraceToken; @@ -3148,7 +3166,7 @@ module TypeScript.Parser { } token2 = peekToken(2); - token2Kind = token2.kind(); + token2Kind = token2.kind; if (SyntaxFacts.isAccessibilityModifier(token1Kind)) { if (isIdentifier(token2)) { @@ -3177,7 +3195,7 @@ module TypeScript.Parser { } var token3 = peekToken(3); - var token3Kind = token3.kind(); + var token3Kind = token3.kind; if (token2Kind === SyntaxKind.QuestionToken) { // (id? // Could be an arrow function, or a parenthesized conditional expression. @@ -3220,7 +3238,7 @@ module TypeScript.Parser { function isPossiblyArrowFunctionExpression(): boolean { var token0 = currentToken(); - if (token0.kind() !== SyntaxKind.OpenParenToken) { + if (token0.kind !== SyntaxKind.OpenParenToken) { // If it didn't start with an (, then it could be generic. That's too complicated // and we have to say it's possibly an arrow function. return true; @@ -3235,7 +3253,7 @@ module TypeScript.Parser { } var token2 = peekToken(2); - var token2Kind = token2.kind(); + var token2Kind = token2.kind; if (token2Kind === SyntaxKind.EqualsToken) { // (id = // @@ -3258,7 +3276,7 @@ module TypeScript.Parser { // (id) var token3 = peekToken(3); - if (token3.kind() === SyntaxKind.ColonToken) { + if (token3.kind === SyntaxKind.ColonToken) { // (id): // // This could be an arrow function. i.e. (id): number => { } @@ -3273,7 +3291,7 @@ module TypeScript.Parser { } function parseObjectLiteralExpression(openBraceToken: ISyntaxToken): ObjectLiteralExpressionSyntax { - // Debug.assert(currentToken().kind() === SyntaxKind.OpenBraceToken); + // Debug.assert(currentToken().kind === SyntaxKind.OpenBraceToken); consumeToken(openBraceToken); // Debug.assert(openBraceToken.fullWidth() > 0); @@ -3282,7 +3300,7 @@ module TypeScript.Parser { var propertyAssignments = parseSeparatedSyntaxList(ListParsingState.ObjectLiteralExpression_PropertyAssignments, skippedTokens); openBraceToken = addSkippedTokensAfterToken(openBraceToken, skippedTokens); - return new syntaxFactory.ObjectLiteralExpressionSyntax(parseNodeData, openBraceToken, propertyAssignments, eatToken(SyntaxKind.CloseBraceToken)); + return new ObjectLiteralExpressionSyntax(parseNodeData, openBraceToken, propertyAssignments, eatToken(SyntaxKind.CloseBraceToken)); } function tryParsePropertyAssignment(inErrorRecovery: boolean): IPropertyAssignmentSyntax { @@ -3321,7 +3339,7 @@ module TypeScript.Parser { } function parseFunctionPropertyAssignment(): FunctionPropertyAssignmentSyntax { - return new syntaxFactory.FunctionPropertyAssignmentSyntax(parseNodeData, + return new FunctionPropertyAssignmentSyntax(parseNodeData, eatPropertyName(), parseCallSignature(/*requireCompleteTypeParameterList:*/ false), parseBlock(/*parseBlockEvenWithNoOpenBrace:*/ false, /*checkForStrictMode:*/ true)); } @@ -3331,7 +3349,7 @@ module TypeScript.Parser { } function parseSimplePropertyAssignment(): SimplePropertyAssignmentSyntax { - return new syntaxFactory.SimplePropertyAssignmentSyntax(parseNodeData, + return new SimplePropertyAssignmentSyntax(parseNodeData, eatPropertyName(), eatToken(SyntaxKind.ColonToken), tryParseAssignmentExpressionOrHigher(/*force:*/ true, /*allowIn:*/ true)); } @@ -3354,12 +3372,14 @@ module TypeScript.Parser { } } - var kind = token.kind(); - return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NumericLiteral; + // We allow a template literal while parser for error tolerance. We'll report errors + // on this later in the grammar checker walker. + var kind = token.kind; + return kind === SyntaxKind.StringLiteral || kind === SyntaxKind.NumericLiteral || kind === SyntaxKind.NoSubstitutionTemplateToken; } function parseArrayLiteralExpression(openBracketToken: ISyntaxToken): ArrayLiteralExpressionSyntax { - // Debug.assert(currentToken().kind() === SyntaxKind.OpenBracketToken); + // Debug.assert(currentToken().kind === SyntaxKind.OpenBracketToken); consumeToken(openBracketToken); // Debug.assert(openBracketToken.fullWidth() > 0); @@ -3367,12 +3387,12 @@ module TypeScript.Parser { var expressions = parseSeparatedSyntaxList(ListParsingState.ArrayLiteralExpression_AssignmentExpressions, skippedTokens); openBracketToken = addSkippedTokensAfterToken(openBracketToken, skippedTokens); - return new syntaxFactory.ArrayLiteralExpressionSyntax(parseNodeData, openBracketToken, expressions, eatToken(SyntaxKind.CloseBracketToken)); + return new ArrayLiteralExpressionSyntax(parseNodeData, openBracketToken, expressions, eatToken(SyntaxKind.CloseBracketToken)); } function parseBlock(parseBlockEvenWithNoOpenBrace: boolean, checkForStrictMode: boolean): BlockSyntax { var openBraceToken = eatToken(SyntaxKind.OpenBraceToken); - var statements = Syntax.emptyList(); + var statements: IStatementSyntax[]; if (parseBlockEvenWithNoOpenBrace || openBraceToken.fullWidth() > 0) { var savedIsInStrictMode = isInStrictMode; @@ -3385,17 +3405,17 @@ module TypeScript.Parser { setStrictMode(savedIsInStrictMode); } - return new syntaxFactory.BlockSyntax(parseNodeData, openBraceToken, statements, eatToken(SyntaxKind.CloseBraceToken)); + return new BlockSyntax(parseNodeData, openBraceToken, statements || [], eatToken(SyntaxKind.CloseBraceToken)); } function parseCallSignature(requireCompleteTypeParameterList: boolean): CallSignatureSyntax { - return new syntaxFactory.CallSignatureSyntax(parseNodeData, + return new CallSignatureSyntax(parseNodeData, tryParseTypeParameterList(requireCompleteTypeParameterList), parseParameterList(), parseOptionalTypeAnnotation(/*allowStringLiteral:*/ false)); } function tryParseTypeParameterList(requireCompleteTypeParameterList: boolean): TypeParameterListSyntax { var _currentToken = currentToken(); - if (_currentToken.kind() !== SyntaxKind.LessThanToken) { + if (_currentToken.kind !== SyntaxKind.LessThanToken) { return undefined; } @@ -3417,7 +3437,7 @@ module TypeScript.Parser { } else { releaseRewindPoint(rewindPoint); - return new syntaxFactory.TypeParameterListSyntax(parseNodeData, lessThanToken, typeParameters, greaterThanToken); + return new TypeParameterListSyntax(parseNodeData, lessThanToken, typeParameters, greaterThanToken); } } @@ -3431,22 +3451,22 @@ module TypeScript.Parser { return undefined; } - return new syntaxFactory.TypeParameterSyntax(parseNodeData, eatIdentifierToken(), tryParseConstraint()); + return new TypeParameterSyntax(parseNodeData, eatIdentifierToken(), tryParseConstraint()); } function tryParseConstraint(): ConstraintSyntax { - if (currentToken().kind() !== SyntaxKind.ExtendsKeyword) { + if (currentToken().kind !== SyntaxKind.ExtendsKeyword) { return undefined; } - return new syntaxFactory.ConstraintSyntax(parseNodeData, eatToken(SyntaxKind.ExtendsKeyword), parseTypeOrExpression()); + return new ConstraintSyntax(parseNodeData, eatToken(SyntaxKind.ExtendsKeyword), parseTypeOrExpression()); } function tryParseParameterList(): ParameterListSyntax { - if (currentToken().kind() === SyntaxKind.OpenParenToken) { + if (currentToken().kind === SyntaxKind.OpenParenToken) { var token1 = peekToken(1); - if (token1.kind() === SyntaxKind.CloseParenToken || isParameterHelper(token1)) { + if (token1.kind === SyntaxKind.CloseParenToken || isParameterHelper(token1)) { return parseParameterList(); } } @@ -3456,7 +3476,7 @@ module TypeScript.Parser { function parseParameterList(): ParameterListSyntax { var openParenToken = eatToken(SyntaxKind.OpenParenToken); - var parameters = Syntax.emptySeparatedList(); + var parameters: ISeparatedSyntaxList; if (openParenToken.fullWidth() > 0) { var skippedTokens: ISyntaxToken[] = getArray(); @@ -3464,17 +3484,17 @@ module TypeScript.Parser { openParenToken = addSkippedTokensAfterToken(openParenToken, skippedTokens); } - return new syntaxFactory.ParameterListSyntax(parseNodeData, openParenToken, parameters, eatToken(SyntaxKind.CloseParenToken)); + return new ParameterListSyntax(parseNodeData, openParenToken, parameters || [], eatToken(SyntaxKind.CloseParenToken)); } function parseOptionalTypeAnnotation(allowStringLiteral: boolean): TypeAnnotationSyntax { - return currentToken().kind() === SyntaxKind.ColonToken ? parseTypeAnnotation(allowStringLiteral) : undefined; + return currentToken().kind === SyntaxKind.ColonToken ? parseTypeAnnotation(allowStringLiteral) : undefined; } function parseTypeAnnotationType(allowStringLiteral: boolean): ITypeSyntax { if (allowStringLiteral) { var _currentToken = currentToken(); - if (_currentToken.kind() === SyntaxKind.StringLiteral) { + if (_currentToken.kind === SyntaxKind.StringLiteral) { return consumeToken(_currentToken); } } @@ -3483,13 +3503,13 @@ module TypeScript.Parser { } function parseTypeAnnotation(allowStringLiteral: boolean): TypeAnnotationSyntax { - return new syntaxFactory.TypeAnnotationSyntax(parseNodeData, consumeToken(currentToken()), parseTypeAnnotationType(allowStringLiteral)); + return new TypeAnnotationSyntax(parseNodeData, consumeToken(currentToken()), parseTypeAnnotationType(allowStringLiteral)); } function isType(): boolean { var _currentToken = currentToken(); - switch (_currentToken.kind()) { + switch (_currentToken.kind) { case SyntaxKind.TypeOfKeyword: case SyntaxKind.AnyKeyword: case SyntaxKind.NumberKeyword: @@ -3537,7 +3557,7 @@ module TypeScript.Parser { return parseFunctionType(); } - if (currentToken().kind() === SyntaxKind.NewKeyword) { + if (currentToken().kind === SyntaxKind.NewKeyword) { return parseConstructorType(); } @@ -3549,11 +3569,11 @@ module TypeScript.Parser { if (type) { var barToken: ISyntaxToken; - while ((barToken = currentToken()).kind() === SyntaxKind.BarToken) { + while ((barToken = currentToken()).kind === SyntaxKind.BarToken) { consumeToken(barToken); var right = parsePrimaryType(); - type = new syntaxFactory.UnionTypeSyntax(parseNodeData, type, barToken, right); + type = new UnionTypeSyntax(parseNodeData, type, barToken, right); } } @@ -3577,30 +3597,30 @@ module TypeScript.Parser { var _currentToken = currentToken(); if (previousTokenHasTrailingNewLine(_currentToken) || - _currentToken.kind() !== SyntaxKind.OpenBracketToken) { + _currentToken.kind !== SyntaxKind.OpenBracketToken) { break; } - type = new syntaxFactory.ArrayTypeSyntax(parseNodeData, type, consumeToken(_currentToken), eatToken(SyntaxKind.CloseBracketToken)); + type = new ArrayTypeSyntax(parseNodeData, type, consumeToken(_currentToken), eatToken(SyntaxKind.CloseBracketToken)); } return type; } function parseTypeQuery(typeOfKeyword: ISyntaxToken): TypeQuerySyntax { - return new syntaxFactory.TypeQuerySyntax(parseNodeData, consumeToken(typeOfKeyword), parseName(/*allowIdentifierNames:*/ true)); + return new TypeQuerySyntax(parseNodeData, consumeToken(typeOfKeyword), parseName(/*allowIdentifierNames:*/ true)); } function tryParseNonArrayType(): ITypeSyntax { var _currentToken = currentToken(); - switch (_currentToken.kind()) { + switch (_currentToken.kind) { case SyntaxKind.AnyKeyword: case SyntaxKind.NumberKeyword: case SyntaxKind.BooleanKeyword: case SyntaxKind.StringKeyword: // if any of these are followed by '.', then this is actually a module name, // and these keywords will be reinterpreted as an identifier. - if (peekToken(1).kind() === SyntaxKind.DotToken) { + if (peekToken(1).kind === SyntaxKind.DotToken) { break; } @@ -3616,7 +3636,7 @@ module TypeScript.Parser { } function parseParenthesizedType(openParenToken: ISyntaxToken): ParenthesizedTypeSyntax { - return new syntaxFactory.ParenthesizedTypeSyntax(parseNodeData, consumeToken(openParenToken), parseType(), eatToken(SyntaxKind.CloseParenToken)); + return new ParenthesizedTypeSyntax(parseNodeData, consumeToken(openParenToken), parseType(), eatToken(SyntaxKind.CloseParenToken)); } function tryParseNameOrGenericType(): ITypeSyntax { @@ -3636,12 +3656,12 @@ module TypeScript.Parser { var typeArgumentList = tryParseTypeArgumentList(/*inExpression:*/ false); return !typeArgumentList ? name - : new syntaxFactory.GenericTypeSyntax(parseNodeData, name, typeArgumentList); + : new GenericTypeSyntax(parseNodeData, name, typeArgumentList); } function isFunctionType(): boolean { var token0 = currentToken(); - var token0Kind = token0.kind(); + var token0Kind = token0.kind; // If we see a < then we consider ourselves to be definitely in a (generic) function type. if (token0Kind === SyntaxKind.LessThanToken) { @@ -3655,7 +3675,7 @@ module TypeScript.Parser { // parenthesized type. if (token0Kind === SyntaxKind.OpenParenToken) { var token1 = peekToken(1); - var token1Kind = token1.kind(); + var token1Kind = token1.kind; if (token1Kind === SyntaxKind.CloseParenToken || token1Kind === SyntaxKind.DotDotDotToken) { // () @@ -3670,7 +3690,7 @@ module TypeScript.Parser { // could be a function type or a parenthesized type. var token2 = peekToken(2); - var token2Kind = token2.kind(); + var token2Kind = token2.kind; if (token2Kind === SyntaxKind.ColonToken || token2Kind === SyntaxKind.CommaToken || @@ -3692,7 +3712,7 @@ module TypeScript.Parser { // ( id ) // // Only a function type if we see an arrow following it. - return peekToken(3).kind() === SyntaxKind.EqualsGreaterThanToken; + return peekToken(3).kind === SyntaxKind.EqualsGreaterThanToken; } } } @@ -3705,18 +3725,18 @@ module TypeScript.Parser { var typeParameterList = tryParseTypeParameterList(/*requireCompleteTypeParameterList:*/ false); var parameterList = parseParameterList(); - return new syntaxFactory.FunctionTypeSyntax(parseNodeData, + return new FunctionTypeSyntax(parseNodeData, typeParameterList, parameterList, eatToken(SyntaxKind.EqualsGreaterThanToken), parseType()); } function parseConstructorType(): ConstructorTypeSyntax { - return new syntaxFactory.ConstructorTypeSyntax(parseNodeData, + return new ConstructorTypeSyntax(parseNodeData, eatToken(SyntaxKind.NewKeyword), tryParseTypeParameterList(/*requireCompleteTypeParameterList:*/ false), parseParameterList(), eatToken(SyntaxKind.EqualsGreaterThanToken), parseType()); } function isParameter(): boolean { - if (currentNode() && currentNode().kind() === SyntaxKind.Parameter) { + if (currentNode() && currentNode().kind === SyntaxKind.Parameter) { return true; } @@ -3724,21 +3744,21 @@ module TypeScript.Parser { } function isParameterHelper(token: ISyntaxToken): boolean { - var tokenKind = token.kind(); + var tokenKind = token.kind; return tokenKind === SyntaxKind.DotDotDotToken || isModifierKind(tokenKind) || isIdentifier(token); } function eatSimpleParameter() { - return new syntaxFactory.ParameterSyntax(parseNodeData, - /*dotDotDotToken:*/ undefined, /*modifiers:*/ Syntax.emptyList(), eatIdentifierToken(), + return new ParameterSyntax(parseNodeData, + /*dotDotDotToken:*/ undefined, /*modifiers:*/ [], eatIdentifierToken(), /*questionToken:*/ undefined, /*typeAnnotation:*/ undefined, /*equalsValueClause:*/ undefined); } function tryParseParameter(): ParameterSyntax { var node = currentNode(); - if (node && node.kind() === SyntaxKind.Parameter) { + if (node && node.kind === SyntaxKind.Parameter) { consumeNode(node); return node; } @@ -3754,7 +3774,7 @@ module TypeScript.Parser { // If we see a modifier alone in a parameter list, like: foo(static) // // then treat it like modifier, and continue parsing the parameter. - if (isModifierKind(_currentToken.kind())) { + if (isModifierKind(_currentToken.kind)) { modifiers = Syntax.list([consumeToken(_currentToken)]); } else { @@ -3771,7 +3791,7 @@ module TypeScript.Parser { equalsValueClause = parseEqualsValueClause(/*allowIn:*/ true); } - return new syntaxFactory.ParameterSyntax(parseNodeData, dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); + return new ParameterSyntax(parseNodeData, dotDotDotToken, modifiers, identifier, questionToken, typeAnnotation, equalsValueClause); } function parseSyntaxList( @@ -3786,7 +3806,7 @@ module TypeScript.Parser { return result; } - function parseSeparatedSyntaxList(currentListType: ListParsingState, skippedTokens: ISyntaxToken[]): T[] { + function parseSeparatedSyntaxList(currentListType: ListParsingState, skippedTokens: ISyntaxToken[]): ISeparatedSyntaxList { var savedListParsingState = listParsingState; listParsingState |= (1 << currentListType); @@ -3799,7 +3819,7 @@ module TypeScript.Parser { // Returns true if we should abort parsing. function abortParsingListOrMoveToNextToken( - currentListType: ListParsingState, nodes: T[], separators: ISyntaxToken[], skippedTokens: ISyntaxToken[]): boolean { + currentListType: ListParsingState, nodeAndSeparators: ISyntaxNodeOrToken[], skippedTokens: ISyntaxToken[]): boolean { // Ok. We're at a token that is not a terminator for the list and wasn't the start of // an item in the list. Definitely report an error for this token. reportUnexpectedTokenDiagnostic(currentListType); @@ -3819,42 +3839,36 @@ module TypeScript.Parser { // Otherwise, if none of the lists we're in can capture this token, then we need to // unilaterally skip it. Note: we've already reported an error above. - addSkippedTokenToList(nodes, separators, skippedTokens, consumeToken(currentToken())); + addSkippedTokenToList(nodeAndSeparators, skippedTokens, consumeToken(currentToken())); // Continue parsing this list. Attach this token to whatever we've seen already. return false; } - - function addSkippedTokenToList( - nodes: T[], separators: ISyntaxToken[], skippedTokens: ISyntaxToken[], skippedToken: ISyntaxToken): void { + + function addSkippedTokenToList( + nodesAndSeparators: ISyntaxNodeOrToken[], skippedTokens: ISyntaxToken[], skippedToken: ISyntaxToken): void { // Now, add this skipped token to the last item we successfully parsed in the list. Or // add it to the list of skipped tokens if we haven't parsed anything. Our caller will // have to deal with them. // - // Note: we only bother doing this if we're creating a concrete syntax tree. - if (syntaxFactory.isConcrete) { - var length = nodes.length + (separators ? separators.length : 0); + var length = nodesAndSeparators.length; - for (var i = length - 1; i >= 0; i--) { - var array: ISyntaxNodeOrToken[] = separators && (i % 2 === 1) ? separators : nodes; - var arrayIndex = separators ? IntegerUtilities.integerDivide(i, 2) : i; - - var item = array[arrayIndex]; - var _lastToken = lastToken(item); - if (_lastToken && _lastToken.fullWidth() > 0) { - array[arrayIndex] = addSkippedTokenAfterNodeOrToken(item, skippedToken); - return; - } + for (var i = length - 1; i >= 0; i--) { + var item = nodesAndSeparators[i]; + var _lastToken = lastToken(item); + if (_lastToken && _lastToken.fullWidth() > 0) { + nodesAndSeparators[i] = addSkippedTokenAfterNodeOrToken(item, skippedToken); + return; } - - // Didn't have anything in the list we could add to. Add to the skipped items array - // for our caller to handle. - skippedTokens.push(skippedToken); } + + // Didn't have anything in the list we could add to. Add to the skipped items array + // for our caller to handle. + skippedTokens.push(skippedToken); } function tryParseExpectedListItem( - currentListType: ListParsingState, inErrorRecovery: boolean, items: ISyntaxElement[], processItems: (items: any[]) => void): boolean { + currentListType: ListParsingState, inErrorRecovery: boolean, items: ISyntaxNodeOrToken[], processItems: (items: ISyntaxNodeOrToken[]) => void): boolean { var item = tryParseExpectedListItemWorker(currentListType, inErrorRecovery); if (item === undefined) { @@ -3873,11 +3887,11 @@ module TypeScript.Parser { function listIsTerminated(currentListType: ListParsingState): boolean { return isExpectedListTerminator(currentListType) || - currentToken().kind() === SyntaxKind.EndOfFileToken; + currentToken().kind === SyntaxKind.EndOfFileToken; } - function parseSyntaxListWorker(currentListType: ListParsingState, skippedTokens: ISyntaxToken[], processItems: (items: any[]) => void ): T[] { - var items: T[] = getArray(); + function parseSyntaxListWorker(currentListType: ListParsingState, skippedTokens: ISyntaxToken[], processItems: (items: ISyntaxNodeOrToken[]) => void ): T[] { + var items: T[] = []; while (true) { // Try to parse an item of the list. If we fail then decide if we need to abort or @@ -3895,7 +3909,7 @@ module TypeScript.Parser { // List wasn't complete and we didn't get an item. Figure out if we should bail out // or skip a token and continue. - var abort = abortParsingListOrMoveToNextToken(currentListType, items, /*separators:*/ undefined, skippedTokens); + var abort = abortParsingListOrMoveToNextToken(currentListType, items, skippedTokens); if (abort) { break; } @@ -3905,18 +3919,11 @@ module TypeScript.Parser { // and didn't want to abort. Continue parsing elements. } - var result = Syntax.list(items); - - // Can't return if it has more then 1 element. In that case, the list will have been - // copied into the SyntaxList. - returnZeroLengthArray(items); - - return result; + return Syntax.list(items); } - function parseSeparatedSyntaxListWorker(currentListType: ListParsingState, skippedTokens: ISyntaxToken[]): T[] { - var nodes: T[] = getArray(); - var separators: ISyntaxToken[] = getArray(); + function parseSeparatedSyntaxListWorker(currentListType: ListParsingState, skippedTokens: ISyntaxToken[]): ISeparatedSyntaxList { + var nodesAndSeparators: ISyntaxNodeOrToken[] = []; // Debug.assert(nodes.length === 0); // Debug.assert(separators.length === 0); @@ -3934,7 +3941,7 @@ module TypeScript.Parser { // continue parsing. // Debug.assert(oldItemsCount % 2 === 0); - var succeeded = tryParseExpectedListItem(currentListType, inErrorRecovery, nodes, /*processItems:*/ undefined); + var succeeded = tryParseExpectedListItem(currentListType, inErrorRecovery, nodesAndSeparators, /*processItems:*/ undefined); if (!succeeded) { // We weren't able to parse out a list element. @@ -3948,7 +3955,7 @@ module TypeScript.Parser { // List wasn't complete and we didn't get an item. Figure out if we should bail out // or skip a token and continue. - var abort = abortParsingListOrMoveToNextToken(currentListType, nodes, separators, skippedTokens); + var abort = abortParsingListOrMoveToNextToken(currentListType, nodesAndSeparators, skippedTokens); if (abort) { break; } @@ -3970,10 +3977,10 @@ module TypeScript.Parser { // allow 'comma' as a separator (for error tolerance). We will later do a post pass // to report when a comma was used improperly in a list that needed semicolons. var _currentToken = currentToken(); - var tokenKind = _currentToken.kind(); + var tokenKind = _currentToken.kind; if (tokenKind === _separatorKind || tokenKind === SyntaxKind.CommaToken) { // Consume the last separator and continue parsing list elements. - separators.push(consumeToken(_currentToken)); + nodesAndSeparators.push(consumeToken(_currentToken)); continue; } @@ -4001,7 +4008,7 @@ module TypeScript.Parser { if (allowAutomaticSemicolonInsertion && canEatAutomaticSemicolon(/*allowWithoutNewline:*/ false)) { var semicolonToken = eatExplicitOrAutomaticSemicolon(/*allowWithoutNewline:*/ false) || Syntax.emptyToken(SyntaxKind.SemicolonToken); - separators.push(semicolonToken); + nodesAndSeparators.push(semicolonToken); // Debug.assert(items.length % 2 === 0); continue; } @@ -4011,7 +4018,7 @@ module TypeScript.Parser { // This time mark that we're in error recovery mode though. // // Note: trying to eat this token will emit the appropriate diagnostic. - separators.push(eatToken(_separatorKind)); + nodesAndSeparators.push(eatToken(_separatorKind)); // Now that we're in 'error recovery' mode we cantweak some parsing rules as // appropriate. For example, if we have: @@ -4027,14 +4034,7 @@ module TypeScript.Parser { inErrorRecovery = true; } - var result = Syntax.separatedList(nodes, separators); - - // Can't return if it has more then 0 elements. In that case, the list will have been - // copied into the SyntaxList. - returnZeroLengthArray(nodes); - returnZeroLengthArray(separators); - - return result; + return Syntax.separatedList(nodesAndSeparators); } function reportUnexpectedTokenDiagnostic(listType: ListParsingState): void { @@ -4085,32 +4085,32 @@ module TypeScript.Parser { } function isExpectedSourceUnit_ModuleElementsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.EndOfFileToken; + return currentToken().kind === SyntaxKind.EndOfFileToken; } function isExpectedEnumDeclaration_EnumElementsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBraceToken; + return currentToken().kind === SyntaxKind.CloseBraceToken; } function isExpectedModuleDeclaration_ModuleElementsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBraceToken; + return currentToken().kind === SyntaxKind.CloseBraceToken; } function isExpectedObjectType_TypeMembersTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBraceToken; + return currentToken().kind === SyntaxKind.CloseBraceToken; } function isExpectedObjectLiteralExpression_PropertyAssignmentsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBraceToken; + return currentToken().kind === SyntaxKind.CloseBraceToken; } function isExpectedLiteralExpression_AssignmentExpressionsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBracketToken; + return currentToken().kind === SyntaxKind.CloseBracketToken; } function isExpectedTypeArgumentList_TypesTerminator(): boolean { var token = currentToken(); - var tokenKind = token.kind(); + var tokenKind = token.kind; if (tokenKind === SyntaxKind.GreaterThanToken) { return true; } @@ -4127,7 +4127,7 @@ module TypeScript.Parser { function isExpectedTupleType_TypesTerminator(): boolean { var token = currentToken(); - var tokenKind = token.kind(); + var tokenKind = token.kind; if (tokenKind === SyntaxKind.CloseBracketToken) { return true; } @@ -4137,7 +4137,7 @@ module TypeScript.Parser { } function isExpectedTypeParameterList_TypeParametersTerminator(): boolean { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind === SyntaxKind.GreaterThanToken) { return true; } @@ -4155,7 +4155,7 @@ module TypeScript.Parser { } function isExpectedParameterList_ParametersTerminator(): boolean { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind === SyntaxKind.CloseParenToken) { return true; } @@ -4176,7 +4176,7 @@ module TypeScript.Parser { } function isExpectedIndexSignature_ParametersTerminator() { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind === SyntaxKind.CloseBracketToken) { return true; } @@ -4192,7 +4192,7 @@ module TypeScript.Parser { function isExpectedVariableDeclaration_VariableDeclarators_DisallowInTerminator(): boolean { // This is the case when we're parsing variable declarations in a for/for-in statement. - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind === SyntaxKind.SemicolonToken || tokenKind === SyntaxKind.CloseParenToken) { @@ -4213,7 +4213,7 @@ module TypeScript.Parser { // For better error recovery, if we see a => then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (currentToken().kind() === SyntaxKind.EqualsGreaterThanToken) { + if (currentToken().kind === SyntaxKind.EqualsGreaterThanToken) { return true; } @@ -4222,7 +4222,7 @@ module TypeScript.Parser { } function isExpectedClassOrInterfaceDeclaration_HeritageClausesTerminator(): boolean { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind === SyntaxKind.OpenBraceToken || tokenKind === SyntaxKind.CloseBraceToken) { return true; } @@ -4231,7 +4231,7 @@ module TypeScript.Parser { } function isExpectedHeritageClause_TypeNameListTerminator(): boolean { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; if (tokenKind === SyntaxKind.ExtendsKeyword || tokenKind === SyntaxKind.ImplementsKeyword) { return true; } @@ -4245,36 +4245,36 @@ module TypeScript.Parser { function isExpectedArgumentList_AssignmentExpressionsTerminator(): boolean { var token0 = currentToken(); - var tokenKind = token0.kind(); + var tokenKind = token0.kind; return tokenKind === SyntaxKind.CloseParenToken || tokenKind === SyntaxKind.SemicolonToken; } function isExpectedClassDeclaration_ClassElementsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBraceToken; + return currentToken().kind === SyntaxKind.CloseBraceToken; } function isExpectedSwitchStatement_SwitchClausesTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBraceToken; + return currentToken().kind === SyntaxKind.CloseBraceToken; } function isExpectedSwitchClause_StatementsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBraceToken || + return currentToken().kind === SyntaxKind.CloseBraceToken || isSwitchClause(); } function isExpectedBlock_StatementsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.CloseBraceToken; + return currentToken().kind === SyntaxKind.CloseBraceToken; } function isExpectedTryBlock_StatementsTerminator(): boolean { - var tokenKind = currentToken().kind(); + var tokenKind = currentToken().kind; return tokenKind === SyntaxKind.CatchKeyword || tokenKind === SyntaxKind.FinallyKeyword; } function isExpectedCatchBlock_StatementsTerminator(): boolean { - return currentToken().kind() === SyntaxKind.FinallyKeyword; + return currentToken().kind === SyntaxKind.FinallyKeyword; } function isExpectedListItem(currentListType: ListParsingState, inErrorRecovery: boolean): any { @@ -4318,7 +4318,7 @@ module TypeScript.Parser { // If we're on a comma then the user has written something like "Foo(a,," or "Foo(,". // Instead of skipping the comma, create an empty expression to go before the comma // so that the tree is more well formed and doesn't have skipped tokens. - if (_currentToken.kind() === SyntaxKind.CommaToken) { + if (_currentToken.kind === SyntaxKind.CommaToken) { return true; } diff --git a/src/services/syntax/prettyPrinter.ts b/src/services/syntax/prettyPrinter.ts index 647590f5fcc..efee0a9e294 100644 --- a/src/services/syntax/prettyPrinter.ts +++ b/src/services/syntax/prettyPrinter.ts @@ -20,7 +20,7 @@ module TypeScript.PrettyPrinter { return 0; } - if (lastToken(element1).kind() === SyntaxKind.CloseBraceToken) { + if (lastToken(element1).kind === SyntaxKind.CloseBraceToken) { return 2; } @@ -40,7 +40,7 @@ module TypeScript.PrettyPrinter { return 0; } - if (lastToken(element1).kind() === SyntaxKind.CloseBraceToken) { + if (lastToken(element1).kind === SyntaxKind.CloseBraceToken) { return 2; } @@ -150,7 +150,7 @@ module TypeScript.PrettyPrinter { this.ensureSpace(); } - visitNodeOrToken(this, childAt(list, i)); + visitNodeOrToken(this, list[i]); } else { this.appendToken(childAt(list, i)); @@ -165,7 +165,7 @@ module TypeScript.PrettyPrinter { this.ensureNewLine(); } - visitNodeOrToken(this, childAt(list, i)); + visitNodeOrToken(this, list[i]); } else { this.appendToken(childAt(list, i)); @@ -278,7 +278,7 @@ module TypeScript.PrettyPrinter { } for (var i = 0, n = childCount(node.typeMembers); i < n; i++) { - visitNodeOrToken(this, childAt(node.typeMembers, i)); + visitNodeOrToken(this, node.typeMembers[i]); if (appendNewLines) { this.ensureNewLine(); @@ -552,7 +552,7 @@ module TypeScript.PrettyPrinter { public visitBinaryExpression(node: BinaryExpressionSyntax): void { visitNodeOrToken(this, node.left); - if (node.operatorToken.kind() !== SyntaxKind.CommaToken) { + if (node.operatorToken.kind !== SyntaxKind.CommaToken) { this.ensureSpace(); } @@ -628,7 +628,7 @@ module TypeScript.PrettyPrinter { } private appendBlockOrStatement(node: IStatementSyntax): void { - if (node.kind() === SyntaxKind.Block) { + if (node.kind === SyntaxKind.Block) { this.ensureSpace(); visitNodeOrToken(this, node); } @@ -654,7 +654,7 @@ module TypeScript.PrettyPrinter { this.ensureNewLine(); this.appendToken(node.elseKeyword); - if (node.statement.kind() === SyntaxKind.IfStatement) { + if (node.statement.kind === SyntaxKind.IfStatement) { this.ensureSpace(); visitNodeOrToken(this, node.statement); } @@ -774,9 +774,9 @@ module TypeScript.PrettyPrinter { } private appendSwitchClauseStatements(node: ISwitchClauseSyntax): void { - if (childCount(node.statements) === 1 && childAt(node.statements, 0).kind() === SyntaxKind.Block) { + if (childCount(node.statements) === 1 && childAt(node.statements, 0).kind === SyntaxKind.Block) { this.ensureSpace(); - visitNodeOrToken(this, childAt(node.statements, 0)); + visitNodeOrToken(this, node.statements[0]); } else if (childCount(node.statements) > 0) { this.ensureNewLine(); @@ -1023,5 +1023,23 @@ module TypeScript.PrettyPrinter { this.appendToken(node.debuggerKeyword); this.appendToken(node.semicolonToken); } + + public visitTemplateExpression(node: TemplateExpressionSyntax): void { + this.appendToken(node.templateStartToken); + this.ensureSpace(); + this.appendSpaceList(node.templateClauses); + } + + public visitTemplateClause(node: TemplateClauseSyntax): void { + visitNodeOrToken(this, node.expression); + this.ensureSpace(); + this.appendToken(node.templateMiddleOrEndToken); + } + + public visitTemplateAccessExpression(node: TemplateAccessExpressionSyntax): void { + visitNodeOrToken(this, node.expression); + this.ensureSpace(); + visitNodeOrToken(this, node.templateExpression); + } } } \ No newline at end of file diff --git a/src/services/syntax/references.ts b/src/services/syntax/references.ts index a4eb9efc595..f2eed1365d5 100644 --- a/src/services/syntax/references.ts +++ b/src/services/syntax/references.ts @@ -17,9 +17,7 @@ /// /// /// -/// /// -/// // SyntaxDedenter depends on SyntaxRewriter // /// @@ -30,6 +28,7 @@ /// /// /// +/// /// /// @@ -41,6 +40,7 @@ /// // Concrete nodes depend on the parser. +/// /// // SyntaxTree depends on PositionTrackingWalker diff --git a/src/services/syntax/scanner.ts b/src/services/syntax/scanner.ts index 62959e458ff..67c40d87902 100644 --- a/src/services/syntax/scanner.ts +++ b/src/services/syntax/scanner.ts @@ -60,84 +60,52 @@ module TypeScript.Scanner { // This gives us 23bit for width (or 8MB of width which should be enough for any codebase). enum ScannerConstants { - LargeTokenFullStartShift = 4, - LargeTokenFullWidthShift = 7, - LargeTokenLeadingTriviaBitMask = 0x01, // 00000001 - LargeTokenLeadingCommentBitMask = 0x02, // 00000010 - LargeTokenTrailingTriviaBitMask = 0x04, // 00000100 - LargeTokenTrailingCommentBitMask = 0x08, // 00001000 - LargeTokenTriviaBitMask = 0x0F, // 00001111 + LargeTokenFullWidthShift = 6, + LargeTokenLeadingTriviaShift = 3, - FixedWidthTokenFullStartShift = 7, - FixedWidthTokenMaxFullStart = 0x7FFFFF, // 23 ones. + WhitespaceTrivia = 0x01, // 00000001 + NewlineTrivia = 0x02, // 00000010 + CommentTrivia = 0x04, // 00000100 + TriviaMask = 0x07, // 00000111 - SmallTokenFullWidthShift = 7, - SmallTokenFullStartShift = 12, - SmallTokenMaxFullStart = 0x3FFFF, // 18 ones. - SmallTokenMaxFullWidth = 0x1F, // 5 ones - SmallTokenFullWidthMask = 0x1F, // 00011111 - - KindMask = 0x7F, // 01111111 - IsVariableWidthMask = 0x80, // 10000000 + KindMask = 0x7F, // 01111111 + IsVariableWidthMask = 0x80, // 10000000 } - // Make sure our math works for packing/unpacking large fullStarts. - Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(1 << 26, 3)) === (1 << 26)); - Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(3 << 25, 1)) === (3 << 25)); - Debug.assert(largeTokenUnpackFullStart(largeTokenPackFullStartAndInfo(10 << 23, 2)) === (10 << 23)); - - function fixedWidthTokenPackData(fullStart: number, kind: SyntaxKind) { - return (fullStart << ScannerConstants.FixedWidthTokenFullStartShift) | kind; + function largeTokenPackData(fullWidth: number, leadingTriviaInfo: number, trailingTriviaInfo: number) { + return (fullWidth << ScannerConstants.LargeTokenFullWidthShift) | (leadingTriviaInfo << ScannerConstants.LargeTokenLeadingTriviaShift) | trailingTriviaInfo; } - function fixedWidthTokenUnpackFullStart(packedData: number) { - return packedData >> ScannerConstants.FixedWidthTokenFullStartShift; + function largeTokenUnpackFullWidth(packedFullWidthAndInfo: number): number { + return packedFullWidthAndInfo >> ScannerConstants.LargeTokenFullWidthShift; } - function smallTokenPackData(fullStart: number, fullWidth: number, kind: SyntaxKind) { - return (fullStart << ScannerConstants.SmallTokenFullStartShift) | - (fullWidth << ScannerConstants.SmallTokenFullWidthShift) | - kind; + function largeTokenUnpackLeadingTriviaInfo(packedFullWidthAndInfo: number): number { + return (packedFullWidthAndInfo >> ScannerConstants.LargeTokenLeadingTriviaShift) & ScannerConstants.TriviaMask; } - function smallTokenUnpackFullWidth(packedData: number): SyntaxKind { - return (packedData >> ScannerConstants.SmallTokenFullWidthShift) & ScannerConstants.SmallTokenFullWidthMask; - } - - function smallTokenUnpackFullStart(packedData: number): number { - return packedData >> ScannerConstants.SmallTokenFullStartShift; - } - - function largeTokenPackFullStartAndInfo(fullStart: number, triviaInfo: number): number { - return (fullStart << ScannerConstants.LargeTokenFullStartShift) | triviaInfo; - } - - function largeTokenUnpackFullWidth(packedFullWidthAndKind: number) { - return packedFullWidthAndKind >> ScannerConstants.LargeTokenFullWidthShift; - } - - function largeTokenUnpackFullStart(packedFullStartAndInfo: number): number { - return packedFullStartAndInfo >> ScannerConstants.LargeTokenFullStartShift; + function largeTokenUnpackTrailingTriviaInfo(packedFullWidthAndInfo: number): number { + return packedFullWidthAndInfo & ScannerConstants.TriviaMask; } function largeTokenUnpackHasLeadingTrivia(packed: number): boolean { - return (packed & ScannerConstants.LargeTokenLeadingTriviaBitMask) !== 0; + return largeTokenUnpackLeadingTriviaInfo(packed) !== 0; } function largeTokenUnpackHasTrailingTrivia(packed: number): boolean { - return (packed & ScannerConstants.LargeTokenTrailingTriviaBitMask) !== 0; + return largeTokenUnpackTrailingTriviaInfo(packed) !== 0; + } + + function hasComment(info: number) { + return (info & ScannerConstants.CommentTrivia) !== 0; } function largeTokenUnpackHasLeadingComment(packed: number): boolean { - return (packed & ScannerConstants.LargeTokenLeadingCommentBitMask) !== 0; + return hasComment(largeTokenUnpackLeadingTriviaInfo(packed)); } function largeTokenUnpackHasTrailingComment(packed: number): boolean { - return (packed & ScannerConstants.LargeTokenTrailingCommentBitMask) !== 0; - } - - function largeTokenUnpackTriviaInfo(packed: number): number { - return packed & ScannerConstants.LargeTokenTriviaBitMask; + return hasComment(largeTokenUnpackTrailingTriviaInfo(packed)); } var isKeywordStartCharacter: number[] = ArrayUtilities.createArray(CharacterCodes.maxAsciiCharacter, 0); @@ -166,7 +134,7 @@ module TypeScript.Scanner { // These tokens are contextually created based on parsing decisions. We can't reuse // them in incremental scenarios as we may be in a context where the parser would not // create them. - switch (token.kind()) { + switch (token.kind) { // Created by the parser when it sees / or /= in a location where it needs an expression. case SyntaxKind.RegularExpressionLiteral: @@ -178,6 +146,11 @@ module TypeScript.Scanner { case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken: return true; + // Created by the parser when it sees } while parsing a template expression. + case SyntaxKind.TemplateMiddleToken: + case SyntaxKind.TemplateEndToken: + return true; + default: return token.isKeywordConvertedToIdentifier(); } @@ -246,50 +219,59 @@ module TypeScript.Scanner { } class FixedWidthTokenWithNoTrivia implements ISyntaxToken { - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; + public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any; + public parent: ISyntaxElement; - constructor(private _packedData: number) { + constructor(private _fullStart: number, public kind: SyntaxKind) { } public setFullStart(fullStart: number): void { - this._packedData = fixedWidthTokenPackData(fullStart, this.kind()); + this._fullStart = fullStart; } + public childCount() { return 0 } + public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() } + public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) } + public isIncrementallyUnusable(): boolean { return false; } public isKeywordConvertedToIdentifier(): boolean { return false; } public hasSkippedToken(): boolean { return false; } - public fullText(): string { return SyntaxFacts.getText(this.kind()); } + public fullText(): string { return SyntaxFacts.getText(this.kind); } public text(): string { return this.fullText(); } public leadingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; } public trailingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; } public leadingTriviaWidth(): number { return 0; } public trailingTriviaWidth(): number { return 0; } - public kind(): SyntaxKind { return this._packedData & ScannerConstants.KindMask; } - public fullWidth(): number { return this.fullText().length; } - public fullStart(): number { return fixedWidthTokenUnpackFullStart(this._packedData); } + public fullWidth(): number { return fixedWidthTokenLength(this.kind); } + public fullStart(): number { return this._fullStart; } public hasLeadingTrivia(): boolean { return false; } public hasTrailingTrivia(): boolean { return false; } public hasLeadingComment(): boolean { return false; } public hasTrailingComment(): boolean { return false; } - public clone(): ISyntaxToken { return new FixedWidthTokenWithNoTrivia(this._packedData); } + public clone(): ISyntaxToken { return new FixedWidthTokenWithNoTrivia(this._fullStart, this.kind); } } class LargeScannerToken implements ISyntaxToken { - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; + public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any; + public parent: ISyntaxElement; private cachedText: string; - constructor(private _packedFullStartAndInfo: number, private _packedFullWidthAndKind: number, cachedText: string) { + + constructor(private _fullStart: number, public kind: SyntaxKind, private _packedFullWidthAndInfo: number, cachedText: string) { if (cachedText !== undefined) { this.cachedText = cachedText; } } public setFullStart(fullStart: number): void { - this._packedFullStartAndInfo = largeTokenPackFullStartAndInfo(fullStart, - largeTokenUnpackTriviaInfo(this._packedFullStartAndInfo)); + this._fullStart = fullStart; } + public childCount() { return 0 } + public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() } + public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) } + private syntaxTreeText(text: ISimpleText) { var result = text || syntaxTree(this).text; Debug.assert(result); @@ -306,7 +288,7 @@ module TypeScript.Scanner { public text(): string { var cachedText = this.cachedText; - return cachedText !== undefined ? cachedText : SyntaxFacts.getText(this.kind()); + return cachedText !== undefined ? cachedText : SyntaxFacts.getText(this.kind); } public leadingTrivia(text?: ISimpleText): ISyntaxTriviaList { return leadingTrivia(this, this.syntaxTreeText(text)); } @@ -320,14 +302,13 @@ module TypeScript.Scanner { return trailingTriviaWidth(this, this.syntaxTreeText(text)); } - public kind(): SyntaxKind { return this._packedFullWidthAndKind & ScannerConstants.KindMask; } - public fullWidth(): number { return largeTokenUnpackFullWidth(this._packedFullWidthAndKind); } - public fullStart(): number { return largeTokenUnpackFullStart(this._packedFullStartAndInfo); } - public hasLeadingTrivia(): boolean { return largeTokenUnpackHasLeadingTrivia(this._packedFullStartAndInfo); } - public hasTrailingTrivia(): boolean { return largeTokenUnpackHasTrailingTrivia(this._packedFullStartAndInfo); } - public hasLeadingComment(): boolean { return largeTokenUnpackHasLeadingComment(this._packedFullStartAndInfo); } - public hasTrailingComment(): boolean { return largeTokenUnpackHasTrailingComment(this._packedFullStartAndInfo); } - public clone(): ISyntaxToken { return new LargeScannerToken(this._packedFullStartAndInfo, this._packedFullWidthAndKind, this.cachedText); } + public fullWidth(): number { return largeTokenUnpackFullWidth(this._packedFullWidthAndInfo); } + public fullStart(): number { return this._fullStart; } + public hasLeadingTrivia(): boolean { return largeTokenUnpackHasLeadingTrivia(this._packedFullWidthAndInfo); } + public hasTrailingTrivia(): boolean { return largeTokenUnpackHasTrailingTrivia(this._packedFullWidthAndInfo); } + public hasLeadingComment(): boolean { return largeTokenUnpackHasLeadingComment(this._packedFullWidthAndInfo); } + public hasTrailingComment(): boolean { return largeTokenUnpackHasTrailingComment(this._packedFullWidthAndInfo); } + public clone(): ISyntaxToken { return new LargeScannerToken(this._fullStart, this.kind, this._packedFullWidthAndInfo, this.cachedText); } } export interface DiagnosticCallback { @@ -368,12 +349,13 @@ module TypeScript.Scanner { } function reset(_text: ISimpleText, _start: number, _end: number) { - Debug.assert(_start <= _text.length(), "Token's start was not within the bounds of text: " + _start + " - [0, " + _text.length() + ")"); - Debug.assert(_end <= _text.length(), "Token's end was not within the bounds of text: " + _end + " - [0, " + _text.length() + ")"); + var textLength = _text.length(); + Debug.assert(_start <= textLength, "Token's start was not within the bounds of text."); + Debug.assert(_end <= textLength, "Token's end was not within the bounds of text:"); if (!str || text !== _text) { text = _text; - str = _text.substr(0, _text.length()); + str = _text.substr(0, textLength); } start = _start; @@ -400,20 +382,14 @@ module TypeScript.Scanner { ((kindAndIsVariableWidth & ScannerConstants.IsVariableWidthMask) === 0); if (isFixedWidth && - leadingTriviaInfo === 0 && trailingTriviaInfo === 0 && - fullStart <= ScannerConstants.FixedWidthTokenMaxFullStart && - (kindAndIsVariableWidth & ScannerConstants.IsVariableWidthMask) === 0) { + leadingTriviaInfo === 0 && trailingTriviaInfo === 0) { - return new FixedWidthTokenWithNoTrivia((fullStart << ScannerConstants.FixedWidthTokenFullStartShift) | kind); + return new FixedWidthTokenWithNoTrivia(fullStart, kind); } else { - // inline the packing logic for perf. - var packedFullStartAndTriviaInfo = (fullStart << ScannerConstants.LargeTokenFullStartShift) | - leadingTriviaInfo | (trailingTriviaInfo << 2); - - var packedFullWidthAndKind = (fullWidth << ScannerConstants.LargeTokenFullWidthShift) | kind; + var packedFullWidthAndInfo = largeTokenPackData(fullWidth, leadingTriviaInfo, trailingTriviaInfo); var cachedText = isFixedWidth ? undefined : text.substr(start, end - start); - return new LargeScannerToken(packedFullStartAndTriviaInfo, packedFullWidthAndKind, cachedText); + return new LargeScannerToken(fullStart, kind, packedFullWidthAndInfo, cachedText); } } @@ -523,7 +499,7 @@ module TypeScript.Scanner { case CharacterCodes.formFeed: index++; // we have trivia - result |= 1; + result |= ScannerConstants.WhitespaceTrivia; continue; case CharacterCodes.carriageReturn: @@ -532,10 +508,12 @@ module TypeScript.Scanner { } // fall through. case CharacterCodes.lineFeed: + case CharacterCodes.paragraphSeparator: + case CharacterCodes.lineSeparator: index++; // we have trivia - result |= 1; + result |= ScannerConstants.NewlineTrivia; // If we're consuming leading trivia, then we will continue consuming more // trivia (including newlines) up to the first token we see. If we're @@ -551,14 +529,14 @@ module TypeScript.Scanner { var ch2 = str.charCodeAt(index + 1); if (ch2 === CharacterCodes.slash) { // we have a comment, and we have trivia - result |= 3; + result |= ScannerConstants.CommentTrivia; skipSingleLineCommentTrivia(); continue; } if (ch2 === CharacterCodes.asterisk) { // we have a comment, and we have trivia - result |= 3; + result |= ScannerConstants.CommentTrivia; skipMultiLineCommentTrivia(); continue; } @@ -568,8 +546,8 @@ module TypeScript.Scanner { return result; default: - if (ch > CharacterCodes.maxAsciiCharacter && slowScanTriviaInfo(ch)) { - result |= 1; + if (ch > CharacterCodes.maxAsciiCharacter && slowScanWhitespaceTriviaInfo(ch)) { + result |= ScannerConstants.WhitespaceTrivia; continue; } @@ -580,7 +558,7 @@ module TypeScript.Scanner { return result; } - function slowScanTriviaInfo(ch: number): boolean { + function slowScanWhitespaceTriviaInfo(ch: number): boolean { switch (ch) { case CharacterCodes.nonBreakingSpace: case CharacterCodes.enQuad: @@ -598,8 +576,6 @@ module TypeScript.Scanner { case CharacterCodes.narrowNoBreakSpace: case CharacterCodes.ideographicSpace: case CharacterCodes.byteOrderMark: - case CharacterCodes.paragraphSeparator: - case CharacterCodes.lineSeparator: index++; return true; @@ -700,7 +676,7 @@ module TypeScript.Scanner { while (true) { if (index === end) { - reportDiagnostic(end, 0, DiagnosticCode.AsteriskSlash_expected, undefined); + reportDiagnostic(end, 0, DiagnosticCode._0_expected, ["*/"]); return; } @@ -742,10 +718,10 @@ module TypeScript.Scanner { index++; switch (character) { - case CharacterCodes.exclamation /*33*/: return scanExclamationToken(); + case CharacterCodes.exclamation/*33*/: return scanExclamationToken(); case CharacterCodes.doubleQuote/*34*/: return scanStringLiteral(character); - case CharacterCodes.percent /*37*/: return scanPercentToken(); - case CharacterCodes.ampersand /*38*/: return scanAmpersandToken(); + case CharacterCodes.percent/*37*/: return scanPercentToken(); + case CharacterCodes.ampersand/*38*/: return scanAmpersandToken(); case CharacterCodes.singleQuote/*39*/: return scanStringLiteral(character); case CharacterCodes.openParen/*40*/: return SyntaxKind.OpenParenToken; case CharacterCodes.closeParen/*41*/: return SyntaxKind.CloseParenToken; @@ -771,10 +747,11 @@ module TypeScript.Scanner { case CharacterCodes.openBracket/*91*/: return SyntaxKind.OpenBracketToken; case CharacterCodes.closeBracket/*93*/: return SyntaxKind.CloseBracketToken; case CharacterCodes.caret/*94*/: return scanCaretToken(); + case CharacterCodes.backtick/*96*/: return scanTemplateToken(character); case CharacterCodes.openBrace/*123*/: return SyntaxKind.OpenBraceToken; case CharacterCodes.bar/*124*/: return scanBarToken(); - case CharacterCodes.closeBrace/*125*/: return SyntaxKind.CloseBraceToken; + case CharacterCodes.closeBrace/*125*/: return scanCloseBraceToken(allowContextualToken, character); case CharacterCodes.tilde/*126*/: return SyntaxKind.TildeToken; } @@ -1073,6 +1050,39 @@ module TypeScript.Scanner { } } + function scanCloseBraceToken(allowContextualToken: boolean, startChar: number): SyntaxKind { + return allowContextualToken ? scanTemplateToken(startChar) : SyntaxKind.CloseBraceToken; + } + + function scanTemplateToken(startChar: number): SyntaxKind { + var startedWithBacktick = startChar === CharacterCodes.backtick; + + while (true) { + if (index === end) { + // Hit the end of the file. + reportDiagnostic(end, 0, DiagnosticCode._0_expected, ["`"]); + break; + } + + var ch = str.charCodeAt(index); + index++; + + if (ch === CharacterCodes.backtick) { + break; + } + + if (ch === CharacterCodes.$ && + index < end && + str.charCodeAt(index) === CharacterCodes.openBrace) { + + index++; + return startedWithBacktick ? SyntaxKind.TemplateStartToken : SyntaxKind.TemplateMiddleToken; + } + } + + return startedWithBacktick ? SyntaxKind.NoSubstitutionTemplateToken : SyntaxKind.TemplateEndToken; + } + function scanAmpersandToken(): SyntaxKind { var character = str.charCodeAt(index); if (character === CharacterCodes.equals) { @@ -1638,11 +1648,14 @@ module TypeScript.Scanner { function resetToPosition(absolutePosition: number): void { Debug.assert(absolutePosition <= text.length(), "Trying to set the position outside the bounds of the text!"); + var resetBackward = absolutePosition <= _absolutePosition; _absolutePosition = absolutePosition; - // First, remove any diagnostics that came after this position. - removeDiagnosticsOnOrAfterPosition(absolutePosition); + if (resetBackward) { + // First, remove any diagnostics that came after this position. + removeDiagnosticsOnOrAfterPosition(absolutePosition); + } // Now, tell our sliding window to throw away all tokens after this position as well. slidingWindow.disgardAllItemsFromCurrentIndexOnwards(); @@ -1654,7 +1667,7 @@ module TypeScript.Scanner { function currentContextualToken(): ISyntaxToken { // We better be on a / or > token right now. - // Debug.assert(SyntaxFacts.isAnyDivideToken(currentToken().kind())); + // Debug.assert(SyntaxFacts.isAnyDivideToken(currentToken().kind)); // First, we're going to rewind all our data to the point where this / or /= token started. // That's because if it does turn out to be a regular expression, then any tokens or token @@ -1674,7 +1687,7 @@ module TypeScript.Scanner { // We have better gotten some sort of regex token. Otherwise, something *very* wrong has // occurred. - // Debug.assert(SyntaxFacts.isAnyDivideOrRegularExpressionToken(token.kind())); + // Debug.assert(SyntaxFacts.isAnyDivideOrRegularExpressionToken(token.kind)); return token; } @@ -1698,4 +1711,9 @@ module TypeScript.Scanner { resetToPosition: resetToPosition, }; } + + var fixedWidthArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 5, 8, 8, 7, 6, 2, 4, 5, 7, 3, 8, 2, 2, 10, 3, 4, 6, 6, 4, 5, 4, 3, 6, 3, 4, 5, 4, 5, 5, 4, 6, 7, 6, 5, 10, 9, 3, 7, 7, 9, 6, 6, 5, 3, 7, 11, 7, 3, 6, 7, 6, 3, 6, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 2, 2, 2, 1, 2]; + function fixedWidthTokenLength(kind: SyntaxKind) { + return fixedWidthArray[kind]; + } } \ No newline at end of file diff --git a/src/services/syntax/scannerUtilities.generated.ts b/src/services/syntax/scannerUtilities.generated.ts index fbf1b1cb952..97f0093a672 100644 --- a/src/services/syntax/scannerUtilities.generated.ts +++ b/src/services/syntax/scannerUtilities.generated.ts @@ -1,8 +1,8 @@ /// module TypeScript { - export class ScannerUtilities { - public static identifierKind(str: string, start: number, length: number): SyntaxKind { + export module ScannerUtilities { + export function identifierKind(str: string, start: number, length: number): SyntaxKind { switch (length) { case 2: // do, if, in switch(str.charCodeAt(start)) { diff --git a/src/services/syntax/syntax.ts b/src/services/syntax/syntax.ts index 87974c850f7..cac2c280d24 100644 --- a/src/services/syntax/syntax.ts +++ b/src/services/syntax/syntax.ts @@ -3,24 +3,13 @@ module TypeScript.Syntax { export var _nextSyntaxID: number = 1; - export function childIndex(parent: ISyntaxElement, child: ISyntaxElement) { - for (var i = 0, n = childCount(parent); i < n; i++) { - var current = childAt(parent, i); - if (current === child) { - return i; - } - } - - throw Errors.invalidOperation(); - } - export function nodeHasSkippedOrMissingTokens(node: ISyntaxNode): boolean { for (var i = 0; i < childCount(node); i++) { var child = childAt(node, i); if (isToken(child)) { var token = child; // If a token is skipped, return true. Or if it is a missing token. The only empty token that is not missing is EOF - if (token.hasSkippedToken() || (width(token) === 0 && token.kind() !== SyntaxKind.EndOfFileToken)) { + if (token.hasSkippedToken() || (width(token) === 0 && token.kind !== SyntaxKind.EndOfFileToken)) { return true; } } @@ -30,7 +19,7 @@ module TypeScript.Syntax { } export function isUnterminatedStringLiteral(token: ISyntaxToken): boolean { - if (token && token.kind() === SyntaxKind.StringLiteral) { + if (token && token.kind === SyntaxKind.StringLiteral) { var text = token.text(); return text.length < 2 || text.charCodeAt(text.length - 1) !== text.charCodeAt(0); } @@ -66,7 +55,7 @@ module TypeScript.Syntax { var triviaList: ISyntaxTriviaList = undefined; var lastTriviaBeforeToken: ISyntaxTrivia = undefined; - if (positionedToken.kind() === SyntaxKind.EndOfFileToken) { + if (positionedToken.kind === SyntaxKind.EndOfFileToken) { // Check if the trivia is leading on the EndOfFile token if (positionedToken.hasLeadingTrivia()) { triviaList = positionedToken.leadingTrivia(); @@ -117,14 +106,14 @@ module TypeScript.Syntax { var positionedToken = findToken(sourceUnit, position); if (positionedToken) { - if (positionedToken.kind() === SyntaxKind.EndOfFileToken) { + if (positionedToken.kind === SyntaxKind.EndOfFileToken) { // EndOfFile token, enusre it did not follow an unterminated string literal positionedToken = previousToken(positionedToken); return positionedToken && positionedToken.trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken); } else if (position > start(positionedToken)) { // Ensure position falls enterily within the literal if it is terminated, or the line if it is not - return (position < end(positionedToken) && (positionedToken.kind() === TypeScript.SyntaxKind.StringLiteral || positionedToken.kind() === TypeScript.SyntaxKind.RegularExpressionLiteral)) || + return (position < end(positionedToken) && (positionedToken.kind === TypeScript.SyntaxKind.StringLiteral || positionedToken.kind === TypeScript.SyntaxKind.RegularExpressionLiteral)) || (position <= end(positionedToken) && isUnterminatedStringLiteral(positionedToken)); } } @@ -132,43 +121,9 @@ module TypeScript.Syntax { return false; } - function findSkippedTokenOnLeftInTriviaList(positionedToken: ISyntaxToken, position: number, lookInLeadingTriviaList: boolean): ISyntaxToken { - var triviaList: TypeScript.ISyntaxTriviaList = undefined; - var fullEnd: number; - - if (lookInLeadingTriviaList) { - triviaList = positionedToken.leadingTrivia(); - fullEnd = positionedToken.fullStart() + triviaList.fullWidth(); - } - else { - triviaList = positionedToken.trailingTrivia(); - fullEnd = TypeScript.fullEnd(positionedToken); - } - - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - var triviaWidth = trivia.fullWidth(); - - if (trivia.isSkippedToken() && position >= fullEnd) { - return trivia.skippedToken(); - } - - fullEnd -= triviaWidth; - } - } - - return undefined; - } - - export function findSkippedTokenOnLeft(positionedToken: ISyntaxToken, position: number): ISyntaxToken { - var positionInLeadingTriviaList = (position < start(positionedToken)); - return findSkippedTokenOnLeftInTriviaList(positionedToken, position, /*lookInLeadingTriviaList*/ positionInLeadingTriviaList); - } - export function getAncestorOfKind(positionedToken: ISyntaxElement, kind: SyntaxKind): ISyntaxElement { while (positionedToken && positionedToken.parent) { - if (positionedToken.parent.kind() === kind) { + if (positionedToken.parent.kind === kind) { return positionedToken.parent; } @@ -184,10 +139,10 @@ module TypeScript.Syntax { export function isIntegerLiteral(expression: IExpressionSyntax): boolean { if (expression) { - switch (expression.kind()) { + switch (expression.kind) { case SyntaxKind.PrefixUnaryExpression: var prefixExpr = expression; - if (prefixExpr.operatorToken.kind() == SyntaxKind.PlusToken || prefixExpr.operatorToken.kind() === SyntaxKind.MinusToken) { + if (prefixExpr.operatorToken.kind == SyntaxKind.PlusToken || prefixExpr.operatorToken.kind === SyntaxKind.MinusToken) { // Note: if there is a + or - sign, we can only allow a normal integer following // (and not a hex integer). i.e. -0xA is a legal expression, but it is not a // *literal*. @@ -218,18 +173,14 @@ module TypeScript.Syntax { return current; } - export function findTokenOnLeft(element: ISyntaxElement, position: number, includeSkippedTokens: boolean = false): ISyntaxToken { - var positionedToken = findToken(element, position, /*includeSkippedTokens*/ false); + export function findTokenOnLeft(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken { + var positionedToken = findToken(sourceUnit, position); var _start = start(positionedToken); // Position better fall within this token. // Debug.assert(position >= positionedToken.fullStart()); // Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken); - if (includeSkippedTokens) { - positionedToken = findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - // if position is after the start of the token, then this token is the token on the left. if (position > _start) { return positionedToken; @@ -241,26 +192,22 @@ module TypeScript.Syntax { return undefined; } - return previousToken(positionedToken, includeSkippedTokens); + return previousToken(positionedToken); } - export function findCompleteTokenOnLeft(element: ISyntaxElement, position: number, includeSkippedTokens: boolean = false): ISyntaxToken { - var positionedToken = findToken(element, position, /*includeSkippedTokens*/ false); + export function findCompleteTokenOnLeft(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken { + var positionedToken = findToken(sourceUnit, position); // Position better fall within this token. // Debug.assert(position >= positionedToken.fullStart()); // Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken); - if (includeSkippedTokens) { - positionedToken = findSkippedTokenOnLeft(positionedToken, position) || positionedToken; - } - // if position is after the end of the token, then this token is the token on the left. if (width(positionedToken) > 0 && position >= end(positionedToken)) { return positionedToken; } - return previousToken(positionedToken, includeSkippedTokens); + return previousToken(positionedToken); } export function firstTokenInLineContainingPosition(syntaxTree: SyntaxTree, position: number): ISyntaxToken { diff --git a/src/services/syntax/syntaxElement.ts b/src/services/syntax/syntaxElement.ts index 53d16e7ef67..e42d9d44cdb 100644 --- a/src/services/syntax/syntaxElement.ts +++ b/src/services/syntax/syntaxElement.ts @@ -1,52 +1,12 @@ /// module TypeScript { - // True if there is only a single instance of this element (and thus can be reused in many - // places in a syntax tree). Examples of this include our empty lists. Because empty - // lists can be found all over the tree, we want to save on memory by using this single - // instance instead of creating new objects for each case. Note: because of this, shared - // nodes don't have positions or parents. - export function isShared(element: ISyntaxElement): boolean { - var kind = element.kind(); - return (kind === SyntaxKind.List || kind === SyntaxKind.SeparatedList) && (element).length === 0; - } - - export function childCount(element: ISyntaxElement): number { - var kind = element.kind(); - if (kind === SyntaxKind.List) { - return (element).length; - } - else if (kind === SyntaxKind.SeparatedList) { - return (element).length + (element).separators.length; - } - else if (kind >= SyntaxKind.FirstToken && kind <= SyntaxKind.LastToken) { - return 0; - } - else { - return nodeMetadata[kind].length; - } - } - - export function childAt(element: ISyntaxElement, index: number): ISyntaxElement { - var kind = element.kind(); - if (kind === SyntaxKind.List) { - return (element)[index]; - } - else if (kind === SyntaxKind.SeparatedList) { - return (index % 2 === 0) ? (element)[index / 2] : (element).separators[(index - 1) / 2]; - } - else { - // Debug.assert(isNode(element)); - return (element)[nodeMetadata[element.kind()][index]]; - } - } - export function syntaxTree(element: ISyntaxElement): SyntaxTree { if (element) { - Debug.assert(!isShared(element)); + // Debug.assert(!isShared(element)); while (element) { - if (element.kind() === SyntaxKind.SourceUnit) { + if (element.kind === SyntaxKind.SourceUnit) { return (element).syntaxTree; } @@ -58,7 +18,7 @@ module TypeScript { } export function parsedInStrictMode(node: ISyntaxNode): boolean { - var info = node.data; + var info = node.__data; if (info === undefined) { return false; } @@ -66,28 +26,13 @@ module TypeScript { return (info & SyntaxConstants.NodeParsedInStrictModeMask) !== 0; } - export function previousToken(token: ISyntaxToken, includeSkippedTokens: boolean = false): ISyntaxToken { - if (includeSkippedTokens) { - var triviaList = token.leadingTrivia(); - if (triviaList && triviaList.hasSkippedToken()) { - var currentTriviaEndPosition = TypeScript.start(token); - for (var i = triviaList.count() - 1; i >= 0; i--) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return trivia.skippedToken(); - } - - currentTriviaEndPosition -= trivia.fullWidth(); - } - } - } - + export function previousToken(token: ISyntaxToken): ISyntaxToken { var start = token.fullStart(); if (start === 0) { return undefined; } - return findToken(syntaxTree(token).sourceUnit(), start - 1, includeSkippedTokens); + return findToken(syntaxTree(token).sourceUnit(), start - 1); } /** @@ -103,24 +48,26 @@ module TypeScript { * Note: findToken will always return a non-missing token with width greater than or equal to * 1 (except for EOF). Empty tokens synthesized by the parser are never returned. */ - export function findToken(element: ISyntaxElement, position: number, includeSkippedTokens: boolean = false): ISyntaxToken { - var endOfFileToken = tryGetEndOfFileAt(element, position); - if (endOfFileToken) { - return endOfFileToken; - } - - if (position < 0 || position >= fullWidth(element)) { + export function findToken(sourceUnit: SourceUnitSyntax, position: number): ISyntaxToken { + if (position < 0) { throw Errors.argumentOutOfRange("position"); } - var positionedToken = findTokenWorker(element, position); - - if (includeSkippedTokens) { - return findSkippedTokenInPositionedToken(positionedToken, position) || positionedToken; + var token = findTokenInNodeOrToken(sourceUnit, 0, position); + if (token) { + Debug.assert(token.fullWidth() > 0); + return token; } - // Could not find a better match - return positionedToken; + if (position === fullWidth(sourceUnit)) { + return sourceUnit.endOfFileToken; + } + + if (position > fullWidth(sourceUnit)) { + throw Errors.argumentOutOfRange("position"); + } + + throw Errors.invalidOperation(); } export function findSkippedTokenInPositionedToken(positionedToken: ISyntaxToken, position: number): ISyntaxToken { @@ -165,44 +112,59 @@ module TypeScript { return undefined; } - function findTokenWorker(element: ISyntaxElement, position: number): ISyntaxToken { - // Debug.assert(position >= 0 && position < this.fullWidth()); - if (isToken(element)) { - Debug.assert(fullWidth(element) > 0); - return element; + function findTokenWorker(element: ISyntaxElement, elementPosition: number, position: number): ISyntaxToken { + if (isList(element)) { + return findTokenInList(element, elementPosition, position); + } + else { + return findTokenInNodeOrToken(element, elementPosition, position); + } + } + + function findTokenInList(list: ISyntaxNodeOrToken[], elementPosition: number, position: number): ISyntaxToken { + for (var i = 0, n = list.length; i < n; i++) { + var child = list[i]; + + var childFullWidth = fullWidth(child); + var elementEndPosition = elementPosition + childFullWidth; + + if (position < elementEndPosition) { + return findTokenWorker(child, elementPosition, position); + } + + elementPosition = elementEndPosition; } - if (isShared(element)) { - // This should never have been called on this element. It has a 0 width, so the client - // should have skipped over this. - throw Errors.invalidOperation(); + return undefined; + } + + + function findTokenInNodeOrToken(nodeOrToken: ISyntaxNodeOrToken, elementPosition: number, position: number): ISyntaxToken { + if (isToken(nodeOrToken)) { + return nodeOrToken; } - // Consider: we could use a binary search here to find the child more quickly. - for (var i = 0, n = childCount(element); i < n; i++) { - var child = childAt(element, i); + var childAtFunction = getChildAtFunction(nodeOrToken); + for (var i = 0, n = childCount(nodeOrToken); i < n; i++) { + var child = childAtFunction(nodeOrToken, i); if (child) { var childFullWidth = fullWidth(child); - if (childFullWidth > 0) { - var childFullStart = fullStart(child); + var elementEndPosition = elementPosition + childFullWidth; - if (position >= childFullStart) { - var childFullEnd = childFullStart + childFullWidth; - - if (position < childFullEnd) { - return findTokenWorker(child, position); - } - } + if (position < elementEndPosition) { + return findTokenWorker(child, elementPosition, position); } + + elementPosition = elementEndPosition; } } - throw Errors.invalidOperation(); + return undefined; } function tryGetEndOfFileAt(element: ISyntaxElement, position: number): ISyntaxToken { - if (element.kind() === SyntaxKind.SourceUnit && position === fullWidth(element)) { + if (element.kind === SyntaxKind.SourceUnit && position === fullWidth(element)) { var sourceUnit = element; return sourceUnit.endOfFileToken; } @@ -210,29 +172,17 @@ module TypeScript { return undefined; } - export function nextToken(token: ISyntaxToken, text?: ISimpleText, includeSkippedTokens: boolean = false): ISyntaxToken { - if (token.kind() === SyntaxKind.EndOfFileToken) { + export function nextToken(token: ISyntaxToken, text?: ISimpleText): ISyntaxToken { + if (token.kind === SyntaxKind.EndOfFileToken) { return undefined; } - if (includeSkippedTokens) { - var triviaList = token.trailingTrivia(text); - if (triviaList && triviaList.hasSkippedToken()) { - for (var i = 0, n = triviaList.count(); i < n; i++) { - var trivia = triviaList.syntaxTriviaAt(i); - if (trivia.isSkippedToken()) { - return trivia.skippedToken(); - } - } - } - } - - return findToken(syntaxTree(token).sourceUnit(), fullEnd(token), includeSkippedTokens); + return findToken(syntaxTree(token).sourceUnit(), fullEnd(token)); } export function isNode(element: ISyntaxElement): boolean { if (element) { - var kind = element.kind(); + var kind = element.kind; return kind >= SyntaxKind.FirstNode && kind <= SyntaxKind.LastNode; } @@ -245,24 +195,20 @@ module TypeScript { export function isToken(element: ISyntaxElement): boolean { if (element) { - return isTokenKind(element.kind()); + return isTokenKind(element.kind); } return false; } export function isList(element: ISyntaxElement): boolean { - return element && element.kind() === SyntaxKind.List; - } - - export function isSeparatedList(element: ISyntaxElement): boolean { - return element && element.kind() === SyntaxKind.SeparatedList; + return element instanceof Array; } export function syntaxID(element: ISyntaxElement): number { - if (isShared(element)) { - throw Errors.invalidOperation("Should not use shared syntax element as a key."); - } + //if (isShared(element)) { + // throw Errors.invalidOperation("Should not use shared syntax element as a key."); + //} var obj = element; if (obj._syntaxID === undefined) { @@ -308,43 +254,16 @@ module TypeScript { export function firstToken(element: ISyntaxElement): ISyntaxToken { if (element) { - var kind = element.kind(); + var kind = element.kind; if (isTokenKind(kind)) { - return fullWidth(element) > 0 || element.kind() === SyntaxKind.EndOfFileToken ? element : undefined; + return (element).fullWidth() > 0 || kind === SyntaxKind.EndOfFileToken ? element : undefined; } - if (kind === SyntaxKind.List) { - var array = element; - for (var i = 0, n = array.length; i < n; i++) { - var token = firstToken(array[i]); - if (token) { - return token; - } - } - } - else if (kind === SyntaxKind.SeparatedList) { - var array = element; - var separators = array.separators; - for (var i = 0, n = array.length + separators.length; i < n; i++) { - var token = firstToken(i % 2 === 0 ? array[i / 2] : separators[(i - 1) / 2]); - if (token) { - return token; - } - } - } - else { - var metadata = nodeMetadata[kind]; - for (var i = 0, n = metadata.length; i < n; i++) { - var child = (element)[metadata[i]]; - var token = firstToken(child); - if (token) { - return token; - } - } - - if (element.kind() === SyntaxKind.SourceUnit) { - return (element).endOfFileToken; + for (var i = 0, n = childCount(element); i < n; i++) { + var token = firstToken(childAt(element, i)); + if (token) { + return token; } } } @@ -354,10 +273,10 @@ module TypeScript { export function lastToken(element: ISyntaxElement): ISyntaxToken { if (isToken(element)) { - return fullWidth(element) > 0 || element.kind() === SyntaxKind.EndOfFileToken ? element : undefined; + return fullWidth(element) > 0 || element.kind === SyntaxKind.EndOfFileToken ? element : undefined; } - if (element.kind() === SyntaxKind.SourceUnit) { + if (element.kind === SyntaxKind.SourceUnit) { return (element).endOfFileToken; } @@ -375,7 +294,7 @@ module TypeScript { } export function fullStart(element: ISyntaxElement): number { - Debug.assert(!isShared(element)); + // Debug.assert(!isShared(element)); var token = isToken(element) ? element : firstToken(element); return token ? token.fullStart() : -1; } @@ -385,10 +304,6 @@ module TypeScript { return (element).fullWidth(); } - if (isShared(element)) { - return 0; - } - var info = data(element); return info >>> SyntaxConstants.NodeFullWidthShift; } @@ -398,28 +313,23 @@ module TypeScript { return (element).isIncrementallyUnusable(); } - if (isShared(element)) { - // All shared lists are reusable. - return false; - } - return (data(element) & SyntaxConstants.NodeIncrementallyUnusableMask) !== 0; } function data(element: ISyntaxElement): number { - Debug.assert(isNode(element) || isList(element) || isSeparatedList(element)); + // Debug.assert(isNode(element) || isList(element)); // Lists and nodes all have a 'data' element. - var dataElement = <{ data: number }>element; + var dataElement = element; - var info = dataElement.data; + var info = dataElement.__data; if (info === undefined) { info = 0; } if ((info & SyntaxConstants.NodeDataComputed) === 0) { info |= computeData(element); - dataElement.data = info; + dataElement.__data = info; } return info; @@ -431,7 +341,7 @@ module TypeScript { var fullWidth = 0; // If we have no children (like an OmmittedExpressionSyntax), we're automatically not reusable. - var isIncrementallyUnusable = slotCount === 0; + var isIncrementallyUnusable = slotCount === 0 && !isList(element); for (var i = 0, n = slotCount; i < n; i++) { var child = childAt(element, i); @@ -483,12 +393,13 @@ module TypeScript { } export interface ISyntaxElement { - kind(): SyntaxKind; - parent?: ISyntaxElement; + kind: SyntaxKind; + parent: ISyntaxElement; } export interface ISyntaxNode extends ISyntaxNodeOrToken { - data: number; + __data: number; + __cachedTokens: ISyntaxToken[]; } export interface IModuleReferenceSyntax extends ISyntaxNode { diff --git a/src/services/syntax/syntaxFacts2.ts b/src/services/syntax/syntaxFacts2.ts index 99a144176a4..7c73eb31513 100644 --- a/src/services/syntax/syntaxFacts2.ts +++ b/src/services/syntax/syntaxFacts2.ts @@ -2,16 +2,8 @@ module TypeScript.SyntaxFacts { export function isDirectivePrologueElement(node: ISyntaxNodeOrToken): boolean { - if (node.kind() === SyntaxKind.ExpressionStatement) { - var expressionStatement = node; - var expression = expressionStatement.expression; - - if (expression.kind() === SyntaxKind.StringLiteral) { - return true; - } - } - - return false; + return node.kind === SyntaxKind.ExpressionStatement && + (node).expression.kind === SyntaxKind.StringLiteral; } export function isUseStrictDirective(node: ISyntaxNodeOrToken): boolean { @@ -23,7 +15,7 @@ module TypeScript.SyntaxFacts { } export function isIdentifierNameOrAnyKeyword(token: ISyntaxToken): boolean { - var tokenKind = token.kind(); + var tokenKind = token.kind; return tokenKind === SyntaxKind.IdentifierName || SyntaxFacts.isAnyKeyword(tokenKind); } diff --git a/src/services/syntax/syntaxGenerator.ts b/src/services/syntax/syntaxGenerator.ts index 667b2563839..a9ae6ff5d53 100644 --- a/src/services/syntax/syntaxGenerator.ts +++ b/src/services/syntax/syntaxGenerator.ts @@ -1,12 +1,10 @@ -/// -/// +/// +/// +/// /// /// -/// +// /// -// Adds argument checking to the generated nodes. Argument checking appears to slow things down -// parsing about 7%. If we want to get that perf back, we can always remove this. -var argumentChecks = false; var forPrettyPrinter = false; interface ITypeDefinition { @@ -14,7 +12,6 @@ interface ITypeDefinition { baseType: string; interfaces?: string[]; children: IMemberDefinition[]; - syntaxKinds?: string[]; isTypeScriptSpecific: boolean; } @@ -29,10 +26,9 @@ interface IMemberDefinition { tokenKinds?: string[]; isTypeScriptSpecific: boolean; elementType?: string; - excludeFromAST?: boolean; } -var interfaces: TypeScript.IIndexable = { +var interfaces: any = { IMemberDeclarationSyntax: 'IClassElementSyntax', IStatementSyntax: 'IModuleElementSyntax', INameSyntax: 'ITypeSyntax', @@ -191,7 +187,7 @@ var definitions:ITypeDefinition[] = [ name: 'VariableDeclaratorSyntax', baseType: 'ISyntaxNode', children: [ - { name: 'propertyName', isToken: true, tokenKinds: ['IdentifierName', 'StringLiteral', 'NumericLiteral'] }, + { name: 'propertyName', isToken: true }, { name: 'typeAnnotation', type: 'TypeAnnotationSyntax', isOptional: true, isTypeScriptSpecific: true }, { name: 'equalsValueClause', type: 'EqualsValueClauseSyntax', isOptional: true } ] @@ -447,6 +443,32 @@ var definitions:ITypeDefinition[] = [ { name: 'closeBracketToken', isToken: true, excludeFromAST: true } ] }, + { + name: 'TemplateAccessExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IMemberExpressionSyntax', 'ICallExpressionSyntax'], + children: [ + { name: 'expression', type: 'ILeftHandSideExpressionSyntax' }, + { name: 'templateExpression', type: 'IPrimaryExpressionSyntax' } + ] + }, + { + name: 'TemplateExpressionSyntax', + baseType: 'ISyntaxNode', + interfaces: ['IPrimaryExpressionSyntax'], + children: [ + { name: 'templateStartToken', isToken: true, excludeFromAST: true }, + { name: 'templateClauses', isList: true, elementType: 'TemplateClauseSyntax' } + ] + }, + { + name: 'TemplateClauseSyntax', + baseType: 'ISyntaxNode', + children: [ + { name: 'expression', type: 'IExpressionSyntax' }, + { name: 'templateMiddleOrEndToken', isToken: true, elementType: 'TemplateSpanSyntax' } + ] + }, { name: 'InvocationExpressionSyntax', baseType: 'ISyntaxNode', @@ -988,19 +1010,11 @@ var definitions:ITypeDefinition[] = [ }]; function firstKind(definition: ITypeDefinition): TypeScript.SyntaxKind { - var kindName = definition.syntaxKinds ? definition.syntaxKinds[0] : getNameWithoutSuffix(definition); - //TypeScript.Environment.standardOut.WriteLine(kindName); - var kind = (TypeScript.SyntaxKind)[kindName]; - //TypeScript.Environment.standardOut.WriteLine(kind); - - return kind; + var kindName = getNameWithoutSuffix(definition); + return (TypeScript.SyntaxKind)[kindName]; } -var sortedDefinitions = definitions.sort((d1, d2) => firstKind(d1) - firstKind(d2)); - -//function endsWith(string: string, value: string): boolean { -// return string.substring(string.length - value.length, string.length) === value; -//} +definitions.sort((d1, d2) => firstKind(d1) - firstKind(d2)); function getStringWithoutSuffix(definition: string) { if (TypeScript.StringUtilities.endsWith(definition, "Syntax")) { @@ -1010,14 +1024,6 @@ function getStringWithoutSuffix(definition: string) { return definition; } -function getStringWithoutPrefix(definition: string) { - if (definition.charAt(0) == "I" && definition.charAt(1).toUpperCase() == definition.charAt(1)) { - return definition.substring(1); - } - - return definition; -} - function getNameWithoutSuffix(definition: ITypeDefinition) { return getStringWithoutSuffix(definition.name); } @@ -1027,7 +1033,7 @@ function getType(child: IMemberDefinition): string { return "ISyntaxToken"; } else if (child.isSeparatedList) { - return child.elementType + "[]"; + return "ISeparatedSyntaxList<" + child.elementType + ">"; } else if (child.isList) { return child.elementType + "[]"; @@ -1037,12 +1043,6 @@ function getType(child: IMemberDefinition): string { } } -var hasKind = false; - -function pascalCase(value: string): string { - return value.substr(0, 1).toUpperCase() + value.substr(1); -} - function camelCase(value: string): string { return value.substr(0, 1).toLowerCase() + value.substr(1); } @@ -1055,464 +1055,6 @@ function getSafeName(child: IMemberDefinition) { return child.name; } -function getPropertyAccess(child: IMemberDefinition, instance = "this"): string { - if (child.type === "SyntaxKind") { - return instance + "._kind"; - } - - return instance + "." + child.name; -} - -function generateProperties(definition: ITypeDefinition): string { - var result = ""; - - if (definition.name === "SourceUnitSyntax") { - result += " public syntaxTree: SyntaxTree = undefined;\r\n"; - } - - var newLine = false; - for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - - if (getType(child) === "SyntaxKind") { - result += " private _" + child.name + ": " + getType(child) + ";\r\n"; - newLine = true; - } - else if (child.name === "arguments") { - result += " public " + child.name + ": " + getType(child) + ";\r\n"; - } - - hasKind = hasKind || (getType(child) === "SyntaxKind"); - } - - if (newLine) { - result += "\r\n"; - } - - return result; -} - -function generateNullChecks(definition: ITypeDefinition): string { - var result = ""; - - for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - - if (!child.isOptional && !child.isToken) { - result += " if (!" + child.name + ") { throw Errors.argumentNull('" + child.name + "'); }\r\n"; - } - } - - return result; -} - -function generateIfKindCheck(child: IMemberDefinition, tokenKinds: string[], indent: string): string { - var result = ""; - - result += indent + " if ("; - - for (var j = 0; j < tokenKinds.length; j++) { - if (j > 0) { - result += " && "; - } - - var tokenKind = tokenKinds[j]; - if (tokenKind === "IdentifierName") { - result += "!SyntaxFacts.isIdentifierName(" + child.name + ".tokenKind)"; - } - else { - result += child.name + ".tokenKind !== SyntaxKind." + tokenKind; - } - } - - result += ") { throw Errors.argument('" + child.name + "'); }\r\n"; - return result; -} - -function generateSwitchCase(tokenKind: string, indent: string): string { - return indent + " case SyntaxKind." + tokenKind + ":\r\n"; -} - -function generateBreakStatement(indent: string): string { - return indent + " break;\r\n"; -} - -function generateSwitchCases(tokenKinds: string[], indent: string): string { - var result = ""; - for (var j = 0; j < tokenKinds.length; j++) { - var tokenKind = tokenKinds[j]; - - result += generateSwitchCase(tokenKind, indent); - } - - if (tokenKinds.length > 0) { - result += generateBreakStatement(indent); - } - - return result; -} - -function generateDefaultCase(child: IMemberDefinition, indent: string): string { - var result = ""; - - result += indent + " default:\r\n"; - result += indent + " throw Errors.argument('" + child.name + "');\r\n"; - - return result; -} - -function generateSwitchKindCheck(child: IMemberDefinition, tokenKinds: string[], indent: string): string { - if (tokenKinds.length === 0) { - return ""; - } - - var result = ""; - - var identifierName = TypeScript.ArrayUtilities.where(tokenKinds, v => v.indexOf("IdentifierName") >= 0); - var notIdentifierName = TypeScript.ArrayUtilities.where(tokenKinds, v => v.indexOf("IdentifierName") < 0); - - if (identifierName.length > 0) { - result += indent + " if (!SyntaxFacts.isIdentifierName(" + child.name + ".tokenKind)) {\r\n"; - if (notIdentifierName.length === 0) { - result += indent + " throw Errors.argument('" + child.name + "');\r\n"; - result += indent + " }\r\n"; - return result; - } - - indent += " "; - } - - if (notIdentifierName.length <= 2) { - result += generateIfKindCheck(child, notIdentifierName, indent); - } - else if (notIdentifierName.length > 2) { - result += indent + " switch (" + child.name + ".tokenKind) {\r\n"; - result += generateSwitchCases(notIdentifierName, indent); - result += generateDefaultCase(child, indent); - result += indent + " }\r\n"; - } - - if (identifierName.length > 0) { - result += indent + " }\r\n"; - } - - // result += indent + " }\r\n"; - return result; -} - -function tokenKinds(child: IMemberDefinition): string[] { - return child.tokenKinds - ? child.tokenKinds - : [pascalCase(child.name)]; -} - -function generateKindCheck(child: IMemberDefinition): string { - var indent = ""; - var result = ""; - - if (child.isOptional) { - indent = " "; - - result += " if (" + child.name + ") {\r\n"; - } - - var kinds = tokenKinds(child); - - if (kinds.length <= 2) { - result += generateIfKindCheck(child, kinds, indent); - } - else { - result += generateSwitchKindCheck(child, kinds, indent); - } - - if (child.isOptional) { - result += " }\r\n"; - } - - return result; -} - -function generateKindChecks(definition: ITypeDefinition): string { - var result = ""; - - for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - - if (child.isToken) { - result += generateKindCheck(child); - } - } - - return result; -} - -function generateArgumentChecks(definition: ITypeDefinition): string { - var result = ""; - - if (argumentChecks) { - result += generateNullChecks(definition); - result += generateKindChecks(definition); - - if (definition.children.length > 0) { - result += "\r\n"; - } - } - - return result; -} - -function generateConstructor(definition: ITypeDefinition): string { - var i: number; - var child: IMemberDefinition; - var base = baseType(definition); - - var result = ""; - result += " constructor(" - - var children = definition.children; - var kindChild: IMemberDefinition = undefined; - for (i = 0; i < children.length; i++) { - child = children[i]; - - if (getType(child) === "SyntaxKind") { - kindChild = child; - } - - if (getType(child) !== "SyntaxKind" && child.name !== "arguments") { - result += "public "; - } - - result += getSafeName(child) + ": " + getType(child); - result += ",\r\n "; - } - - result += "data: number) {\r\n"; - - if (kindChild) { - result += " super(kind, data); \r\n"; - } - else { - result += " super(SyntaxKind." + getNameWithoutSuffix(definition) + ", data); \r\n"; - } - - if (definition.children.length > 0) { - result += "\r\n"; - } - - result += generateArgumentChecks(definition); - - for (i = 0; i < definition.children.length; i++) { - child = definition.children[i]; - - if (child.type === "SyntaxKind" || child.name === "arguments") { - result += " " + getPropertyAccess(child) + " = " + getSafeName(child) + ";\r\n"; - } - } - - for (i = 0; i < definition.children.length; i++) { - child = definition.children[i]; - - if (child.type !== "SyntaxKind") { - if (child.isOptional) { - result += " " + getSafeName(child) + " && (" + getSafeName(child) + ".parent = this);\r\n"; - } - else if (child.isList || child.isSeparatedList) { - result += " !isShared(" + getSafeName(child) + ") && (" + getSafeName(child) + ".parent = this);\r\n"; - } - else { - result += " " + getSafeName(child) + ".parent = this;\r\n"; - } - } - } - - //result += " Syntax.setParentForChildren(this);\r\n"; - result += " }\r\n"; - - return result; -} - -function isOptional(child: IMemberDefinition) { - if (child.isOptional) { - return true; - } - - if (child.isList && !child.requiresAtLeastOneItem) { - return true; - } - - if (child.isSeparatedList && !child.requiresAtLeastOneItem) { - return true; - } - - return false; -} - -function generateFactory1Method(definition: ITypeDefinition): string { - return ""; - - var mandatoryChildren = TypeScript.ArrayUtilities.where( - definition.children, c => !isOptional(c)); - if (mandatoryChildren.length === definition.children.length) { - return ""; - } - - var result = "\r\n public static create(" - var i: number; - var child: IMemberDefinition; - - for (i = 0; i < mandatoryChildren.length; i++) { - child = mandatoryChildren[i]; - - result += child.name + ": " + getType(child); - - if (i < mandatoryChildren.length - 1) { - result += ",\r\n "; - } - } - - result += "): " + definition.name + " {\r\n"; - - result += " return new " + definition.name + "("; - - for (i = 0; i < definition.children.length; i++) { - child = definition.children[i]; - - if (!isOptional(child)) { - result += child.name; - } - else if (child.isList) { - result += "Syntax.emptyList<" + child.elementType + ">()"; - } - else if (child.isSeparatedList) { - result += "Syntax.emptySeparatedList<" + child.elementType + ">()"; - } - else { - result += "undefined"; - } - - result += ", "; - } - - result += "/*data:*/ 0);\r\n"; - result += " }\r\n"; - - return result; -} - -function isKeywordOrPunctuation(kind: string): boolean { - if (TypeScript.StringUtilities.endsWith(kind, "Keyword")) { - return true; - } - - if (TypeScript.StringUtilities.endsWith(kind, "Token") && - kind !== "IdentifierName" && - kind !== "EndOfFileToken") { - return true; - } - - return false; -} - -function isDefaultConstructable(definition: ITypeDefinition): boolean { - if (!definition) { - return false; - } - - for (var i = 0; i < definition.children.length; i++) { - if (isMandatory(definition.children[i])) { - // If any child is mandatory, then the type is not default constructable. - return false; - } - } - - // We can default construct this. - return true; -} - -function isMandatory(child: IMemberDefinition): boolean { - // If it's optional then it's not mandatory. - if (isOptional(child)) { - return false; - } - - // Kinds are always mandatory. As are non-optional lists. - if (child.type === "SyntaxKind" || child.isList || child.isSeparatedList) { - return true; - } - - // We have a non optional node or token. Tokens are mandatory if they're not keywords or - // punctuation. - if (child.isToken) { - var kinds = tokenKinds(child); - var isFixed = kinds.length === 1 && isKeywordOrPunctuation(kinds[0]); - - return !isFixed; - } - - // It's a node. It's mandatory if we can't default construct it. - return !isDefaultConstructable(memberDefinitionType(child)); -} - -function generateFactory2Method(definition: ITypeDefinition): string { - return ""; - - var mandatoryChildren: IMemberDefinition[] = TypeScript.ArrayUtilities.where(definition.children, isMandatory); - if (mandatoryChildren.length === definition.children.length) { - return ""; - } - - var i: number; - var child: IMemberDefinition; - var result = "\r\n public static create1(" - - for (i = 0; i < mandatoryChildren.length; i++) { - child = mandatoryChildren[i]; - - result += child.name + ": " + getType(child); - - if (i < mandatoryChildren.length - 1) { - result += ",\r\n "; - } - } - - result += "): " + definition.name + " {\r\n"; - result += " return new " + definition.name + "("; - - for (i = 0; i < definition.children.length; i++) { - child = definition.children[i]; - - if (isMandatory(child)) { - result += child.name; - } - else if (child.isList) { - result += "Syntax.emptyList<" + child.elementType + ">()"; - } - else if (child.isSeparatedList) { - result += "Syntax.emptySeparatedList<" + child.elementType + ">()"; - } - else if (isOptional(child)) { - result += "undefined"; - } - else if (child.isToken) { - result += "Syntax.token(SyntaxKind." + tokenKinds(child)[0] + ")"; - } - else { - result += child.type + ".create1()"; - } - - result += ", "; - } - - result += "/*data:*/ 0);\r\n"; - result += " }\r\n"; - - return result; -} - -function generateFactoryMethod(definition: ITypeDefinition): string { - return generateFactory1Method(definition) + generateFactory2Method(definition); -} - function generateBrands(definition: ITypeDefinition, accessibility: boolean): string { var properties = ""; @@ -1543,6 +1085,7 @@ function generateBrands(definition: ITypeDefinition, accessibility: boolean): st } } + types.push("_syntaxNodeOrTokenBrand"); if (types.length > 0) { properties += " "; @@ -1560,449 +1103,61 @@ function generateBrands(definition: ITypeDefinition, accessibility: boolean): st return properties; } -function generateKindMethod(definition: ITypeDefinition): string { - var result = ""; - - //if (!hasKind) { - // result += "\r\n"; - // result += " public get kind(): SyntaxKind {\r\n"; - // result += " return SyntaxKind." + getNameWithoutSuffix(definition) + ";\r\n"; - // result += " }\r\n"; - //} - - return result; -} - -function generateSlotMethods(definition: ITypeDefinition): string { - var result = ""; - return result; - - result += "\r\n"; - result += " public childCount(): number {\r\n"; - var slotCount = hasKind ? (definition.children.length - 1) : definition.children.length; - - result += " return " + slotCount + ";\r\n"; - result += " }\r\n\r\n"; - - result += " public childAt(slot: number): ISyntaxElement {\r\n"; - - if (slotCount === 0) { - result += " throw Errors.invalidOperation();\r\n"; - } - else { - result += " switch (slot) {\r\n"; - - var index = 0; - for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - if (child.type === "SyntaxKind") { - continue; - } - - result += " case " + index + ": return this." + child.name + ";\r\n"; - index++; - } - - result += " default: throw Errors.invalidOperation();\r\n"; - result += " }\r\n"; - } - - result += " }\r\n"; - - return result; -} - -function generateFirstTokenMethod(definition: ITypeDefinition): string { - var result = ""; - - result += "\r\n"; - result += " public firstToken(): ISyntaxToken {\r\n"; - result += " var token: ISyntaxToken = undefined;\r\n"; +function generateConstructorFunction(definition: ITypeDefinition) { + var result = " export var " + definition.name + ": " + getNameWithoutSuffix(definition) + "Constructor = function(data: number"; for (var i = 0; i < definition.children.length; i++) { var child = definition.children[i]; - - if (getType(child) === "SyntaxKind") { - continue; - } - - if (child.name === "endOfFileToken") { - continue; - } - - result += " if ("; - - if (child.isOptional) { - result += getPropertyAccess(child) + " && "; - } - - if (child.isToken) { - result += getPropertyAccess(child) + ".width() > 0"; - result += ") { return " + getPropertyAccess(child) + "; }\r\n"; - } - else { - result += "(token = " + getPropertyAccess(child) + ".firstToken())"; - result += ") { return token; }\r\n"; - } - } - - if (definition.name === "SourceUnitSyntax") { - result += " return this._endOfFileToken;\r\n"; - } - else { - result += " return undefined;\r\n"; - } - - result += " }\r\n"; - - result += " }\r\n"; - - return result; -} - -function generateLastTokenMethod(definition: ITypeDefinition): string { - var result = ""; - - result += "\r\n"; - result += " public lastToken(): ISyntaxToken {\r\n"; - - if (definition.name === "SourceUnitSyntax") { - result += " return this._endOfFileToken;\r\n"; - } - else { - result += " var token: ISyntaxToken = undefined;\r\n"; - - for (var i = definition.children.length - 1; i >= 0; i--) { - var child = definition.children[i]; - - if (getType(child) === "SyntaxKind") { - continue; - } - - if (child.name === "endOfFileToken") { - continue; - } - - result += " if ("; - - if (child.isOptional) { - result += getPropertyAccess(child) + " && "; - } - - if (child.isToken) { - result += getPropertyAccess(child) + ".width() > 0"; - result += ") { return " + getPropertyAccess(child) + "; }\r\n"; - } - else { - result += "(token = " + getPropertyAccess(child) + ".lastToken())"; - result += ") { return token; }\r\n"; - } - } - - result += " return undefined;\r\n"; - } - - result += " }\r\n"; - - return result; -} - -function baseType(definition: ITypeDefinition): ITypeDefinition { - return TypeScript.ArrayUtilities.firstOrDefault(definitions, d => d.name === definition.baseType); -} - -function memberDefinitionType(child: IMemberDefinition): ITypeDefinition { - // Debug.assert(child.type !== undefined); - return TypeScript.ArrayUtilities.firstOrDefault(definitions, d => d.name === child.type); -} - -function derivesFrom(def1: ITypeDefinition, def2: ITypeDefinition): boolean { - var current = def1; - while (current) { - var base = baseType(current); - if (base === def2) { - return true; - } - - current = base; - } - - return false; -} - -function contains(definition: ITypeDefinition, child: IMemberDefinition) { - return TypeScript.ArrayUtilities.any(definition.children, - c => c.name === child.name && - c.isList === child.isList && - c.isSeparatedList === child.isSeparatedList && - c.isToken === child.isToken && - c.type === child.type); -} - -function generateAccessors(definition: ITypeDefinition): string { - var result = ""; - - //if (definition.name === "SourceUnitSyntax") { - // result += "\r\n"; - // result += " public syntaxTree(): SyntaxTree {\r\n"; - // result += " return this._syntaxTree;\r\n"; - // result += " }\r\n"; - //} - - //for (var i = 0; i < definition.children.length; i++) { - // var child = definition.children[i]; - - // if (child.type === "SyntaxKind") { - // result += "\r\n"; - // result += " public get " + child.name + "(): " + getType(child) + " {\r\n"; - // result += " return " + getPropertyAccess(child) + ";\r\n"; - // result += " }\r\n"; - // } - //} - - return result; -} - -function generateWithMethod(definition: ITypeDefinition, child: IMemberDefinition): string { - return ""; - - var result = ""; - result += "\r\n"; - result += " public with" + pascalCase(child.name) + "(" + getSafeName(child) + ": " + getType(child) + "): " + definition.name + " {\r\n"; - result += " return this.update(" - - for (var i = 0; i < definition.children.length; i++) { - if (i > 0) { - result += ", "; - } - - if (definition.children[i] === child) { - result += getSafeName(child); - } - else { - result += getPropertyAccess(definition.children[i]); - } - } - - result += ");\r\n"; - result += " }\r\n"; - - if (child.isList || child.isSeparatedList) { - if (TypeScript.StringUtilities.endsWith(child.name, "s")) { - var pascalName = pascalCase(child.name); - pascalName = pascalName.substring(0, pascalName.length - 1); - - var argName = getSafeName(child); - argName = argName.substring(0, argName.length - 1) - - result += "\r\n"; - result += " public with" + pascalName + "(" + argName + ": " + child.elementType + "): " + definition.name + " {\r\n"; - result += " return this.with" + pascalCase(child.name) + "(" - - if (child.isList) { - result += "Syntax.list<" + child.elementType + ">([" + argName + "])"; - } - else { - result += "Syntax.separatedList<" + child.elementType + ">([" + argName + "])"; - } - - result += ");\r\n"; - result += " }\r\n"; - } - } - - return result; -} - -function generateWithMethods(definition: ITypeDefinition): string { - var result = ""; - return ""; - - for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - result += generateWithMethod(definition, child); - } - - return result; -} - -function generateTriviaMethods(definition: ITypeDefinition): string { - return ""; - - var result = "\r\n"; - result += " public withLeadingTrivia(trivia: ISyntaxTriviaList): " + definition.name + " {\r\n"; - result += " return <" + definition.name + ">super.withLeadingTrivia(trivia);\r\n"; - result += " }\r\n\r\n"; - result += " public withTrailingTrivia(trivia: ISyntaxTriviaList): " + definition.name + " {\r\n"; - result += " return <" + definition.name + ">super.withTrailingTrivia(trivia);\r\n"; - result += " }\r\n"; - - return result; -} - -function generateUpdateMethod(definition: ITypeDefinition): string { - // return ""; - - var result = ""; - - result += "\r\n"; - result += " public update("; - - var i: number; - var child: IMemberDefinition; - - for (i = 0; i < definition.children.length; i++) { - child = definition.children[i]; - - result += getSafeName(child) + ": " + getType(child); - - if (i < definition.children.length - 1) { - result += ",\r\n "; - } - } - - result += "): " + definition.name + " {\r\n"; - - if (definition.children.length === 0) { - result += " return this;\r\n"; - } - else { - result += " if ("; - - for (i = 0; i < definition.children.length; i++) { - child = definition.children[i]; - - if (i !== 0) { - result += " && "; - } - - result += getPropertyAccess(child) + " === " + getSafeName(child); - } - - result += ") {\r\n"; - result += " return this;\r\n"; - result += " }\r\n\r\n"; - - result += " return new " + definition.name + "("; - - for (i = 0; i < definition.children.length; i++) { - child = definition.children[i]; - - result += getSafeName(child); - result += ", "; - } - - result += "this.parsedInStrictMode() ? SyntaxConstants.NodeParsedInStrictModeMask : 0);\r\n"; - } - - result += " }\r\n"; - - return result; -} - -function generateNode(definition: ITypeDefinition, abstract: boolean): string { - var result = " export class " + definition.name + " extends SyntaxNode" - - if (definition.interfaces) { - result += " implements "; - result += definition.interfaces.join(", "); - } - - result += " {\r\n"; - - if (definition.name === "SourceUnitSyntax") { - result += " public syntaxTree: SyntaxTree = undefined;\r\n"; - } - - for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - result += " public " + child.name + ": " + getType(child) + ";\r\n"; - } - - result += generateBrands(definition, /*accessibility:*/ true); - - result += " constructor(data: number"; - - for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - result += ", " + getSafeName(child) + ": " + getType(child); + result += ", "; + result += getSafeName(child); + result += ": " + getType(child); } result += ") {\r\n"; - result += " super(data);\r\n"; - if (definition.name === "SourceUnitSyntax") { - result += " this.parent = undefined,\r\n"; - } + result += " if (data) { this.__data = data; }\r\n"; + + if (definition.children.length) { + result += " "; - if (definition.children) { for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - if (child.excludeFromAST && abstract) { - continue; + if (i) { + result += ", "; } - result += " this." + child.name + " = " + getSafeName(child) + ",\r\n"; + var child = definition.children[i]; + result += "this." + child.name + " = " + getSafeName(child); } + + result += ";\r\n"; } if (definition.children.length > 0) { - var first = true; + result += " "; + for (var i = 0; i < definition.children.length; i++) { + if (i) { + result += ", "; + } + var child = definition.children[i]; - if (child.excludeFromAST && abstract) { - continue; - } - if (!first) { - result += ",\r\n"; - } - first = false; - - if (child.isList || child.isSeparatedList) { - result += " !isShared(" + getSafeName(child) + ") && (" + getSafeName(child) + ".parent = this)"; - } - else if (child.isOptional) { - result += " " + getSafeName(child) + " && (" + getSafeName(child) + ".parent = this)"; + if (child.isOptional) { + result += getSafeName(child) + " && (" + getSafeName(child) + ".parent = this)"; } else { - result += " " + getSafeName(child) + ".parent = this"; + result += getSafeName(child) + ".parent = this"; } } result += ";\r\n"; } - result += " }\r\n"; - result += " }"; + result += " };\r\n"; + result += " " + definition.name + ".prototype.kind = SyntaxKind." + getNameWithoutSuffix(definition) + ";\r\n"; + return result; } -function syntaxKindName(kind: TypeScript.SyntaxKind): string { - for (var name in TypeScript.SyntaxKind) { - if (TypeScript.SyntaxKind[name] === kind) { - return name; - } - } - - throw new Error(); -} - -function getDefinitionForKind(kind: TypeScript.SyntaxKind): ITypeDefinition { - var kindName = syntaxKindName(kind); - - return TypeScript.ArrayUtilities.firstOrDefault(definitions, d => { - if (getNameWithoutSuffix(d) === kindName) { - return true; - } - - if (d.syntaxKinds) { - return TypeScript.ArrayUtilities.contains(d.syntaxKinds, kindName); - } - - return false; - }); -} - function generateSyntaxInterfaces(): string { var result = "///\r\n\r\n"; @@ -2018,48 +1173,6 @@ function generateSyntaxInterfaces(): string { result += generateSyntaxInterface(definition); } - result += "\r\n\r\n"; - - result += " export var nodeMetadata: string[][] = ["; - for (var i = 0; i <= TypeScript.SyntaxKind.LastNode; i++) { - if (i < TypeScript.SyntaxKind.FirstNode) { - result += "[],"; - continue; - } - - var kindName = syntaxKindName(i); - - var definition = getDefinitionForKind(i); - - var metadata = "["; - var children = definition.children.filter(m => m.type !== "SyntaxKind").map(m => '"' + m.name + '"'); - metadata += children.join(","); - metadata += "],"; - - result += metadata; - } - result += "];\r\n\r\n"; - - result += " export module Syntax {\r\n" - - result += " export interface ISyntaxFactory {\r\n"; - result += " isConcrete: boolean;\r\n"; - - for (var i = 0; i < definitions.length; i++) { - var definition = definitions[i]; - result += " " + definition.name + ": { new(data: number"; - - for (var j = 0; j < definition.children.length; j++) { - var child = definition.children[j]; - result += ", " + child.name + ": " + getType(child); - } - - result += "): " + definition.name + " };\r\n"; - } - - result += " }\r\n"; - result += " }\r\n"; - result += "}"; return result; } @@ -2083,53 +1196,40 @@ function generateSyntaxInterface(definition: ITypeDefinition): string { result += " " + child.name + ": " + getType(child) + ";\r\n"; } - result += " }"; + result += " }\r\n"; + result += " export interface " + getNameWithoutSuffix(definition) + "Constructor {"; + result += " new (data: number"; + + for (var i = 0; i < definition.children.length; i++) { + var child = definition.children[i]; + result += ", "; + result += getSafeName(child); + result += ": " + getType(child); + } + + result += "): " + definition.name; + result += " }\r\n"; return result; } - -function generateNodes(abstract: boolean): string { +function generateNodes(): string { var result = "///\r\n\r\n"; - result += "module TypeScript.Syntax."; - - var moduleName = abstract ? "Abstract" : "Concrete"; - result += moduleName; + result += "module TypeScript"; result += " {\r\n"; - result += " // Inject this module as the factory for producing syntax nodes in the parser.\r\n"; - result += " Parser.syntaxFactory = " + moduleName + ";\r\n"; - result += " export var isConcrete: boolean = " + !abstract + ";\r\n\r\n"; for (var i = 0; i < definitions.length; i++) { var definition = definitions[i]; - if (i > 0) { + if (i) { result += "\r\n"; } - result += generateNode(definition, abstract); + result += generateConstructorFunction(definition); } - result += "\r\n\r\n "; - - for (var i = 0; i < definitions.length; i++) { - var definition = definitions[i]; - - if (definition.syntaxKinds) { - continue; - } - - if (i) { - result += ", " - } - - result += "(" + definition.name + ").prototype.__kind = SyntaxKind." + getNameWithoutSuffix(definition) - } - - result += ";\r\n"; - result += "}"; return result; } @@ -2138,165 +1238,30 @@ function isInterface(name: string) { return name.substr(0, 1) === "I" && name.substr(1, 1).toUpperCase() === name.substr(1, 1) } -function isNodeOrToken(child: IMemberDefinition) { - // IWhatever. - return child.type && isInterface(child.type); -} - -function generateRewriter(): string { - var result = "///\r\n\r\n"; - - result += "module TypeScript {\r\n" + -" export class SyntaxRewriter implements ISyntaxVisitor {\r\n" + -" public visitToken(token: ISyntaxToken): ISyntaxToken {\r\n" + -" return token;\r\n" + -" }\r\n" + -"\r\n" + -" public visitNode(node: ISyntaxNode): ISyntaxNode {\r\n" + -" return visitNodeOrToken(this, node);\r\n" + -" }\r\n" + -"\r\n" + -" public visitNodeOrToken(node: ISyntaxNodeOrToken): ISyntaxNodeOrToken {\r\n" + -" return isToken(node) ? this.visitToken(node) : this.visitNode(node);\r\n" + -" }\r\n" + -"\r\n" + -" public visitList(list: T[]): T[] {\r\n" + -" var newItems: T[] = undefined;\r\n" + -"\r\n" + -" for (var i = 0, n = list.length; i < n; i++) {\r\n" + -" var item = list[i];\r\n" + -" var newItem = this.visitNodeOrToken(item);\r\n" + -"\r\n" + -" if (item !== newItem && !newItems) {\r\n" + -" newItems = [];\r\n" + -" for (var j = 0; j < i; j++) {\r\n" + -" newItems.push(list[j]);\r\n" + -" }\r\n" + -" }\r\n" + -"\r\n" + -" if (newItems) {\r\n" + -" newItems.push(newItem);\r\n" + -" }\r\n" + -" }\r\n" + -"\r\n" + -" // Debug.assert(!newItems || newItems.length === childCount(list));\r\n" + -" return !newItems ? list : Syntax.list(newItems);\r\n" + -" }\r\n" + -"\r\n" + -" public visitSeparatedList(list: T[]): T[] {\r\n" + -" var newItems: ISyntaxNodeOrToken[] = undefined;\r\n" + -"\r\n" + -" for (var i = 0, n = childCount(list); i < n; i++) {\r\n" + -" var item = childAt(list, i);\r\n" + -" var newItem = isToken(item) ? this.visitToken(item) : this.visitNode(item);\r\n" + -"\r\n" + -" if (item !== newItem && !newItems) {\r\n" + -" newItems = [];\r\n" + -" for (var j = 0; j < i; j++) {\r\n" + -" newItems.push(childAt(list, j));\r\n" + -" }\r\n" + -" }\r\n" + -"\r\n" + -" if (newItems) {\r\n" + -" newItems.push(newItem);\r\n" + -" }\r\n" + -" }\r\n" + -"\r\n" + -" // Debug.assert(newItems === undefined || newItems.length === childCount(list));\r\n" + -" return !newItems ? list : Syntax.separatedList(newItems);\r\n" + -" }\r\n"; - - for (var i = 0; i < definitions.length; i++) { - var definition = definitions[i]; - - result += "\r\n"; - result += " public visit" + getNameWithoutSuffix(definition) + "(node: " + definition.name + "): any {\r\n"; - - if (definition.children.length === 0) { - result += " return node;\r\n" - result += " }\r\n"; - continue; - } - - //if (definition.children.length === 1) { - // result += " return node.with" + pascalCase(definition.children[0].name) + "(\r\n"; - //} - //else { - result += " return node.update(\r\n"; - //} - - for (var j = 0; j < definition.children.length; j++) { - var child = definition.children[j]; - - result += " "; - if (child.isOptional) { - result += "!node." + child.name + " ? undefined : "; - } - - if (child.isToken) { - result += "this.visitToken(node." + child.name + ")"; - } - else if (child.isList) { - result += "this.visitList(node." + child.name + ")"; - } - else if (child.isSeparatedList) { - result += "this.visitSeparatedList(node." + child.name + ")"; - } - else if (child.type === "SyntaxKind") { - result += "node.kind"; - } - else if (isNodeOrToken(child)) { - result += "<" + child.type + ">this.visitNodeOrToken(node." + child.name + ")"; - } - else { - result += "<" + child.type + ">this.visitNode(node." + child.name + ")"; - } - - if (j < definition.children.length - 1) { - result += ",\r\n"; - } - } - - result += ");\r\n"; - result += " }\r\n"; - } - - result += " }"; - result += "\r\n}"; - return result; -} - function generateWalker(): string { var result = ""; result += -"///\r\n"+ -"\r\n" + -"module TypeScript {\r\n" + -" export class SyntaxWalker implements ISyntaxVisitor {\r\n" + -" public visitToken(token: ISyntaxToken): void {\r\n" + -" }\r\n" + -"\r\n" + -" private visitOptionalToken(token: ISyntaxToken): void {\r\n" + -" if (token === undefined) {\r\n" + -" return;\r\n" + -" }\r\n" + -"\r\n" + -" this.visitToken(token);\r\n" + -" }\r\n" + -"\r\n" + -" public visitList(list: ISyntaxNodeOrToken[]): void {\r\n" + -" for (var i = 0, n = list.length; i < n; i++) {\r\n" + -" visitNodeOrToken(this, list[i]);\r\n" + -" }\r\n" + -" }\r\n" + -"\r\n" + -" public visitSeparatedList(list: ISyntaxNodeOrToken[]): void {\r\n" + -" for (var i = 0, n = childCount(list); i < n; i++) {\r\n" + -" var item = childAt(list, i);\r\n" + -" visitNodeOrToken(this, item);\r\n" + -" }\r\n" + -" }\r\n"; + "///\r\n" + + "\r\n" + + "module TypeScript {\r\n" + + " export class SyntaxWalker implements ISyntaxVisitor {\r\n" + + " public visitToken(token: ISyntaxToken): void {\r\n" + + " }\r\n" + + "\r\n" + + " private visitOptionalToken(token: ISyntaxToken): void {\r\n" + + " if (token === undefined) {\r\n" + + " return;\r\n" + + " }\r\n" + + "\r\n" + + " this.visitToken(token);\r\n" + + " }\r\n" + + "\r\n" + + " public visitList(list: ISyntaxNodeOrToken[]): void {\r\n" + + " for (var i = 0, n = list.length; i < n; i++) {\r\n" + + " visitNodeOrToken(this, list[i]);\r\n" + + " }\r\n" + + " }\r\n"; for (var i = 0; i < definitions.length; i++) { var definition = definitions[i]; @@ -2315,16 +1280,18 @@ function generateWalker(): string { result += " this.visitToken(node." + child.name + ");\r\n"; } } - else if (child.isList) { + else if (child.isList || child.isSeparatedList) { result += " this.visitList(node." + child.name + ");\r\n"; } - else if (child.isSeparatedList) { - result += " this.visitSeparatedList(node." + child.name + ");\r\n"; + else if (child.isToken) { + if (child.isOptional) { + result += " this.visitOptionalToken(node." + child.name + ");\r\n"; + } + else { + result += " this.visitToken(node." + child.name + ");\r\n"; + } } - else if (isNodeOrToken(child)) { - result += " visitNodeOrToken(this, node." + child.name + ");\r\n"; - } - else if (child.type !== "SyntaxKind") { + else { result += " visitNodeOrToken(this, node." + child.name + ");\r\n"; } } @@ -2346,7 +1313,7 @@ function firstEnumName(e: any, value: number) { } function groupBy(array: T[], func: (v: T) => string): any { - var result: TypeScript.IIndexable = {}; + var result: any = {}; for (var i = 0, n = array.length; i < n; i++) { var v: any = array[i]; @@ -2389,7 +1356,6 @@ function generateKeywordCondition(keywords: { text: string; kind: TypeScript.Syn } else { result += " // " + TypeScript.ArrayUtilities.select(keywords, k => k.text).join(", ") + "\r\n" - // result += "\r\n"; index = currentCharacter === 0 ? "start" : ("start + " + currentCharacter); result += indent + "switch(str.charCodeAt(" + index + ")) {\r\n" @@ -2410,7 +1376,6 @@ function generateKeywordCondition(keywords: { text: string; kind: TypeScript.Syn } function min(array: T[], func: (v: T) => number): number { - // Debug.assert(array.length > 0); var min = func(array[0]); for (var i = 1; i < array.length; i++) { @@ -2424,7 +1389,6 @@ function min(array: T[], func: (v: T) => number): number { } function max(array: T[], func: (v: T) => number): number { - // Debug.assert(array.length > 0); var max = func(array[0]); for (var i = 1; i < array.length; i++) { @@ -2437,11 +1401,43 @@ function max(array: T[], func: (v: T) => number): number { return max; } +function generateUtilities(): string { + var result = ""; + result += " var fixedWidthArray = ["; + for (var i = 0; i <= TypeScript.SyntaxKind.LastFixedWidth; i++) { + if (i) { + result += ", "; + } + + if (i < TypeScript.SyntaxKind.FirstFixedWidth) { + result += "0"; + } + else { + result += TypeScript.SyntaxFacts.getText(i).length; + } + } + result += "];\r\n"; + + result += " function fixedWidthTokenLength(kind: SyntaxKind) {\r\n"; + result += " return fixedWidthArray[kind];\r\n"; + + //result += " switch (kind) {\r\n"; + + //for (var k = TypeScript.SyntaxKind.FirstFixedWidth; k <= TypeScript.SyntaxKind.LastFixedWidth; k++) { + // result += " case SyntaxKind." + syntaxKindName(k) + ": return " + TypeScript.SyntaxFacts.getText(k).length + ";\r\n"; + //} + //result += " default: throw new Error();\r\n"; + //result += " }\r\n"; + result += " }\r\n"; + + return result; +} + function generateScannerUtilities(): string { var result = "///\r\n" + "\r\n" + "module TypeScript {\r\n" + - " export class ScannerUtilities {\r\n"; + " export module ScannerUtilities {\r\n"; var i: number; var keywords: { text: string; kind: TypeScript.SyntaxKind; }[] = []; @@ -2452,7 +1448,7 @@ function generateScannerUtilities(): string { keywords.sort((a, b) => a.text.localeCompare(b.text)); - result += " public static identifierKind(str: string, start: number, length: number): SyntaxKind {\r\n"; + result += " export function identifierKind(str: string, start: number, length: number): SyntaxKind {\r\n"; var minTokenLength = min(keywords, k => k.text.length); var maxTokenLength = max(keywords, k => k.text.length); @@ -2477,6 +1473,16 @@ function generateScannerUtilities(): string { return result; } +function syntaxKindName(kind: TypeScript.SyntaxKind): string { + for (var name in TypeScript.SyntaxKind) { + if (TypeScript.SyntaxKind[name] === kind) { + return name; + } + } + + throw new Error(); +} + function generateVisitor(): string { var result = ""; @@ -2485,35 +1491,25 @@ function generateVisitor(): string { result += "module TypeScript {\r\n"; result += " export function visitNodeOrToken(visitor: ISyntaxVisitor, element: ISyntaxNodeOrToken): any {\r\n"; result += " if (element === undefined) { return undefined; }\r\n"; - result += " if (isToken(element)) { return visitor.visitToken(element); }\r\n"; - result += " switch (element.kind()) {\r\n"; + + result += " switch (element.kind) {\r\n"; for (var i = 0; i < definitions.length; i++) { var definition = definitions[i]; - if (definition.syntaxKinds) { - result += " "; - for (var j = 0; j < definition.syntaxKinds.length; j++) { - result += " case SyntaxKind." + definition.syntaxKinds[j] + ":" - } - result += "\r\n "; - } - else { - result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ": "; - } - + result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ": "; result += "return visitor.visit" + getNameWithoutSuffix(definition) + "(<" + definition.name + ">element);\r\n"; } - result += " }\r\n\r\n"; - result += " throw Errors.invalidOperation();\r\n"; + result += " default: return visitor.visitToken(element);\r\n"; + result += " }\r\n"; result += " }\r\n\r\n"; result += " export interface ISyntaxVisitor {\r\n"; result += " visitToken(token: ISyntaxToken): any;\r\n"; - for (i = 0; i < definitions.length; i++) { - definition = definitions[i]; + for (var i = 0; i < definitions.length; i++) { + var definition = definitions[i]; result += " visit" + getNameWithoutSuffix(definition) + "(node: " + definition.name + "): any;\r\n"; } @@ -2524,320 +1520,120 @@ function generateVisitor(): string { return result; } -function generateDefaultVisitor(): string { - var result = ""; - - result += "///\r\n\r\n"; - - result += "module TypeScript {\r\n"; - if (!forPrettyPrinter) { - result += " export class SyntaxVisitor implements ISyntaxVisitor {\r\n"; - result += " public defaultVisit(node: ISyntaxNodeOrToken): any {\r\n"; - result += " return undefined;\r\n"; - result += " }\r\n"; - result += "\r\n"; - result += " public visitToken(token: ISyntaxToken): any {\r\n"; - result += " return this.defaultVisit(token);\r\n"; - result += " }\r\n"; - - for (var i = 0; i < definitions.length; i++) { - var definition = definitions[i]; - - result += "\r\n public visit" + getNameWithoutSuffix(definition) + "(node: " + definition.name + "): any {\r\n"; - result += " return this.defaultVisit(node);\r\n"; - result += " }\r\n"; - } - - result += " }"; - } - - result += "\r\n}"; - - return result; -} - -function generateFactory(): string { - var result = "///\r\n"; - - result += "\r\nmodule TypeScript.Syntax {\r\n"; - result += " export interface IFactory {\r\n"; - - var i: number; - var j: number; - var definition: ITypeDefinition; - var child: IMemberDefinition; - - for (i = 0; i < definitions.length; i++) { - definition = definitions[i]; - result += " " + camelCase(getNameWithoutSuffix(definition)) + "("; - - for (j = 0; j < definition.children.length; j++) { - if (j > 0) { - result += ", "; - } - - child = definition.children[j]; - result += child.name + ": " + getType(child); - } - - result += "): " + definition.name + ";\r\n"; - } - - result += " }\r\n\r\n"; - - // TODO: stop exporting these once compiler bugs are fixed. - result += " export class NormalModeFactory implements IFactory {\r\n"; - - for (i = 0; i < definitions.length; i++) { - definition = definitions[i]; - result += " " + camelCase(getNameWithoutSuffix(definition)) + "("; - - for (j = 0; j < definition.children.length; j++) { - if (j > 0) { - result += ", "; - } - - child = definition.children[j]; - result += getSafeName(child) + ": " + getType(child); - } - - result += "): " + definition.name + " {\r\n"; - result += " return new " + definition.name + "("; - - for (j = 0; j < definition.children.length; j++) { - child = definition.children[j]; - result += getSafeName(child); - result += ", "; - } - - result += "/*data:*/ 0);\r\n"; - result += " }\r\n" - } - - result += " }\r\n\r\n"; - - // TODO: stop exporting these once compiler bugs are fixed. - result += " export class StrictModeFactory implements IFactory {\r\n"; - - for (i = 0; i < definitions.length; i++) { - definition = definitions[i]; - result += " " + camelCase(getNameWithoutSuffix(definition)) + "("; - - for (j = 0; j < definition.children.length; j++) { - if (j > 0) { - result += ", "; - } - - child = definition.children[j]; - result += getSafeName(child) + ": " + getType(child); - } - - result += "): " + definition.name + " {\r\n"; - result += " return new " + definition.name + "("; - - for (j = 0; j < definition.children.length; j++) { - child = definition.children[j]; - result += getSafeName(child); - result += ", "; - } - - result += "/*data:*/ SyntaxConstants.NodeParsedInStrictModeMask);\r\n"; - - result += " }\r\n" - } - - result += " }\r\n\r\n"; - - result += " export var normalModeFactory: IFactory = new NormalModeFactory();\r\n"; - result += " export var strictModeFactory: IFactory = new StrictModeFactory();\r\n"; - result += "}"; - - return result; -} - function generateServicesUtilities(): string { - var result = ""; // "/// \r\n\r\n"; - - result += generateIsTypeScriptSpecific(); - - return result; -} - -function generateIsTypeScriptSpecific(): string { var result = ""; - result += "module TypeScript {\r\n"; - result += " function isSeparatedListTypeScriptSpecific(list: ISyntaxNodeOrToken[]): boolean {\r\n" - result += " for (var i = 0, n = childCount(list); i < n; i++) {\r\n"; - result += " if (isTypeScriptSpecific(childAt(list, i))) {\r\n"; - result += " return true;\r\n"; - result += " }\r\n"; - result += " }\r\n\r\n"; - result += " return false;\r\n"; + result += " var childCountArray = ["; + for (var i = 0, n = TypeScript.SyntaxKind.LastNode; i <= n; i++) { + if (i) { + result += ", "; + } + + if (i <= TypeScript.SyntaxKind.LastToken) { + result += "0"; + } + else { + var definition = TypeScript.ArrayUtilities.first(definitions, d => firstKind(d) === i); + result += definition.children.length; + } + } + result += "];\r\n\r\n"; + + result += " export function childCount(element: ISyntaxElement): number {\r\n"; + result += " if (isList(element)) { return (element).length; }\r\n"; + result += " return childCountArray[element.kind];\r\n"; result += " }\r\n\r\n"; - result += " function isListTypeScriptSpecific(list: ISyntaxNodeOrToken[]): boolean {\r\n" - result += " for (var i = 0, n = list.length; i < n; i++) {\r\n"; - result += " if (isTypeScriptSpecific(list[i])) {\r\n"; - result += " return true;\r\n"; - result += " }\r\n"; - result += " }\r\n\r\n"; - result += " return false;\r\n"; - result += " }\r\n\r\n"; + result += " var childAtArray: ((nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement)[] = [\r\n "; - result += " export function isTypeScriptSpecific(element: ISyntaxElement): boolean {\r\n" - result += " if (!element) { return false; }\r\n"; - result += " if (isToken(element)) { return false; }\r\n"; - result += " if (isList(element)) { return isListTypeScriptSpecific(element); }\r\n"; - result += " if (isSeparatedList(element)) { return isSeparatedListTypeScriptSpecific(element); }\r\n\r\n"; - result += " switch (element.kind()) {\r\n"; + for (var i = 0; i < TypeScript.SyntaxKind.FirstNode; i++) { + if (i) { + result += ", "; + } + + result += "undefined"; + } for (var i = 0; i < definitions.length; i++) { var definition = definitions[i]; - if (!definition.isTypeScriptSpecific) { - continue; - } + result += ",\r\n" + result += " (node: " + definition.name + ", index: number): ISyntaxElement => {\r\n"; - if (definition.syntaxKinds) { - for (var j = 0; j < definition.syntaxKinds.length; j++) { - result += " case SyntaxKind." + definition.syntaxKinds[j] + ":\r\n"; + if (definition.children.length) { + result += " switch (index) {\r\n"; + + for (var j = 0; j < definition.children.length; j++) { + result += " case " + j + ": return node." + definition.children[j].name + ";\r\n"; } + + result += " }\r\n"; } else { - result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ":\r\n"; + result += " throw Errors.invalidOperation();\r\n"; } + + + result += " }"; } - result += " return true;\r\n"; + result += "\r\n ];\r\n"; - var triviallyFalseDefinitions = definitions.filter(d => d.children.filter(c => c.type !== "SyntaxKind" && !c.isToken).length === 0); - for (var i = 0; i < triviallyFalseDefinitions.length; i++) { - var definition = triviallyFalseDefinitions[i]; - if (definition.isTypeScriptSpecific) { - continue; - } + //for (var i = 0; i < definitions.length; i++) { + // var definition = definitions[i]; + // result += " function " + camelCase(getNameWithoutSuffix(definition)) + "ChildAt(node: " + definition.name + ", index: number): ISyntaxElement {\r\n"; + // if (definition.children.length) { + // result += " switch (index) {\r\n"; - if (definition.syntaxKinds) { - for (var j = 0; j < definition.syntaxKinds.length; j++) { - result += " case SyntaxKind." + definition.syntaxKinds[j] + ":\r\n"; - } - } - else { - result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ":\r\n"; - } - } + // for (var j = 0; j < definition.children.length; j++) { + // result += " case " + j + ": return node." + definition.children[j].name + ";\r\n"; + // } - result += " return false;\r\n"; + // result += " }\r\n"; + // } + // else { + // result += " throw Errors.invalidOperation();\r\n"; + // } + // result += " }\r\n"; + //} - for (var i = 0; i < definitions.length; i++) { - var definition = definitions[i]; - if (definition.isTypeScriptSpecific) { - continue; - } - if (definition.children.filter(c => c.type !== "SyntaxKind" && !c.isToken).length === 0) { - continue; - } + result += " export function childAt(element: ISyntaxElement, index: number): ISyntaxElement {\r\n"; + result += " if (isList(element)) { return (element)[index]; }\r\n"; + result += " return childAtArray[element.kind](element, index);\r\n"; + //result += " switch (element.kind) {\r\n"; - if (definition.syntaxKinds) { - result += " "; - for (var j = 0; j < definition.syntaxKinds.length; j++) { - result += " case SyntaxKind." + definition.syntaxKinds[j] + ":"; - } - } - else { - result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ":"; - } - result += "\r\n"; - result += " return is" + getNameWithoutSuffix(definition) + "TypeScriptSpecific(<" + definition.name + ">element);\r\n"; - } + //for (var i = 0; i < definitions.length; i++) { + // var definition = definitions[i]; + // result += " case SyntaxKind." + getNameWithoutSuffix(definition) + ": return " + camelCase(getNameWithoutSuffix(definition)) + "ChildAt(<" + definition.name + ">element, index);\r\n"; + //} - result += " }\r\n"; + //result += " }\r\n"; + result += " }\r\n\r\n"; + + result += " export function getChildAtFunction(element: ISyntaxNodeOrToken): (nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement {\r\n"; + result += " return childAtArray[element.kind];\r\n"; result += " }\r\n"; - for (var i = 0; i < definitions.length; i++) { - var definition = definitions[i]; - if (definition.isTypeScriptSpecific) { - continue; - } - - var importantChildren = definition.children.filter(d => d.type !== "SyntaxKind" && !d.isToken); - if (importantChildren.length > 0) { - result += generateIsTypeScriptSpecificMethod(definition); - } - } result += "}"; - return result; -} - -function generateIsTypeScriptSpecificMethod(definition: ITypeDefinition): string { - var result = "\r\n function is" + getNameWithoutSuffix(definition) + "TypeScriptSpecific(node: " + definition.name + "): boolean {\r\n"; - - result += " return "; - - var addedCheck = false; - for (var i = 0; i < definition.children.length; i++) { - var child = definition.children[i]; - - if (child.type === "SyntaxKind") { - continue; - } - - if (child.isToken) { - continue; - } - - if (addedCheck) { - result += " ||\r\n "; - } - - addedCheck = true; - - if (child.isTypeScriptSpecific) { - if (child.isList) { - result += getPropertyAccess(child, "node") + ".length > 0"; - } - else if (child.isSeparatedList) { - result += getPropertyAccess(child, "node") + ".childCount() > 0"; - } - else { - result += "!!" + getPropertyAccess(child, "node"); - } - } - else { - result += "isTypeScriptSpecific(" + getPropertyAccess(child, "node") + ")"; - } - } - - if (!addedCheck) { - result += "false"; - } - - result += ";\r\n"; - result += " }\r\n"; return result; } -var syntaxNodesConcrete = generateNodes(/*abstract:*/ false); -var syntaxNodesAbstract = generateNodes(/*abstract:*/ true); +var syntaxNodesConcrete = generateNodes(); var syntaxInterfaces = generateSyntaxInterfaces(); -var rewriter = generateRewriter(); var walker = generateWalker(); var scannerUtilities = generateScannerUtilities(); var visitor = generateVisitor(); -var defaultVisitor = generateDefaultVisitor(); var servicesUtilities = generateServicesUtilities(); +var utilities = generateUtilities(); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\compiler\\syntax\\syntaxNodes.concrete.generated.ts", syntaxNodesConcrete, false); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\compiler\\syntax\\syntaxNodes.abstract.generated.ts", syntaxNodesAbstract, false); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\compiler\\syntax\\syntaxNodes.interfaces.generated.ts", syntaxInterfaces, false); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\services\\syntaxRewriter.generated.ts", rewriter, false); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\compiler\\syntax\\syntaxWalker.generated.ts", walker, false); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\compiler\\syntax\\scannerUtilities.generated.ts", scannerUtilities, false); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\compiler\\syntax\\syntaxVisitor.generated.ts", visitor, false); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\compiler\\syntax\\defaultSyntaxVisitor.generated.ts", defaultVisitor, false); -TypeScript.Environment.writeFile(TypeScript.Environment.currentDirectory() + "\\src\\services\\syntaxUtilities.generated.ts", servicesUtilities, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxNodes.concrete.generated.ts", syntaxNodesConcrete, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxInterfaces.generated.ts", syntaxInterfaces, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxWalker.generated.ts", walker, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\scannerUtilities.generated.ts", scannerUtilities, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxVisitor.generated.ts", visitor, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\syntaxUtilities.generated.ts", servicesUtilities, false); +sys.writeFile(sys.getCurrentDirectory() + "\\src\\services\\syntax\\utilities.generated.ts", utilities, false); diff --git a/src/services/syntax/syntaxInterfaces.generated.ts b/src/services/syntax/syntaxInterfaces.generated.ts index b7f99f68b28..ba1b6a7298a 100644 --- a/src/services/syntax/syntaxInterfaces.generated.ts +++ b/src/services/syntax/syntaxInterfaces.generated.ts @@ -1,499 +1,688 @@ /// module TypeScript { - export enum NodeFlags { - Export = 0x00000001, // Declarations - Ambient = 0x00000002, // Declarations - Optional = 0x00000004, // Parameter/Property/Method - Rest = 0x00000008, // Parameter - Public = 0x00000010, // Property/Method - Private = 0x00000020, // Property/Method - Static = 0x00000040, // Property/Method + export interface SourceUnitSyntax extends ISyntaxNode { + syntaxTree: SyntaxTree; + moduleElements: IModuleElementSyntax[]; + endOfFileToken: ISyntaxToken; } + export interface SourceUnitConstructor { new (data: number, moduleElements: IModuleElementSyntax[], endOfFileToken: ISyntaxToken): SourceUnitSyntax } - interface SyntaxElement { - kind: SyntaxKind; + export interface QualifiedNameSyntax extends ISyntaxNode, INameSyntax { + left: INameSyntax; + dotToken: ISyntaxToken; + right: ISyntaxToken; } + export interface QualifiedNameConstructor { new (data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken): QualifiedNameSyntax } - interface SyntaxNode extends SyntaxElement { - flags: NodeFlags; + export interface ObjectTypeSyntax extends ISyntaxNode, ITypeSyntax { + openBraceToken: ISyntaxToken; + typeMembers: ISeparatedSyntaxList; + closeBraceToken: ISyntaxToken; } + export interface ObjectTypeConstructor { new (data: number, openBraceToken: ISyntaxToken, typeMembers: ISeparatedSyntaxList, closeBraceToken: ISyntaxToken): ObjectTypeSyntax } - function nodeStart(node: Node): number { + export interface FunctionTypeSyntax extends ISyntaxNode, ITypeSyntax { + typeParameterList: TypeParameterListSyntax; + parameterList: ParameterListSyntax; + equalsGreaterThanToken: ISyntaxToken; + type: ITypeSyntax; + } + export interface FunctionTypeConstructor { new (data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax): FunctionTypeSyntax } + + export interface ArrayTypeSyntax extends ISyntaxNode, ITypeSyntax { + type: ITypeSyntax; + openBracketToken: ISyntaxToken; + closeBracketToken: ISyntaxToken; + } + export interface ArrayTypeConstructor { new (data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken): ArrayTypeSyntax } + + export interface ConstructorTypeSyntax extends ISyntaxNode, ITypeSyntax { + newKeyword: ISyntaxToken; + typeParameterList: TypeParameterListSyntax; + parameterList: ParameterListSyntax; + equalsGreaterThanToken: ISyntaxToken; + type: ITypeSyntax; + } + export interface ConstructorTypeConstructor { new (data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax): ConstructorTypeSyntax } + + export interface GenericTypeSyntax extends ISyntaxNode, ITypeSyntax { + name: INameSyntax; + typeArgumentList: TypeArgumentListSyntax; + } + export interface GenericTypeConstructor { new (data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax): GenericTypeSyntax } + + export interface TypeQuerySyntax extends ISyntaxNode, ITypeSyntax { + typeOfKeyword: ISyntaxToken; + name: INameSyntax; + } + export interface TypeQueryConstructor { new (data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax): TypeQuerySyntax } + + export interface TupleTypeSyntax extends ISyntaxNode, ITypeSyntax { + openBracketToken: ISyntaxToken; + types: ISeparatedSyntaxList; + closeBracketToken: ISyntaxToken; + } + export interface TupleTypeConstructor { new (data: number, openBracketToken: ISyntaxToken, types: ISeparatedSyntaxList, closeBracketToken: ISyntaxToken): TupleTypeSyntax } + + export interface UnionTypeSyntax extends ISyntaxNode, ITypeSyntax { + left: ITypeSyntax; + barToken: ISyntaxToken; + right: ITypeSyntax; + } + export interface UnionTypeConstructor { new (data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax): UnionTypeSyntax } + + export interface ParenthesizedTypeSyntax extends ISyntaxNode, ITypeSyntax { + openParenToken: ISyntaxToken; + type: ITypeSyntax; + closeParenToken: ISyntaxToken; + } + export interface ParenthesizedTypeConstructor { new (data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken): ParenthesizedTypeSyntax } + + export interface InterfaceDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax { + modifiers: ISyntaxToken[]; + interfaceKeyword: ISyntaxToken; + identifier: ISyntaxToken; + typeParameterList: TypeParameterListSyntax; + heritageClauses: HeritageClauseSyntax[]; + body: ObjectTypeSyntax; + } + export interface InterfaceDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax): InterfaceDeclarationSyntax } + + export interface FunctionDeclarationSyntax extends ISyntaxNode, IStatementSyntax { + modifiers: ISyntaxToken[]; + functionKeyword: ISyntaxToken; + identifier: ISyntaxToken; + callSignature: CallSignatureSyntax; + block: BlockSyntax; + semicolonToken: ISyntaxToken; + } + export interface FunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): FunctionDeclarationSyntax } + + export interface ModuleDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax { + modifiers: ISyntaxToken[]; + moduleKeyword: ISyntaxToken; + name: INameSyntax; + stringLiteral: ISyntaxToken; + openBraceToken: ISyntaxToken; + moduleElements: IModuleElementSyntax[]; + closeBraceToken: ISyntaxToken; + } + export interface ModuleDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken): ModuleDeclarationSyntax } + + export interface ClassDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax { + modifiers: ISyntaxToken[]; + classKeyword: ISyntaxToken; + identifier: ISyntaxToken; + typeParameterList: TypeParameterListSyntax; + heritageClauses: HeritageClauseSyntax[]; + openBraceToken: ISyntaxToken; + classElements: IClassElementSyntax[]; + closeBraceToken: ISyntaxToken; } + export interface ClassDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken): ClassDeclarationSyntax } + + export interface EnumDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax { + modifiers: ISyntaxToken[]; + enumKeyword: ISyntaxToken; + identifier: ISyntaxToken; + openBraceToken: ISyntaxToken; + enumElements: ISeparatedSyntaxList; + closeBraceToken: ISyntaxToken; + } + export interface EnumDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: ISeparatedSyntaxList, closeBraceToken: ISyntaxToken): EnumDeclarationSyntax } + + export interface ImportDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax { + modifiers: ISyntaxToken[]; + importKeyword: ISyntaxToken; + identifier: ISyntaxToken; + equalsToken: ISyntaxToken; + moduleReference: IModuleReferenceSyntax; + semicolonToken: ISyntaxToken; + } + export interface ImportDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken): ImportDeclarationSyntax } - function nodeWidth(node: Node): number { - } - - interface SyntaxToken extends Name, PrimaryExpression { - } - - // The raw text of the token, as written in the original source. - function tokenText(token: SyntaxToken): string { - } - - // The token's javascript value. i.e. 0.0 in the text would have the javascript number value: 0. - function tokenValue(token: SyntaxToken): any { - } - - // The token's value in string form. i.e. \u0041 in the source text would result in a string with the text: A. - function tokenValueText(token: SyntaxToken): string { - } - - interface SyntaxList extends SyntaxElement { - length: number; - item(index: number): T; - } - - interface SourceUnit extends Node { - moduleElements: SyntaxList; - } - - interface QualifiedName extends Name { - left: Name; - right: SyntaxToken; - } - - interface ObjectType extends Type { - typeMembers: SyntaxList; - } - - interface FunctionType extends Type { - typeParameterList?: TypeParameterList; - parameterList: ParameterList; - type: Type; - } - - interface ArrayType extends Type { - type: Type; - } - - interface ConstructorType extends Type { - typeParameterList?: TypeParameterList; - parameterList: ParameterList; - type: Type; - } - - interface GenericType extends Type { - name: Name; - typeArgumentList: TypeArgumentList; - } - - interface TypeQuery extends Type { - name: Name; - } - - interface InterfaceDeclaration extends ModuleElement { - identifier: SyntaxToken; - typeParameterList?: TypeParameterList; - heritageClauses: SyntaxList; - body: ObjectType; - } - - interface FunctionDeclaration extends Statement { - identifier: SyntaxToken; - callSignature: CallSignature; - block?: Block; - } - - interface ModuleDeclaration extends ModuleElement { - name?: Name; - stringLiteral?: SyntaxToken; - moduleElements: SyntaxList; - } + export interface ExportAssignmentSyntax extends ISyntaxNode, IModuleElementSyntax { + exportKeyword: ISyntaxToken; + equalsToken: ISyntaxToken; + identifier: ISyntaxToken; + semicolonToken: ISyntaxToken; + } + export interface ExportAssignmentConstructor { new (data: number, exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): ExportAssignmentSyntax } + + export interface MemberFunctionDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax { + modifiers: ISyntaxToken[]; + propertyName: ISyntaxToken; + callSignature: CallSignatureSyntax; + block: BlockSyntax; + semicolonToken: ISyntaxToken; + } + export interface MemberFunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): MemberFunctionDeclarationSyntax } + + export interface MemberVariableDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax { + modifiers: ISyntaxToken[]; + variableDeclarator: VariableDeclaratorSyntax; + semicolonToken: ISyntaxToken; + } + export interface MemberVariableDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken): MemberVariableDeclarationSyntax } + + export interface ConstructorDeclarationSyntax extends ISyntaxNode, IClassElementSyntax { + modifiers: ISyntaxToken[]; + constructorKeyword: ISyntaxToken; + callSignature: CallSignatureSyntax; + block: BlockSyntax; + semicolonToken: ISyntaxToken; + } + export interface ConstructorDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): ConstructorDeclarationSyntax } + + export interface IndexMemberDeclarationSyntax extends ISyntaxNode, IClassElementSyntax { + modifiers: ISyntaxToken[]; + indexSignature: IndexSignatureSyntax; + semicolonToken: ISyntaxToken; + } + export interface IndexMemberDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax, semicolonToken: ISyntaxToken): IndexMemberDeclarationSyntax } + + export interface GetAccessorSyntax extends ISyntaxNode, IMemberDeclarationSyntax, IPropertyAssignmentSyntax { + modifiers: ISyntaxToken[]; + getKeyword: ISyntaxToken; + propertyName: ISyntaxToken; + callSignature: CallSignatureSyntax; + block: BlockSyntax; + } + export interface GetAccessorConstructor { new (data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): GetAccessorSyntax } + + export interface SetAccessorSyntax extends ISyntaxNode, IMemberDeclarationSyntax, IPropertyAssignmentSyntax { + modifiers: ISyntaxToken[]; + setKeyword: ISyntaxToken; + propertyName: ISyntaxToken; + callSignature: CallSignatureSyntax; + block: BlockSyntax; + } + export interface SetAccessorConstructor { new (data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): SetAccessorSyntax } + + export interface PropertySignatureSyntax extends ISyntaxNode, ITypeMemberSyntax { + propertyName: ISyntaxToken; + questionToken: ISyntaxToken; + typeAnnotation: TypeAnnotationSyntax; + } + export interface PropertySignatureConstructor { new (data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax): PropertySignatureSyntax } + + export interface CallSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax { + typeParameterList: TypeParameterListSyntax; + parameterList: ParameterListSyntax; + typeAnnotation: TypeAnnotationSyntax; + } + export interface CallSignatureConstructor { new (data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax): CallSignatureSyntax } + + export interface ConstructSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax { + newKeyword: ISyntaxToken; + callSignature: CallSignatureSyntax; + } + export interface ConstructSignatureConstructor { new (data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax): ConstructSignatureSyntax } + + export interface IndexSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax { + openBracketToken: ISyntaxToken; + parameters: ISeparatedSyntaxList; + closeBracketToken: ISyntaxToken; + typeAnnotation: TypeAnnotationSyntax; + } + export interface IndexSignatureConstructor { new (data: number, openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax): IndexSignatureSyntax } - interface ClassDeclaration extends ModuleElement { - identifier: SyntaxToken; - typeParameterList?: TypeParameterList; - heritageClauses: SyntaxList; - classElements: SyntaxList; - } - - interface EnumDeclaration extends ModuleElement { - identifier: SyntaxToken; - enumElements: SyntaxList; - } - - interface ImportDeclaration extends ModuleElement { - identifier: SyntaxToken; - moduleReference: ModuleReference; - } - - interface ExportAssignment extends ModuleElement { - identifier: SyntaxToken; - } - - interface MemberFunctionDeclaration extends MemberDeclaration { - propertyName: SyntaxToken; - callSignature: CallSignature; - block?: Block; - } - - interface MemberVariableDeclaration extends MemberDeclaration { - variableDeclarator: VariableDeclarator; - } + export interface MethodSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax { + propertyName: ISyntaxToken; + questionToken: ISyntaxToken; + callSignature: CallSignatureSyntax; + } + export interface MethodSignatureConstructor { new (data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax): MethodSignatureSyntax } - interface ConstructorDeclaration extends ClassElement { - callSignature: CallSignature; - block?: Block; + export interface BlockSyntax extends ISyntaxNode, IStatementSyntax { + openBraceToken: ISyntaxToken; + statements: IStatementSyntax[]; + closeBraceToken: ISyntaxToken; } + export interface BlockConstructor { new (data: number, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken): BlockSyntax } - interface IndexMemberDeclaration extends ClassElement { - indexSignature: IndexSignature; + export interface IfStatementSyntax extends ISyntaxNode, IStatementSyntax { + ifKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + condition: IExpressionSyntax; + closeParenToken: ISyntaxToken; + statement: IStatementSyntax; + elseClause: ElseClauseSyntax; } + export interface IfStatementConstructor { new (data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax): IfStatementSyntax } - interface GetAccessor extends MemberDeclaration, PropertyAssignment { - propertyName: SyntaxToken; - callSignature: CallSignature; - block: Block; + export interface VariableStatementSyntax extends ISyntaxNode, IStatementSyntax { + modifiers: ISyntaxToken[]; + variableDeclaration: VariableDeclarationSyntax; + semicolonToken: ISyntaxToken; } + export interface VariableStatementConstructor { new (data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken): VariableStatementSyntax } - interface SetAccessor extends MemberDeclaration, PropertyAssignment { - propertyName: SyntaxToken; - callSignature: CallSignature; - block: Block; + export interface ExpressionStatementSyntax extends ISyntaxNode, IStatementSyntax { + expression: IExpressionSyntax; + semicolonToken: ISyntaxToken; } - - interface PropertySignature extends TypeMember { - propertyName: SyntaxToken; - typeAnnotation?: TypeAnnotation; - } - - interface CallSignature extends TypeMember { - typeParameterList?: TypeParameterList; - parameterList: ParameterList; - typeAnnotation?: TypeAnnotation; - } - - interface ConstructSignature extends TypeMember { - callSignature: CallSignature; - } - - interface IndexSignature extends TypeMember { - parameters: SyntaxList; - typeAnnotation?: TypeAnnotation; - } - - interface MethodSignature extends TypeMember { - propertyName: SyntaxToken; - callSignature: CallSignature; - } - - interface Block extends Statement { - statements: SyntaxList; - } - - interface IfStatement extends Statement { - condition: Expression; - statement: Statement; - elseClause?: ElseClause; - } - - interface VariableStatement extends Statement { - variableDeclaration: VariableDeclaration; - } - - interface ExpressionStatement extends Statement { - expression: Expression; - } - - interface ReturnStatement extends Statement { - expression?: Expression; - } - - interface SwitchStatement extends Statement { - expression: Expression; - switchClauses: SyntaxList; - } - - interface BreakStatement extends Statement { - identifier?: SyntaxToken; - } - - interface ContinueStatement extends Statement { - identifier?: SyntaxToken; - } - - interface ForStatement extends Statement { - variableDeclaration?: VariableDeclaration; - initializer?: Expression; - condition?: Expression; - incrementor?: Expression; - statement: Statement; - } - - interface ForInStatement extends Statement { - variableDeclaration?: VariableDeclaration; - left?: Expression; - expression: Expression; - statement: Statement; - } - - interface ThrowStatement extends Statement { - expression: Expression; - } - - interface WhileStatement extends Statement { - condition: Expression; - statement: Statement; - } - - interface TryStatement extends Statement { - block: Block; - catchClause?: CatchClause; - finallyClause?: FinallyClause; - } - - interface LabeledStatement extends Statement { - identifier: SyntaxToken; - statement: Statement; - } - - interface DoStatement extends Statement { - statement: Statement; - condition: Expression; - } - - interface WithStatement extends Statement { - condition: Expression; - statement: Statement; - } - - interface PrefixUnaryExpression extends UnaryExpression { - operand: UnaryExpression; + export interface ExpressionStatementConstructor { new (data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ExpressionStatementSyntax } + + export interface ReturnStatementSyntax extends ISyntaxNode, IStatementSyntax { + returnKeyword: ISyntaxToken; + expression: IExpressionSyntax; + semicolonToken: ISyntaxToken; } + export interface ReturnStatementConstructor { new (data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ReturnStatementSyntax } - interface DeleteExpression extends UnaryExpression { - expression: UnaryExpression; + export interface SwitchStatementSyntax extends ISyntaxNode, IStatementSyntax { + switchKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + expression: IExpressionSyntax; + closeParenToken: ISyntaxToken; + openBraceToken: ISyntaxToken; + switchClauses: ISwitchClauseSyntax[]; + closeBraceToken: ISyntaxToken; + } + export interface SwitchStatementConstructor { new (data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken): SwitchStatementSyntax } + + export interface BreakStatementSyntax extends ISyntaxNode, IStatementSyntax { + breakKeyword: ISyntaxToken; + identifier: ISyntaxToken; + semicolonToken: ISyntaxToken; } + export interface BreakStatementConstructor { new (data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): BreakStatementSyntax } - interface TypeOfExpression extends UnaryExpression { - expression: UnaryExpression; + export interface ContinueStatementSyntax extends ISyntaxNode, IStatementSyntax { + continueKeyword: ISyntaxToken; + identifier: ISyntaxToken; + semicolonToken: ISyntaxToken; } + export interface ContinueStatementConstructor { new (data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): ContinueStatementSyntax } - interface VoidExpression extends UnaryExpression { - expression: UnaryExpression; + export interface ForStatementSyntax extends ISyntaxNode, IStatementSyntax { + forKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + variableDeclaration: VariableDeclarationSyntax; + initializer: IExpressionSyntax; + firstSemicolonToken: ISyntaxToken; + condition: IExpressionSyntax; + secondSemicolonToken: ISyntaxToken; + incrementor: IExpressionSyntax; + closeParenToken: ISyntaxToken; + statement: IStatementSyntax; } + export interface ForStatementConstructor { new (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForStatementSyntax } - interface ConditionalExpression extends Expression { - condition: Expression; - whenTrue: Expression; - whenFalse: Expression; + export interface ForInStatementSyntax extends ISyntaxNode, IStatementSyntax { + forKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + variableDeclaration: VariableDeclarationSyntax; + left: IExpressionSyntax; + inKeyword: ISyntaxToken; + expression: IExpressionSyntax; + closeParenToken: ISyntaxToken; + statement: IStatementSyntax; } + export interface ForInStatementConstructor { new (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForInStatementSyntax } - interface BinaryExpression extends Expression { - left: Expression; - right: Expression; + export interface EmptyStatementSyntax extends ISyntaxNode, IStatementSyntax { + semicolonToken: ISyntaxToken; } + export interface EmptyStatementConstructor { new (data: number, semicolonToken: ISyntaxToken): EmptyStatementSyntax } - interface PostfixUnaryExpression extends PostfixExpression { - operand: LeftHandSideExpression; + export interface ThrowStatementSyntax extends ISyntaxNode, IStatementSyntax { + throwKeyword: ISyntaxToken; + expression: IExpressionSyntax; + semicolonToken: ISyntaxToken; } + export interface ThrowStatementConstructor { new (data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ThrowStatementSyntax } - interface MemberAccessExpression extends MemberExpression, CallExpression { - expression: LeftHandSideExpression; - name: SyntaxToken; + export interface WhileStatementSyntax extends ISyntaxNode, IStatementSyntax { + whileKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + condition: IExpressionSyntax; + closeParenToken: ISyntaxToken; + statement: IStatementSyntax; } + export interface WhileStatementConstructor { new (data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): WhileStatementSyntax } - interface InvocationExpression extends CallExpression { - expression: LeftHandSideExpression; - argumentList: ArgumentList; + export interface TryStatementSyntax extends ISyntaxNode, IStatementSyntax { + tryKeyword: ISyntaxToken; + block: BlockSyntax; + catchClause: CatchClauseSyntax; + finallyClause: FinallyClauseSyntax; } + export interface TryStatementConstructor { new (data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax): TryStatementSyntax } - interface ArrayLiteralExpression extends PrimaryExpression { - expressions: SyntaxList; + export interface LabeledStatementSyntax extends ISyntaxNode, IStatementSyntax { + identifier: ISyntaxToken; + colonToken: ISyntaxToken; + statement: IStatementSyntax; } + export interface LabeledStatementConstructor { new (data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax): LabeledStatementSyntax } - interface ObjectLiteralExpression extends PrimaryExpression { - propertyAssignments: SyntaxList; + export interface DoStatementSyntax extends ISyntaxNode, IStatementSyntax { + doKeyword: ISyntaxToken; + statement: IStatementSyntax; + whileKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + condition: IExpressionSyntax; + closeParenToken: ISyntaxToken; + semicolonToken: ISyntaxToken; } + export interface DoStatementConstructor { new (data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken): DoStatementSyntax } - interface ObjectCreationExpression extends MemberExpression { - expression: MemberExpression; - argumentList?: ArgumentList; + export interface DebuggerStatementSyntax extends ISyntaxNode, IStatementSyntax { + debuggerKeyword: ISyntaxToken; + semicolonToken: ISyntaxToken; } + export interface DebuggerStatementConstructor { new (data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken): DebuggerStatementSyntax } - interface ParenthesizedExpression extends PrimaryExpression { - expression: Expression; + export interface WithStatementSyntax extends ISyntaxNode, IStatementSyntax { + withKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + condition: IExpressionSyntax; + closeParenToken: ISyntaxToken; + statement: IStatementSyntax; } + export interface WithStatementConstructor { new (data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): WithStatementSyntax } - interface ParenthesizedArrowFunctionExpression extends UnaryExpression { - callSignature: CallSignature; - block?: Block; - expression?: Expression; + export interface PrefixUnaryExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax { + operatorToken: ISyntaxToken; + operand: IUnaryExpressionSyntax; } + export interface PrefixUnaryExpressionConstructor { new (data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax): PrefixUnaryExpressionSyntax } - interface SimpleArrowFunctionExpression extends UnaryExpression { - parameter: Parameter; - block?: Block; - expression?: Expression; + export interface DeleteExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax { + deleteKeyword: ISyntaxToken; + expression: IUnaryExpressionSyntax; } + export interface DeleteExpressionConstructor { new (data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): DeleteExpressionSyntax } - interface CastExpression extends UnaryExpression { - type: Type; - expression: UnaryExpression; + export interface TypeOfExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax { + typeOfKeyword: ISyntaxToken; + expression: IUnaryExpressionSyntax; } + export interface TypeOfExpressionConstructor { new (data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): TypeOfExpressionSyntax } - interface ElementAccessExpression extends MemberExpression, CallExpression { - expression: LeftHandSideExpression; - argumentExpression: Expression; + export interface VoidExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax { + voidKeyword: ISyntaxToken; + expression: IUnaryExpressionSyntax; } + export interface VoidExpressionConstructor { new (data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): VoidExpressionSyntax } - interface FunctionExpression extends PrimaryExpression { - identifier?: SyntaxToken; - callSignature: CallSignature; - block: Block; + export interface ConditionalExpressionSyntax extends ISyntaxNode, IExpressionSyntax { + condition: IExpressionSyntax; + questionToken: ISyntaxToken; + whenTrue: IExpressionSyntax; + colonToken: ISyntaxToken; + whenFalse: IExpressionSyntax; } + export interface ConditionalExpressionConstructor { new (data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax): ConditionalExpressionSyntax } - interface VariableDeclaration extends Node { - variableDeclarators: SyntaxList; + export interface BinaryExpressionSyntax extends ISyntaxNode, IExpressionSyntax { + left: IExpressionSyntax; + operatorToken: ISyntaxToken; + right: IExpressionSyntax; } + export interface BinaryExpressionConstructor { new (data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax): BinaryExpressionSyntax } - interface VariableDeclarator extends Node { - propertyName: SyntaxToken; - typeAnnotation?: TypeAnnotation; - equalsValueClause?: EqualsValueClause; + export interface PostfixUnaryExpressionSyntax extends ISyntaxNode, IPostfixExpressionSyntax { + operand: ILeftHandSideExpressionSyntax; + operatorToken: ISyntaxToken; } + export interface PostfixUnaryExpressionConstructor { new (data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken): PostfixUnaryExpressionSyntax } - interface ArgumentList extends Node { - typeArgumentList?: TypeArgumentList; - arguments: SyntaxList; + export interface MemberAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax { + expression: ILeftHandSideExpressionSyntax; + dotToken: ISyntaxToken; + name: ISyntaxToken; } + export interface MemberAccessExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken): MemberAccessExpressionSyntax } - interface ParameterList extends Node { - parameters: SyntaxList; + export interface InvocationExpressionSyntax extends ISyntaxNode, ICallExpressionSyntax { + expression: ILeftHandSideExpressionSyntax; + argumentList: ArgumentListSyntax; } + export interface InvocationExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax): InvocationExpressionSyntax } - interface TypeArgumentList extends Node { - typeArguments: SyntaxList; + export interface ArrayLiteralExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { + openBracketToken: ISyntaxToken; + expressions: ISeparatedSyntaxList; + closeBracketToken: ISyntaxToken; } + export interface ArrayLiteralExpressionConstructor { new (data: number, openBracketToken: ISyntaxToken, expressions: ISeparatedSyntaxList, closeBracketToken: ISyntaxToken): ArrayLiteralExpressionSyntax } - interface TypeParameterList extends Node { - typeParameters: SyntaxList; + export interface ObjectLiteralExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { + openBraceToken: ISyntaxToken; + propertyAssignments: ISeparatedSyntaxList; + closeBraceToken: ISyntaxToken; } + export interface ObjectLiteralExpressionConstructor { new (data: number, openBraceToken: ISyntaxToken, propertyAssignments: ISeparatedSyntaxList, closeBraceToken: ISyntaxToken): ObjectLiteralExpressionSyntax } - interface HeritageClause extends Node { - typeNames: SyntaxList; + export interface ObjectCreationExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { + newKeyword: ISyntaxToken; + expression: IMemberExpressionSyntax; + argumentList: ArgumentListSyntax; } + export interface ObjectCreationExpressionConstructor { new (data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax): ObjectCreationExpressionSyntax } - interface EqualsValueClause extends Node { - value: Expression; + export interface ParenthesizedExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { + openParenToken: ISyntaxToken; + expression: IExpressionSyntax; + closeParenToken: ISyntaxToken; } + export interface ParenthesizedExpressionConstructor { new (data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken): ParenthesizedExpressionSyntax } - interface CaseSwitchClause extends SwitchClause { - expression: Expression; - statements: SyntaxList; + export interface ParenthesizedArrowFunctionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax { + callSignature: CallSignatureSyntax; + equalsGreaterThanToken: ISyntaxToken; + block: BlockSyntax; + expression: IExpressionSyntax; } + export interface ParenthesizedArrowFunctionExpressionConstructor { new (data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax): ParenthesizedArrowFunctionExpressionSyntax } - interface DefaultSwitchClause extends SwitchClause { - statements: SyntaxList; + export interface SimpleArrowFunctionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax { + parameter: ParameterSyntax; + equalsGreaterThanToken: ISyntaxToken; + block: BlockSyntax; + expression: IExpressionSyntax; } + export interface SimpleArrowFunctionExpressionConstructor { new (data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax): SimpleArrowFunctionExpressionSyntax } - interface ElseClause extends Node { - statement: Statement; + export interface CastExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax { + lessThanToken: ISyntaxToken; + type: ITypeSyntax; + greaterThanToken: ISyntaxToken; + expression: IUnaryExpressionSyntax; } + export interface CastExpressionConstructor { new (data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax): CastExpressionSyntax } - interface CatchClause extends Node { - identifier: SyntaxToken; - typeAnnotation?: TypeAnnotation; - block: Block; + export interface ElementAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax { + expression: ILeftHandSideExpressionSyntax; + openBracketToken: ISyntaxToken; + argumentExpression: IExpressionSyntax; + closeBracketToken: ISyntaxToken; } + export interface ElementAccessExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken): ElementAccessExpressionSyntax } - interface FinallyClause extends Node { - block: Block; + export interface FunctionExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { + functionKeyword: ISyntaxToken; + identifier: ISyntaxToken; + callSignature: CallSignatureSyntax; + block: BlockSyntax; } + export interface FunctionExpressionConstructor { new (data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionExpressionSyntax } - interface TypeParameter extends Node { - identifier: SyntaxToken; - constraint?: Constraint; + export interface OmittedExpressionSyntax extends ISyntaxNode, IExpressionSyntax { } + export interface OmittedExpressionConstructor { new (data: number): OmittedExpressionSyntax } - interface Constraint extends Node { - type: Type; + export interface TemplateExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { + templateStartToken: ISyntaxToken; + templateClauses: TemplateClauseSyntax[]; } + export interface TemplateExpressionConstructor { new (data: number, templateStartToken: ISyntaxToken, templateClauses: TemplateClauseSyntax[]): TemplateExpressionSyntax } - interface SimplePropertyAssignment extends PropertyAssignment { - propertyName: SyntaxToken; - expression: Expression; + export interface TemplateAccessExpressionSyntax extends ISyntaxNode, IMemberExpressionSyntax, ICallExpressionSyntax { + expression: ILeftHandSideExpressionSyntax; + templateExpression: IPrimaryExpressionSyntax; } + export interface TemplateAccessExpressionConstructor { new (data: number, expression: ILeftHandSideExpressionSyntax, templateExpression: IPrimaryExpressionSyntax): TemplateAccessExpressionSyntax } - interface FunctionPropertyAssignment extends PropertyAssignment { - propertyName: SyntaxToken; - callSignature: CallSignature; - block: Block; + export interface VariableDeclarationSyntax extends ISyntaxNode { + varKeyword: ISyntaxToken; + variableDeclarators: ISeparatedSyntaxList; } + export interface VariableDeclarationConstructor { new (data: number, varKeyword: ISyntaxToken, variableDeclarators: ISeparatedSyntaxList): VariableDeclarationSyntax } - interface Parameter extends Node { - identifier: SyntaxToken; - typeAnnotation?: TypeAnnotation; - equalsValueClause?: EqualsValueClause; + export interface VariableDeclaratorSyntax extends ISyntaxNode { + propertyName: ISyntaxToken; + typeAnnotation: TypeAnnotationSyntax; + equalsValueClause: EqualsValueClauseSyntax; } + export interface VariableDeclaratorConstructor { new (data: number, propertyName: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): VariableDeclaratorSyntax } - interface EnumElement extends Node { - propertyName: SyntaxToken; - equalsValueClause?: EqualsValueClause; + export interface ArgumentListSyntax extends ISyntaxNode { + typeArgumentList: TypeArgumentListSyntax; + openParenToken: ISyntaxToken; + arguments: ISeparatedSyntaxList; + closeParenToken: ISyntaxToken; } + export interface ArgumentListConstructor { new (data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, _arguments: ISeparatedSyntaxList, closeParenToken: ISyntaxToken): ArgumentListSyntax } - interface TypeAnnotation extends Node { - type: Type; + export interface ParameterListSyntax extends ISyntaxNode { + openParenToken: ISyntaxToken; + parameters: ISeparatedSyntaxList; + closeParenToken: ISyntaxToken; } + export interface ParameterListConstructor { new (data: number, openParenToken: ISyntaxToken, parameters: ISeparatedSyntaxList, closeParenToken: ISyntaxToken): ParameterListSyntax } - interface ExternalModuleReference extends ModuleReference { - stringLiteral: SyntaxToken; + export interface TypeArgumentListSyntax extends ISyntaxNode { + lessThanToken: ISyntaxToken; + typeArguments: ISeparatedSyntaxList; + greaterThanToken: ISyntaxToken; } + export interface TypeArgumentListConstructor { new (data: number, lessThanToken: ISyntaxToken, typeArguments: ISeparatedSyntaxList, greaterThanToken: ISyntaxToken): TypeArgumentListSyntax } - interface ModuleNameModuleReference extends ModuleReference { - moduleName: Name; + export interface TypeParameterListSyntax extends ISyntaxNode { + lessThanToken: ISyntaxToken; + typeParameters: ISeparatedSyntaxList; + greaterThanToken: ISyntaxToken; } + export interface TypeParameterListConstructor { new (data: number, lessThanToken: ISyntaxToken, typeParameters: ISeparatedSyntaxList, greaterThanToken: ISyntaxToken): TypeParameterListSyntax } - interface MemberDeclaration extends ClassElement { + export interface HeritageClauseSyntax extends ISyntaxNode { + extendsOrImplementsKeyword: ISyntaxToken; + typeNames: ISeparatedSyntaxList; } + export interface HeritageClauseConstructor { new (data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: ISeparatedSyntaxList): HeritageClauseSyntax } - interface Statement extends ModuleElement { + export interface EqualsValueClauseSyntax extends ISyntaxNode { + equalsToken: ISyntaxToken; + value: IExpressionSyntax; } + export interface EqualsValueClauseConstructor { new (data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax): EqualsValueClauseSyntax } - interface Name extends Type { + export interface CaseSwitchClauseSyntax extends ISyntaxNode, ISwitchClauseSyntax { + caseKeyword: ISyntaxToken; + expression: IExpressionSyntax; + colonToken: ISyntaxToken; + statements: IStatementSyntax[]; } + export interface CaseSwitchClauseConstructor { new (data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]): CaseSwitchClauseSyntax } - interface UnaryExpression extends Expression { + export interface DefaultSwitchClauseSyntax extends ISyntaxNode, ISwitchClauseSyntax { + defaultKeyword: ISyntaxToken; + colonToken: ISyntaxToken; + statements: IStatementSyntax[]; } + export interface DefaultSwitchClauseConstructor { new (data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]): DefaultSwitchClauseSyntax } - interface PostfixExpression extends UnaryExpression { + export interface ElseClauseSyntax extends ISyntaxNode { + elseKeyword: ISyntaxToken; + statement: IStatementSyntax; } + export interface ElseClauseConstructor { new (data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax): ElseClauseSyntax } - interface LeftHandSideExpression extends PostfixExpression { + export interface CatchClauseSyntax extends ISyntaxNode { + catchKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + identifier: ISyntaxToken; + typeAnnotation: TypeAnnotationSyntax; + closeParenToken: ISyntaxToken; + block: BlockSyntax; } + export interface CatchClauseConstructor { new (data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax): CatchClauseSyntax } - interface MemberExpression extends LeftHandSideExpression { + export interface FinallyClauseSyntax extends ISyntaxNode { + finallyKeyword: ISyntaxToken; + block: BlockSyntax; } + export interface FinallyClauseConstructor { new (data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax): FinallyClauseSyntax } - interface CallExpression extends LeftHandSideExpression { + export interface TemplateClauseSyntax extends ISyntaxNode { + expression: IExpressionSyntax; + templateMiddleOrEndToken: ISyntaxToken; } + export interface TemplateClauseConstructor { new (data: number, expression: IExpressionSyntax, templateMiddleOrEndToken: ISyntaxToken): TemplateClauseSyntax } - interface PrimaryExpression extends MemberExpression { + export interface TypeParameterSyntax extends ISyntaxNode { + identifier: ISyntaxToken; + constraint: ConstraintSyntax; } + export interface TypeParameterConstructor { new (data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax): TypeParameterSyntax } - interface ModuleElement extends SyntaxElement { + export interface ConstraintSyntax extends ISyntaxNode { + extendsKeyword: ISyntaxToken; + typeOrExpression: ISyntaxNodeOrToken; } + export interface ConstraintConstructor { new (data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken): ConstraintSyntax } - interface ModuleReference extends Node { + export interface SimplePropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax { + propertyName: ISyntaxToken; + colonToken: ISyntaxToken; + expression: IExpressionSyntax; } + export interface SimplePropertyAssignmentConstructor { new (data: number, propertyName: ISyntaxToken, colonToken: ISyntaxToken, expression: IExpressionSyntax): SimplePropertyAssignmentSyntax } - interface ClassElement extends Node { + export interface FunctionPropertyAssignmentSyntax extends ISyntaxNode, IPropertyAssignmentSyntax { + propertyName: ISyntaxToken; + callSignature: CallSignatureSyntax; + block: BlockSyntax; } + export interface FunctionPropertyAssignmentConstructor { new (data: number, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionPropertyAssignmentSyntax } - interface TypeMember extends Node { + export interface ParameterSyntax extends ISyntaxNode { + dotDotDotToken: ISyntaxToken; + modifiers: ISyntaxToken[]; + identifier: ISyntaxToken; + questionToken: ISyntaxToken; + typeAnnotation: TypeAnnotationSyntax; + equalsValueClause: EqualsValueClauseSyntax; } + export interface ParameterConstructor { new (data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): ParameterSyntax } - interface PropertyAssignment extends Node { + export interface EnumElementSyntax extends ISyntaxNode { + propertyName: ISyntaxToken; + equalsValueClause: EqualsValueClauseSyntax; } + export interface EnumElementConstructor { new (data: number, propertyName: ISyntaxToken, equalsValueClause: EqualsValueClauseSyntax): EnumElementSyntax } - interface SwitchClause extends Node { + export interface TypeAnnotationSyntax extends ISyntaxNode { + colonToken: ISyntaxToken; + type: ITypeSyntax; } + export interface TypeAnnotationConstructor { new (data: number, colonToken: ISyntaxToken, type: ITypeSyntax): TypeAnnotationSyntax } - interface Expression extends SyntaxElement { + export interface ExternalModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax { + requireKeyword: ISyntaxToken; + openParenToken: ISyntaxToken; + stringLiteral: ISyntaxToken; + closeParenToken: ISyntaxToken; } + export interface ExternalModuleReferenceConstructor { new (data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken): ExternalModuleReferenceSyntax } - interface Type extends SyntaxElement { + export interface ModuleNameModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax { + moduleName: INameSyntax; } + export interface ModuleNameModuleReferenceConstructor { new (data: number, moduleName: INameSyntax): ModuleNameModuleReferenceSyntax } } \ No newline at end of file diff --git a/src/services/syntax/syntaxKind.ts b/src/services/syntax/syntaxKind.ts index 3f27168c678..8af2e944834 100644 --- a/src/services/syntax/syntaxKind.ts +++ b/src/services/syntax/syntaxKind.ts @@ -5,8 +5,6 @@ module TypeScript { // Variable width tokens, trivia and lists. None, List, - SeparatedList, - TriviaList, // Trivia WhitespaceTrivia, @@ -28,6 +26,12 @@ module TypeScript { NumericLiteral, StringLiteral, + // Template tokens + NoSubstitutionTemplateToken, + TemplateStartToken, + TemplateMiddleToken, + TemplateEndToken, + // All fixed width tokens follow. // Keywords @@ -228,6 +232,8 @@ module TypeScript { ElementAccessExpression, FunctionExpression, OmittedExpression, + TemplateExpression, + TemplateAccessExpression, // Variable declarations VariableDeclaration, @@ -247,6 +253,7 @@ module TypeScript { ElseClause, CatchClause, FinallyClause, + TemplateClause, // Generics TypeParameter, diff --git a/src/services/syntax/syntaxList.ts b/src/services/syntax/syntaxList.ts index df33153def6..235e3defd53 100644 --- a/src/services/syntax/syntaxList.ts +++ b/src/services/syntax/syntaxList.ts @@ -1,60 +1,53 @@ /// interface Array { - data: number; - separators?: TypeScript.ISyntaxToken[]; + __data: number; - kind(): TypeScript.SyntaxKind; + kind: TypeScript.SyntaxKind; parent: TypeScript.ISyntaxElement; +} - separatorCount(): number; - separatorAt(index: number): TypeScript.ISyntaxToken; +module TypeScript { + export interface ISeparatedSyntaxList extends Array { + //separatorCount(): number; + //separatorAt(index: number): TypeScript.ISyntaxToken; + + //nonSeparatorCount(): number; + //nonSeparatorAt(index: number): T; + } +} + +module TypeScript { + export function separatorCount(list: ISeparatedSyntaxList) { + return list.length >> 1; + } + + export function nonSeparatorCount(list: ISeparatedSyntaxList) { + return (list.length + 1) >> 1; + } + + export function separatorAt(list: ISeparatedSyntaxList, index: number): ISyntaxToken { + return list[(index << 1) + 1]; + } + + export function nonSeparatorAt(list: ISeparatedSyntaxList, index: number): T { + return list[index << 1]; + } } module TypeScript.Syntax { - var _emptyList: ISyntaxNodeOrToken[] = []; - - var _emptySeparatedList: ISyntaxNodeOrToken[] = []; - var _emptySeparators: ISyntaxToken[] = []; - - _emptySeparatedList.separators = _emptySeparators; - - function assertEmptyLists() { - // Debug.assert(_emptyList.length === 0); - // var separators = _emptySeparatedList.separators; - // Debug.assert(!separators || separators.length === 0); + function addArrayPrototypeValue(name: string, val: any) { + if (Object.defineProperty && (Array.prototype)[name] === undefined) { + Object.defineProperty(Array.prototype, name, { value: val, writable: false }); + } + else { + (Array.prototype)[name] = val; + } } - Array.prototype.kind = function () { - return this.separators === undefined ? SyntaxKind.List : SyntaxKind.SeparatedList; - } - - Array.prototype.separatorCount = function (): number { - assertEmptyLists(); - // Debug.assert(this.kind === SyntaxKind.SeparatedList); - return this.separators.length; - } - - Array.prototype.separatorAt = function (index: number): ISyntaxToken { - assertEmptyLists(); - // Debug.assert(this.kind === SyntaxKind.SeparatedList); - // Debug.assert(index >= 0 && index < this.separators.length); - return this.separators[index]; - } - - export function emptyList(): T[] { - return _emptyList; - } - - export function emptySeparatedList(): T[] { - return _emptySeparatedList; - } + addArrayPrototypeValue("kind", SyntaxKind.List); export function list(nodes: T[]): T[] { - if (!nodes || nodes.length === 0) { - return emptyList(); - } - for (var i = 0, n = nodes.length; i < n; i++) { nodes[i].parent = nodes; } @@ -62,34 +55,11 @@ module TypeScript.Syntax { return nodes; } - export function separatedList(nodes: T[], separators: ISyntaxToken[]): T[] { - if (!nodes || nodes.length === 0) { - return emptySeparatedList(); + export function separatedList(nodesAndTokens: ISyntaxNodeOrToken[]): ISeparatedSyntaxList { + for (var i = 0, n = nodesAndTokens.length; i < n; i++) { + nodesAndTokens[i].parent = nodesAndTokens; } - // Debug.assert(separators.length === nodes.length || separators.length == (nodes.length - 1)); - - for (var i = 0, n = nodes.length; i < n; i++) { - nodes[i].parent = nodes; - } - - for (var i = 0, n = separators.length; i < n; i++) { - separators[i].parent = nodes; - } - - - nodes.separators = separators.length === 0 ? _emptySeparators : separators; - - return nodes; - } - - export function nonSeparatorIndexOf(list: T[], ast: ISyntaxNodeOrToken): number { - for (var i = 0, n = list.length; i < n; i++) { - if (list[i] === ast) { - return i; - } - } - - return -1; + return >nodesAndTokens; } } \ No newline at end of file diff --git a/src/services/syntax/syntaxNode.ts b/src/services/syntax/syntaxNode.ts deleted file mode 100644 index 464c59793aa..00000000000 --- a/src/services/syntax/syntaxNode.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -module TypeScript { - export class SyntaxNode implements ISyntaxNodeOrToken { - private __kind: SyntaxKind; - public data: number; - public parent: ISyntaxElement; - - constructor(data: number) { - if (data) { - this.data = data; - } - } - - public kind(): SyntaxKind { - return this.__kind; - } - } -} \ No newline at end of file diff --git a/src/services/syntax/syntaxNodeOrToken.ts b/src/services/syntax/syntaxNodeOrToken.ts index 695268d843f..6cb173df11a 100644 --- a/src/services/syntax/syntaxNodeOrToken.ts +++ b/src/services/syntax/syntaxNodeOrToken.ts @@ -2,5 +2,6 @@ module TypeScript { export interface ISyntaxNodeOrToken extends ISyntaxElement { + _syntaxNodeOrTokenBrand: any; } } \ No newline at end of file diff --git a/src/services/syntax/syntaxNodes.abstract.generated.ts b/src/services/syntax/syntaxNodes.abstract.generated.ts deleted file mode 100644 index 158ff7bf1c3..00000000000 --- a/src/services/syntax/syntaxNodes.abstract.generated.ts +++ /dev/null @@ -1,1225 +0,0 @@ -/// - -module TypeScript.Syntax.Abstract { - // Inject this module as the factory for producing syntax nodes in the parser. - Parser.syntaxFactory = Abstract; - export var isConcrete: boolean = false; - - export class SourceUnitSyntax extends SyntaxNode { - public syntaxTree: SyntaxTree = undefined; - public moduleElements: IModuleElementSyntax[]; - public endOfFileToken: ISyntaxToken; - constructor(data: number, moduleElements: IModuleElementSyntax[], endOfFileToken: ISyntaxToken) { - super(data); - this.parent = undefined, - this.moduleElements = moduleElements, - this.endOfFileToken = endOfFileToken, - !isShared(moduleElements) && (moduleElements.parent = this), - endOfFileToken.parent = this; - } - } - export class QualifiedNameSyntax extends SyntaxNode implements INameSyntax { - public left: INameSyntax; - public dotToken: ISyntaxToken; - public right: ISyntaxToken; - public _nameBrand: any; public _typeBrand: any; - constructor(data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken) { - super(data); - this.left = left, - this.right = right, - left.parent = this, - right.parent = this; - } - } - export class ObjectTypeSyntax extends SyntaxNode implements ITypeSyntax { - public openBraceToken: ISyntaxToken; - public typeMembers: ITypeMemberSyntax[]; - public closeBraceToken: ISyntaxToken; - public _typeBrand: any; - constructor(data: number, openBraceToken: ISyntaxToken, typeMembers: ITypeMemberSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.typeMembers = typeMembers, - !isShared(typeMembers) && (typeMembers.parent = this); - } - } - export class FunctionTypeSyntax extends SyntaxNode implements ITypeSyntax { - public typeParameterList: TypeParameterListSyntax; - public parameterList: ParameterListSyntax; - public equalsGreaterThanToken: ISyntaxToken; - public type: ITypeSyntax; - public _typeBrand: any; - constructor(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) { - super(data); - this.typeParameterList = typeParameterList, - this.parameterList = parameterList, - this.type = type, - typeParameterList && (typeParameterList.parent = this), - parameterList.parent = this, - type.parent = this; - } - } - export class ArrayTypeSyntax extends SyntaxNode implements ITypeSyntax { - public type: ITypeSyntax; - public openBracketToken: ISyntaxToken; - public closeBracketToken: ISyntaxToken; - public _typeBrand: any; - constructor(data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken) { - super(data); - this.type = type, - type.parent = this; - } - } - export class ConstructorTypeSyntax extends SyntaxNode implements ITypeSyntax { - public newKeyword: ISyntaxToken; - public typeParameterList: TypeParameterListSyntax; - public parameterList: ParameterListSyntax; - public equalsGreaterThanToken: ISyntaxToken; - public type: ITypeSyntax; - public _typeBrand: any; - constructor(data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) { - super(data); - this.typeParameterList = typeParameterList, - this.parameterList = parameterList, - this.type = type, - typeParameterList && (typeParameterList.parent = this), - parameterList.parent = this, - type.parent = this; - } - } - export class GenericTypeSyntax extends SyntaxNode implements ITypeSyntax { - public name: INameSyntax; - public typeArgumentList: TypeArgumentListSyntax; - public _typeBrand: any; - constructor(data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax) { - super(data); - this.name = name, - this.typeArgumentList = typeArgumentList, - name.parent = this, - typeArgumentList.parent = this; - } - } - export class TypeQuerySyntax extends SyntaxNode implements ITypeSyntax { - public typeOfKeyword: ISyntaxToken; - public name: INameSyntax; - public _typeBrand: any; - constructor(data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax) { - super(data); - this.name = name, - name.parent = this; - } - } - export class TupleTypeSyntax extends SyntaxNode implements ITypeSyntax { - public openBracketToken: ISyntaxToken; - public types: ITypeSyntax[]; - public closeBracketToken: ISyntaxToken; - public _typeBrand: any; - constructor(data: number, openBracketToken: ISyntaxToken, types: ITypeSyntax[], closeBracketToken: ISyntaxToken) { - super(data); - this.types = types, - !isShared(types) && (types.parent = this); - } - } - export class UnionTypeSyntax extends SyntaxNode implements ITypeSyntax { - public left: ITypeSyntax; - public barToken: ISyntaxToken; - public right: ITypeSyntax; - public _typeBrand: any; - constructor(data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax) { - super(data); - this.left = left, - this.right = right, - left.parent = this, - right.parent = this; - } - } - export class ParenthesizedTypeSyntax extends SyntaxNode implements ITypeSyntax { - public openParenToken: ISyntaxToken; - public type: ITypeSyntax; - public closeParenToken: ISyntaxToken; - public _typeBrand: any; - constructor(data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken) { - super(data); - this.type = type, - type.parent = this; - } - } - export class InterfaceDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public interfaceKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public typeParameterList: TypeParameterListSyntax; - public heritageClauses: HeritageClauseSyntax[]; - public body: ObjectTypeSyntax; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax) { - super(data); - this.modifiers = modifiers, - this.identifier = identifier, - this.typeParameterList = typeParameterList, - this.heritageClauses = heritageClauses, - this.body = body, - !isShared(modifiers) && (modifiers.parent = this), - identifier.parent = this, - typeParameterList && (typeParameterList.parent = this), - !isShared(heritageClauses) && (heritageClauses.parent = this), - body.parent = this; - } - } - export class FunctionDeclarationSyntax extends SyntaxNode implements IStatementSyntax { - public modifiers: ISyntaxToken[]; - public functionKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.identifier = identifier, - this.callSignature = callSignature, - this.block = block, - !isShared(modifiers) && (modifiers.parent = this), - identifier.parent = this, - callSignature.parent = this, - block && (block.parent = this); - } - } - export class ModuleDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public moduleKeyword: ISyntaxToken; - public name: INameSyntax; - public stringLiteral: ISyntaxToken; - public openBraceToken: ISyntaxToken; - public moduleElements: IModuleElementSyntax[]; - public closeBraceToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.name = name, - this.stringLiteral = stringLiteral, - this.moduleElements = moduleElements, - !isShared(modifiers) && (modifiers.parent = this), - name && (name.parent = this), - stringLiteral && (stringLiteral.parent = this), - !isShared(moduleElements) && (moduleElements.parent = this); - } - } - export class ClassDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public classKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public typeParameterList: TypeParameterListSyntax; - public heritageClauses: HeritageClauseSyntax[]; - public openBraceToken: ISyntaxToken; - public classElements: IClassElementSyntax[]; - public closeBraceToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.identifier = identifier, - this.typeParameterList = typeParameterList, - this.heritageClauses = heritageClauses, - this.classElements = classElements, - !isShared(modifiers) && (modifiers.parent = this), - identifier.parent = this, - typeParameterList && (typeParameterList.parent = this), - !isShared(heritageClauses) && (heritageClauses.parent = this), - !isShared(classElements) && (classElements.parent = this); - } - } - export class EnumDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public enumKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public openBraceToken: ISyntaxToken; - public enumElements: EnumElementSyntax[]; - public closeBraceToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: EnumElementSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.identifier = identifier, - this.enumElements = enumElements, - !isShared(modifiers) && (modifiers.parent = this), - identifier.parent = this, - !isShared(enumElements) && (enumElements.parent = this); - } - } - export class ImportDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public importKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public equalsToken: ISyntaxToken; - public moduleReference: IModuleReferenceSyntax; - public semicolonToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.identifier = identifier, - this.moduleReference = moduleReference, - !isShared(modifiers) && (modifiers.parent = this), - identifier.parent = this, - moduleReference.parent = this; - } - } - export class ExportAssignmentSyntax extends SyntaxNode implements IModuleElementSyntax { - public exportKeyword: ISyntaxToken; - public equalsToken: ISyntaxToken; - public identifier: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.identifier = identifier, - identifier.parent = this; - } - } - export class MemberFunctionDeclarationSyntax extends SyntaxNode implements IMemberDeclarationSyntax { - public modifiers: ISyntaxToken[]; - public propertyName: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public semicolonToken: ISyntaxToken; - public _memberDeclarationBrand: any; public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.propertyName = propertyName, - this.callSignature = callSignature, - this.block = block, - !isShared(modifiers) && (modifiers.parent = this), - propertyName.parent = this, - callSignature.parent = this, - block && (block.parent = this); - } - } - export class MemberVariableDeclarationSyntax extends SyntaxNode implements IMemberDeclarationSyntax { - public modifiers: ISyntaxToken[]; - public variableDeclarator: VariableDeclaratorSyntax; - public semicolonToken: ISyntaxToken; - public _memberDeclarationBrand: any; public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.variableDeclarator = variableDeclarator, - !isShared(modifiers) && (modifiers.parent = this), - variableDeclarator.parent = this; - } - } - export class ConstructorDeclarationSyntax extends SyntaxNode implements IClassElementSyntax { - public modifiers: ISyntaxToken[]; - public constructorKeyword: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public semicolonToken: ISyntaxToken; - public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.constructorKeyword = constructorKeyword, - this.callSignature = callSignature, - this.block = block, - !isShared(modifiers) && (modifiers.parent = this), - constructorKeyword.parent = this, - callSignature.parent = this, - block && (block.parent = this); - } - } - export class IndexMemberDeclarationSyntax extends SyntaxNode implements IClassElementSyntax { - public modifiers: ISyntaxToken[]; - public indexSignature: IndexSignatureSyntax; - public semicolonToken: ISyntaxToken; - public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.indexSignature = indexSignature, - !isShared(modifiers) && (modifiers.parent = this), - indexSignature.parent = this; - } - } - export class GetAccessorSyntax extends SyntaxNode implements IMemberDeclarationSyntax, IPropertyAssignmentSyntax { - public modifiers: ISyntaxToken[]; - public getKeyword: ISyntaxToken; - public propertyName: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public _memberDeclarationBrand: any; public _propertyAssignmentBrand: any; public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { - super(data); - this.modifiers = modifiers, - this.propertyName = propertyName, - this.callSignature = callSignature, - this.block = block, - !isShared(modifiers) && (modifiers.parent = this), - propertyName.parent = this, - callSignature.parent = this, - block.parent = this; - } - } - export class SetAccessorSyntax extends SyntaxNode implements IMemberDeclarationSyntax, IPropertyAssignmentSyntax { - public modifiers: ISyntaxToken[]; - public setKeyword: ISyntaxToken; - public propertyName: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public _memberDeclarationBrand: any; public _propertyAssignmentBrand: any; public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { - super(data); - this.modifiers = modifiers, - this.propertyName = propertyName, - this.callSignature = callSignature, - this.block = block, - !isShared(modifiers) && (modifiers.parent = this), - propertyName.parent = this, - callSignature.parent = this, - block.parent = this; - } - } - export class PropertySignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public propertyName: ISyntaxToken; - public questionToken: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public _typeMemberBrand: any; - constructor(data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) { - super(data); - this.propertyName = propertyName, - this.questionToken = questionToken, - this.typeAnnotation = typeAnnotation, - propertyName.parent = this, - questionToken && (questionToken.parent = this), - typeAnnotation && (typeAnnotation.parent = this); - } - } - export class CallSignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public typeParameterList: TypeParameterListSyntax; - public parameterList: ParameterListSyntax; - public typeAnnotation: TypeAnnotationSyntax; - public _typeMemberBrand: any; - constructor(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax) { - super(data); - this.typeParameterList = typeParameterList, - this.parameterList = parameterList, - this.typeAnnotation = typeAnnotation, - typeParameterList && (typeParameterList.parent = this), - parameterList.parent = this, - typeAnnotation && (typeAnnotation.parent = this); - } - } - export class ConstructSignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public newKeyword: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public _typeMemberBrand: any; - constructor(data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax) { - super(data); - this.callSignature = callSignature, - callSignature.parent = this; - } - } - export class IndexSignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public openBracketToken: ISyntaxToken; - public parameters: ParameterSyntax[]; - public closeBracketToken: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public _typeMemberBrand: any; - constructor(data: number, openBracketToken: ISyntaxToken, parameters: ParameterSyntax[], closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) { - super(data); - this.openBracketToken = openBracketToken, - this.parameters = parameters, - this.closeBracketToken = closeBracketToken, - this.typeAnnotation = typeAnnotation, - openBracketToken.parent = this, - !isShared(parameters) && (parameters.parent = this), - closeBracketToken.parent = this, - typeAnnotation && (typeAnnotation.parent = this); - } - } - export class MethodSignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public propertyName: ISyntaxToken; - public questionToken: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public _typeMemberBrand: any; - constructor(data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax) { - super(data); - this.propertyName = propertyName, - this.questionToken = questionToken, - this.callSignature = callSignature, - propertyName.parent = this, - questionToken && (questionToken.parent = this), - callSignature.parent = this; - } - } - export class BlockSyntax extends SyntaxNode implements IStatementSyntax { - public openBraceToken: ISyntaxToken; - public statements: IStatementSyntax[]; - public closeBraceToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.openBraceToken = openBraceToken, - this.statements = statements, - openBraceToken.parent = this, - !isShared(statements) && (statements.parent = this); - } - } - export class IfStatementSyntax extends SyntaxNode implements IStatementSyntax { - public ifKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public condition: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public elseClause: ElseClauseSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax) { - super(data); - this.condition = condition, - this.statement = statement, - this.elseClause = elseClause, - condition.parent = this, - statement.parent = this, - elseClause && (elseClause.parent = this); - } - } - export class VariableStatementSyntax extends SyntaxNode implements IStatementSyntax { - public modifiers: ISyntaxToken[]; - public variableDeclaration: VariableDeclarationSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.variableDeclaration = variableDeclaration, - !isShared(modifiers) && (modifiers.parent = this), - variableDeclaration.parent = this; - } - } - export class ExpressionStatementSyntax extends SyntaxNode implements IStatementSyntax { - public expression: IExpressionSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.expression = expression, - expression.parent = this; - } - } - export class ReturnStatementSyntax extends SyntaxNode implements IStatementSyntax { - public returnKeyword: ISyntaxToken; - public expression: IExpressionSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.returnKeyword = returnKeyword, - this.expression = expression, - returnKeyword.parent = this, - expression && (expression.parent = this); - } - } - export class SwitchStatementSyntax extends SyntaxNode implements IStatementSyntax { - public switchKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public expression: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public openBraceToken: ISyntaxToken; - public switchClauses: ISwitchClauseSyntax[]; - public closeBraceToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.expression = expression, - this.switchClauses = switchClauses, - expression.parent = this, - !isShared(switchClauses) && (switchClauses.parent = this); - } - } - export class BreakStatementSyntax extends SyntaxNode implements IStatementSyntax { - public breakKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.breakKeyword = breakKeyword, - this.identifier = identifier, - breakKeyword.parent = this, - identifier && (identifier.parent = this); - } - } - export class ContinueStatementSyntax extends SyntaxNode implements IStatementSyntax { - public continueKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.continueKeyword = continueKeyword, - this.identifier = identifier, - continueKeyword.parent = this, - identifier && (identifier.parent = this); - } - } - export class ForStatementSyntax extends SyntaxNode implements IStatementSyntax { - public forKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public variableDeclaration: VariableDeclarationSyntax; - public initializer: IExpressionSyntax; - public firstSemicolonToken: ISyntaxToken; - public condition: IExpressionSyntax; - public secondSemicolonToken: ISyntaxToken; - public incrementor: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.variableDeclaration = variableDeclaration, - this.initializer = initializer, - this.condition = condition, - this.incrementor = incrementor, - this.statement = statement, - variableDeclaration && (variableDeclaration.parent = this), - initializer && (initializer.parent = this), - condition && (condition.parent = this), - incrementor && (incrementor.parent = this), - statement.parent = this; - } - } - export class ForInStatementSyntax extends SyntaxNode implements IStatementSyntax { - public forKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public variableDeclaration: VariableDeclarationSyntax; - public left: IExpressionSyntax; - public inKeyword: ISyntaxToken; - public expression: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.variableDeclaration = variableDeclaration, - this.left = left, - this.expression = expression, - this.statement = statement, - variableDeclaration && (variableDeclaration.parent = this), - left && (left.parent = this), - expression.parent = this, - statement.parent = this; - } - } - export class EmptyStatementSyntax extends SyntaxNode implements IStatementSyntax { - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, semicolonToken: ISyntaxToken) { - super(data); - this.semicolonToken = semicolonToken, - semicolonToken.parent = this; - } - } - export class ThrowStatementSyntax extends SyntaxNode implements IStatementSyntax { - public throwKeyword: ISyntaxToken; - public expression: IExpressionSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.expression = expression, - expression.parent = this; - } - } - export class WhileStatementSyntax extends SyntaxNode implements IStatementSyntax { - public whileKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public condition: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.condition = condition, - this.statement = statement, - condition.parent = this, - statement.parent = this; - } - } - export class TryStatementSyntax extends SyntaxNode implements IStatementSyntax { - public tryKeyword: ISyntaxToken; - public block: BlockSyntax; - public catchClause: CatchClauseSyntax; - public finallyClause: FinallyClauseSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax) { - super(data); - this.block = block, - this.catchClause = catchClause, - this.finallyClause = finallyClause, - block.parent = this, - catchClause && (catchClause.parent = this), - finallyClause && (finallyClause.parent = this); - } - } - export class LabeledStatementSyntax extends SyntaxNode implements IStatementSyntax { - public identifier: ISyntaxToken; - public colonToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.identifier = identifier, - this.statement = statement, - identifier.parent = this, - statement.parent = this; - } - } - export class DoStatementSyntax extends SyntaxNode implements IStatementSyntax { - public doKeyword: ISyntaxToken; - public statement: IStatementSyntax; - public whileKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public condition: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.statement = statement, - this.condition = condition, - statement.parent = this, - condition.parent = this; - } - } - export class DebuggerStatementSyntax extends SyntaxNode implements IStatementSyntax { - public debuggerKeyword: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.debuggerKeyword = debuggerKeyword, - debuggerKeyword.parent = this; - } - } - export class WithStatementSyntax extends SyntaxNode implements IStatementSyntax { - public withKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public condition: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.condition = condition, - this.statement = statement, - condition.parent = this, - statement.parent = this; - } - } - export class PrefixUnaryExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public operatorToken: ISyntaxToken; - public operand: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax) { - super(data); - this.operatorToken = operatorToken, - this.operand = operand, - operatorToken.parent = this, - operand.parent = this; - } - } - export class DeleteExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public deleteKeyword: ISyntaxToken; - public expression: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { - super(data); - this.expression = expression, - expression.parent = this; - } - } - export class TypeOfExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public typeOfKeyword: ISyntaxToken; - public expression: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { - super(data); - this.expression = expression, - expression.parent = this; - } - } - export class VoidExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public voidKeyword: ISyntaxToken; - public expression: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { - super(data); - this.expression = expression, - expression.parent = this; - } - } - export class ConditionalExpressionSyntax extends SyntaxNode implements IExpressionSyntax { - public condition: IExpressionSyntax; - public questionToken: ISyntaxToken; - public whenTrue: IExpressionSyntax; - public colonToken: ISyntaxToken; - public whenFalse: IExpressionSyntax; - public _expressionBrand: any; - constructor(data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax) { - super(data); - this.condition = condition, - this.whenTrue = whenTrue, - this.whenFalse = whenFalse, - condition.parent = this, - whenTrue.parent = this, - whenFalse.parent = this; - } - } - export class BinaryExpressionSyntax extends SyntaxNode implements IExpressionSyntax { - public left: IExpressionSyntax; - public operatorToken: ISyntaxToken; - public right: IExpressionSyntax; - public _expressionBrand: any; - constructor(data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax) { - super(data); - this.left = left, - this.operatorToken = operatorToken, - this.right = right, - left.parent = this, - operatorToken.parent = this, - right.parent = this; - } - } - export class PostfixUnaryExpressionSyntax extends SyntaxNode implements IPostfixExpressionSyntax { - public operand: ILeftHandSideExpressionSyntax; - public operatorToken: ISyntaxToken; - public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken) { - super(data); - this.operand = operand, - this.operatorToken = operatorToken, - operand.parent = this, - operatorToken.parent = this; - } - } - export class MemberAccessExpressionSyntax extends SyntaxNode implements IMemberExpressionSyntax, ICallExpressionSyntax { - public expression: ILeftHandSideExpressionSyntax; - public dotToken: ISyntaxToken; - public name: ISyntaxToken; - public _memberExpressionBrand: any; public _callExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken) { - super(data); - this.expression = expression, - this.name = name, - expression.parent = this, - name.parent = this; - } - } - export class InvocationExpressionSyntax extends SyntaxNode implements ICallExpressionSyntax { - public expression: ILeftHandSideExpressionSyntax; - public argumentList: ArgumentListSyntax; - public _callExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax) { - super(data); - this.expression = expression, - this.argumentList = argumentList, - expression.parent = this, - argumentList.parent = this; - } - } - export class ArrayLiteralExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public openBracketToken: ISyntaxToken; - public expressions: IExpressionSyntax[]; - public closeBracketToken: ISyntaxToken; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, openBracketToken: ISyntaxToken, expressions: IExpressionSyntax[], closeBracketToken: ISyntaxToken) { - super(data); - this.expressions = expressions, - !isShared(expressions) && (expressions.parent = this); - } - } - export class ObjectLiteralExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public openBraceToken: ISyntaxToken; - public propertyAssignments: IPropertyAssignmentSyntax[]; - public closeBraceToken: ISyntaxToken; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, openBraceToken: ISyntaxToken, propertyAssignments: IPropertyAssignmentSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.propertyAssignments = propertyAssignments, - !isShared(propertyAssignments) && (propertyAssignments.parent = this); - } - } - export class ObjectCreationExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public newKeyword: ISyntaxToken; - public expression: IMemberExpressionSyntax; - public argumentList: ArgumentListSyntax; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax) { - super(data); - this.expression = expression, - this.argumentList = argumentList, - expression.parent = this, - argumentList && (argumentList.parent = this); - } - } - export class ParenthesizedExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public openParenToken: ISyntaxToken; - public expression: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken) { - super(data); - this.expression = expression, - expression.parent = this; - } - } - export class ParenthesizedArrowFunctionExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public callSignature: CallSignatureSyntax; - public equalsGreaterThanToken: ISyntaxToken; - public block: BlockSyntax; - public expression: IExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) { - super(data); - this.callSignature = callSignature, - this.block = block, - this.expression = expression, - callSignature.parent = this, - block && (block.parent = this), - expression && (expression.parent = this); - } - } - export class SimpleArrowFunctionExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public parameter: ParameterSyntax; - public equalsGreaterThanToken: ISyntaxToken; - public block: BlockSyntax; - public expression: IExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) { - super(data); - this.parameter = parameter, - this.block = block, - this.expression = expression, - parameter.parent = this, - block && (block.parent = this), - expression && (expression.parent = this); - } - } - export class CastExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public lessThanToken: ISyntaxToken; - public type: ITypeSyntax; - public greaterThanToken: ISyntaxToken; - public expression: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax) { - super(data); - this.type = type, - this.expression = expression, - type.parent = this, - expression.parent = this; - } - } - export class ElementAccessExpressionSyntax extends SyntaxNode implements IMemberExpressionSyntax, ICallExpressionSyntax { - public expression: ILeftHandSideExpressionSyntax; - public openBracketToken: ISyntaxToken; - public argumentExpression: IExpressionSyntax; - public closeBracketToken: ISyntaxToken; - public _memberExpressionBrand: any; public _callExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken) { - super(data); - this.expression = expression, - this.argumentExpression = argumentExpression, - expression.parent = this, - argumentExpression.parent = this; - } - } - export class FunctionExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public functionKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { - super(data); - this.identifier = identifier, - this.callSignature = callSignature, - this.block = block, - identifier && (identifier.parent = this), - callSignature.parent = this, - block.parent = this; - } - } - export class OmittedExpressionSyntax extends SyntaxNode implements IExpressionSyntax { - public _expressionBrand: any; - constructor(data: number) { - super(data); - } - } - export class VariableDeclarationSyntax extends SyntaxNode { - public varKeyword: ISyntaxToken; - public variableDeclarators: VariableDeclaratorSyntax[]; - constructor(data: number, varKeyword: ISyntaxToken, variableDeclarators: VariableDeclaratorSyntax[]) { - super(data); - this.varKeyword = varKeyword, - this.variableDeclarators = variableDeclarators, - varKeyword.parent = this, - !isShared(variableDeclarators) && (variableDeclarators.parent = this); - } - } - export class VariableDeclaratorSyntax extends SyntaxNode { - public propertyName: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public equalsValueClause: EqualsValueClauseSyntax; - constructor(data: number, propertyName: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) { - super(data); - this.propertyName = propertyName, - this.typeAnnotation = typeAnnotation, - this.equalsValueClause = equalsValueClause, - propertyName.parent = this, - typeAnnotation && (typeAnnotation.parent = this), - equalsValueClause && (equalsValueClause.parent = this); - } - } - export class ArgumentListSyntax extends SyntaxNode { - public typeArgumentList: TypeArgumentListSyntax; - public openParenToken: ISyntaxToken; - public arguments: IExpressionSyntax[]; - public closeParenToken: ISyntaxToken; - constructor(data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, _arguments: IExpressionSyntax[], closeParenToken: ISyntaxToken) { - super(data); - this.typeArgumentList = typeArgumentList, - this.arguments = _arguments, - typeArgumentList && (typeArgumentList.parent = this), - !isShared(_arguments) && (_arguments.parent = this); - } - } - export class ParameterListSyntax extends SyntaxNode { - public openParenToken: ISyntaxToken; - public parameters: ParameterSyntax[]; - public closeParenToken: ISyntaxToken; - constructor(data: number, openParenToken: ISyntaxToken, parameters: ParameterSyntax[], closeParenToken: ISyntaxToken) { - super(data); - this.parameters = parameters, - !isShared(parameters) && (parameters.parent = this); - } - } - export class TypeArgumentListSyntax extends SyntaxNode { - public lessThanToken: ISyntaxToken; - public typeArguments: ITypeSyntax[]; - public greaterThanToken: ISyntaxToken; - constructor(data: number, lessThanToken: ISyntaxToken, typeArguments: ITypeSyntax[], greaterThanToken: ISyntaxToken) { - super(data); - this.lessThanToken = lessThanToken, - this.typeArguments = typeArguments, - lessThanToken.parent = this, - !isShared(typeArguments) && (typeArguments.parent = this); - } - } - export class TypeParameterListSyntax extends SyntaxNode { - public lessThanToken: ISyntaxToken; - public typeParameters: TypeParameterSyntax[]; - public greaterThanToken: ISyntaxToken; - constructor(data: number, lessThanToken: ISyntaxToken, typeParameters: TypeParameterSyntax[], greaterThanToken: ISyntaxToken) { - super(data); - this.lessThanToken = lessThanToken, - this.typeParameters = typeParameters, - lessThanToken.parent = this, - !isShared(typeParameters) && (typeParameters.parent = this); - } - } - export class HeritageClauseSyntax extends SyntaxNode { - public extendsOrImplementsKeyword: ISyntaxToken; - public typeNames: INameSyntax[]; - constructor(data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: INameSyntax[]) { - super(data); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword, - this.typeNames = typeNames, - extendsOrImplementsKeyword.parent = this, - !isShared(typeNames) && (typeNames.parent = this); - } - } - export class EqualsValueClauseSyntax extends SyntaxNode { - public equalsToken: ISyntaxToken; - public value: IExpressionSyntax; - constructor(data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax) { - super(data); - this.value = value, - value.parent = this; - } - } - export class CaseSwitchClauseSyntax extends SyntaxNode implements ISwitchClauseSyntax { - public caseKeyword: ISyntaxToken; - public expression: IExpressionSyntax; - public colonToken: ISyntaxToken; - public statements: IStatementSyntax[]; - public _switchClauseBrand: any; - constructor(data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]) { - super(data); - this.expression = expression, - this.statements = statements, - expression.parent = this, - !isShared(statements) && (statements.parent = this); - } - } - export class DefaultSwitchClauseSyntax extends SyntaxNode implements ISwitchClauseSyntax { - public defaultKeyword: ISyntaxToken; - public colonToken: ISyntaxToken; - public statements: IStatementSyntax[]; - public _switchClauseBrand: any; - constructor(data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]) { - super(data); - this.statements = statements, - !isShared(statements) && (statements.parent = this); - } - } - export class ElseClauseSyntax extends SyntaxNode { - public elseKeyword: ISyntaxToken; - public statement: IStatementSyntax; - constructor(data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.statement = statement, - statement.parent = this; - } - } - export class CatchClauseSyntax extends SyntaxNode { - public catchKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public identifier: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public closeParenToken: ISyntaxToken; - public block: BlockSyntax; - constructor(data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax) { - super(data); - this.identifier = identifier, - this.typeAnnotation = typeAnnotation, - this.block = block, - identifier.parent = this, - typeAnnotation && (typeAnnotation.parent = this), - block.parent = this; - } - } - export class FinallyClauseSyntax extends SyntaxNode { - public finallyKeyword: ISyntaxToken; - public block: BlockSyntax; - constructor(data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax) { - super(data); - this.block = block, - block.parent = this; - } - } - export class TypeParameterSyntax extends SyntaxNode { - public identifier: ISyntaxToken; - public constraint: ConstraintSyntax; - constructor(data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax) { - super(data); - this.identifier = identifier, - this.constraint = constraint, - identifier.parent = this, - constraint && (constraint.parent = this); - } - } - export class ConstraintSyntax extends SyntaxNode { - public extendsKeyword: ISyntaxToken; - public typeOrExpression: ISyntaxNodeOrToken; - constructor(data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken) { - super(data); - this.typeOrExpression = typeOrExpression, - typeOrExpression.parent = this; - } - } - export class SimplePropertyAssignmentSyntax extends SyntaxNode implements IPropertyAssignmentSyntax { - public propertyName: ISyntaxToken; - public colonToken: ISyntaxToken; - public expression: IExpressionSyntax; - public _propertyAssignmentBrand: any; - constructor(data: number, propertyName: ISyntaxToken, colonToken: ISyntaxToken, expression: IExpressionSyntax) { - super(data); - this.propertyName = propertyName, - this.expression = expression, - propertyName.parent = this, - expression.parent = this; - } - } - export class FunctionPropertyAssignmentSyntax extends SyntaxNode implements IPropertyAssignmentSyntax { - public propertyName: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public _propertyAssignmentBrand: any; - constructor(data: number, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { - super(data); - this.propertyName = propertyName, - this.callSignature = callSignature, - this.block = block, - propertyName.parent = this, - callSignature.parent = this, - block.parent = this; - } - } - export class ParameterSyntax extends SyntaxNode { - public dotDotDotToken: ISyntaxToken; - public modifiers: ISyntaxToken[]; - public identifier: ISyntaxToken; - public questionToken: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public equalsValueClause: EqualsValueClauseSyntax; - constructor(data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) { - super(data); - this.dotDotDotToken = dotDotDotToken, - this.modifiers = modifiers, - this.identifier = identifier, - this.questionToken = questionToken, - this.typeAnnotation = typeAnnotation, - this.equalsValueClause = equalsValueClause, - dotDotDotToken && (dotDotDotToken.parent = this), - !isShared(modifiers) && (modifiers.parent = this), - identifier.parent = this, - questionToken && (questionToken.parent = this), - typeAnnotation && (typeAnnotation.parent = this), - equalsValueClause && (equalsValueClause.parent = this); - } - } - export class EnumElementSyntax extends SyntaxNode { - public propertyName: ISyntaxToken; - public equalsValueClause: EqualsValueClauseSyntax; - constructor(data: number, propertyName: ISyntaxToken, equalsValueClause: EqualsValueClauseSyntax) { - super(data); - this.propertyName = propertyName, - this.equalsValueClause = equalsValueClause, - propertyName.parent = this, - equalsValueClause && (equalsValueClause.parent = this); - } - } - export class TypeAnnotationSyntax extends SyntaxNode { - public colonToken: ISyntaxToken; - public type: ITypeSyntax; - constructor(data: number, colonToken: ISyntaxToken, type: ITypeSyntax) { - super(data); - this.type = type, - type.parent = this; - } - } - export class ExternalModuleReferenceSyntax extends SyntaxNode implements IModuleReferenceSyntax { - public requireKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public stringLiteral: ISyntaxToken; - public closeParenToken: ISyntaxToken; - public _moduleReferenceBrand: any; - constructor(data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken) { - super(data); - this.stringLiteral = stringLiteral, - stringLiteral.parent = this; - } - } - export class ModuleNameModuleReferenceSyntax extends SyntaxNode implements IModuleReferenceSyntax { - public moduleName: INameSyntax; - public _moduleReferenceBrand: any; - constructor(data: number, moduleName: INameSyntax) { - super(data); - this.moduleName = moduleName, - moduleName.parent = this; - } - } - - (SourceUnitSyntax).prototype.__kind = SyntaxKind.SourceUnit, (QualifiedNameSyntax).prototype.__kind = SyntaxKind.QualifiedName, (ObjectTypeSyntax).prototype.__kind = SyntaxKind.ObjectType, (FunctionTypeSyntax).prototype.__kind = SyntaxKind.FunctionType, (ArrayTypeSyntax).prototype.__kind = SyntaxKind.ArrayType, (ConstructorTypeSyntax).prototype.__kind = SyntaxKind.ConstructorType, (GenericTypeSyntax).prototype.__kind = SyntaxKind.GenericType, (TypeQuerySyntax).prototype.__kind = SyntaxKind.TypeQuery, (TupleTypeSyntax).prototype.__kind = SyntaxKind.TupleType, (UnionTypeSyntax).prototype.__kind = SyntaxKind.UnionType, (ParenthesizedTypeSyntax).prototype.__kind = SyntaxKind.ParenthesizedType, (InterfaceDeclarationSyntax).prototype.__kind = SyntaxKind.InterfaceDeclaration, (FunctionDeclarationSyntax).prototype.__kind = SyntaxKind.FunctionDeclaration, (ModuleDeclarationSyntax).prototype.__kind = SyntaxKind.ModuleDeclaration, (ClassDeclarationSyntax).prototype.__kind = SyntaxKind.ClassDeclaration, (EnumDeclarationSyntax).prototype.__kind = SyntaxKind.EnumDeclaration, (ImportDeclarationSyntax).prototype.__kind = SyntaxKind.ImportDeclaration, (ExportAssignmentSyntax).prototype.__kind = SyntaxKind.ExportAssignment, (MemberFunctionDeclarationSyntax).prototype.__kind = SyntaxKind.MemberFunctionDeclaration, (MemberVariableDeclarationSyntax).prototype.__kind = SyntaxKind.MemberVariableDeclaration, (ConstructorDeclarationSyntax).prototype.__kind = SyntaxKind.ConstructorDeclaration, (IndexMemberDeclarationSyntax).prototype.__kind = SyntaxKind.IndexMemberDeclaration, (GetAccessorSyntax).prototype.__kind = SyntaxKind.GetAccessor, (SetAccessorSyntax).prototype.__kind = SyntaxKind.SetAccessor, (PropertySignatureSyntax).prototype.__kind = SyntaxKind.PropertySignature, (CallSignatureSyntax).prototype.__kind = SyntaxKind.CallSignature, (ConstructSignatureSyntax).prototype.__kind = SyntaxKind.ConstructSignature, (IndexSignatureSyntax).prototype.__kind = SyntaxKind.IndexSignature, (MethodSignatureSyntax).prototype.__kind = SyntaxKind.MethodSignature, (BlockSyntax).prototype.__kind = SyntaxKind.Block, (IfStatementSyntax).prototype.__kind = SyntaxKind.IfStatement, (VariableStatementSyntax).prototype.__kind = SyntaxKind.VariableStatement, (ExpressionStatementSyntax).prototype.__kind = SyntaxKind.ExpressionStatement, (ReturnStatementSyntax).prototype.__kind = SyntaxKind.ReturnStatement, (SwitchStatementSyntax).prototype.__kind = SyntaxKind.SwitchStatement, (BreakStatementSyntax).prototype.__kind = SyntaxKind.BreakStatement, (ContinueStatementSyntax).prototype.__kind = SyntaxKind.ContinueStatement, (ForStatementSyntax).prototype.__kind = SyntaxKind.ForStatement, (ForInStatementSyntax).prototype.__kind = SyntaxKind.ForInStatement, (EmptyStatementSyntax).prototype.__kind = SyntaxKind.EmptyStatement, (ThrowStatementSyntax).prototype.__kind = SyntaxKind.ThrowStatement, (WhileStatementSyntax).prototype.__kind = SyntaxKind.WhileStatement, (TryStatementSyntax).prototype.__kind = SyntaxKind.TryStatement, (LabeledStatementSyntax).prototype.__kind = SyntaxKind.LabeledStatement, (DoStatementSyntax).prototype.__kind = SyntaxKind.DoStatement, (DebuggerStatementSyntax).prototype.__kind = SyntaxKind.DebuggerStatement, (WithStatementSyntax).prototype.__kind = SyntaxKind.WithStatement, (PrefixUnaryExpressionSyntax).prototype.__kind = SyntaxKind.PrefixUnaryExpression, (DeleteExpressionSyntax).prototype.__kind = SyntaxKind.DeleteExpression, (TypeOfExpressionSyntax).prototype.__kind = SyntaxKind.TypeOfExpression, (VoidExpressionSyntax).prototype.__kind = SyntaxKind.VoidExpression, (ConditionalExpressionSyntax).prototype.__kind = SyntaxKind.ConditionalExpression, (BinaryExpressionSyntax).prototype.__kind = SyntaxKind.BinaryExpression, (PostfixUnaryExpressionSyntax).prototype.__kind = SyntaxKind.PostfixUnaryExpression, (MemberAccessExpressionSyntax).prototype.__kind = SyntaxKind.MemberAccessExpression, (InvocationExpressionSyntax).prototype.__kind = SyntaxKind.InvocationExpression, (ArrayLiteralExpressionSyntax).prototype.__kind = SyntaxKind.ArrayLiteralExpression, (ObjectLiteralExpressionSyntax).prototype.__kind = SyntaxKind.ObjectLiteralExpression, (ObjectCreationExpressionSyntax).prototype.__kind = SyntaxKind.ObjectCreationExpression, (ParenthesizedExpressionSyntax).prototype.__kind = SyntaxKind.ParenthesizedExpression, (ParenthesizedArrowFunctionExpressionSyntax).prototype.__kind = SyntaxKind.ParenthesizedArrowFunctionExpression, (SimpleArrowFunctionExpressionSyntax).prototype.__kind = SyntaxKind.SimpleArrowFunctionExpression, (CastExpressionSyntax).prototype.__kind = SyntaxKind.CastExpression, (ElementAccessExpressionSyntax).prototype.__kind = SyntaxKind.ElementAccessExpression, (FunctionExpressionSyntax).prototype.__kind = SyntaxKind.FunctionExpression, (OmittedExpressionSyntax).prototype.__kind = SyntaxKind.OmittedExpression, (VariableDeclarationSyntax).prototype.__kind = SyntaxKind.VariableDeclaration, (VariableDeclaratorSyntax).prototype.__kind = SyntaxKind.VariableDeclarator, (ArgumentListSyntax).prototype.__kind = SyntaxKind.ArgumentList, (ParameterListSyntax).prototype.__kind = SyntaxKind.ParameterList, (TypeArgumentListSyntax).prototype.__kind = SyntaxKind.TypeArgumentList, (TypeParameterListSyntax).prototype.__kind = SyntaxKind.TypeParameterList, (HeritageClauseSyntax).prototype.__kind = SyntaxKind.HeritageClause, (EqualsValueClauseSyntax).prototype.__kind = SyntaxKind.EqualsValueClause, (CaseSwitchClauseSyntax).prototype.__kind = SyntaxKind.CaseSwitchClause, (DefaultSwitchClauseSyntax).prototype.__kind = SyntaxKind.DefaultSwitchClause, (ElseClauseSyntax).prototype.__kind = SyntaxKind.ElseClause, (CatchClauseSyntax).prototype.__kind = SyntaxKind.CatchClause, (FinallyClauseSyntax).prototype.__kind = SyntaxKind.FinallyClause, (TypeParameterSyntax).prototype.__kind = SyntaxKind.TypeParameter, (ConstraintSyntax).prototype.__kind = SyntaxKind.Constraint, (SimplePropertyAssignmentSyntax).prototype.__kind = SyntaxKind.SimplePropertyAssignment, (FunctionPropertyAssignmentSyntax).prototype.__kind = SyntaxKind.FunctionPropertyAssignment, (ParameterSyntax).prototype.__kind = SyntaxKind.Parameter, (EnumElementSyntax).prototype.__kind = SyntaxKind.EnumElement, (TypeAnnotationSyntax).prototype.__kind = SyntaxKind.TypeAnnotation, (ExternalModuleReferenceSyntax).prototype.__kind = SyntaxKind.ExternalModuleReference, (ModuleNameModuleReferenceSyntax).prototype.__kind = SyntaxKind.ModuleNameModuleReference; -} \ No newline at end of file diff --git a/src/services/syntax/syntaxNodes.concrete.generated.ts b/src/services/syntax/syntaxNodes.concrete.generated.ts index 0f119267315..5cbe6b4ee84 100644 --- a/src/services/syntax/syntaxNodes.concrete.generated.ts +++ b/src/services/syntax/syntaxNodes.concrete.generated.ts @@ -1,1465 +1,1098 @@ /// -module TypeScript.Syntax.Concrete { - // Inject this module as the factory for producing syntax nodes in the parser. - Parser.syntaxFactory = Concrete; - export var isConcrete: boolean = true; +module TypeScript { + export var SourceUnitSyntax: SourceUnitConstructor = function (data: number, moduleElements: IModuleElementSyntax[], endOfFileToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.moduleElements = moduleElements, + this.endOfFileToken = endOfFileToken, + moduleElements.parent = this, + endOfFileToken.parent = this; + }; + SourceUnitSyntax.prototype.kind = SyntaxKind.SourceUnit; - export class SourceUnitSyntax extends SyntaxNode { - public syntaxTree: SyntaxTree = undefined; - public moduleElements: IModuleElementSyntax[]; - public endOfFileToken: ISyntaxToken; - constructor(data: number, moduleElements: IModuleElementSyntax[], endOfFileToken: ISyntaxToken) { - super(data); - this.parent = undefined, - this.moduleElements = moduleElements, - this.endOfFileToken = endOfFileToken, - !isShared(moduleElements) && (moduleElements.parent = this), - endOfFileToken.parent = this; - } - } - export class QualifiedNameSyntax extends SyntaxNode implements INameSyntax { - public left: INameSyntax; - public dotToken: ISyntaxToken; - public right: ISyntaxToken; - public _nameBrand: any; public _typeBrand: any; - constructor(data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken) { - super(data); - this.left = left, - this.dotToken = dotToken, - this.right = right, - left.parent = this, - dotToken.parent = this, - right.parent = this; - } - } - export class ObjectTypeSyntax extends SyntaxNode implements ITypeSyntax { - public openBraceToken: ISyntaxToken; - public typeMembers: ITypeMemberSyntax[]; - public closeBraceToken: ISyntaxToken; - public _typeBrand: any; - constructor(data: number, openBraceToken: ISyntaxToken, typeMembers: ITypeMemberSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.openBraceToken = openBraceToken, - this.typeMembers = typeMembers, - this.closeBraceToken = closeBraceToken, - openBraceToken.parent = this, - !isShared(typeMembers) && (typeMembers.parent = this), - closeBraceToken.parent = this; - } - } - export class FunctionTypeSyntax extends SyntaxNode implements ITypeSyntax { - public typeParameterList: TypeParameterListSyntax; - public parameterList: ParameterListSyntax; - public equalsGreaterThanToken: ISyntaxToken; - public type: ITypeSyntax; - public _typeBrand: any; - constructor(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) { - super(data); - this.typeParameterList = typeParameterList, - this.parameterList = parameterList, - this.equalsGreaterThanToken = equalsGreaterThanToken, - this.type = type, - typeParameterList && (typeParameterList.parent = this), - parameterList.parent = this, - equalsGreaterThanToken.parent = this, - type.parent = this; - } - } - export class ArrayTypeSyntax extends SyntaxNode implements ITypeSyntax { - public type: ITypeSyntax; - public openBracketToken: ISyntaxToken; - public closeBracketToken: ISyntaxToken; - public _typeBrand: any; - constructor(data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken) { - super(data); - this.type = type, - this.openBracketToken = openBracketToken, - this.closeBracketToken = closeBracketToken, - type.parent = this, - openBracketToken.parent = this, - closeBracketToken.parent = this; - } - } - export class ConstructorTypeSyntax extends SyntaxNode implements ITypeSyntax { - public newKeyword: ISyntaxToken; - public typeParameterList: TypeParameterListSyntax; - public parameterList: ParameterListSyntax; - public equalsGreaterThanToken: ISyntaxToken; - public type: ITypeSyntax; - public _typeBrand: any; - constructor(data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) { - super(data); - this.newKeyword = newKeyword, - this.typeParameterList = typeParameterList, - this.parameterList = parameterList, - this.equalsGreaterThanToken = equalsGreaterThanToken, - this.type = type, - newKeyword.parent = this, - typeParameterList && (typeParameterList.parent = this), - parameterList.parent = this, - equalsGreaterThanToken.parent = this, - type.parent = this; - } - } - export class GenericTypeSyntax extends SyntaxNode implements ITypeSyntax { - public name: INameSyntax; - public typeArgumentList: TypeArgumentListSyntax; - public _typeBrand: any; - constructor(data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax) { - super(data); - this.name = name, - this.typeArgumentList = typeArgumentList, - name.parent = this, - typeArgumentList.parent = this; - } - } - export class TypeQuerySyntax extends SyntaxNode implements ITypeSyntax { - public typeOfKeyword: ISyntaxToken; - public name: INameSyntax; - public _typeBrand: any; - constructor(data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax) { - super(data); - this.typeOfKeyword = typeOfKeyword, - this.name = name, - typeOfKeyword.parent = this, - name.parent = this; - } - } - export class TupleTypeSyntax extends SyntaxNode implements ITypeSyntax { - public openBracketToken: ISyntaxToken; - public types: ITypeSyntax[]; - public closeBracketToken: ISyntaxToken; - public _typeBrand: any; - constructor(data: number, openBracketToken: ISyntaxToken, types: ITypeSyntax[], closeBracketToken: ISyntaxToken) { - super(data); - this.openBracketToken = openBracketToken, - this.types = types, - this.closeBracketToken = closeBracketToken, - openBracketToken.parent = this, - !isShared(types) && (types.parent = this), - closeBracketToken.parent = this; - } - } - export class UnionTypeSyntax extends SyntaxNode implements ITypeSyntax { - public left: ITypeSyntax; - public barToken: ISyntaxToken; - public right: ITypeSyntax; - public _typeBrand: any; - constructor(data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax) { - super(data); - this.left = left, - this.barToken = barToken, - this.right = right, - left.parent = this, - barToken.parent = this, - right.parent = this; - } - } - export class ParenthesizedTypeSyntax extends SyntaxNode implements ITypeSyntax { - public openParenToken: ISyntaxToken; - public type: ITypeSyntax; - public closeParenToken: ISyntaxToken; - public _typeBrand: any; - constructor(data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken) { - super(data); - this.openParenToken = openParenToken, - this.type = type, - this.closeParenToken = closeParenToken, - openParenToken.parent = this, - type.parent = this, - closeParenToken.parent = this; - } - } - export class InterfaceDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public interfaceKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public typeParameterList: TypeParameterListSyntax; - public heritageClauses: HeritageClauseSyntax[]; - public body: ObjectTypeSyntax; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax) { - super(data); - this.modifiers = modifiers, - this.interfaceKeyword = interfaceKeyword, - this.identifier = identifier, - this.typeParameterList = typeParameterList, - this.heritageClauses = heritageClauses, - this.body = body, - !isShared(modifiers) && (modifiers.parent = this), - interfaceKeyword.parent = this, - identifier.parent = this, - typeParameterList && (typeParameterList.parent = this), - !isShared(heritageClauses) && (heritageClauses.parent = this), - body.parent = this; - } - } - export class FunctionDeclarationSyntax extends SyntaxNode implements IStatementSyntax { - public modifiers: ISyntaxToken[]; - public functionKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.functionKeyword = functionKeyword, - this.identifier = identifier, - this.callSignature = callSignature, - this.block = block, - this.semicolonToken = semicolonToken, - !isShared(modifiers) && (modifiers.parent = this), - functionKeyword.parent = this, - identifier.parent = this, - callSignature.parent = this, - block && (block.parent = this), - semicolonToken && (semicolonToken.parent = this); - } - } - export class ModuleDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public moduleKeyword: ISyntaxToken; - public name: INameSyntax; - public stringLiteral: ISyntaxToken; - public openBraceToken: ISyntaxToken; - public moduleElements: IModuleElementSyntax[]; - public closeBraceToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.moduleKeyword = moduleKeyword, - this.name = name, - this.stringLiteral = stringLiteral, - this.openBraceToken = openBraceToken, - this.moduleElements = moduleElements, - this.closeBraceToken = closeBraceToken, - !isShared(modifiers) && (modifiers.parent = this), - moduleKeyword.parent = this, - name && (name.parent = this), - stringLiteral && (stringLiteral.parent = this), - openBraceToken.parent = this, - !isShared(moduleElements) && (moduleElements.parent = this), - closeBraceToken.parent = this; - } - } - export class ClassDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public classKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public typeParameterList: TypeParameterListSyntax; - public heritageClauses: HeritageClauseSyntax[]; - public openBraceToken: ISyntaxToken; - public classElements: IClassElementSyntax[]; - public closeBraceToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.classKeyword = classKeyword, - this.identifier = identifier, - this.typeParameterList = typeParameterList, - this.heritageClauses = heritageClauses, - this.openBraceToken = openBraceToken, - this.classElements = classElements, - this.closeBraceToken = closeBraceToken, - !isShared(modifiers) && (modifiers.parent = this), - classKeyword.parent = this, - identifier.parent = this, - typeParameterList && (typeParameterList.parent = this), - !isShared(heritageClauses) && (heritageClauses.parent = this), - openBraceToken.parent = this, - !isShared(classElements) && (classElements.parent = this), - closeBraceToken.parent = this; - } - } - export class EnumDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public enumKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public openBraceToken: ISyntaxToken; - public enumElements: EnumElementSyntax[]; - public closeBraceToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: EnumElementSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.enumKeyword = enumKeyword, - this.identifier = identifier, - this.openBraceToken = openBraceToken, - this.enumElements = enumElements, - this.closeBraceToken = closeBraceToken, - !isShared(modifiers) && (modifiers.parent = this), - enumKeyword.parent = this, - identifier.parent = this, - openBraceToken.parent = this, - !isShared(enumElements) && (enumElements.parent = this), - closeBraceToken.parent = this; - } - } - export class ImportDeclarationSyntax extends SyntaxNode implements IModuleElementSyntax { - public modifiers: ISyntaxToken[]; - public importKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public equalsToken: ISyntaxToken; - public moduleReference: IModuleReferenceSyntax; - public semicolonToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.importKeyword = importKeyword, - this.identifier = identifier, - this.equalsToken = equalsToken, - this.moduleReference = moduleReference, - this.semicolonToken = semicolonToken, - !isShared(modifiers) && (modifiers.parent = this), - importKeyword.parent = this, - identifier.parent = this, - equalsToken.parent = this, - moduleReference.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class ExportAssignmentSyntax extends SyntaxNode implements IModuleElementSyntax { - public exportKeyword: ISyntaxToken; - public equalsToken: ISyntaxToken; - public identifier: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _moduleElementBrand: any; - constructor(data: number, exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.exportKeyword = exportKeyword, - this.equalsToken = equalsToken, - this.identifier = identifier, - this.semicolonToken = semicolonToken, - exportKeyword.parent = this, - equalsToken.parent = this, - identifier.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class MemberFunctionDeclarationSyntax extends SyntaxNode implements IMemberDeclarationSyntax { - public modifiers: ISyntaxToken[]; - public propertyName: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public semicolonToken: ISyntaxToken; - public _memberDeclarationBrand: any; public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.propertyName = propertyName, - this.callSignature = callSignature, - this.block = block, - this.semicolonToken = semicolonToken, - !isShared(modifiers) && (modifiers.parent = this), - propertyName.parent = this, - callSignature.parent = this, - block && (block.parent = this), - semicolonToken && (semicolonToken.parent = this); - } - } - export class MemberVariableDeclarationSyntax extends SyntaxNode implements IMemberDeclarationSyntax { - public modifiers: ISyntaxToken[]; - public variableDeclarator: VariableDeclaratorSyntax; - public semicolonToken: ISyntaxToken; - public _memberDeclarationBrand: any; public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.variableDeclarator = variableDeclarator, - this.semicolonToken = semicolonToken, - !isShared(modifiers) && (modifiers.parent = this), - variableDeclarator.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class ConstructorDeclarationSyntax extends SyntaxNode implements IClassElementSyntax { - public modifiers: ISyntaxToken[]; - public constructorKeyword: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public semicolonToken: ISyntaxToken; - public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.constructorKeyword = constructorKeyword, - this.callSignature = callSignature, - this.block = block, - this.semicolonToken = semicolonToken, - !isShared(modifiers) && (modifiers.parent = this), - constructorKeyword.parent = this, - callSignature.parent = this, - block && (block.parent = this), - semicolonToken && (semicolonToken.parent = this); - } - } - export class IndexMemberDeclarationSyntax extends SyntaxNode implements IClassElementSyntax { - public modifiers: ISyntaxToken[]; - public indexSignature: IndexSignatureSyntax; - public semicolonToken: ISyntaxToken; - public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.indexSignature = indexSignature, - this.semicolonToken = semicolonToken, - !isShared(modifiers) && (modifiers.parent = this), - indexSignature.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class GetAccessorSyntax extends SyntaxNode implements IMemberDeclarationSyntax, IPropertyAssignmentSyntax { - public modifiers: ISyntaxToken[]; - public getKeyword: ISyntaxToken; - public propertyName: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public _memberDeclarationBrand: any; public _propertyAssignmentBrand: any; public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { - super(data); - this.modifiers = modifiers, - this.getKeyword = getKeyword, - this.propertyName = propertyName, - this.callSignature = callSignature, - this.block = block, - !isShared(modifiers) && (modifiers.parent = this), - getKeyword.parent = this, - propertyName.parent = this, - callSignature.parent = this, - block.parent = this; - } - } - export class SetAccessorSyntax extends SyntaxNode implements IMemberDeclarationSyntax, IPropertyAssignmentSyntax { - public modifiers: ISyntaxToken[]; - public setKeyword: ISyntaxToken; - public propertyName: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public _memberDeclarationBrand: any; public _propertyAssignmentBrand: any; public _classElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { - super(data); - this.modifiers = modifiers, - this.setKeyword = setKeyword, - this.propertyName = propertyName, - this.callSignature = callSignature, - this.block = block, - !isShared(modifiers) && (modifiers.parent = this), - setKeyword.parent = this, - propertyName.parent = this, - callSignature.parent = this, - block.parent = this; - } - } - export class PropertySignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public propertyName: ISyntaxToken; - public questionToken: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public _typeMemberBrand: any; - constructor(data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) { - super(data); - this.propertyName = propertyName, - this.questionToken = questionToken, - this.typeAnnotation = typeAnnotation, - propertyName.parent = this, - questionToken && (questionToken.parent = this), - typeAnnotation && (typeAnnotation.parent = this); - } - } - export class CallSignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public typeParameterList: TypeParameterListSyntax; - public parameterList: ParameterListSyntax; - public typeAnnotation: TypeAnnotationSyntax; - public _typeMemberBrand: any; - constructor(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax) { - super(data); - this.typeParameterList = typeParameterList, - this.parameterList = parameterList, - this.typeAnnotation = typeAnnotation, - typeParameterList && (typeParameterList.parent = this), - parameterList.parent = this, - typeAnnotation && (typeAnnotation.parent = this); - } - } - export class ConstructSignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public newKeyword: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public _typeMemberBrand: any; - constructor(data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax) { - super(data); - this.newKeyword = newKeyword, - this.callSignature = callSignature, - newKeyword.parent = this, - callSignature.parent = this; - } - } - export class IndexSignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public openBracketToken: ISyntaxToken; - public parameters: ParameterSyntax[]; - public closeBracketToken: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public _typeMemberBrand: any; - constructor(data: number, openBracketToken: ISyntaxToken, parameters: ParameterSyntax[], closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) { - super(data); - this.openBracketToken = openBracketToken, - this.parameters = parameters, - this.closeBracketToken = closeBracketToken, - this.typeAnnotation = typeAnnotation, - openBracketToken.parent = this, - !isShared(parameters) && (parameters.parent = this), - closeBracketToken.parent = this, - typeAnnotation && (typeAnnotation.parent = this); - } - } - export class MethodSignatureSyntax extends SyntaxNode implements ITypeMemberSyntax { - public propertyName: ISyntaxToken; - public questionToken: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public _typeMemberBrand: any; - constructor(data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax) { - super(data); - this.propertyName = propertyName, - this.questionToken = questionToken, - this.callSignature = callSignature, - propertyName.parent = this, - questionToken && (questionToken.parent = this), - callSignature.parent = this; - } - } - export class BlockSyntax extends SyntaxNode implements IStatementSyntax { - public openBraceToken: ISyntaxToken; - public statements: IStatementSyntax[]; - public closeBraceToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.openBraceToken = openBraceToken, - this.statements = statements, - this.closeBraceToken = closeBraceToken, - openBraceToken.parent = this, - !isShared(statements) && (statements.parent = this), - closeBraceToken.parent = this; - } - } - export class IfStatementSyntax extends SyntaxNode implements IStatementSyntax { - public ifKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public condition: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public elseClause: ElseClauseSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax) { - super(data); - this.ifKeyword = ifKeyword, - this.openParenToken = openParenToken, - this.condition = condition, - this.closeParenToken = closeParenToken, - this.statement = statement, - this.elseClause = elseClause, - ifKeyword.parent = this, - openParenToken.parent = this, - condition.parent = this, - closeParenToken.parent = this, - statement.parent = this, - elseClause && (elseClause.parent = this); - } - } - export class VariableStatementSyntax extends SyntaxNode implements IStatementSyntax { - public modifiers: ISyntaxToken[]; - public variableDeclaration: VariableDeclarationSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.modifiers = modifiers, - this.variableDeclaration = variableDeclaration, - this.semicolonToken = semicolonToken, - !isShared(modifiers) && (modifiers.parent = this), - variableDeclaration.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class ExpressionStatementSyntax extends SyntaxNode implements IStatementSyntax { - public expression: IExpressionSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.expression = expression, - this.semicolonToken = semicolonToken, - expression.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class ReturnStatementSyntax extends SyntaxNode implements IStatementSyntax { - public returnKeyword: ISyntaxToken; - public expression: IExpressionSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.returnKeyword = returnKeyword, - this.expression = expression, - this.semicolonToken = semicolonToken, - returnKeyword.parent = this, - expression && (expression.parent = this), - semicolonToken && (semicolonToken.parent = this); - } - } - export class SwitchStatementSyntax extends SyntaxNode implements IStatementSyntax { - public switchKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public expression: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public openBraceToken: ISyntaxToken; - public switchClauses: ISwitchClauseSyntax[]; - public closeBraceToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.switchKeyword = switchKeyword, - this.openParenToken = openParenToken, - this.expression = expression, - this.closeParenToken = closeParenToken, - this.openBraceToken = openBraceToken, - this.switchClauses = switchClauses, - this.closeBraceToken = closeBraceToken, - switchKeyword.parent = this, - openParenToken.parent = this, - expression.parent = this, - closeParenToken.parent = this, - openBraceToken.parent = this, - !isShared(switchClauses) && (switchClauses.parent = this), - closeBraceToken.parent = this; - } - } - export class BreakStatementSyntax extends SyntaxNode implements IStatementSyntax { - public breakKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.breakKeyword = breakKeyword, - this.identifier = identifier, - this.semicolonToken = semicolonToken, - breakKeyword.parent = this, - identifier && (identifier.parent = this), - semicolonToken && (semicolonToken.parent = this); - } - } - export class ContinueStatementSyntax extends SyntaxNode implements IStatementSyntax { - public continueKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.continueKeyword = continueKeyword, - this.identifier = identifier, - this.semicolonToken = semicolonToken, - continueKeyword.parent = this, - identifier && (identifier.parent = this), - semicolonToken && (semicolonToken.parent = this); - } - } - export class ForStatementSyntax extends SyntaxNode implements IStatementSyntax { - public forKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public variableDeclaration: VariableDeclarationSyntax; - public initializer: IExpressionSyntax; - public firstSemicolonToken: ISyntaxToken; - public condition: IExpressionSyntax; - public secondSemicolonToken: ISyntaxToken; - public incrementor: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.forKeyword = forKeyword, - this.openParenToken = openParenToken, - this.variableDeclaration = variableDeclaration, - this.initializer = initializer, - this.firstSemicolonToken = firstSemicolonToken, - this.condition = condition, - this.secondSemicolonToken = secondSemicolonToken, - this.incrementor = incrementor, - this.closeParenToken = closeParenToken, - this.statement = statement, - forKeyword.parent = this, - openParenToken.parent = this, - variableDeclaration && (variableDeclaration.parent = this), - initializer && (initializer.parent = this), - firstSemicolonToken.parent = this, - condition && (condition.parent = this), - secondSemicolonToken.parent = this, - incrementor && (incrementor.parent = this), - closeParenToken.parent = this, - statement.parent = this; - } - } - export class ForInStatementSyntax extends SyntaxNode implements IStatementSyntax { - public forKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public variableDeclaration: VariableDeclarationSyntax; - public left: IExpressionSyntax; - public inKeyword: ISyntaxToken; - public expression: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.forKeyword = forKeyword, - this.openParenToken = openParenToken, - this.variableDeclaration = variableDeclaration, - this.left = left, - this.inKeyword = inKeyword, - this.expression = expression, - this.closeParenToken = closeParenToken, - this.statement = statement, - forKeyword.parent = this, - openParenToken.parent = this, - variableDeclaration && (variableDeclaration.parent = this), - left && (left.parent = this), - inKeyword.parent = this, - expression.parent = this, - closeParenToken.parent = this, - statement.parent = this; - } - } - export class EmptyStatementSyntax extends SyntaxNode implements IStatementSyntax { - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, semicolonToken: ISyntaxToken) { - super(data); - this.semicolonToken = semicolonToken, - semicolonToken.parent = this; - } - } - export class ThrowStatementSyntax extends SyntaxNode implements IStatementSyntax { - public throwKeyword: ISyntaxToken; - public expression: IExpressionSyntax; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { - super(data); - this.throwKeyword = throwKeyword, - this.expression = expression, - this.semicolonToken = semicolonToken, - throwKeyword.parent = this, - expression.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class WhileStatementSyntax extends SyntaxNode implements IStatementSyntax { - public whileKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public condition: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.whileKeyword = whileKeyword, - this.openParenToken = openParenToken, - this.condition = condition, - this.closeParenToken = closeParenToken, - this.statement = statement, - whileKeyword.parent = this, - openParenToken.parent = this, - condition.parent = this, - closeParenToken.parent = this, - statement.parent = this; - } - } - export class TryStatementSyntax extends SyntaxNode implements IStatementSyntax { - public tryKeyword: ISyntaxToken; - public block: BlockSyntax; - public catchClause: CatchClauseSyntax; - public finallyClause: FinallyClauseSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax) { - super(data); - this.tryKeyword = tryKeyword, - this.block = block, - this.catchClause = catchClause, - this.finallyClause = finallyClause, - tryKeyword.parent = this, - block.parent = this, - catchClause && (catchClause.parent = this), - finallyClause && (finallyClause.parent = this); - } - } - export class LabeledStatementSyntax extends SyntaxNode implements IStatementSyntax { - public identifier: ISyntaxToken; - public colonToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.identifier = identifier, - this.colonToken = colonToken, - this.statement = statement, - identifier.parent = this, - colonToken.parent = this, - statement.parent = this; - } - } - export class DoStatementSyntax extends SyntaxNode implements IStatementSyntax { - public doKeyword: ISyntaxToken; - public statement: IStatementSyntax; - public whileKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public condition: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.doKeyword = doKeyword, - this.statement = statement, - this.whileKeyword = whileKeyword, - this.openParenToken = openParenToken, - this.condition = condition, - this.closeParenToken = closeParenToken, - this.semicolonToken = semicolonToken, - doKeyword.parent = this, - statement.parent = this, - whileKeyword.parent = this, - openParenToken.parent = this, - condition.parent = this, - closeParenToken.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class DebuggerStatementSyntax extends SyntaxNode implements IStatementSyntax { - public debuggerKeyword: ISyntaxToken; - public semicolonToken: ISyntaxToken; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken) { - super(data); - this.debuggerKeyword = debuggerKeyword, - this.semicolonToken = semicolonToken, - debuggerKeyword.parent = this, - semicolonToken && (semicolonToken.parent = this); - } - } - export class WithStatementSyntax extends SyntaxNode implements IStatementSyntax { - public withKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public condition: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public statement: IStatementSyntax; - public _statementBrand: any; public _moduleElementBrand: any; - constructor(data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.withKeyword = withKeyword, - this.openParenToken = openParenToken, - this.condition = condition, - this.closeParenToken = closeParenToken, - this.statement = statement, - withKeyword.parent = this, - openParenToken.parent = this, - condition.parent = this, - closeParenToken.parent = this, - statement.parent = this; - } - } - export class PrefixUnaryExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public operatorToken: ISyntaxToken; - public operand: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax) { - super(data); - this.operatorToken = operatorToken, - this.operand = operand, - operatorToken.parent = this, - operand.parent = this; - } - } - export class DeleteExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public deleteKeyword: ISyntaxToken; - public expression: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { - super(data); - this.deleteKeyword = deleteKeyword, - this.expression = expression, - deleteKeyword.parent = this, - expression.parent = this; - } - } - export class TypeOfExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public typeOfKeyword: ISyntaxToken; - public expression: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { - super(data); - this.typeOfKeyword = typeOfKeyword, - this.expression = expression, - typeOfKeyword.parent = this, - expression.parent = this; - } - } - export class VoidExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public voidKeyword: ISyntaxToken; - public expression: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { - super(data); - this.voidKeyword = voidKeyword, - this.expression = expression, - voidKeyword.parent = this, - expression.parent = this; - } - } - export class ConditionalExpressionSyntax extends SyntaxNode implements IExpressionSyntax { - public condition: IExpressionSyntax; - public questionToken: ISyntaxToken; - public whenTrue: IExpressionSyntax; - public colonToken: ISyntaxToken; - public whenFalse: IExpressionSyntax; - public _expressionBrand: any; - constructor(data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax) { - super(data); - this.condition = condition, - this.questionToken = questionToken, - this.whenTrue = whenTrue, - this.colonToken = colonToken, - this.whenFalse = whenFalse, - condition.parent = this, - questionToken.parent = this, - whenTrue.parent = this, - colonToken.parent = this, - whenFalse.parent = this; - } - } - export class BinaryExpressionSyntax extends SyntaxNode implements IExpressionSyntax { - public left: IExpressionSyntax; - public operatorToken: ISyntaxToken; - public right: IExpressionSyntax; - public _expressionBrand: any; - constructor(data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax) { - super(data); - this.left = left, - this.operatorToken = operatorToken, - this.right = right, - left.parent = this, - operatorToken.parent = this, - right.parent = this; - } - } - export class PostfixUnaryExpressionSyntax extends SyntaxNode implements IPostfixExpressionSyntax { - public operand: ILeftHandSideExpressionSyntax; - public operatorToken: ISyntaxToken; - public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken) { - super(data); - this.operand = operand, - this.operatorToken = operatorToken, - operand.parent = this, - operatorToken.parent = this; - } - } - export class MemberAccessExpressionSyntax extends SyntaxNode implements IMemberExpressionSyntax, ICallExpressionSyntax { - public expression: ILeftHandSideExpressionSyntax; - public dotToken: ISyntaxToken; - public name: ISyntaxToken; - public _memberExpressionBrand: any; public _callExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken) { - super(data); - this.expression = expression, - this.dotToken = dotToken, - this.name = name, - expression.parent = this, - dotToken.parent = this, - name.parent = this; - } - } - export class InvocationExpressionSyntax extends SyntaxNode implements ICallExpressionSyntax { - public expression: ILeftHandSideExpressionSyntax; - public argumentList: ArgumentListSyntax; - public _callExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax) { - super(data); - this.expression = expression, - this.argumentList = argumentList, - expression.parent = this, - argumentList.parent = this; - } - } - export class ArrayLiteralExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public openBracketToken: ISyntaxToken; - public expressions: IExpressionSyntax[]; - public closeBracketToken: ISyntaxToken; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, openBracketToken: ISyntaxToken, expressions: IExpressionSyntax[], closeBracketToken: ISyntaxToken) { - super(data); - this.openBracketToken = openBracketToken, - this.expressions = expressions, - this.closeBracketToken = closeBracketToken, - openBracketToken.parent = this, - !isShared(expressions) && (expressions.parent = this), - closeBracketToken.parent = this; - } - } - export class ObjectLiteralExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public openBraceToken: ISyntaxToken; - public propertyAssignments: IPropertyAssignmentSyntax[]; - public closeBraceToken: ISyntaxToken; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, openBraceToken: ISyntaxToken, propertyAssignments: IPropertyAssignmentSyntax[], closeBraceToken: ISyntaxToken) { - super(data); - this.openBraceToken = openBraceToken, - this.propertyAssignments = propertyAssignments, - this.closeBraceToken = closeBraceToken, - openBraceToken.parent = this, - !isShared(propertyAssignments) && (propertyAssignments.parent = this), - closeBraceToken.parent = this; - } - } - export class ObjectCreationExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public newKeyword: ISyntaxToken; - public expression: IMemberExpressionSyntax; - public argumentList: ArgumentListSyntax; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax) { - super(data); - this.newKeyword = newKeyword, - this.expression = expression, - this.argumentList = argumentList, - newKeyword.parent = this, - expression.parent = this, - argumentList && (argumentList.parent = this); - } - } - export class ParenthesizedExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public openParenToken: ISyntaxToken; - public expression: IExpressionSyntax; - public closeParenToken: ISyntaxToken; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken) { - super(data); - this.openParenToken = openParenToken, - this.expression = expression, - this.closeParenToken = closeParenToken, - openParenToken.parent = this, - expression.parent = this, - closeParenToken.parent = this; - } - } - export class ParenthesizedArrowFunctionExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public callSignature: CallSignatureSyntax; - public equalsGreaterThanToken: ISyntaxToken; - public block: BlockSyntax; - public expression: IExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) { - super(data); - this.callSignature = callSignature, - this.equalsGreaterThanToken = equalsGreaterThanToken, - this.block = block, - this.expression = expression, - callSignature.parent = this, - equalsGreaterThanToken.parent = this, - block && (block.parent = this), - expression && (expression.parent = this); - } - } - export class SimpleArrowFunctionExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public parameter: ParameterSyntax; - public equalsGreaterThanToken: ISyntaxToken; - public block: BlockSyntax; - public expression: IExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) { - super(data); - this.parameter = parameter, - this.equalsGreaterThanToken = equalsGreaterThanToken, - this.block = block, - this.expression = expression, - parameter.parent = this, - equalsGreaterThanToken.parent = this, - block && (block.parent = this), - expression && (expression.parent = this); - } - } - export class CastExpressionSyntax extends SyntaxNode implements IUnaryExpressionSyntax { - public lessThanToken: ISyntaxToken; - public type: ITypeSyntax; - public greaterThanToken: ISyntaxToken; - public expression: IUnaryExpressionSyntax; - public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax) { - super(data); - this.lessThanToken = lessThanToken, - this.type = type, - this.greaterThanToken = greaterThanToken, - this.expression = expression, - lessThanToken.parent = this, - type.parent = this, - greaterThanToken.parent = this, - expression.parent = this; - } - } - export class ElementAccessExpressionSyntax extends SyntaxNode implements IMemberExpressionSyntax, ICallExpressionSyntax { - public expression: ILeftHandSideExpressionSyntax; - public openBracketToken: ISyntaxToken; - public argumentExpression: IExpressionSyntax; - public closeBracketToken: ISyntaxToken; - public _memberExpressionBrand: any; public _callExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken) { - super(data); - this.expression = expression, - this.openBracketToken = openBracketToken, - this.argumentExpression = argumentExpression, - this.closeBracketToken = closeBracketToken, - expression.parent = this, - openBracketToken.parent = this, - argumentExpression.parent = this, - closeBracketToken.parent = this; - } - } - export class FunctionExpressionSyntax extends SyntaxNode implements IPrimaryExpressionSyntax { - public functionKeyword: ISyntaxToken; - public identifier: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; - constructor(data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { - super(data); - this.functionKeyword = functionKeyword, - this.identifier = identifier, - this.callSignature = callSignature, - this.block = block, - functionKeyword.parent = this, - identifier && (identifier.parent = this), - callSignature.parent = this, - block.parent = this; - } - } - export class OmittedExpressionSyntax extends SyntaxNode implements IExpressionSyntax { - public _expressionBrand: any; - constructor(data: number) { - super(data); - } - } - export class VariableDeclarationSyntax extends SyntaxNode { - public varKeyword: ISyntaxToken; - public variableDeclarators: VariableDeclaratorSyntax[]; - constructor(data: number, varKeyword: ISyntaxToken, variableDeclarators: VariableDeclaratorSyntax[]) { - super(data); - this.varKeyword = varKeyword, - this.variableDeclarators = variableDeclarators, - varKeyword.parent = this, - !isShared(variableDeclarators) && (variableDeclarators.parent = this); - } - } - export class VariableDeclaratorSyntax extends SyntaxNode { - public propertyName: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public equalsValueClause: EqualsValueClauseSyntax; - constructor(data: number, propertyName: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) { - super(data); - this.propertyName = propertyName, - this.typeAnnotation = typeAnnotation, - this.equalsValueClause = equalsValueClause, - propertyName.parent = this, - typeAnnotation && (typeAnnotation.parent = this), - equalsValueClause && (equalsValueClause.parent = this); - } - } - export class ArgumentListSyntax extends SyntaxNode { - public typeArgumentList: TypeArgumentListSyntax; - public openParenToken: ISyntaxToken; - public arguments: IExpressionSyntax[]; - public closeParenToken: ISyntaxToken; - constructor(data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, _arguments: IExpressionSyntax[], closeParenToken: ISyntaxToken) { - super(data); - this.typeArgumentList = typeArgumentList, - this.openParenToken = openParenToken, - this.arguments = _arguments, - this.closeParenToken = closeParenToken, - typeArgumentList && (typeArgumentList.parent = this), - openParenToken.parent = this, - !isShared(_arguments) && (_arguments.parent = this), - closeParenToken.parent = this; - } - } - export class ParameterListSyntax extends SyntaxNode { - public openParenToken: ISyntaxToken; - public parameters: ParameterSyntax[]; - public closeParenToken: ISyntaxToken; - constructor(data: number, openParenToken: ISyntaxToken, parameters: ParameterSyntax[], closeParenToken: ISyntaxToken) { - super(data); - this.openParenToken = openParenToken, - this.parameters = parameters, - this.closeParenToken = closeParenToken, - openParenToken.parent = this, - !isShared(parameters) && (parameters.parent = this), - closeParenToken.parent = this; - } - } - export class TypeArgumentListSyntax extends SyntaxNode { - public lessThanToken: ISyntaxToken; - public typeArguments: ITypeSyntax[]; - public greaterThanToken: ISyntaxToken; - constructor(data: number, lessThanToken: ISyntaxToken, typeArguments: ITypeSyntax[], greaterThanToken: ISyntaxToken) { - super(data); - this.lessThanToken = lessThanToken, - this.typeArguments = typeArguments, - this.greaterThanToken = greaterThanToken, - lessThanToken.parent = this, - !isShared(typeArguments) && (typeArguments.parent = this), - greaterThanToken.parent = this; - } - } - export class TypeParameterListSyntax extends SyntaxNode { - public lessThanToken: ISyntaxToken; - public typeParameters: TypeParameterSyntax[]; - public greaterThanToken: ISyntaxToken; - constructor(data: number, lessThanToken: ISyntaxToken, typeParameters: TypeParameterSyntax[], greaterThanToken: ISyntaxToken) { - super(data); - this.lessThanToken = lessThanToken, - this.typeParameters = typeParameters, - this.greaterThanToken = greaterThanToken, - lessThanToken.parent = this, - !isShared(typeParameters) && (typeParameters.parent = this), - greaterThanToken.parent = this; - } - } - export class HeritageClauseSyntax extends SyntaxNode { - public extendsOrImplementsKeyword: ISyntaxToken; - public typeNames: INameSyntax[]; - constructor(data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: INameSyntax[]) { - super(data); - this.extendsOrImplementsKeyword = extendsOrImplementsKeyword, - this.typeNames = typeNames, - extendsOrImplementsKeyword.parent = this, - !isShared(typeNames) && (typeNames.parent = this); - } - } - export class EqualsValueClauseSyntax extends SyntaxNode { - public equalsToken: ISyntaxToken; - public value: IExpressionSyntax; - constructor(data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax) { - super(data); - this.equalsToken = equalsToken, - this.value = value, - equalsToken.parent = this, - value.parent = this; - } - } - export class CaseSwitchClauseSyntax extends SyntaxNode implements ISwitchClauseSyntax { - public caseKeyword: ISyntaxToken; - public expression: IExpressionSyntax; - public colonToken: ISyntaxToken; - public statements: IStatementSyntax[]; - public _switchClauseBrand: any; - constructor(data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]) { - super(data); - this.caseKeyword = caseKeyword, - this.expression = expression, - this.colonToken = colonToken, - this.statements = statements, - caseKeyword.parent = this, - expression.parent = this, - colonToken.parent = this, - !isShared(statements) && (statements.parent = this); - } - } - export class DefaultSwitchClauseSyntax extends SyntaxNode implements ISwitchClauseSyntax { - public defaultKeyword: ISyntaxToken; - public colonToken: ISyntaxToken; - public statements: IStatementSyntax[]; - public _switchClauseBrand: any; - constructor(data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]) { - super(data); - this.defaultKeyword = defaultKeyword, - this.colonToken = colonToken, - this.statements = statements, - defaultKeyword.parent = this, - colonToken.parent = this, - !isShared(statements) && (statements.parent = this); - } - } - export class ElseClauseSyntax extends SyntaxNode { - public elseKeyword: ISyntaxToken; - public statement: IStatementSyntax; - constructor(data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax) { - super(data); - this.elseKeyword = elseKeyword, - this.statement = statement, - elseKeyword.parent = this, - statement.parent = this; - } - } - export class CatchClauseSyntax extends SyntaxNode { - public catchKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public identifier: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public closeParenToken: ISyntaxToken; - public block: BlockSyntax; - constructor(data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax) { - super(data); - this.catchKeyword = catchKeyword, - this.openParenToken = openParenToken, - this.identifier = identifier, - this.typeAnnotation = typeAnnotation, - this.closeParenToken = closeParenToken, - this.block = block, - catchKeyword.parent = this, - openParenToken.parent = this, - identifier.parent = this, - typeAnnotation && (typeAnnotation.parent = this), - closeParenToken.parent = this, - block.parent = this; - } - } - export class FinallyClauseSyntax extends SyntaxNode { - public finallyKeyword: ISyntaxToken; - public block: BlockSyntax; - constructor(data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax) { - super(data); - this.finallyKeyword = finallyKeyword, - this.block = block, - finallyKeyword.parent = this, - block.parent = this; - } - } - export class TypeParameterSyntax extends SyntaxNode { - public identifier: ISyntaxToken; - public constraint: ConstraintSyntax; - constructor(data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax) { - super(data); - this.identifier = identifier, - this.constraint = constraint, - identifier.parent = this, - constraint && (constraint.parent = this); - } - } - export class ConstraintSyntax extends SyntaxNode { - public extendsKeyword: ISyntaxToken; - public typeOrExpression: ISyntaxNodeOrToken; - constructor(data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken) { - super(data); - this.extendsKeyword = extendsKeyword, - this.typeOrExpression = typeOrExpression, - extendsKeyword.parent = this, - typeOrExpression.parent = this; - } - } - export class SimplePropertyAssignmentSyntax extends SyntaxNode implements IPropertyAssignmentSyntax { - public propertyName: ISyntaxToken; - public colonToken: ISyntaxToken; - public expression: IExpressionSyntax; - public _propertyAssignmentBrand: any; - constructor(data: number, propertyName: ISyntaxToken, colonToken: ISyntaxToken, expression: IExpressionSyntax) { - super(data); - this.propertyName = propertyName, - this.colonToken = colonToken, - this.expression = expression, - propertyName.parent = this, - colonToken.parent = this, - expression.parent = this; - } - } - export class FunctionPropertyAssignmentSyntax extends SyntaxNode implements IPropertyAssignmentSyntax { - public propertyName: ISyntaxToken; - public callSignature: CallSignatureSyntax; - public block: BlockSyntax; - public _propertyAssignmentBrand: any; - constructor(data: number, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { - super(data); - this.propertyName = propertyName, - this.callSignature = callSignature, - this.block = block, - propertyName.parent = this, - callSignature.parent = this, - block.parent = this; - } - } - export class ParameterSyntax extends SyntaxNode { - public dotDotDotToken: ISyntaxToken; - public modifiers: ISyntaxToken[]; - public identifier: ISyntaxToken; - public questionToken: ISyntaxToken; - public typeAnnotation: TypeAnnotationSyntax; - public equalsValueClause: EqualsValueClauseSyntax; - constructor(data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) { - super(data); - this.dotDotDotToken = dotDotDotToken, - this.modifiers = modifiers, - this.identifier = identifier, - this.questionToken = questionToken, - this.typeAnnotation = typeAnnotation, - this.equalsValueClause = equalsValueClause, - dotDotDotToken && (dotDotDotToken.parent = this), - !isShared(modifiers) && (modifiers.parent = this), - identifier.parent = this, - questionToken && (questionToken.parent = this), - typeAnnotation && (typeAnnotation.parent = this), - equalsValueClause && (equalsValueClause.parent = this); - } - } - export class EnumElementSyntax extends SyntaxNode { - public propertyName: ISyntaxToken; - public equalsValueClause: EqualsValueClauseSyntax; - constructor(data: number, propertyName: ISyntaxToken, equalsValueClause: EqualsValueClauseSyntax) { - super(data); - this.propertyName = propertyName, - this.equalsValueClause = equalsValueClause, - propertyName.parent = this, - equalsValueClause && (equalsValueClause.parent = this); - } - } - export class TypeAnnotationSyntax extends SyntaxNode { - public colonToken: ISyntaxToken; - public type: ITypeSyntax; - constructor(data: number, colonToken: ISyntaxToken, type: ITypeSyntax) { - super(data); - this.colonToken = colonToken, - this.type = type, - colonToken.parent = this, - type.parent = this; - } - } - export class ExternalModuleReferenceSyntax extends SyntaxNode implements IModuleReferenceSyntax { - public requireKeyword: ISyntaxToken; - public openParenToken: ISyntaxToken; - public stringLiteral: ISyntaxToken; - public closeParenToken: ISyntaxToken; - public _moduleReferenceBrand: any; - constructor(data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken) { - super(data); - this.requireKeyword = requireKeyword, - this.openParenToken = openParenToken, - this.stringLiteral = stringLiteral, - this.closeParenToken = closeParenToken, - requireKeyword.parent = this, - openParenToken.parent = this, - stringLiteral.parent = this, - closeParenToken.parent = this; - } - } - export class ModuleNameModuleReferenceSyntax extends SyntaxNode implements IModuleReferenceSyntax { - public moduleName: INameSyntax; - public _moduleReferenceBrand: any; - constructor(data: number, moduleName: INameSyntax) { - super(data); - this.moduleName = moduleName, - moduleName.parent = this; - } - } + export var QualifiedNameSyntax: QualifiedNameConstructor = function (data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken) { + if (data) { this.__data = data; } + this.left = left, + this.dotToken = dotToken, + this.right = right, + left.parent = this, + dotToken.parent = this, + right.parent = this; + }; + QualifiedNameSyntax.prototype.kind = SyntaxKind.QualifiedName; - (SourceUnitSyntax).prototype.__kind = SyntaxKind.SourceUnit, (QualifiedNameSyntax).prototype.__kind = SyntaxKind.QualifiedName, (ObjectTypeSyntax).prototype.__kind = SyntaxKind.ObjectType, (FunctionTypeSyntax).prototype.__kind = SyntaxKind.FunctionType, (ArrayTypeSyntax).prototype.__kind = SyntaxKind.ArrayType, (ConstructorTypeSyntax).prototype.__kind = SyntaxKind.ConstructorType, (GenericTypeSyntax).prototype.__kind = SyntaxKind.GenericType, (TypeQuerySyntax).prototype.__kind = SyntaxKind.TypeQuery, (TupleTypeSyntax).prototype.__kind = SyntaxKind.TupleType, (UnionTypeSyntax).prototype.__kind = SyntaxKind.UnionType, (ParenthesizedTypeSyntax).prototype.__kind = SyntaxKind.ParenthesizedType, (InterfaceDeclarationSyntax).prototype.__kind = SyntaxKind.InterfaceDeclaration, (FunctionDeclarationSyntax).prototype.__kind = SyntaxKind.FunctionDeclaration, (ModuleDeclarationSyntax).prototype.__kind = SyntaxKind.ModuleDeclaration, (ClassDeclarationSyntax).prototype.__kind = SyntaxKind.ClassDeclaration, (EnumDeclarationSyntax).prototype.__kind = SyntaxKind.EnumDeclaration, (ImportDeclarationSyntax).prototype.__kind = SyntaxKind.ImportDeclaration, (ExportAssignmentSyntax).prototype.__kind = SyntaxKind.ExportAssignment, (MemberFunctionDeclarationSyntax).prototype.__kind = SyntaxKind.MemberFunctionDeclaration, (MemberVariableDeclarationSyntax).prototype.__kind = SyntaxKind.MemberVariableDeclaration, (ConstructorDeclarationSyntax).prototype.__kind = SyntaxKind.ConstructorDeclaration, (IndexMemberDeclarationSyntax).prototype.__kind = SyntaxKind.IndexMemberDeclaration, (GetAccessorSyntax).prototype.__kind = SyntaxKind.GetAccessor, (SetAccessorSyntax).prototype.__kind = SyntaxKind.SetAccessor, (PropertySignatureSyntax).prototype.__kind = SyntaxKind.PropertySignature, (CallSignatureSyntax).prototype.__kind = SyntaxKind.CallSignature, (ConstructSignatureSyntax).prototype.__kind = SyntaxKind.ConstructSignature, (IndexSignatureSyntax).prototype.__kind = SyntaxKind.IndexSignature, (MethodSignatureSyntax).prototype.__kind = SyntaxKind.MethodSignature, (BlockSyntax).prototype.__kind = SyntaxKind.Block, (IfStatementSyntax).prototype.__kind = SyntaxKind.IfStatement, (VariableStatementSyntax).prototype.__kind = SyntaxKind.VariableStatement, (ExpressionStatementSyntax).prototype.__kind = SyntaxKind.ExpressionStatement, (ReturnStatementSyntax).prototype.__kind = SyntaxKind.ReturnStatement, (SwitchStatementSyntax).prototype.__kind = SyntaxKind.SwitchStatement, (BreakStatementSyntax).prototype.__kind = SyntaxKind.BreakStatement, (ContinueStatementSyntax).prototype.__kind = SyntaxKind.ContinueStatement, (ForStatementSyntax).prototype.__kind = SyntaxKind.ForStatement, (ForInStatementSyntax).prototype.__kind = SyntaxKind.ForInStatement, (EmptyStatementSyntax).prototype.__kind = SyntaxKind.EmptyStatement, (ThrowStatementSyntax).prototype.__kind = SyntaxKind.ThrowStatement, (WhileStatementSyntax).prototype.__kind = SyntaxKind.WhileStatement, (TryStatementSyntax).prototype.__kind = SyntaxKind.TryStatement, (LabeledStatementSyntax).prototype.__kind = SyntaxKind.LabeledStatement, (DoStatementSyntax).prototype.__kind = SyntaxKind.DoStatement, (DebuggerStatementSyntax).prototype.__kind = SyntaxKind.DebuggerStatement, (WithStatementSyntax).prototype.__kind = SyntaxKind.WithStatement, (PrefixUnaryExpressionSyntax).prototype.__kind = SyntaxKind.PrefixUnaryExpression, (DeleteExpressionSyntax).prototype.__kind = SyntaxKind.DeleteExpression, (TypeOfExpressionSyntax).prototype.__kind = SyntaxKind.TypeOfExpression, (VoidExpressionSyntax).prototype.__kind = SyntaxKind.VoidExpression, (ConditionalExpressionSyntax).prototype.__kind = SyntaxKind.ConditionalExpression, (BinaryExpressionSyntax).prototype.__kind = SyntaxKind.BinaryExpression, (PostfixUnaryExpressionSyntax).prototype.__kind = SyntaxKind.PostfixUnaryExpression, (MemberAccessExpressionSyntax).prototype.__kind = SyntaxKind.MemberAccessExpression, (InvocationExpressionSyntax).prototype.__kind = SyntaxKind.InvocationExpression, (ArrayLiteralExpressionSyntax).prototype.__kind = SyntaxKind.ArrayLiteralExpression, (ObjectLiteralExpressionSyntax).prototype.__kind = SyntaxKind.ObjectLiteralExpression, (ObjectCreationExpressionSyntax).prototype.__kind = SyntaxKind.ObjectCreationExpression, (ParenthesizedExpressionSyntax).prototype.__kind = SyntaxKind.ParenthesizedExpression, (ParenthesizedArrowFunctionExpressionSyntax).prototype.__kind = SyntaxKind.ParenthesizedArrowFunctionExpression, (SimpleArrowFunctionExpressionSyntax).prototype.__kind = SyntaxKind.SimpleArrowFunctionExpression, (CastExpressionSyntax).prototype.__kind = SyntaxKind.CastExpression, (ElementAccessExpressionSyntax).prototype.__kind = SyntaxKind.ElementAccessExpression, (FunctionExpressionSyntax).prototype.__kind = SyntaxKind.FunctionExpression, (OmittedExpressionSyntax).prototype.__kind = SyntaxKind.OmittedExpression, (VariableDeclarationSyntax).prototype.__kind = SyntaxKind.VariableDeclaration, (VariableDeclaratorSyntax).prototype.__kind = SyntaxKind.VariableDeclarator, (ArgumentListSyntax).prototype.__kind = SyntaxKind.ArgumentList, (ParameterListSyntax).prototype.__kind = SyntaxKind.ParameterList, (TypeArgumentListSyntax).prototype.__kind = SyntaxKind.TypeArgumentList, (TypeParameterListSyntax).prototype.__kind = SyntaxKind.TypeParameterList, (HeritageClauseSyntax).prototype.__kind = SyntaxKind.HeritageClause, (EqualsValueClauseSyntax).prototype.__kind = SyntaxKind.EqualsValueClause, (CaseSwitchClauseSyntax).prototype.__kind = SyntaxKind.CaseSwitchClause, (DefaultSwitchClauseSyntax).prototype.__kind = SyntaxKind.DefaultSwitchClause, (ElseClauseSyntax).prototype.__kind = SyntaxKind.ElseClause, (CatchClauseSyntax).prototype.__kind = SyntaxKind.CatchClause, (FinallyClauseSyntax).prototype.__kind = SyntaxKind.FinallyClause, (TypeParameterSyntax).prototype.__kind = SyntaxKind.TypeParameter, (ConstraintSyntax).prototype.__kind = SyntaxKind.Constraint, (SimplePropertyAssignmentSyntax).prototype.__kind = SyntaxKind.SimplePropertyAssignment, (FunctionPropertyAssignmentSyntax).prototype.__kind = SyntaxKind.FunctionPropertyAssignment, (ParameterSyntax).prototype.__kind = SyntaxKind.Parameter, (EnumElementSyntax).prototype.__kind = SyntaxKind.EnumElement, (TypeAnnotationSyntax).prototype.__kind = SyntaxKind.TypeAnnotation, (ExternalModuleReferenceSyntax).prototype.__kind = SyntaxKind.ExternalModuleReference, (ModuleNameModuleReferenceSyntax).prototype.__kind = SyntaxKind.ModuleNameModuleReference; + export var ObjectTypeSyntax: ObjectTypeConstructor = function (data: number, openBraceToken: ISyntaxToken, typeMembers: ISeparatedSyntaxList, closeBraceToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.openBraceToken = openBraceToken, + this.typeMembers = typeMembers, + this.closeBraceToken = closeBraceToken, + openBraceToken.parent = this, + typeMembers.parent = this, + closeBraceToken.parent = this; + }; + ObjectTypeSyntax.prototype.kind = SyntaxKind.ObjectType; + + export var FunctionTypeSyntax: FunctionTypeConstructor = function (data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) { + if (data) { this.__data = data; } + this.typeParameterList = typeParameterList, + this.parameterList = parameterList, + this.equalsGreaterThanToken = equalsGreaterThanToken, + this.type = type, + typeParameterList && (typeParameterList.parent = this), + parameterList.parent = this, + equalsGreaterThanToken.parent = this, + type.parent = this; + }; + FunctionTypeSyntax.prototype.kind = SyntaxKind.FunctionType; + + export var ArrayTypeSyntax: ArrayTypeConstructor = function (data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.type = type, + this.openBracketToken = openBracketToken, + this.closeBracketToken = closeBracketToken, + type.parent = this, + openBracketToken.parent = this, + closeBracketToken.parent = this; + }; + ArrayTypeSyntax.prototype.kind = SyntaxKind.ArrayType; + + export var ConstructorTypeSyntax: ConstructorTypeConstructor = function (data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax) { + if (data) { this.__data = data; } + this.newKeyword = newKeyword, + this.typeParameterList = typeParameterList, + this.parameterList = parameterList, + this.equalsGreaterThanToken = equalsGreaterThanToken, + this.type = type, + newKeyword.parent = this, + typeParameterList && (typeParameterList.parent = this), + parameterList.parent = this, + equalsGreaterThanToken.parent = this, + type.parent = this; + }; + ConstructorTypeSyntax.prototype.kind = SyntaxKind.ConstructorType; + + export var GenericTypeSyntax: GenericTypeConstructor = function (data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax) { + if (data) { this.__data = data; } + this.name = name, + this.typeArgumentList = typeArgumentList, + name.parent = this, + typeArgumentList.parent = this; + }; + GenericTypeSyntax.prototype.kind = SyntaxKind.GenericType; + + export var TypeQuerySyntax: TypeQueryConstructor = function (data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax) { + if (data) { this.__data = data; } + this.typeOfKeyword = typeOfKeyword, + this.name = name, + typeOfKeyword.parent = this, + name.parent = this; + }; + TypeQuerySyntax.prototype.kind = SyntaxKind.TypeQuery; + + export var TupleTypeSyntax: TupleTypeConstructor = function (data: number, openBracketToken: ISyntaxToken, types: ISeparatedSyntaxList, closeBracketToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.openBracketToken = openBracketToken, + this.types = types, + this.closeBracketToken = closeBracketToken, + openBracketToken.parent = this, + types.parent = this, + closeBracketToken.parent = this; + }; + TupleTypeSyntax.prototype.kind = SyntaxKind.TupleType; + + export var UnionTypeSyntax: UnionTypeConstructor = function (data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax) { + if (data) { this.__data = data; } + this.left = left, + this.barToken = barToken, + this.right = right, + left.parent = this, + barToken.parent = this, + right.parent = this; + }; + UnionTypeSyntax.prototype.kind = SyntaxKind.UnionType; + + export var ParenthesizedTypeSyntax: ParenthesizedTypeConstructor = function (data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.openParenToken = openParenToken, + this.type = type, + this.closeParenToken = closeParenToken, + openParenToken.parent = this, + type.parent = this, + closeParenToken.parent = this; + }; + ParenthesizedTypeSyntax.prototype.kind = SyntaxKind.ParenthesizedType; + + export var InterfaceDeclarationSyntax: InterfaceDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.interfaceKeyword = interfaceKeyword, + this.identifier = identifier, + this.typeParameterList = typeParameterList, + this.heritageClauses = heritageClauses, + this.body = body, + modifiers.parent = this, + interfaceKeyword.parent = this, + identifier.parent = this, + typeParameterList && (typeParameterList.parent = this), + heritageClauses.parent = this, + body.parent = this; + }; + InterfaceDeclarationSyntax.prototype.kind = SyntaxKind.InterfaceDeclaration; + + export var FunctionDeclarationSyntax: FunctionDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.functionKeyword = functionKeyword, + this.identifier = identifier, + this.callSignature = callSignature, + this.block = block, + this.semicolonToken = semicolonToken, + modifiers.parent = this, + functionKeyword.parent = this, + identifier.parent = this, + callSignature.parent = this, + block && (block.parent = this), + semicolonToken && (semicolonToken.parent = this); + }; + FunctionDeclarationSyntax.prototype.kind = SyntaxKind.FunctionDeclaration; + + export var ModuleDeclarationSyntax: ModuleDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.moduleKeyword = moduleKeyword, + this.name = name, + this.stringLiteral = stringLiteral, + this.openBraceToken = openBraceToken, + this.moduleElements = moduleElements, + this.closeBraceToken = closeBraceToken, + modifiers.parent = this, + moduleKeyword.parent = this, + name && (name.parent = this), + stringLiteral && (stringLiteral.parent = this), + openBraceToken.parent = this, + moduleElements.parent = this, + closeBraceToken.parent = this; + }; + ModuleDeclarationSyntax.prototype.kind = SyntaxKind.ModuleDeclaration; + + export var ClassDeclarationSyntax: ClassDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.classKeyword = classKeyword, + this.identifier = identifier, + this.typeParameterList = typeParameterList, + this.heritageClauses = heritageClauses, + this.openBraceToken = openBraceToken, + this.classElements = classElements, + this.closeBraceToken = closeBraceToken, + modifiers.parent = this, + classKeyword.parent = this, + identifier.parent = this, + typeParameterList && (typeParameterList.parent = this), + heritageClauses.parent = this, + openBraceToken.parent = this, + classElements.parent = this, + closeBraceToken.parent = this; + }; + ClassDeclarationSyntax.prototype.kind = SyntaxKind.ClassDeclaration; + + export var EnumDeclarationSyntax: EnumDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: ISeparatedSyntaxList, closeBraceToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.enumKeyword = enumKeyword, + this.identifier = identifier, + this.openBraceToken = openBraceToken, + this.enumElements = enumElements, + this.closeBraceToken = closeBraceToken, + modifiers.parent = this, + enumKeyword.parent = this, + identifier.parent = this, + openBraceToken.parent = this, + enumElements.parent = this, + closeBraceToken.parent = this; + }; + EnumDeclarationSyntax.prototype.kind = SyntaxKind.EnumDeclaration; + + export var ImportDeclarationSyntax: ImportDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.importKeyword = importKeyword, + this.identifier = identifier, + this.equalsToken = equalsToken, + this.moduleReference = moduleReference, + this.semicolonToken = semicolonToken, + modifiers.parent = this, + importKeyword.parent = this, + identifier.parent = this, + equalsToken.parent = this, + moduleReference.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + ImportDeclarationSyntax.prototype.kind = SyntaxKind.ImportDeclaration; + + export var ExportAssignmentSyntax: ExportAssignmentConstructor = function (data: number, exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.exportKeyword = exportKeyword, + this.equalsToken = equalsToken, + this.identifier = identifier, + this.semicolonToken = semicolonToken, + exportKeyword.parent = this, + equalsToken.parent = this, + identifier.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + ExportAssignmentSyntax.prototype.kind = SyntaxKind.ExportAssignment; + + export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.propertyName = propertyName, + this.callSignature = callSignature, + this.block = block, + this.semicolonToken = semicolonToken, + modifiers.parent = this, + propertyName.parent = this, + callSignature.parent = this, + block && (block.parent = this), + semicolonToken && (semicolonToken.parent = this); + }; + MemberFunctionDeclarationSyntax.prototype.kind = SyntaxKind.MemberFunctionDeclaration; + + export var MemberVariableDeclarationSyntax: MemberVariableDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.variableDeclarator = variableDeclarator, + this.semicolonToken = semicolonToken, + modifiers.parent = this, + variableDeclarator.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + MemberVariableDeclarationSyntax.prototype.kind = SyntaxKind.MemberVariableDeclaration; + + export var ConstructorDeclarationSyntax: ConstructorDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.constructorKeyword = constructorKeyword, + this.callSignature = callSignature, + this.block = block, + this.semicolonToken = semicolonToken, + modifiers.parent = this, + constructorKeyword.parent = this, + callSignature.parent = this, + block && (block.parent = this), + semicolonToken && (semicolonToken.parent = this); + }; + ConstructorDeclarationSyntax.prototype.kind = SyntaxKind.ConstructorDeclaration; + + export var IndexMemberDeclarationSyntax: IndexMemberDeclarationConstructor = function (data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.indexSignature = indexSignature, + this.semicolonToken = semicolonToken, + modifiers.parent = this, + indexSignature.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + IndexMemberDeclarationSyntax.prototype.kind = SyntaxKind.IndexMemberDeclaration; + + export var GetAccessorSyntax: GetAccessorConstructor = function (data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.getKeyword = getKeyword, + this.propertyName = propertyName, + this.callSignature = callSignature, + this.block = block, + modifiers.parent = this, + getKeyword.parent = this, + propertyName.parent = this, + callSignature.parent = this, + block.parent = this; + }; + GetAccessorSyntax.prototype.kind = SyntaxKind.GetAccessor; + + export var SetAccessorSyntax: SetAccessorConstructor = function (data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.setKeyword = setKeyword, + this.propertyName = propertyName, + this.callSignature = callSignature, + this.block = block, + modifiers.parent = this, + setKeyword.parent = this, + propertyName.parent = this, + callSignature.parent = this, + block.parent = this; + }; + SetAccessorSyntax.prototype.kind = SyntaxKind.SetAccessor; + + export var PropertySignatureSyntax: PropertySignatureConstructor = function (data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) { + if (data) { this.__data = data; } + this.propertyName = propertyName, + this.questionToken = questionToken, + this.typeAnnotation = typeAnnotation, + propertyName.parent = this, + questionToken && (questionToken.parent = this), + typeAnnotation && (typeAnnotation.parent = this); + }; + PropertySignatureSyntax.prototype.kind = SyntaxKind.PropertySignature; + + export var CallSignatureSyntax: CallSignatureConstructor = function (data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax) { + if (data) { this.__data = data; } + this.typeParameterList = typeParameterList, + this.parameterList = parameterList, + this.typeAnnotation = typeAnnotation, + typeParameterList && (typeParameterList.parent = this), + parameterList.parent = this, + typeAnnotation && (typeAnnotation.parent = this); + }; + CallSignatureSyntax.prototype.kind = SyntaxKind.CallSignature; + + export var ConstructSignatureSyntax: ConstructSignatureConstructor = function (data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax) { + if (data) { this.__data = data; } + this.newKeyword = newKeyword, + this.callSignature = callSignature, + newKeyword.parent = this, + callSignature.parent = this; + }; + ConstructSignatureSyntax.prototype.kind = SyntaxKind.ConstructSignature; + + export var IndexSignatureSyntax: IndexSignatureConstructor = function (data: number, openBracketToken: ISyntaxToken, parameters: ISeparatedSyntaxList, closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax) { + if (data) { this.__data = data; } + this.openBracketToken = openBracketToken, + this.parameters = parameters, + this.closeBracketToken = closeBracketToken, + this.typeAnnotation = typeAnnotation, + openBracketToken.parent = this, + parameters.parent = this, + closeBracketToken.parent = this, + typeAnnotation && (typeAnnotation.parent = this); + }; + IndexSignatureSyntax.prototype.kind = SyntaxKind.IndexSignature; + + export var MethodSignatureSyntax: MethodSignatureConstructor = function (data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax) { + if (data) { this.__data = data; } + this.propertyName = propertyName, + this.questionToken = questionToken, + this.callSignature = callSignature, + propertyName.parent = this, + questionToken && (questionToken.parent = this), + callSignature.parent = this; + }; + MethodSignatureSyntax.prototype.kind = SyntaxKind.MethodSignature; + + export var BlockSyntax: BlockConstructor = function (data: number, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.openBraceToken = openBraceToken, + this.statements = statements, + this.closeBraceToken = closeBraceToken, + openBraceToken.parent = this, + statements.parent = this, + closeBraceToken.parent = this; + }; + BlockSyntax.prototype.kind = SyntaxKind.Block; + + export var IfStatementSyntax: IfStatementConstructor = function (data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax) { + if (data) { this.__data = data; } + this.ifKeyword = ifKeyword, + this.openParenToken = openParenToken, + this.condition = condition, + this.closeParenToken = closeParenToken, + this.statement = statement, + this.elseClause = elseClause, + ifKeyword.parent = this, + openParenToken.parent = this, + condition.parent = this, + closeParenToken.parent = this, + statement.parent = this, + elseClause && (elseClause.parent = this); + }; + IfStatementSyntax.prototype.kind = SyntaxKind.IfStatement; + + export var VariableStatementSyntax: VariableStatementConstructor = function (data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.modifiers = modifiers, + this.variableDeclaration = variableDeclaration, + this.semicolonToken = semicolonToken, + modifiers.parent = this, + variableDeclaration.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + VariableStatementSyntax.prototype.kind = SyntaxKind.VariableStatement; + + export var ExpressionStatementSyntax: ExpressionStatementConstructor = function (data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.expression = expression, + this.semicolonToken = semicolonToken, + expression.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + ExpressionStatementSyntax.prototype.kind = SyntaxKind.ExpressionStatement; + + export var ReturnStatementSyntax: ReturnStatementConstructor = function (data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.returnKeyword = returnKeyword, + this.expression = expression, + this.semicolonToken = semicolonToken, + returnKeyword.parent = this, + expression && (expression.parent = this), + semicolonToken && (semicolonToken.parent = this); + }; + ReturnStatementSyntax.prototype.kind = SyntaxKind.ReturnStatement; + + export var SwitchStatementSyntax: SwitchStatementConstructor = function (data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.switchKeyword = switchKeyword, + this.openParenToken = openParenToken, + this.expression = expression, + this.closeParenToken = closeParenToken, + this.openBraceToken = openBraceToken, + this.switchClauses = switchClauses, + this.closeBraceToken = closeBraceToken, + switchKeyword.parent = this, + openParenToken.parent = this, + expression.parent = this, + closeParenToken.parent = this, + openBraceToken.parent = this, + switchClauses.parent = this, + closeBraceToken.parent = this; + }; + SwitchStatementSyntax.prototype.kind = SyntaxKind.SwitchStatement; + + export var BreakStatementSyntax: BreakStatementConstructor = function (data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.breakKeyword = breakKeyword, + this.identifier = identifier, + this.semicolonToken = semicolonToken, + breakKeyword.parent = this, + identifier && (identifier.parent = this), + semicolonToken && (semicolonToken.parent = this); + }; + BreakStatementSyntax.prototype.kind = SyntaxKind.BreakStatement; + + export var ContinueStatementSyntax: ContinueStatementConstructor = function (data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.continueKeyword = continueKeyword, + this.identifier = identifier, + this.semicolonToken = semicolonToken, + continueKeyword.parent = this, + identifier && (identifier.parent = this), + semicolonToken && (semicolonToken.parent = this); + }; + ContinueStatementSyntax.prototype.kind = SyntaxKind.ContinueStatement; + + export var ForStatementSyntax: ForStatementConstructor = function (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { + if (data) { this.__data = data; } + this.forKeyword = forKeyword, + this.openParenToken = openParenToken, + this.variableDeclaration = variableDeclaration, + this.initializer = initializer, + this.firstSemicolonToken = firstSemicolonToken, + this.condition = condition, + this.secondSemicolonToken = secondSemicolonToken, + this.incrementor = incrementor, + this.closeParenToken = closeParenToken, + this.statement = statement, + forKeyword.parent = this, + openParenToken.parent = this, + variableDeclaration && (variableDeclaration.parent = this), + initializer && (initializer.parent = this), + firstSemicolonToken.parent = this, + condition && (condition.parent = this), + secondSemicolonToken.parent = this, + incrementor && (incrementor.parent = this), + closeParenToken.parent = this, + statement.parent = this; + }; + ForStatementSyntax.prototype.kind = SyntaxKind.ForStatement; + + export var ForInStatementSyntax: ForInStatementConstructor = function (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { + if (data) { this.__data = data; } + this.forKeyword = forKeyword, + this.openParenToken = openParenToken, + this.variableDeclaration = variableDeclaration, + this.left = left, + this.inKeyword = inKeyword, + this.expression = expression, + this.closeParenToken = closeParenToken, + this.statement = statement, + forKeyword.parent = this, + openParenToken.parent = this, + variableDeclaration && (variableDeclaration.parent = this), + left && (left.parent = this), + inKeyword.parent = this, + expression.parent = this, + closeParenToken.parent = this, + statement.parent = this; + }; + ForInStatementSyntax.prototype.kind = SyntaxKind.ForInStatement; + + export var EmptyStatementSyntax: EmptyStatementConstructor = function (data: number, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.semicolonToken = semicolonToken, + semicolonToken.parent = this; + }; + EmptyStatementSyntax.prototype.kind = SyntaxKind.EmptyStatement; + + export var ThrowStatementSyntax: ThrowStatementConstructor = function (data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.throwKeyword = throwKeyword, + this.expression = expression, + this.semicolonToken = semicolonToken, + throwKeyword.parent = this, + expression.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + ThrowStatementSyntax.prototype.kind = SyntaxKind.ThrowStatement; + + export var WhileStatementSyntax: WhileStatementConstructor = function (data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { + if (data) { this.__data = data; } + this.whileKeyword = whileKeyword, + this.openParenToken = openParenToken, + this.condition = condition, + this.closeParenToken = closeParenToken, + this.statement = statement, + whileKeyword.parent = this, + openParenToken.parent = this, + condition.parent = this, + closeParenToken.parent = this, + statement.parent = this; + }; + WhileStatementSyntax.prototype.kind = SyntaxKind.WhileStatement; + + export var TryStatementSyntax: TryStatementConstructor = function (data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax) { + if (data) { this.__data = data; } + this.tryKeyword = tryKeyword, + this.block = block, + this.catchClause = catchClause, + this.finallyClause = finallyClause, + tryKeyword.parent = this, + block.parent = this, + catchClause && (catchClause.parent = this), + finallyClause && (finallyClause.parent = this); + }; + TryStatementSyntax.prototype.kind = SyntaxKind.TryStatement; + + export var LabeledStatementSyntax: LabeledStatementConstructor = function (data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax) { + if (data) { this.__data = data; } + this.identifier = identifier, + this.colonToken = colonToken, + this.statement = statement, + identifier.parent = this, + colonToken.parent = this, + statement.parent = this; + }; + LabeledStatementSyntax.prototype.kind = SyntaxKind.LabeledStatement; + + export var DoStatementSyntax: DoStatementConstructor = function (data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.doKeyword = doKeyword, + this.statement = statement, + this.whileKeyword = whileKeyword, + this.openParenToken = openParenToken, + this.condition = condition, + this.closeParenToken = closeParenToken, + this.semicolonToken = semicolonToken, + doKeyword.parent = this, + statement.parent = this, + whileKeyword.parent = this, + openParenToken.parent = this, + condition.parent = this, + closeParenToken.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + DoStatementSyntax.prototype.kind = SyntaxKind.DoStatement; + + export var DebuggerStatementSyntax: DebuggerStatementConstructor = function (data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.debuggerKeyword = debuggerKeyword, + this.semicolonToken = semicolonToken, + debuggerKeyword.parent = this, + semicolonToken && (semicolonToken.parent = this); + }; + DebuggerStatementSyntax.prototype.kind = SyntaxKind.DebuggerStatement; + + export var WithStatementSyntax: WithStatementConstructor = function (data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) { + if (data) { this.__data = data; } + this.withKeyword = withKeyword, + this.openParenToken = openParenToken, + this.condition = condition, + this.closeParenToken = closeParenToken, + this.statement = statement, + withKeyword.parent = this, + openParenToken.parent = this, + condition.parent = this, + closeParenToken.parent = this, + statement.parent = this; + }; + WithStatementSyntax.prototype.kind = SyntaxKind.WithStatement; + + export var PrefixUnaryExpressionSyntax: PrefixUnaryExpressionConstructor = function (data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax) { + if (data) { this.__data = data; } + this.operatorToken = operatorToken, + this.operand = operand, + operatorToken.parent = this, + operand.parent = this; + }; + PrefixUnaryExpressionSyntax.prototype.kind = SyntaxKind.PrefixUnaryExpression; + + export var DeleteExpressionSyntax: DeleteExpressionConstructor = function (data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { + if (data) { this.__data = data; } + this.deleteKeyword = deleteKeyword, + this.expression = expression, + deleteKeyword.parent = this, + expression.parent = this; + }; + DeleteExpressionSyntax.prototype.kind = SyntaxKind.DeleteExpression; + + export var TypeOfExpressionSyntax: TypeOfExpressionConstructor = function (data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { + if (data) { this.__data = data; } + this.typeOfKeyword = typeOfKeyword, + this.expression = expression, + typeOfKeyword.parent = this, + expression.parent = this; + }; + TypeOfExpressionSyntax.prototype.kind = SyntaxKind.TypeOfExpression; + + export var VoidExpressionSyntax: VoidExpressionConstructor = function (data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax) { + if (data) { this.__data = data; } + this.voidKeyword = voidKeyword, + this.expression = expression, + voidKeyword.parent = this, + expression.parent = this; + }; + VoidExpressionSyntax.prototype.kind = SyntaxKind.VoidExpression; + + export var ConditionalExpressionSyntax: ConditionalExpressionConstructor = function (data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax) { + if (data) { this.__data = data; } + this.condition = condition, + this.questionToken = questionToken, + this.whenTrue = whenTrue, + this.colonToken = colonToken, + this.whenFalse = whenFalse, + condition.parent = this, + questionToken.parent = this, + whenTrue.parent = this, + colonToken.parent = this, + whenFalse.parent = this; + }; + ConditionalExpressionSyntax.prototype.kind = SyntaxKind.ConditionalExpression; + + export var BinaryExpressionSyntax: BinaryExpressionConstructor = function (data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax) { + if (data) { this.__data = data; } + this.left = left, + this.operatorToken = operatorToken, + this.right = right, + left.parent = this, + operatorToken.parent = this, + right.parent = this; + }; + BinaryExpressionSyntax.prototype.kind = SyntaxKind.BinaryExpression; + + export var PostfixUnaryExpressionSyntax: PostfixUnaryExpressionConstructor = function (data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.operand = operand, + this.operatorToken = operatorToken, + operand.parent = this, + operatorToken.parent = this; + }; + PostfixUnaryExpressionSyntax.prototype.kind = SyntaxKind.PostfixUnaryExpression; + + export var MemberAccessExpressionSyntax: MemberAccessExpressionConstructor = function (data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken) { + if (data) { this.__data = data; } + this.expression = expression, + this.dotToken = dotToken, + this.name = name, + expression.parent = this, + dotToken.parent = this, + name.parent = this; + }; + MemberAccessExpressionSyntax.prototype.kind = SyntaxKind.MemberAccessExpression; + + export var InvocationExpressionSyntax: InvocationExpressionConstructor = function (data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax) { + if (data) { this.__data = data; } + this.expression = expression, + this.argumentList = argumentList, + expression.parent = this, + argumentList.parent = this; + }; + InvocationExpressionSyntax.prototype.kind = SyntaxKind.InvocationExpression; + + export var ArrayLiteralExpressionSyntax: ArrayLiteralExpressionConstructor = function (data: number, openBracketToken: ISyntaxToken, expressions: ISeparatedSyntaxList, closeBracketToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.openBracketToken = openBracketToken, + this.expressions = expressions, + this.closeBracketToken = closeBracketToken, + openBracketToken.parent = this, + expressions.parent = this, + closeBracketToken.parent = this; + }; + ArrayLiteralExpressionSyntax.prototype.kind = SyntaxKind.ArrayLiteralExpression; + + export var ObjectLiteralExpressionSyntax: ObjectLiteralExpressionConstructor = function (data: number, openBraceToken: ISyntaxToken, propertyAssignments: ISeparatedSyntaxList, closeBraceToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.openBraceToken = openBraceToken, + this.propertyAssignments = propertyAssignments, + this.closeBraceToken = closeBraceToken, + openBraceToken.parent = this, + propertyAssignments.parent = this, + closeBraceToken.parent = this; + }; + ObjectLiteralExpressionSyntax.prototype.kind = SyntaxKind.ObjectLiteralExpression; + + export var ObjectCreationExpressionSyntax: ObjectCreationExpressionConstructor = function (data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax) { + if (data) { this.__data = data; } + this.newKeyword = newKeyword, + this.expression = expression, + this.argumentList = argumentList, + newKeyword.parent = this, + expression.parent = this, + argumentList && (argumentList.parent = this); + }; + ObjectCreationExpressionSyntax.prototype.kind = SyntaxKind.ObjectCreationExpression; + + export var ParenthesizedExpressionSyntax: ParenthesizedExpressionConstructor = function (data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.openParenToken = openParenToken, + this.expression = expression, + this.closeParenToken = closeParenToken, + openParenToken.parent = this, + expression.parent = this, + closeParenToken.parent = this; + }; + ParenthesizedExpressionSyntax.prototype.kind = SyntaxKind.ParenthesizedExpression; + + export var ParenthesizedArrowFunctionExpressionSyntax: ParenthesizedArrowFunctionExpressionConstructor = function (data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) { + if (data) { this.__data = data; } + this.callSignature = callSignature, + this.equalsGreaterThanToken = equalsGreaterThanToken, + this.block = block, + this.expression = expression, + callSignature.parent = this, + equalsGreaterThanToken.parent = this, + block && (block.parent = this), + expression && (expression.parent = this); + }; + ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = SyntaxKind.ParenthesizedArrowFunctionExpression; + + export var SimpleArrowFunctionExpressionSyntax: SimpleArrowFunctionExpressionConstructor = function (data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) { + if (data) { this.__data = data; } + this.parameter = parameter, + this.equalsGreaterThanToken = equalsGreaterThanToken, + this.block = block, + this.expression = expression, + parameter.parent = this, + equalsGreaterThanToken.parent = this, + block && (block.parent = this), + expression && (expression.parent = this); + }; + SimpleArrowFunctionExpressionSyntax.prototype.kind = SyntaxKind.SimpleArrowFunctionExpression; + + export var CastExpressionSyntax: CastExpressionConstructor = function (data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax) { + if (data) { this.__data = data; } + this.lessThanToken = lessThanToken, + this.type = type, + this.greaterThanToken = greaterThanToken, + this.expression = expression, + lessThanToken.parent = this, + type.parent = this, + greaterThanToken.parent = this, + expression.parent = this; + }; + CastExpressionSyntax.prototype.kind = SyntaxKind.CastExpression; + + export var ElementAccessExpressionSyntax: ElementAccessExpressionConstructor = function (data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.expression = expression, + this.openBracketToken = openBracketToken, + this.argumentExpression = argumentExpression, + this.closeBracketToken = closeBracketToken, + expression.parent = this, + openBracketToken.parent = this, + argumentExpression.parent = this, + closeBracketToken.parent = this; + }; + ElementAccessExpressionSyntax.prototype.kind = SyntaxKind.ElementAccessExpression; + + export var FunctionExpressionSyntax: FunctionExpressionConstructor = function (data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { + if (data) { this.__data = data; } + this.functionKeyword = functionKeyword, + this.identifier = identifier, + this.callSignature = callSignature, + this.block = block, + functionKeyword.parent = this, + identifier && (identifier.parent = this), + callSignature.parent = this, + block.parent = this; + }; + FunctionExpressionSyntax.prototype.kind = SyntaxKind.FunctionExpression; + + export var OmittedExpressionSyntax: OmittedExpressionConstructor = function (data: number) { + if (data) { this.__data = data; } + }; + OmittedExpressionSyntax.prototype.kind = SyntaxKind.OmittedExpression; + + export var TemplateExpressionSyntax: TemplateExpressionConstructor = function (data: number, templateStartToken: ISyntaxToken, templateClauses: TemplateClauseSyntax[]) { + if (data) { this.__data = data; } + this.templateStartToken = templateStartToken, + this.templateClauses = templateClauses, + templateStartToken.parent = this, + templateClauses.parent = this; + }; + TemplateExpressionSyntax.prototype.kind = SyntaxKind.TemplateExpression; + + export var TemplateAccessExpressionSyntax: TemplateAccessExpressionConstructor = function (data: number, expression: ILeftHandSideExpressionSyntax, templateExpression: IPrimaryExpressionSyntax) { + if (data) { this.__data = data; } + this.expression = expression, + this.templateExpression = templateExpression, + expression.parent = this, + templateExpression.parent = this; + }; + TemplateAccessExpressionSyntax.prototype.kind = SyntaxKind.TemplateAccessExpression; + + export var VariableDeclarationSyntax: VariableDeclarationConstructor = function (data: number, varKeyword: ISyntaxToken, variableDeclarators: ISeparatedSyntaxList) { + if (data) { this.__data = data; } + this.varKeyword = varKeyword, + this.variableDeclarators = variableDeclarators, + varKeyword.parent = this, + variableDeclarators.parent = this; + }; + VariableDeclarationSyntax.prototype.kind = SyntaxKind.VariableDeclaration; + + export var VariableDeclaratorSyntax: VariableDeclaratorConstructor = function (data: number, propertyName: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) { + if (data) { this.__data = data; } + this.propertyName = propertyName, + this.typeAnnotation = typeAnnotation, + this.equalsValueClause = equalsValueClause, + propertyName.parent = this, + typeAnnotation && (typeAnnotation.parent = this), + equalsValueClause && (equalsValueClause.parent = this); + }; + VariableDeclaratorSyntax.prototype.kind = SyntaxKind.VariableDeclarator; + + export var ArgumentListSyntax: ArgumentListConstructor = function (data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, _arguments: ISeparatedSyntaxList, closeParenToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.typeArgumentList = typeArgumentList, + this.openParenToken = openParenToken, + this.arguments = _arguments, + this.closeParenToken = closeParenToken, + typeArgumentList && (typeArgumentList.parent = this), + openParenToken.parent = this, + _arguments.parent = this, + closeParenToken.parent = this; + }; + ArgumentListSyntax.prototype.kind = SyntaxKind.ArgumentList; + + export var ParameterListSyntax: ParameterListConstructor = function (data: number, openParenToken: ISyntaxToken, parameters: ISeparatedSyntaxList, closeParenToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.openParenToken = openParenToken, + this.parameters = parameters, + this.closeParenToken = closeParenToken, + openParenToken.parent = this, + parameters.parent = this, + closeParenToken.parent = this; + }; + ParameterListSyntax.prototype.kind = SyntaxKind.ParameterList; + + export var TypeArgumentListSyntax: TypeArgumentListConstructor = function (data: number, lessThanToken: ISyntaxToken, typeArguments: ISeparatedSyntaxList, greaterThanToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.lessThanToken = lessThanToken, + this.typeArguments = typeArguments, + this.greaterThanToken = greaterThanToken, + lessThanToken.parent = this, + typeArguments.parent = this, + greaterThanToken.parent = this; + }; + TypeArgumentListSyntax.prototype.kind = SyntaxKind.TypeArgumentList; + + export var TypeParameterListSyntax: TypeParameterListConstructor = function (data: number, lessThanToken: ISyntaxToken, typeParameters: ISeparatedSyntaxList, greaterThanToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.lessThanToken = lessThanToken, + this.typeParameters = typeParameters, + this.greaterThanToken = greaterThanToken, + lessThanToken.parent = this, + typeParameters.parent = this, + greaterThanToken.parent = this; + }; + TypeParameterListSyntax.prototype.kind = SyntaxKind.TypeParameterList; + + export var HeritageClauseSyntax: HeritageClauseConstructor = function (data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: ISeparatedSyntaxList) { + if (data) { this.__data = data; } + this.extendsOrImplementsKeyword = extendsOrImplementsKeyword, + this.typeNames = typeNames, + extendsOrImplementsKeyword.parent = this, + typeNames.parent = this; + }; + HeritageClauseSyntax.prototype.kind = SyntaxKind.HeritageClause; + + export var EqualsValueClauseSyntax: EqualsValueClauseConstructor = function (data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax) { + if (data) { this.__data = data; } + this.equalsToken = equalsToken, + this.value = value, + equalsToken.parent = this, + value.parent = this; + }; + EqualsValueClauseSyntax.prototype.kind = SyntaxKind.EqualsValueClause; + + export var CaseSwitchClauseSyntax: CaseSwitchClauseConstructor = function (data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]) { + if (data) { this.__data = data; } + this.caseKeyword = caseKeyword, + this.expression = expression, + this.colonToken = colonToken, + this.statements = statements, + caseKeyword.parent = this, + expression.parent = this, + colonToken.parent = this, + statements.parent = this; + }; + CaseSwitchClauseSyntax.prototype.kind = SyntaxKind.CaseSwitchClause; + + export var DefaultSwitchClauseSyntax: DefaultSwitchClauseConstructor = function (data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]) { + if (data) { this.__data = data; } + this.defaultKeyword = defaultKeyword, + this.colonToken = colonToken, + this.statements = statements, + defaultKeyword.parent = this, + colonToken.parent = this, + statements.parent = this; + }; + DefaultSwitchClauseSyntax.prototype.kind = SyntaxKind.DefaultSwitchClause; + + export var ElseClauseSyntax: ElseClauseConstructor = function (data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax) { + if (data) { this.__data = data; } + this.elseKeyword = elseKeyword, + this.statement = statement, + elseKeyword.parent = this, + statement.parent = this; + }; + ElseClauseSyntax.prototype.kind = SyntaxKind.ElseClause; + + export var CatchClauseSyntax: CatchClauseConstructor = function (data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax) { + if (data) { this.__data = data; } + this.catchKeyword = catchKeyword, + this.openParenToken = openParenToken, + this.identifier = identifier, + this.typeAnnotation = typeAnnotation, + this.closeParenToken = closeParenToken, + this.block = block, + catchKeyword.parent = this, + openParenToken.parent = this, + identifier.parent = this, + typeAnnotation && (typeAnnotation.parent = this), + closeParenToken.parent = this, + block.parent = this; + }; + CatchClauseSyntax.prototype.kind = SyntaxKind.CatchClause; + + export var FinallyClauseSyntax: FinallyClauseConstructor = function (data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax) { + if (data) { this.__data = data; } + this.finallyKeyword = finallyKeyword, + this.block = block, + finallyKeyword.parent = this, + block.parent = this; + }; + FinallyClauseSyntax.prototype.kind = SyntaxKind.FinallyClause; + + export var TemplateClauseSyntax: TemplateClauseConstructor = function (data: number, expression: IExpressionSyntax, templateMiddleOrEndToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.expression = expression, + this.templateMiddleOrEndToken = templateMiddleOrEndToken, + expression.parent = this, + templateMiddleOrEndToken.parent = this; + }; + TemplateClauseSyntax.prototype.kind = SyntaxKind.TemplateClause; + + export var TypeParameterSyntax: TypeParameterConstructor = function (data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax) { + if (data) { this.__data = data; } + this.identifier = identifier, + this.constraint = constraint, + identifier.parent = this, + constraint && (constraint.parent = this); + }; + TypeParameterSyntax.prototype.kind = SyntaxKind.TypeParameter; + + export var ConstraintSyntax: ConstraintConstructor = function (data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken) { + if (data) { this.__data = data; } + this.extendsKeyword = extendsKeyword, + this.typeOrExpression = typeOrExpression, + extendsKeyword.parent = this, + typeOrExpression.parent = this; + }; + ConstraintSyntax.prototype.kind = SyntaxKind.Constraint; + + export var SimplePropertyAssignmentSyntax: SimplePropertyAssignmentConstructor = function (data: number, propertyName: ISyntaxToken, colonToken: ISyntaxToken, expression: IExpressionSyntax) { + if (data) { this.__data = data; } + this.propertyName = propertyName, + this.colonToken = colonToken, + this.expression = expression, + propertyName.parent = this, + colonToken.parent = this, + expression.parent = this; + }; + SimplePropertyAssignmentSyntax.prototype.kind = SyntaxKind.SimplePropertyAssignment; + + export var FunctionPropertyAssignmentSyntax: FunctionPropertyAssignmentConstructor = function (data: number, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax) { + if (data) { this.__data = data; } + this.propertyName = propertyName, + this.callSignature = callSignature, + this.block = block, + propertyName.parent = this, + callSignature.parent = this, + block.parent = this; + }; + FunctionPropertyAssignmentSyntax.prototype.kind = SyntaxKind.FunctionPropertyAssignment; + + export var ParameterSyntax: ParameterConstructor = function (data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax) { + if (data) { this.__data = data; } + this.dotDotDotToken = dotDotDotToken, + this.modifiers = modifiers, + this.identifier = identifier, + this.questionToken = questionToken, + this.typeAnnotation = typeAnnotation, + this.equalsValueClause = equalsValueClause, + dotDotDotToken && (dotDotDotToken.parent = this), + modifiers.parent = this, + identifier.parent = this, + questionToken && (questionToken.parent = this), + typeAnnotation && (typeAnnotation.parent = this), + equalsValueClause && (equalsValueClause.parent = this); + }; + ParameterSyntax.prototype.kind = SyntaxKind.Parameter; + + export var EnumElementSyntax: EnumElementConstructor = function (data: number, propertyName: ISyntaxToken, equalsValueClause: EqualsValueClauseSyntax) { + if (data) { this.__data = data; } + this.propertyName = propertyName, + this.equalsValueClause = equalsValueClause, + propertyName.parent = this, + equalsValueClause && (equalsValueClause.parent = this); + }; + EnumElementSyntax.prototype.kind = SyntaxKind.EnumElement; + + export var TypeAnnotationSyntax: TypeAnnotationConstructor = function (data: number, colonToken: ISyntaxToken, type: ITypeSyntax) { + if (data) { this.__data = data; } + this.colonToken = colonToken, + this.type = type, + colonToken.parent = this, + type.parent = this; + }; + TypeAnnotationSyntax.prototype.kind = SyntaxKind.TypeAnnotation; + + export var ExternalModuleReferenceSyntax: ExternalModuleReferenceConstructor = function (data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken) { + if (data) { this.__data = data; } + this.requireKeyword = requireKeyword, + this.openParenToken = openParenToken, + this.stringLiteral = stringLiteral, + this.closeParenToken = closeParenToken, + requireKeyword.parent = this, + openParenToken.parent = this, + stringLiteral.parent = this, + closeParenToken.parent = this; + }; + ExternalModuleReferenceSyntax.prototype.kind = SyntaxKind.ExternalModuleReference; + + export var ModuleNameModuleReferenceSyntax: ModuleNameModuleReferenceConstructor = function (data: number, moduleName: INameSyntax) { + if (data) { this.__data = data; } + this.moduleName = moduleName, + moduleName.parent = this; + }; + ModuleNameModuleReferenceSyntax.prototype.kind = SyntaxKind.ModuleNameModuleReference; } \ No newline at end of file diff --git a/src/services/syntax/syntaxNodes.interfaces.generated.ts b/src/services/syntax/syntaxNodes.interfaces.generated.ts index 700910c344d..23fe6c40f56 100644 --- a/src/services/syntax/syntaxNodes.interfaces.generated.ts +++ b/src/services/syntax/syntaxNodes.interfaces.generated.ts @@ -13,7 +13,7 @@ module TypeScript { } export interface ObjectTypeSyntax extends ISyntaxNode, ITypeSyntax { openBraceToken: ISyntaxToken; - typeMembers: ITypeMemberSyntax[]; + typeMembers: ISeparatedSyntaxList; closeBraceToken: ISyntaxToken; } export interface FunctionTypeSyntax extends ISyntaxNode, ITypeSyntax { @@ -44,7 +44,7 @@ module TypeScript { } export interface TupleTypeSyntax extends ISyntaxNode, ITypeSyntax { openBracketToken: ISyntaxToken; - types: ITypeSyntax[]; + types: ISeparatedSyntaxList; closeBracketToken: ISyntaxToken; } export interface UnionTypeSyntax extends ISyntaxNode, ITypeSyntax { @@ -97,7 +97,7 @@ module TypeScript { enumKeyword: ISyntaxToken; identifier: ISyntaxToken; openBraceToken: ISyntaxToken; - enumElements: EnumElementSyntax[]; + enumElements: ISeparatedSyntaxList; closeBraceToken: ISyntaxToken; } export interface ImportDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax { @@ -168,7 +168,7 @@ module TypeScript { } export interface IndexSignatureSyntax extends ISyntaxNode, ITypeMemberSyntax { openBracketToken: ISyntaxToken; - parameters: ParameterSyntax[]; + parameters: ISeparatedSyntaxList; closeBracketToken: ISyntaxToken; typeAnnotation: TypeAnnotationSyntax; } @@ -334,12 +334,12 @@ module TypeScript { } export interface ArrayLiteralExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { openBracketToken: ISyntaxToken; - expressions: IExpressionSyntax[]; + expressions: ISeparatedSyntaxList; closeBracketToken: ISyntaxToken; } export interface ObjectLiteralExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { openBraceToken: ISyntaxToken; - propertyAssignments: IPropertyAssignmentSyntax[]; + propertyAssignments: ISeparatedSyntaxList; closeBraceToken: ISyntaxToken; } export interface ObjectCreationExpressionSyntax extends ISyntaxNode, IPrimaryExpressionSyntax { @@ -386,7 +386,7 @@ module TypeScript { } export interface VariableDeclarationSyntax extends ISyntaxNode { varKeyword: ISyntaxToken; - variableDeclarators: VariableDeclaratorSyntax[]; + variableDeclarators: ISeparatedSyntaxList; } export interface VariableDeclaratorSyntax extends ISyntaxNode { propertyName: ISyntaxToken; @@ -396,27 +396,27 @@ module TypeScript { export interface ArgumentListSyntax extends ISyntaxNode { typeArgumentList: TypeArgumentListSyntax; openParenToken: ISyntaxToken; - arguments: IExpressionSyntax[]; + arguments: ISeparatedSyntaxList; closeParenToken: ISyntaxToken; } export interface ParameterListSyntax extends ISyntaxNode { openParenToken: ISyntaxToken; - parameters: ParameterSyntax[]; + parameters: ISeparatedSyntaxList; closeParenToken: ISyntaxToken; } export interface TypeArgumentListSyntax extends ISyntaxNode { lessThanToken: ISyntaxToken; - typeArguments: ITypeSyntax[]; + typeArguments: ISeparatedSyntaxList; greaterThanToken: ISyntaxToken; } export interface TypeParameterListSyntax extends ISyntaxNode { lessThanToken: ISyntaxToken; - typeParameters: TypeParameterSyntax[]; + typeParameters: ISeparatedSyntaxList; greaterThanToken: ISyntaxToken; } export interface HeritageClauseSyntax extends ISyntaxNode { extendsOrImplementsKeyword: ISyntaxToken; - typeNames: INameSyntax[]; + typeNames: ISeparatedSyntaxList; } export interface EqualsValueClauseSyntax extends ISyntaxNode { equalsToken: ISyntaxToken; @@ -492,100 +492,4 @@ module TypeScript { export interface ModuleNameModuleReferenceSyntax extends ISyntaxNode, IModuleReferenceSyntax { moduleName: INameSyntax; } - - export var nodeMetadata: string[][] = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],["moduleElements","endOfFileToken"],["left","dotToken","right"],["openBraceToken","typeMembers","closeBraceToken"],["typeParameterList","parameterList","equalsGreaterThanToken","type"],["type","openBracketToken","closeBracketToken"],["newKeyword","typeParameterList","parameterList","equalsGreaterThanToken","type"],["name","typeArgumentList"],["typeOfKeyword","name"],["openBracketToken","types","closeBracketToken"],["left","barToken","right"],["openParenToken","type","closeParenToken"],["modifiers","interfaceKeyword","identifier","typeParameterList","heritageClauses","body"],["modifiers","functionKeyword","identifier","callSignature","block","semicolonToken"],["modifiers","moduleKeyword","name","stringLiteral","openBraceToken","moduleElements","closeBraceToken"],["modifiers","classKeyword","identifier","typeParameterList","heritageClauses","openBraceToken","classElements","closeBraceToken"],["modifiers","enumKeyword","identifier","openBraceToken","enumElements","closeBraceToken"],["modifiers","importKeyword","identifier","equalsToken","moduleReference","semicolonToken"],["exportKeyword","equalsToken","identifier","semicolonToken"],["modifiers","propertyName","callSignature","block","semicolonToken"],["modifiers","variableDeclarator","semicolonToken"],["modifiers","constructorKeyword","callSignature","block","semicolonToken"],["modifiers","indexSignature","semicolonToken"],["modifiers","getKeyword","propertyName","callSignature","block"],["modifiers","setKeyword","propertyName","callSignature","block"],["propertyName","questionToken","typeAnnotation"],["typeParameterList","parameterList","typeAnnotation"],["newKeyword","callSignature"],["openBracketToken","parameters","closeBracketToken","typeAnnotation"],["propertyName","questionToken","callSignature"],["openBraceToken","statements","closeBraceToken"],["ifKeyword","openParenToken","condition","closeParenToken","statement","elseClause"],["modifiers","variableDeclaration","semicolonToken"],["expression","semicolonToken"],["returnKeyword","expression","semicolonToken"],["switchKeyword","openParenToken","expression","closeParenToken","openBraceToken","switchClauses","closeBraceToken"],["breakKeyword","identifier","semicolonToken"],["continueKeyword","identifier","semicolonToken"],["forKeyword","openParenToken","variableDeclaration","initializer","firstSemicolonToken","condition","secondSemicolonToken","incrementor","closeParenToken","statement"],["forKeyword","openParenToken","variableDeclaration","left","inKeyword","expression","closeParenToken","statement"],["semicolonToken"],["throwKeyword","expression","semicolonToken"],["whileKeyword","openParenToken","condition","closeParenToken","statement"],["tryKeyword","block","catchClause","finallyClause"],["identifier","colonToken","statement"],["doKeyword","statement","whileKeyword","openParenToken","condition","closeParenToken","semicolonToken"],["debuggerKeyword","semicolonToken"],["withKeyword","openParenToken","condition","closeParenToken","statement"],["operatorToken","operand"],["deleteKeyword","expression"],["typeOfKeyword","expression"],["voidKeyword","expression"],["condition","questionToken","whenTrue","colonToken","whenFalse"],["left","operatorToken","right"],["operand","operatorToken"],["expression","dotToken","name"],["expression","argumentList"],["openBracketToken","expressions","closeBracketToken"],["openBraceToken","propertyAssignments","closeBraceToken"],["newKeyword","expression","argumentList"],["openParenToken","expression","closeParenToken"],["callSignature","equalsGreaterThanToken","block","expression"],["parameter","equalsGreaterThanToken","block","expression"],["lessThanToken","type","greaterThanToken","expression"],["expression","openBracketToken","argumentExpression","closeBracketToken"],["functionKeyword","identifier","callSignature","block"],[],["varKeyword","variableDeclarators"],["propertyName","typeAnnotation","equalsValueClause"],["typeArgumentList","openParenToken","arguments","closeParenToken"],["openParenToken","parameters","closeParenToken"],["lessThanToken","typeArguments","greaterThanToken"],["lessThanToken","typeParameters","greaterThanToken"],["extendsOrImplementsKeyword","typeNames"],["equalsToken","value"],["caseKeyword","expression","colonToken","statements"],["defaultKeyword","colonToken","statements"],["elseKeyword","statement"],["catchKeyword","openParenToken","identifier","typeAnnotation","closeParenToken","block"],["finallyKeyword","block"],["identifier","constraint"],["extendsKeyword","typeOrExpression"],["propertyName","colonToken","expression"],["propertyName","callSignature","block"],["dotDotDotToken","modifiers","identifier","questionToken","typeAnnotation","equalsValueClause"],["propertyName","equalsValueClause"],["colonToken","type"],["requireKeyword","openParenToken","stringLiteral","closeParenToken"],["moduleName"],]; - - export module Syntax { - export interface ISyntaxFactory { - isConcrete: boolean; - SourceUnitSyntax: { new(data: number, moduleElements: IModuleElementSyntax[], endOfFileToken: ISyntaxToken): SourceUnitSyntax }; - QualifiedNameSyntax: { new(data: number, left: INameSyntax, dotToken: ISyntaxToken, right: ISyntaxToken): QualifiedNameSyntax }; - ObjectTypeSyntax: { new(data: number, openBraceToken: ISyntaxToken, typeMembers: ITypeMemberSyntax[], closeBraceToken: ISyntaxToken): ObjectTypeSyntax }; - FunctionTypeSyntax: { new(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax): FunctionTypeSyntax }; - ArrayTypeSyntax: { new(data: number, type: ITypeSyntax, openBracketToken: ISyntaxToken, closeBracketToken: ISyntaxToken): ArrayTypeSyntax }; - ConstructorTypeSyntax: { new(data: number, newKeyword: ISyntaxToken, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, equalsGreaterThanToken: ISyntaxToken, type: ITypeSyntax): ConstructorTypeSyntax }; - GenericTypeSyntax: { new(data: number, name: INameSyntax, typeArgumentList: TypeArgumentListSyntax): GenericTypeSyntax }; - TypeQuerySyntax: { new(data: number, typeOfKeyword: ISyntaxToken, name: INameSyntax): TypeQuerySyntax }; - TupleTypeSyntax: { new(data: number, openBracketToken: ISyntaxToken, types: ITypeSyntax[], closeBracketToken: ISyntaxToken): TupleTypeSyntax }; - UnionTypeSyntax: { new(data: number, left: ITypeSyntax, barToken: ISyntaxToken, right: ITypeSyntax): UnionTypeSyntax }; - ParenthesizedTypeSyntax: { new(data: number, openParenToken: ISyntaxToken, type: ITypeSyntax, closeParenToken: ISyntaxToken): ParenthesizedTypeSyntax }; - InterfaceDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], interfaceKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], body: ObjectTypeSyntax): InterfaceDeclarationSyntax }; - FunctionDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): FunctionDeclarationSyntax }; - ModuleDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken): ModuleDeclarationSyntax }; - ClassDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], classKeyword: ISyntaxToken, identifier: ISyntaxToken, typeParameterList: TypeParameterListSyntax, heritageClauses: HeritageClauseSyntax[], openBraceToken: ISyntaxToken, classElements: IClassElementSyntax[], closeBraceToken: ISyntaxToken): ClassDeclarationSyntax }; - EnumDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], enumKeyword: ISyntaxToken, identifier: ISyntaxToken, openBraceToken: ISyntaxToken, enumElements: EnumElementSyntax[], closeBraceToken: ISyntaxToken): EnumDeclarationSyntax }; - ImportDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], importKeyword: ISyntaxToken, identifier: ISyntaxToken, equalsToken: ISyntaxToken, moduleReference: IModuleReferenceSyntax, semicolonToken: ISyntaxToken): ImportDeclarationSyntax }; - ExportAssignmentSyntax: { new(data: number, exportKeyword: ISyntaxToken, equalsToken: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): ExportAssignmentSyntax }; - MemberFunctionDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): MemberFunctionDeclarationSyntax }; - MemberVariableDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], variableDeclarator: VariableDeclaratorSyntax, semicolonToken: ISyntaxToken): MemberVariableDeclarationSyntax }; - ConstructorDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): ConstructorDeclarationSyntax }; - IndexMemberDeclarationSyntax: { new(data: number, modifiers: ISyntaxToken[], indexSignature: IndexSignatureSyntax, semicolonToken: ISyntaxToken): IndexMemberDeclarationSyntax }; - GetAccessorSyntax: { new(data: number, modifiers: ISyntaxToken[], getKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): GetAccessorSyntax }; - SetAccessorSyntax: { new(data: number, modifiers: ISyntaxToken[], setKeyword: ISyntaxToken, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): SetAccessorSyntax }; - PropertySignatureSyntax: { new(data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax): PropertySignatureSyntax }; - CallSignatureSyntax: { new(data: number, typeParameterList: TypeParameterListSyntax, parameterList: ParameterListSyntax, typeAnnotation: TypeAnnotationSyntax): CallSignatureSyntax }; - ConstructSignatureSyntax: { new(data: number, newKeyword: ISyntaxToken, callSignature: CallSignatureSyntax): ConstructSignatureSyntax }; - IndexSignatureSyntax: { new(data: number, openBracketToken: ISyntaxToken, parameters: ParameterSyntax[], closeBracketToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax): IndexSignatureSyntax }; - MethodSignatureSyntax: { new(data: number, propertyName: ISyntaxToken, questionToken: ISyntaxToken, callSignature: CallSignatureSyntax): MethodSignatureSyntax }; - BlockSyntax: { new(data: number, openBraceToken: ISyntaxToken, statements: IStatementSyntax[], closeBraceToken: ISyntaxToken): BlockSyntax }; - IfStatementSyntax: { new(data: number, ifKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax, elseClause: ElseClauseSyntax): IfStatementSyntax }; - VariableStatementSyntax: { new(data: number, modifiers: ISyntaxToken[], variableDeclaration: VariableDeclarationSyntax, semicolonToken: ISyntaxToken): VariableStatementSyntax }; - ExpressionStatementSyntax: { new(data: number, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ExpressionStatementSyntax }; - ReturnStatementSyntax: { new(data: number, returnKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ReturnStatementSyntax }; - SwitchStatementSyntax: { new(data: number, switchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, openBraceToken: ISyntaxToken, switchClauses: ISwitchClauseSyntax[], closeBraceToken: ISyntaxToken): SwitchStatementSyntax }; - BreakStatementSyntax: { new(data: number, breakKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): BreakStatementSyntax }; - ContinueStatementSyntax: { new(data: number, continueKeyword: ISyntaxToken, identifier: ISyntaxToken, semicolonToken: ISyntaxToken): ContinueStatementSyntax }; - ForStatementSyntax: { new(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForStatementSyntax }; - ForInStatementSyntax: { new(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForInStatementSyntax }; - EmptyStatementSyntax: { new(data: number, semicolonToken: ISyntaxToken): EmptyStatementSyntax }; - ThrowStatementSyntax: { new(data: number, throwKeyword: ISyntaxToken, expression: IExpressionSyntax, semicolonToken: ISyntaxToken): ThrowStatementSyntax }; - WhileStatementSyntax: { new(data: number, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): WhileStatementSyntax }; - TryStatementSyntax: { new(data: number, tryKeyword: ISyntaxToken, block: BlockSyntax, catchClause: CatchClauseSyntax, finallyClause: FinallyClauseSyntax): TryStatementSyntax }; - LabeledStatementSyntax: { new(data: number, identifier: ISyntaxToken, colonToken: ISyntaxToken, statement: IStatementSyntax): LabeledStatementSyntax }; - DoStatementSyntax: { new(data: number, doKeyword: ISyntaxToken, statement: IStatementSyntax, whileKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, semicolonToken: ISyntaxToken): DoStatementSyntax }; - DebuggerStatementSyntax: { new(data: number, debuggerKeyword: ISyntaxToken, semicolonToken: ISyntaxToken): DebuggerStatementSyntax }; - WithStatementSyntax: { new(data: number, withKeyword: ISyntaxToken, openParenToken: ISyntaxToken, condition: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): WithStatementSyntax }; - PrefixUnaryExpressionSyntax: { new(data: number, operatorToken: ISyntaxToken, operand: IUnaryExpressionSyntax): PrefixUnaryExpressionSyntax }; - DeleteExpressionSyntax: { new(data: number, deleteKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): DeleteExpressionSyntax }; - TypeOfExpressionSyntax: { new(data: number, typeOfKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): TypeOfExpressionSyntax }; - VoidExpressionSyntax: { new(data: number, voidKeyword: ISyntaxToken, expression: IUnaryExpressionSyntax): VoidExpressionSyntax }; - ConditionalExpressionSyntax: { new(data: number, condition: IExpressionSyntax, questionToken: ISyntaxToken, whenTrue: IExpressionSyntax, colonToken: ISyntaxToken, whenFalse: IExpressionSyntax): ConditionalExpressionSyntax }; - BinaryExpressionSyntax: { new(data: number, left: IExpressionSyntax, operatorToken: ISyntaxToken, right: IExpressionSyntax): BinaryExpressionSyntax }; - PostfixUnaryExpressionSyntax: { new(data: number, operand: ILeftHandSideExpressionSyntax, operatorToken: ISyntaxToken): PostfixUnaryExpressionSyntax }; - MemberAccessExpressionSyntax: { new(data: number, expression: ILeftHandSideExpressionSyntax, dotToken: ISyntaxToken, name: ISyntaxToken): MemberAccessExpressionSyntax }; - InvocationExpressionSyntax: { new(data: number, expression: ILeftHandSideExpressionSyntax, argumentList: ArgumentListSyntax): InvocationExpressionSyntax }; - ArrayLiteralExpressionSyntax: { new(data: number, openBracketToken: ISyntaxToken, expressions: IExpressionSyntax[], closeBracketToken: ISyntaxToken): ArrayLiteralExpressionSyntax }; - ObjectLiteralExpressionSyntax: { new(data: number, openBraceToken: ISyntaxToken, propertyAssignments: IPropertyAssignmentSyntax[], closeBraceToken: ISyntaxToken): ObjectLiteralExpressionSyntax }; - ObjectCreationExpressionSyntax: { new(data: number, newKeyword: ISyntaxToken, expression: IMemberExpressionSyntax, argumentList: ArgumentListSyntax): ObjectCreationExpressionSyntax }; - ParenthesizedExpressionSyntax: { new(data: number, openParenToken: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken): ParenthesizedExpressionSyntax }; - ParenthesizedArrowFunctionExpressionSyntax: { new(data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax): ParenthesizedArrowFunctionExpressionSyntax }; - SimpleArrowFunctionExpressionSyntax: { new(data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax): SimpleArrowFunctionExpressionSyntax }; - CastExpressionSyntax: { new(data: number, lessThanToken: ISyntaxToken, type: ITypeSyntax, greaterThanToken: ISyntaxToken, expression: IUnaryExpressionSyntax): CastExpressionSyntax }; - ElementAccessExpressionSyntax: { new(data: number, expression: ILeftHandSideExpressionSyntax, openBracketToken: ISyntaxToken, argumentExpression: IExpressionSyntax, closeBracketToken: ISyntaxToken): ElementAccessExpressionSyntax }; - FunctionExpressionSyntax: { new(data: number, functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionExpressionSyntax }; - OmittedExpressionSyntax: { new(data: number): OmittedExpressionSyntax }; - VariableDeclarationSyntax: { new(data: number, varKeyword: ISyntaxToken, variableDeclarators: VariableDeclaratorSyntax[]): VariableDeclarationSyntax }; - VariableDeclaratorSyntax: { new(data: number, propertyName: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): VariableDeclaratorSyntax }; - ArgumentListSyntax: { new(data: number, typeArgumentList: TypeArgumentListSyntax, openParenToken: ISyntaxToken, arguments: IExpressionSyntax[], closeParenToken: ISyntaxToken): ArgumentListSyntax }; - ParameterListSyntax: { new(data: number, openParenToken: ISyntaxToken, parameters: ParameterSyntax[], closeParenToken: ISyntaxToken): ParameterListSyntax }; - TypeArgumentListSyntax: { new(data: number, lessThanToken: ISyntaxToken, typeArguments: ITypeSyntax[], greaterThanToken: ISyntaxToken): TypeArgumentListSyntax }; - TypeParameterListSyntax: { new(data: number, lessThanToken: ISyntaxToken, typeParameters: TypeParameterSyntax[], greaterThanToken: ISyntaxToken): TypeParameterListSyntax }; - HeritageClauseSyntax: { new(data: number, extendsOrImplementsKeyword: ISyntaxToken, typeNames: INameSyntax[]): HeritageClauseSyntax }; - EqualsValueClauseSyntax: { new(data: number, equalsToken: ISyntaxToken, value: IExpressionSyntax): EqualsValueClauseSyntax }; - CaseSwitchClauseSyntax: { new(data: number, caseKeyword: ISyntaxToken, expression: IExpressionSyntax, colonToken: ISyntaxToken, statements: IStatementSyntax[]): CaseSwitchClauseSyntax }; - DefaultSwitchClauseSyntax: { new(data: number, defaultKeyword: ISyntaxToken, colonToken: ISyntaxToken, statements: IStatementSyntax[]): DefaultSwitchClauseSyntax }; - ElseClauseSyntax: { new(data: number, elseKeyword: ISyntaxToken, statement: IStatementSyntax): ElseClauseSyntax }; - CatchClauseSyntax: { new(data: number, catchKeyword: ISyntaxToken, openParenToken: ISyntaxToken, identifier: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, closeParenToken: ISyntaxToken, block: BlockSyntax): CatchClauseSyntax }; - FinallyClauseSyntax: { new(data: number, finallyKeyword: ISyntaxToken, block: BlockSyntax): FinallyClauseSyntax }; - TypeParameterSyntax: { new(data: number, identifier: ISyntaxToken, constraint: ConstraintSyntax): TypeParameterSyntax }; - ConstraintSyntax: { new(data: number, extendsKeyword: ISyntaxToken, typeOrExpression: ISyntaxNodeOrToken): ConstraintSyntax }; - SimplePropertyAssignmentSyntax: { new(data: number, propertyName: ISyntaxToken, colonToken: ISyntaxToken, expression: IExpressionSyntax): SimplePropertyAssignmentSyntax }; - FunctionPropertyAssignmentSyntax: { new(data: number, propertyName: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax): FunctionPropertyAssignmentSyntax }; - ParameterSyntax: { new(data: number, dotDotDotToken: ISyntaxToken, modifiers: ISyntaxToken[], identifier: ISyntaxToken, questionToken: ISyntaxToken, typeAnnotation: TypeAnnotationSyntax, equalsValueClause: EqualsValueClauseSyntax): ParameterSyntax }; - EnumElementSyntax: { new(data: number, propertyName: ISyntaxToken, equalsValueClause: EqualsValueClauseSyntax): EnumElementSyntax }; - TypeAnnotationSyntax: { new(data: number, colonToken: ISyntaxToken, type: ITypeSyntax): TypeAnnotationSyntax }; - ExternalModuleReferenceSyntax: { new(data: number, requireKeyword: ISyntaxToken, openParenToken: ISyntaxToken, stringLiteral: ISyntaxToken, closeParenToken: ISyntaxToken): ExternalModuleReferenceSyntax }; - ModuleNameModuleReferenceSyntax: { new(data: number, moduleName: INameSyntax): ModuleNameModuleReferenceSyntax }; - } - } } \ No newline at end of file diff --git a/src/services/syntax/syntaxToken.ts b/src/services/syntax/syntaxToken.ts index 857ffde59c0..12d543103a0 100644 --- a/src/services/syntax/syntaxToken.ts +++ b/src/services/syntax/syntaxToken.ts @@ -74,7 +74,7 @@ module TypeScript { return undefined; } - var kind = token.kind(); + var kind = token.kind; var text = token.text(); if (kind === SyntaxKind.IdentifierName) { @@ -98,15 +98,23 @@ module TypeScript { return IntegerUtilities.isHexInteger(text) ? parseInt(text, /*radix:*/ 16) : parseFloat(text); } else if (kind === SyntaxKind.StringLiteral) { - if (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) { - // Properly terminated. Remove the quotes, and massage any escape characters we see. - return massageEscapes(text.substr(1, text.length - 2)); - } - else { - // Not property terminated. Remove the first quote and massage any escape characters we see. - return massageEscapes(text.substr(1)); - - } + return (text.length > 1 && text.charCodeAt(text.length - 1) === text.charCodeAt(0)) + ? massageEscapes(text.substr(1, text.length - "''".length)) + : massageEscapes(text.substr(1)); + } + else if (kind === SyntaxKind.NoSubstitutionTemplateToken || kind === SyntaxKind.TemplateEndToken) { + // Both of these template types may be missing their closing backtick (if they were at + // the end of the file). Check to make sure it is there before grabbing the portion + // we're examining. + return (text.length > 1 && text.charCodeAt(text.length - 1) === CharacterCodes.backtick) + ? massageTemplate(text.substr(1, text.length - "``".length)) + : massageTemplate(text.substr(1)); + } + else if (kind === SyntaxKind.TemplateStartToken || kind === SyntaxKind.TemplateMiddleToken) { + // Both these tokens must have been properly ended. i.e. if it didn't end with a ${ + // then we would not have parsed a start or middle token out at all. So we don't + // need to check for an incomplete token. + return massageTemplate(text.substr(1, text.length - "`${".length)); } else if (kind === SyntaxKind.RegularExpressionLiteral) { return regularExpressionValue(text); @@ -124,6 +132,18 @@ module TypeScript { return value === undefined ? "" : massageDisallowedIdentifiers(value.toString()); } + function massageTemplate(text: string): string { + // First, convert all carriage-return newlines into line-feed newlines. This is due to: + // + // The TRV of LineTerminatorSequence :: is the code unit value 0x000A. + // ... + // The TRV of LineTerminatorSequence :: is the sequence consisting of the code unit value 0x000A. + text = text.replace("\r\n", "\n").replace("\r", "\n"); + + // Now remove any escape characters that may be in the string. + return massageEscapes(text); + } + export function massageEscapes(text: string): string { return text.indexOf("\\") >= 0 ? convertEscapes(text) : text; } @@ -264,7 +284,7 @@ module TypeScript { module TypeScript.Syntax { export function realizeToken(token: ISyntaxToken, text: ISimpleText): ISyntaxToken { - return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), token.trailingTrivia(text)); + return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), token.trailingTrivia(text)); } export function convertKeywordToIdentifier(token: ISyntaxToken): ISyntaxToken { @@ -272,11 +292,11 @@ module TypeScript.Syntax { } export function withLeadingTrivia(token: ISyntaxToken, leadingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken { - return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text(), token.trailingTrivia(text)); + return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text(), token.trailingTrivia(text)); } export function withTrailingTrivia(token: ISyntaxToken, trailingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken { - return new RealizedToken(token.fullStart(), token.kind(), token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), trailingTrivia); + return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), trailingTrivia); } export function emptyToken(kind: SyntaxKind): ISyntaxToken { @@ -284,21 +304,22 @@ module TypeScript.Syntax { } class EmptyToken implements ISyntaxToken { - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; + public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any; + public parent: ISyntaxElement; - constructor(private _kind: SyntaxKind) { + constructor(public kind: SyntaxKind) { } public setFullStart(fullStart: number): void { // An empty token is always at the -1 position. } - public kind(): SyntaxKind { - return this._kind; - } + public childCount() { return 0 } + public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() } + public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) } public clone(): ISyntaxToken { - return new EmptyToken(this.kind()); + return new EmptyToken(this.kind); } // Empty tokens are never incrementally reusable. @@ -338,7 +359,7 @@ module TypeScript.Syntax { while (true) { var parent = current.parent; if (parent === undefined) { - Debug.assert(current.kind() === SyntaxKind.SourceUnit, "We had a node without a parent that was not the root node!"); + Debug.assert(current.kind === SyntaxKind.SourceUnit, "We had a node without a parent that was not the root node!"); // We walked all the way to the top, and never found a previous element. This // can happen with code like: @@ -397,22 +418,21 @@ module TypeScript.Syntax { class RealizedToken implements ISyntaxToken { private _fullStart: number; - private _kind: SyntaxKind; private _isKeywordConvertedToIdentifier: boolean; private _leadingTrivia: ISyntaxTriviaList; private _text: string; private _trailingTrivia: ISyntaxTriviaList; - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; + public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any; + public parent: ISyntaxElement; constructor(fullStart: number, - kind: SyntaxKind, + public kind: SyntaxKind, isKeywordConvertedToIdentifier: boolean, leadingTrivia: ISyntaxTriviaList, text: string, trailingTrivia: ISyntaxTriviaList) { this._fullStart = fullStart; - this._kind = kind; this._isKeywordConvertedToIdentifier = isKeywordConvertedToIdentifier; this._text = text; @@ -432,12 +452,12 @@ module TypeScript.Syntax { this._fullStart = fullStart; } - public kind(): SyntaxKind { - return this._kind; - } + public childCount() { return 0 } + public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() } + public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) } public clone(): ISyntaxToken { - return new RealizedToken(this._fullStart, this.kind(), this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text, this._trailingTrivia); + return new RealizedToken(this._fullStart, this.kind, this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text, this._trailingTrivia); } // Realized tokens are created from the parser. They are *never* incrementally reusable. @@ -468,19 +488,21 @@ module TypeScript.Syntax { } class ConvertedKeywordToken implements ISyntaxToken { - public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; + public _primaryExpressionBrand: any; public _memberExpressionBrand: any; public _leftHandSideExpressionBrand: any; public _postfixExpressionBrand: any; public _unaryExpressionBrand: any; public _expressionBrand: any; public _typeBrand: any; public _syntaxNodeOrTokenBrand: any; + public parent: ISyntaxElement; + public kind: SyntaxKind; constructor(private underlyingToken: ISyntaxToken) { } - public kind() { - return SyntaxKind.IdentifierName; - } - public setFullStart(fullStart: number): void { this.underlyingToken.setFullStart(fullStart); } + public childCount() { return 0 } + public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() } + public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) } + public fullStart(): number { return this.underlyingToken.fullStart(); } @@ -559,4 +581,5 @@ module TypeScript.Syntax { return new ConvertedKeywordToken(this.underlyingToken); } } + ConvertedKeywordToken.prototype.kind = SyntaxKind.IdentifierName; } \ No newline at end of file diff --git a/src/services/syntax/syntaxTree.ts b/src/services/syntax/syntaxTree.ts index 30aa3d7e979..a61d3707a46 100644 --- a/src/services/syntax/syntaxTree.ts +++ b/src/services/syntax/syntaxTree.ts @@ -4,7 +4,6 @@ module TypeScript { export var syntaxDiagnosticsTime: number = 0; export class SyntaxTree { - private _isConcrete: boolean; private _sourceUnit: SourceUnitSyntax; private _isDeclaration: boolean; private _parserDiagnostics: Diagnostic[]; @@ -17,14 +16,12 @@ module TypeScript { private _amdDependencies: string[]; private _isExternalModule: boolean; - constructor(isConcrete: boolean, - sourceUnit: SourceUnitSyntax, + constructor(sourceUnit: SourceUnitSyntax, isDeclaration: boolean, diagnostics: Diagnostic[], fileName: string, public text: ISimpleText, languageVersion: ts.ScriptTarget) { - this._isConcrete = isConcrete; this._sourceUnit = sourceUnit; this._isDeclaration = isDeclaration; this._parserDiagnostics = diagnostics; @@ -35,10 +32,6 @@ module TypeScript { sourceUnit.syntaxTree = this; } - public isConcrete(): boolean { - return this._isConcrete; - } - public sourceUnit(): SourceUnitSyntax { return this._sourceUnit; } @@ -169,10 +162,10 @@ module TypeScript { private checkParameterListOrder(node: ParameterListSyntax): boolean { var seenOptionalParameter = false; - var parameterCount = node.parameters.length; + var parameterCount = nonSeparatorCount(node.parameters); for (var i = 0; i < parameterCount; i++) { - var parameter = node.parameters[i]; + var parameter = nonSeparatorAt(node.parameters, i); if (parameter.dotDotDotToken) { if (i !== (parameterCount - 1)) { @@ -210,8 +203,8 @@ module TypeScript { } private checkParameterListAcessibilityModifiers(node: ParameterListSyntax): boolean { - for (var i = 0, n = node.parameters.length; i < n; i++) { - var parameter = node.parameters[i]; + for (var i = 0, n = nonSeparatorCount(node.parameters); i < n; i++) { + var parameter = nonSeparatorAt(node.parameters, i); if (this.checkParameterAccessibilityModifiers(node, parameter)) { return true; @@ -238,7 +231,7 @@ module TypeScript { } private checkParameterAccessibilityModifier(parameterList: ParameterListSyntax, modifier: ISyntaxToken, modifierIndex: number): boolean { - if (!SyntaxFacts.isAccessibilityModifier(modifier.kind())) { + if (!SyntaxFacts.isAccessibilityModifier(modifier.kind)) { this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_cannot_appear_on_a_parameter, [modifier.text()]); return true; } @@ -255,17 +248,17 @@ module TypeScript { private checkForTrailingComma(list: ISyntaxNodeOrToken[]): boolean { // If we have at least one child, and we have an even number of children, then that // means we have an illegal trailing separator. - if (childCount(list) === 0 || childCount(list) % 2 === 1) { + if (list.length === 0 || list.length % 2 === 1) { return false; } - var child = childAt(list, childCount(list) - 1); + var child = list[list.length - 1]; this.pushDiagnostic(child, DiagnosticCode.Trailing_comma_not_allowed); return true; } - private checkForAtLeastOneElement(parent: ISyntaxElement, list: ISyntaxNodeOrToken[], reportToken: ISyntaxToken, listKind: string): boolean { + private checkForAtLeastOneElement(list: ISyntaxNodeOrToken[], reportToken: ISyntaxToken, listKind: string): boolean { if (childCount(list) > 0) { return false; } @@ -287,7 +280,7 @@ module TypeScript { public visitHeritageClause(node: HeritageClauseSyntax): void { if (this.checkForTrailingComma(node.typeNames) || - this.checkForAtLeastOneElement(node, node.typeNames, node.extendsOrImplementsKeyword, SyntaxFacts.getText(node.extendsOrImplementsKeyword.kind()))) { + this.checkForAtLeastOneElement(node.typeNames, node.extendsOrImplementsKeyword, SyntaxFacts.getText(node.extendsOrImplementsKeyword.kind))) { return; } @@ -303,7 +296,7 @@ module TypeScript { } public visitVariableDeclaration(node: VariableDeclarationSyntax): void { - if (this.checkForAtLeastOneElement(node, node.variableDeclarators, node.varKeyword, getLocalizedText(DiagnosticCode.variable_declaration, undefined)) || + if (this.checkForAtLeastOneElement(node.variableDeclarators, node.varKeyword, getLocalizedText(DiagnosticCode.variable_declaration, undefined)) || this.checkForTrailingComma(node.variableDeclarators)) { return; } @@ -313,7 +306,7 @@ module TypeScript { public visitTypeArgumentList(node: TypeArgumentListSyntax): void { if (this.checkForTrailingComma(node.typeArguments) || - this.checkForAtLeastOneElement(node, node.typeArguments, node.lessThanToken, getLocalizedText(DiagnosticCode.type_argument, undefined))) { + this.checkForAtLeastOneElement(node.typeArguments, node.lessThanToken, getLocalizedText(DiagnosticCode.type_argument, undefined))) { return; } @@ -322,7 +315,7 @@ module TypeScript { public visitTupleType(node: TupleTypeSyntax): void { if (this.checkForTrailingComma(node.types) || - this.checkForAtLeastOneElement(node, node.types, node.openBracketToken, getLocalizedText(DiagnosticCode.type, undefined))) { + this.checkForAtLeastOneElement(node.types, node.openBracketToken, getLocalizedText(DiagnosticCode.type, undefined))) { return } @@ -331,7 +324,7 @@ module TypeScript { public visitTypeParameterList(node: TypeParameterListSyntax): void { if (this.checkForTrailingComma(node.typeParameters) || - this.checkForAtLeastOneElement(node, node.typeParameters, node.lessThanToken, getLocalizedText(DiagnosticCode.type_parameter, undefined))) { + this.checkForAtLeastOneElement(node.typeParameters, node.lessThanToken, getLocalizedText(DiagnosticCode.type_parameter, undefined))) { return; } @@ -344,7 +337,7 @@ module TypeScript { return true; } - var parameter = node.parameters[0]; + var parameter = nonSeparatorAt(node.parameters, 0); if (parameter.dotDotDotToken) { this.pushDiagnostic(parameter, DiagnosticCode.Index_signatures_cannot_have_rest_parameters); @@ -366,8 +359,8 @@ module TypeScript { this.pushDiagnostic(parameter, DiagnosticCode.Index_signature_parameter_must_have_a_type_annotation); return true; } - else if (parameter.typeAnnotation.type.kind() !== SyntaxKind.StringKeyword && - parameter.typeAnnotation.type.kind() !== SyntaxKind.NumberKeyword) { + else if (parameter.typeAnnotation.type.kind !== SyntaxKind.StringKeyword && + parameter.typeAnnotation.type.kind !== SyntaxKind.NumberKeyword) { this.pushDiagnostic(parameter, DiagnosticCode.Index_signature_parameter_type_must_be_string_or_number); return true; } @@ -396,7 +389,7 @@ module TypeScript { Debug.assert(i <= 2); var heritageClause = node.heritageClauses[i]; - if (heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ExtendsKeyword) { + if (heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ExtendsKeyword) { if (seenExtendsClause) { this.pushDiagnostic(heritageClause, DiagnosticCode.extends_clause_already_seen); return true; @@ -407,7 +400,7 @@ module TypeScript { return true; } - if (heritageClause.typeNames.length > 1) { + if (nonSeparatorCount(heritageClause.typeNames) > 1) { this.pushDiagnostic(heritageClause, DiagnosticCode.Classes_can_only_extend_a_single_class); return true; } @@ -415,7 +408,7 @@ module TypeScript { seenExtendsClause = true; } else { - Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ImplementsKeyword); + Debug.assert(heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ImplementsKeyword); if (seenImplementsClause) { this.pushDiagnostic(heritageClause, DiagnosticCode.implements_clause_already_seen); return true; @@ -475,7 +468,7 @@ module TypeScript { Debug.assert(i <= 1); var heritageClause = node.heritageClauses[i]; - if (heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ExtendsKeyword) { + if (heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ExtendsKeyword) { if (seenExtendsClause) { this.pushDiagnostic(heritageClause, DiagnosticCode.extends_clause_already_seen); return true; @@ -484,7 +477,7 @@ module TypeScript { seenExtendsClause = true; } else { - Debug.assert(heritageClause.extendsOrImplementsKeyword.kind() === SyntaxKind.ImplementsKeyword); + Debug.assert(heritageClause.extendsOrImplementsKeyword.kind === SyntaxKind.ImplementsKeyword); this.pushDiagnostic(heritageClause, DiagnosticCode.Interface_declaration_cannot_have_implements_clause); return true; } @@ -496,7 +489,7 @@ module TypeScript { private checkInterfaceModifiers(modifiers: ISyntaxToken[]): boolean { for (var i = 0, n = modifiers.length; i < n; i++) { var modifier = modifiers[i]; - if (modifier.kind() === SyntaxKind.DeclareKeyword) { + if (modifier.kind === SyntaxKind.DeclareKeyword) { this.pushDiagnostic(modifier, DiagnosticCode.A_declare_modifier_cannot_be_used_with_an_interface_declaration); return true; @@ -523,7 +516,7 @@ module TypeScript { for (var i = 0, n = list.length; i < n; i++) { var modifier = list[i]; - if (SyntaxFacts.isAccessibilityModifier(modifier.kind())) { + if (SyntaxFacts.isAccessibilityModifier(modifier.kind)) { if (seenAccessibilityModifier) { this.pushDiagnostic(modifier, DiagnosticCode.Accessibility_modifier_already_seen); return true; @@ -537,7 +530,7 @@ module TypeScript { seenAccessibilityModifier = true; } - else if (modifier.kind() === SyntaxKind.StaticKeyword) { + else if (modifier.kind === SyntaxKind.StaticKeyword) { if (seenStaticModifier) { this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_already_seen, [modifier.text()]); return true; @@ -562,8 +555,25 @@ module TypeScript { super.visitMemberVariableDeclaration(node); } + public visitMethodSignature(node: MethodSignatureSyntax): void { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + + super.visitMethodSignature(node); + } + + public visitPropertySignature(node: PropertySignatureSyntax): void { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + + super.visitPropertySignature(node); + } + public visitMemberFunctionDeclaration(node: MemberFunctionDeclarationSyntax): void { - if (this.checkClassElementModifiers(node.modifiers)) { + if (this.checkClassElementModifiers(node.modifiers) || + this.checkForTemplatePropertyName(node.propertyName)) { return; } @@ -589,14 +599,14 @@ module TypeScript { private checkIndexMemberModifiers(node: IndexMemberDeclarationSyntax): boolean { if (node.modifiers.length > 0) { - this.pushDiagnostic(childAt(node.modifiers, 0), DiagnosticCode.Modifiers_cannot_appear_here); + this.pushDiagnostic(node.modifiers[0], DiagnosticCode.Modifiers_cannot_appear_here); return true; } return false; } - private checkEcmaScriptVersionIsAtLeast(parent: ISyntaxElement, reportToken: ISyntaxToken, languageVersion: ts.ScriptTarget, diagnosticKey: string): boolean { + private checkEcmaScriptVersionIsAtLeast(reportToken: ISyntaxToken, languageVersion: ts.ScriptTarget, diagnosticKey: string): boolean { if (this.syntaxTree.languageVersion() < languageVersion) { this.pushDiagnostic(reportToken, diagnosticKey); return true; @@ -614,11 +624,12 @@ module TypeScript { public visitGetAccessor(node: GetAccessorSyntax): void { if (this.checkForAccessorDeclarationInAmbientContext(node) || - this.checkEcmaScriptVersionIsAtLeast(node, node.propertyName, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || - this.checkForDisallowedModifiers(node, node.modifiers) || + this.checkEcmaScriptVersionIsAtLeast(node.propertyName, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || + this.checkForDisallowedModifiers(node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkForDisallowedAccessorTypeParameters(node.callSignature) || - this.checkGetAccessorParameter(node)) { + this.checkGetAccessorParameter(node) || + this.checkForTemplatePropertyName(node.propertyName)) { return; } @@ -654,12 +665,12 @@ module TypeScript { private checkSetAccessorParameter(node: SetAccessorSyntax): boolean { var parameters = node.callSignature.parameterList.parameters; - if (childCount(parameters) !== 1) { + if (nonSeparatorCount(parameters) !== 1) { this.pushDiagnostic(node.propertyName, DiagnosticCode.set_accessor_must_have_exactly_one_parameter); return true; } - var parameter = parameters[0]; + var parameter = nonSeparatorAt(parameters, 0); if (parameter.questionToken) { this.pushDiagnostic(parameter, DiagnosticCode.set_accessor_parameter_cannot_be_optional); @@ -679,14 +690,23 @@ module TypeScript { return false; } + public visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): void { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + + super.visitSimplePropertyAssignment(node); + } + public visitSetAccessor(node: SetAccessorSyntax): void { if (this.checkForAccessorDeclarationInAmbientContext(node) || - this.checkEcmaScriptVersionIsAtLeast(node, node.propertyName, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || - this.checkForDisallowedModifiers(node, node.modifiers) || + this.checkEcmaScriptVersionIsAtLeast(node.propertyName, ts.ScriptTarget.ES5, DiagnosticCode.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher) || + this.checkForDisallowedModifiers(node.modifiers) || this.checkClassElementModifiers(node.modifiers) || this.checkForDisallowedAccessorTypeParameters(node.callSignature) || this.checkForDisallowedSetAccessorTypeAnnotation(node) || - this.checkSetAccessorParameter(node)) { + this.checkSetAccessorParameter(node) || + this.checkForTemplatePropertyName(node.propertyName)) { return; } @@ -710,28 +730,27 @@ module TypeScript { private checkEnumElements(node: EnumDeclarationSyntax): boolean { var previousValueWasComputed = false; - for (var i = 0, n = childCount(node.enumElements); i < n; i++) { - var child = childAt(node.enumElements, i); + for (var i = 0, n = nonSeparatorCount(node.enumElements); i < n; i++) { + var enumElement = nonSeparatorAt(node.enumElements, i); - if (i % 2 === 0) { - var enumElement = child; + if (!enumElement.equalsValueClause && previousValueWasComputed) { + this.pushDiagnostic(enumElement, DiagnosticCode.Enum_member_must_have_initializer); + return true; + } - if (!enumElement.equalsValueClause && previousValueWasComputed) { - this.pushDiagnostic(enumElement, DiagnosticCode.Enum_member_must_have_initializer); - return true; - } - - if (enumElement.equalsValueClause) { - var value = enumElement.equalsValueClause.value; - previousValueWasComputed = !Syntax.isIntegerLiteral(value); - } + if (enumElement.equalsValueClause) { + var value = enumElement.equalsValueClause.value; + previousValueWasComputed = !Syntax.isIntegerLiteral(value); } } - return false; } public visitEnumElement(node: EnumElementSyntax): void { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + if (this.inAmbientDeclaration && node.equalsValueClause) { var expression = node.equalsValueClause.value; if (!Syntax.isIntegerLiteral(expression)) { @@ -744,7 +763,7 @@ module TypeScript { } public visitInvocationExpression(node: InvocationExpressionSyntax): void { - if (node.expression.kind() === SyntaxKind.SuperKeyword && + if (node.expression.kind === SyntaxKind.SuperKeyword && node.argumentList.typeArgumentList) { this.pushDiagnostic(node, DiagnosticCode.super_invocation_cannot_have_type_arguments); } @@ -758,13 +777,13 @@ module TypeScript { for (var i = 0, n = modifiers.length; i < n; i++) { var modifier = modifiers[i]; - if (SyntaxFacts.isAccessibilityModifier(modifier.kind()) || - modifier.kind() === SyntaxKind.StaticKeyword) { + if (SyntaxFacts.isAccessibilityModifier(modifier.kind) || + modifier.kind === SyntaxKind.StaticKeyword) { this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_cannot_appear_on_a_module_element, [modifier.text()]); return true; } - if (modifier.kind() === SyntaxKind.DeclareKeyword) { + if (modifier.kind === SyntaxKind.DeclareKeyword) { if (seenDeclareModifier) { this.pushDiagnostic(modifier, DiagnosticCode.Accessibility_modifier_already_seen); return; @@ -772,7 +791,7 @@ module TypeScript { seenDeclareModifier = true; } - else if (modifier.kind() === SyntaxKind.ExportKeyword) { + else if (modifier.kind === SyntaxKind.ExportKeyword) { if (seenExportModifier) { this.pushDiagnostic(modifier, DiagnosticCode._0_modifier_already_seen, [modifier.text()]); return; @@ -795,9 +814,9 @@ module TypeScript { if (!node.stringLiteral) { for (var i = 0, n = node.moduleElements.length; i < n; i++) { var child = node.moduleElements[i]; - if (child.kind() === SyntaxKind.ImportDeclaration) { + if (child.kind === SyntaxKind.ImportDeclaration) { var importDeclaration = child; - if (importDeclaration.moduleReference.kind() === SyntaxKind.ExternalModuleReference) { + if (importDeclaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) { this.pushDiagnostic(importDeclaration, DiagnosticCode.Import_declarations_in_an_internal_module_cannot_reference_an_external_module); } } @@ -855,7 +874,7 @@ module TypeScript { for (var i = 0, n = node.moduleElements.length; i < n; i++) { var child = node.moduleElements[i]; - if (child.kind() === SyntaxKind.ExportAssignment) { + if (child.kind === SyntaxKind.ExportAssignment) { this.pushDiagnostic(child, DiagnosticCode.Export_assignment_cannot_be_used_in_internal_modules); return true; } @@ -879,7 +898,7 @@ module TypeScript { if (this.inAmbientDeclaration || this.syntaxTree.isDeclaration()) { // Provide a specialized message for a block as a statement versus the block as a // function body. - if (node.parent.kind() === SyntaxKind.List) { + if (node.parent.kind === SyntaxKind.List) { this.pushDiagnostic(firstToken(node), DiagnosticCode.Statements_are_not_allowed_in_ambient_contexts); } else { @@ -960,7 +979,7 @@ module TypeScript { private inSwitchStatement(ast: ISyntaxElement): boolean { while (ast) { - if (ast.kind() === SyntaxKind.SwitchStatement) { + if (ast.kind === SyntaxKind.SwitchStatement) { return true; } @@ -975,7 +994,7 @@ module TypeScript { } private isIterationStatement(ast: ISyntaxElement): boolean { - switch (ast.kind()) { + switch (ast.kind) { case SyntaxKind.ForStatement: case SyntaxKind.ForInStatement: case SyntaxKind.WhileStatement: @@ -1007,7 +1026,7 @@ module TypeScript { element = element.parent; while (element) { - if (element.kind() === SyntaxKind.LabeledStatement) { + if (element.kind === SyntaxKind.LabeledStatement) { var labeledStatement = element; if (breakable) { // Breakable labels can be placed on any construct @@ -1033,7 +1052,7 @@ module TypeScript { } private labelIsOnContinuableConstruct(statement: ISyntaxElement): boolean { - switch (statement.kind()) { + switch (statement.kind) { case SyntaxKind.LabeledStatement: // Labels work transitively. i.e. if you have: // foo: @@ -1283,10 +1302,10 @@ module TypeScript { return false; } - private checkForDisallowedModifiers(parent: ISyntaxElement, modifiers: ISyntaxToken[]): boolean { + private checkForDisallowedModifiers(modifiers: ISyntaxToken[]): boolean { if (this.inBlock || this.inObjectLiteralExpression) { if (modifiers.length > 0) { - this.pushDiagnostic(childAt(modifiers, 0), DiagnosticCode.Modifiers_cannot_appear_here); + this.pushDiagnostic(modifiers[0], DiagnosticCode.Modifiers_cannot_appear_here); return true; } } @@ -1296,7 +1315,7 @@ module TypeScript { public visitFunctionDeclaration(node: FunctionDeclarationSyntax): void { if (this.checkForDisallowedDeclareModifier(node.modifiers) || - this.checkForDisallowedModifiers(node, node.modifiers) || + this.checkForDisallowedModifiers(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.identifier, node.modifiers) || this.checkModuleElementModifiers(node.modifiers) || this.checkForDisallowedEvalOrArguments(node, node.identifier)) { @@ -1318,9 +1337,17 @@ module TypeScript { super.visitFunctionExpression(node); } + public visitFunctionPropertyAssignment(node: FunctionPropertyAssignmentSyntax): void { + if (this.checkForTemplatePropertyName(node.propertyName)) { + return; + } + + super.visitFunctionPropertyAssignment(node); + } + public visitVariableStatement(node: VariableStatementSyntax): void { if (this.checkForDisallowedDeclareModifier(node.modifiers) || - this.checkForDisallowedModifiers(node, node.modifiers) || + this.checkForDisallowedModifiers(node.modifiers) || this.checkForRequiredDeclareModifier(node, node.variableDeclaration.varKeyword, node.modifiers) || this.checkModuleElementModifiers(node.modifiers)) { @@ -1333,10 +1360,10 @@ module TypeScript { this.inAmbientDeclaration = savedInAmbientDeclaration; } - private checkListSeparators(parent: ISyntaxElement, list: T[], kind: SyntaxKind): boolean { - for (var i = 0, n = childCount(list); i < n; i++) { - var child = childAt(list, i); - if (i % 2 === 1 && child.kind() !== kind) { + private checkListSeparators(list: ISeparatedSyntaxList, kind: SyntaxKind): boolean { + for (var i = 0, n = separatorCount(list); i < n; i++) { + var child = separatorAt(list, i); + if (child.kind !== kind) { this.pushDiagnostic(child, DiagnosticCode._0_expected, [SyntaxFacts.getText(kind)]); } } @@ -1345,7 +1372,7 @@ module TypeScript { } public visitObjectType(node: ObjectTypeSyntax): void { - if (this.checkListSeparators(node, node.typeMembers, SyntaxKind.SemicolonToken)) { + if (this.checkListSeparators(node.typeMembers, SyntaxKind.SemicolonToken)) { return; } @@ -1382,15 +1409,25 @@ module TypeScript { public visitVariableDeclarator(node: VariableDeclaratorSyntax): void { if (this.checkVariableDeclaratorInitializer(node) || - this.checkVariableDeclaratorIdentifier(node)) { + this.checkVariableDeclaratorIdentifier(node) || + this.checkForTemplatePropertyName(node.propertyName)) { return; } super.visitVariableDeclarator(node); } + private checkForTemplatePropertyName(token: ISyntaxToken): boolean { + if (token.kind === SyntaxKind.NoSubstitutionTemplateToken) { + this.pushDiagnostic(token, DiagnosticCode.Template_literal_cannot_be_used_as_an_element_name); + return true; + } + + return false; + } + private checkVariableDeclaratorIdentifier(node: VariableDeclaratorSyntax): boolean { - if (node.parent.kind() !== SyntaxKind.MemberVariableDeclaration) { + if (node.parent.kind !== SyntaxKind.MemberVariableDeclaration) { if (this.checkForDisallowedEvalOrArguments(node, node.propertyName)) { return true; } @@ -1423,8 +1460,8 @@ module TypeScript { private checkConstructorModifiers(modifiers: ISyntaxToken[]): boolean { for (var i = 0, n = modifiers.length; i < n; i++) { var child = modifiers[i]; - if (child.kind() !== SyntaxKind.PublicKeyword) { - this.pushDiagnostic(child, DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [SyntaxFacts.getText(child.kind())]); + if (child.kind !== SyntaxKind.PublicKeyword) { + this.pushDiagnostic(child, DiagnosticCode._0_modifier_cannot_appear_on_a_constructor_declaration, [SyntaxFacts.getText(child.kind)]); return true; } } @@ -1494,7 +1531,7 @@ module TypeScript { } private isPreIncrementOrDecrementExpression(node: PrefixUnaryExpressionSyntax) { - switch (node.operatorToken.kind()) { + switch (node.operatorToken.kind) { case SyntaxKind.MinusMinusToken: case SyntaxKind.PlusPlusToken: return true; @@ -1504,7 +1541,7 @@ module TypeScript { } public visitDeleteExpression(node: DeleteExpressionSyntax): void { - if (parsedInStrictMode(node) && node.expression.kind() === SyntaxKind.IdentifierName) { + if (parsedInStrictMode(node) && node.expression.kind === SyntaxKind.IdentifierName) { this.pushDiagnostic(firstToken(node), DiagnosticCode.delete_cannot_be_called_on_an_identifier_in_strict_mode); return; } @@ -1513,7 +1550,7 @@ module TypeScript { } private checkIllegalAssignment(node: BinaryExpressionSyntax): boolean { - if (parsedInStrictMode(node) && SyntaxFacts.isAssignmentOperatorToken(node.operatorToken.kind()) && this.isEvalOrArguments(node.left)) { + if (parsedInStrictMode(node) && SyntaxFacts.isAssignmentOperatorToken(node.operatorToken.kind) && this.isEvalOrArguments(node.left)) { this.pushDiagnostic(node.operatorToken, DiagnosticCode.Invalid_use_of_0_in_strict_mode, [this.getEvalOrArguments(node.left)]); return true; } @@ -1522,7 +1559,7 @@ module TypeScript { } private getEvalOrArguments(expr: IExpressionSyntax): string { - if (expr.kind() === SyntaxKind.IdentifierName) { + if (expr.kind === SyntaxKind.IdentifierName) { var text = tokenValueText(expr); if (text === "eval" || text === "arguments") { return text; @@ -1545,7 +1582,7 @@ module TypeScript { } private checkConstraintType(node: ConstraintSyntax): boolean { - if (!SyntaxFacts.isType(node.typeOrExpression.kind())) { + if (!SyntaxFacts.isType(node.typeOrExpression.kind)) { this.pushDiagnostic(node.typeOrExpression, DiagnosticCode.Type_expected); return true; } @@ -1602,13 +1639,13 @@ module TypeScript { var moduleElement = node.moduleElements[i]; var _firstToken = firstToken(moduleElement); - if (_firstToken && _firstToken.kind() === SyntaxKind.ExportKeyword) { + if (_firstToken && _firstToken.kind === SyntaxKind.ExportKeyword) { return new TextSpan(start(_firstToken), width(_firstToken)); } - if (moduleElement.kind() === SyntaxKind.ImportDeclaration) { + if (moduleElement.kind === SyntaxKind.ImportDeclaration) { var importDecl = moduleElement; - if (importDecl.moduleReference.kind() === SyntaxKind.ExternalModuleReference) { + if (importDecl.moduleReference.kind === SyntaxKind.ExternalModuleReference) { var literal = (importDecl.moduleReference).stringLiteral; return new TextSpan(start(literal), width(literal)); } diff --git a/src/services/syntax/syntaxTriviaList.ts b/src/services/syntax/syntaxTriviaList.ts index ad0b2b51fa4..ad5f1df3039 100644 --- a/src/services/syntax/syntaxTriviaList.ts +++ b/src/services/syntax/syntaxTriviaList.ts @@ -28,10 +28,6 @@ module TypeScript { module TypeScript.Syntax { class EmptyTriviaList implements ISyntaxTriviaList { - public kind() { - return SyntaxKind.TriviaList; - } - public isShared(): boolean { return true; } @@ -91,10 +87,6 @@ module TypeScript.Syntax { this.item.parent = this; } - public kind() { - return SyntaxKind.TriviaList; - } - public isShared(): boolean { return false; } @@ -155,10 +147,6 @@ module TypeScript.Syntax { }); } - public kind() { - return SyntaxKind.TriviaList; - } - public isShared(): boolean { return false; } diff --git a/src/services/syntax/syntaxUtilities.generated.ts b/src/services/syntax/syntaxUtilities.generated.ts new file mode 100644 index 00000000000..17152889f5c --- /dev/null +++ b/src/services/syntax/syntaxUtilities.generated.ts @@ -0,0 +1,703 @@ +module TypeScript { + var childCountArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 3, 4, 3, 5, 2, 2, 3, 3, 3, 6, 6, 7, 8, 6, 6, 4, 5, 3, 5, 3, 5, 5, 3, 3, 2, 4, 3, 3, 6, 3, 2, 3, 7, 3, 3, 10, 8, 1, 3, 5, 4, 3, 7, 2, 5, 2, 2, 2, 2, 5, 3, 2, 3, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 2, 2, 2, 3, 4, 3, 3, 3, 2, 2, 4, 3, 2, 6, 2, 2, 2, 2, 3, 3, 6, 2, 2, 4, 1]; + + export function childCount(element: ISyntaxElement): number { + if (isList(element)) { return (element).length; } + return childCountArray[element.kind]; + } + + var childAtArray: ((nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement)[] = [ + undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, + (node: SourceUnitSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.moduleElements; + case 1: return node.endOfFileToken; + } + }, + (node: QualifiedNameSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.left; + case 1: return node.dotToken; + case 2: return node.right; + } + }, + (node: ObjectTypeSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openBraceToken; + case 1: return node.typeMembers; + case 2: return node.closeBraceToken; + } + }, + (node: FunctionTypeSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.typeParameterList; + case 1: return node.parameterList; + case 2: return node.equalsGreaterThanToken; + case 3: return node.type; + } + }, + (node: ArrayTypeSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.type; + case 1: return node.openBracketToken; + case 2: return node.closeBracketToken; + } + }, + (node: ConstructorTypeSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.newKeyword; + case 1: return node.typeParameterList; + case 2: return node.parameterList; + case 3: return node.equalsGreaterThanToken; + case 4: return node.type; + } + }, + (node: GenericTypeSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.name; + case 1: return node.typeArgumentList; + } + }, + (node: TypeQuerySyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.typeOfKeyword; + case 1: return node.name; + } + }, + (node: TupleTypeSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openBracketToken; + case 1: return node.types; + case 2: return node.closeBracketToken; + } + }, + (node: UnionTypeSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.left; + case 1: return node.barToken; + case 2: return node.right; + } + }, + (node: ParenthesizedTypeSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openParenToken; + case 1: return node.type; + case 2: return node.closeParenToken; + } + }, + (node: InterfaceDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.interfaceKeyword; + case 2: return node.identifier; + case 3: return node.typeParameterList; + case 4: return node.heritageClauses; + case 5: return node.body; + } + }, + (node: FunctionDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.functionKeyword; + case 2: return node.identifier; + case 3: return node.callSignature; + case 4: return node.block; + case 5: return node.semicolonToken; + } + }, + (node: ModuleDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.moduleKeyword; + case 2: return node.name; + case 3: return node.stringLiteral; + case 4: return node.openBraceToken; + case 5: return node.moduleElements; + case 6: return node.closeBraceToken; + } + }, + (node: ClassDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.classKeyword; + case 2: return node.identifier; + case 3: return node.typeParameterList; + case 4: return node.heritageClauses; + case 5: return node.openBraceToken; + case 6: return node.classElements; + case 7: return node.closeBraceToken; + } + }, + (node: EnumDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.enumKeyword; + case 2: return node.identifier; + case 3: return node.openBraceToken; + case 4: return node.enumElements; + case 5: return node.closeBraceToken; + } + }, + (node: ImportDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.importKeyword; + case 2: return node.identifier; + case 3: return node.equalsToken; + case 4: return node.moduleReference; + case 5: return node.semicolonToken; + } + }, + (node: ExportAssignmentSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.exportKeyword; + case 1: return node.equalsToken; + case 2: return node.identifier; + case 3: return node.semicolonToken; + } + }, + (node: MemberFunctionDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.propertyName; + case 2: return node.callSignature; + case 3: return node.block; + case 4: return node.semicolonToken; + } + }, + (node: MemberVariableDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.variableDeclarator; + case 2: return node.semicolonToken; + } + }, + (node: ConstructorDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.constructorKeyword; + case 2: return node.callSignature; + case 3: return node.block; + case 4: return node.semicolonToken; + } + }, + (node: IndexMemberDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.indexSignature; + case 2: return node.semicolonToken; + } + }, + (node: GetAccessorSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.getKeyword; + case 2: return node.propertyName; + case 3: return node.callSignature; + case 4: return node.block; + } + }, + (node: SetAccessorSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.setKeyword; + case 2: return node.propertyName; + case 3: return node.callSignature; + case 4: return node.block; + } + }, + (node: PropertySignatureSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.propertyName; + case 1: return node.questionToken; + case 2: return node.typeAnnotation; + } + }, + (node: CallSignatureSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.typeParameterList; + case 1: return node.parameterList; + case 2: return node.typeAnnotation; + } + }, + (node: ConstructSignatureSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.newKeyword; + case 1: return node.callSignature; + } + }, + (node: IndexSignatureSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openBracketToken; + case 1: return node.parameters; + case 2: return node.closeBracketToken; + case 3: return node.typeAnnotation; + } + }, + (node: MethodSignatureSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.propertyName; + case 1: return node.questionToken; + case 2: return node.callSignature; + } + }, + (node: BlockSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openBraceToken; + case 1: return node.statements; + case 2: return node.closeBraceToken; + } + }, + (node: IfStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.ifKeyword; + case 1: return node.openParenToken; + case 2: return node.condition; + case 3: return node.closeParenToken; + case 4: return node.statement; + case 5: return node.elseClause; + } + }, + (node: VariableStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.modifiers; + case 1: return node.variableDeclaration; + case 2: return node.semicolonToken; + } + }, + (node: ExpressionStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.expression; + case 1: return node.semicolonToken; + } + }, + (node: ReturnStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.returnKeyword; + case 1: return node.expression; + case 2: return node.semicolonToken; + } + }, + (node: SwitchStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.switchKeyword; + case 1: return node.openParenToken; + case 2: return node.expression; + case 3: return node.closeParenToken; + case 4: return node.openBraceToken; + case 5: return node.switchClauses; + case 6: return node.closeBraceToken; + } + }, + (node: BreakStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.breakKeyword; + case 1: return node.identifier; + case 2: return node.semicolonToken; + } + }, + (node: ContinueStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.continueKeyword; + case 1: return node.identifier; + case 2: return node.semicolonToken; + } + }, + (node: ForStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.forKeyword; + case 1: return node.openParenToken; + case 2: return node.variableDeclaration; + case 3: return node.initializer; + case 4: return node.firstSemicolonToken; + case 5: return node.condition; + case 6: return node.secondSemicolonToken; + case 7: return node.incrementor; + case 8: return node.closeParenToken; + case 9: return node.statement; + } + }, + (node: ForInStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.forKeyword; + case 1: return node.openParenToken; + case 2: return node.variableDeclaration; + case 3: return node.left; + case 4: return node.inKeyword; + case 5: return node.expression; + case 6: return node.closeParenToken; + case 7: return node.statement; + } + }, + (node: EmptyStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.semicolonToken; + } + }, + (node: ThrowStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.throwKeyword; + case 1: return node.expression; + case 2: return node.semicolonToken; + } + }, + (node: WhileStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.whileKeyword; + case 1: return node.openParenToken; + case 2: return node.condition; + case 3: return node.closeParenToken; + case 4: return node.statement; + } + }, + (node: TryStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.tryKeyword; + case 1: return node.block; + case 2: return node.catchClause; + case 3: return node.finallyClause; + } + }, + (node: LabeledStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.identifier; + case 1: return node.colonToken; + case 2: return node.statement; + } + }, + (node: DoStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.doKeyword; + case 1: return node.statement; + case 2: return node.whileKeyword; + case 3: return node.openParenToken; + case 4: return node.condition; + case 5: return node.closeParenToken; + case 6: return node.semicolonToken; + } + }, + (node: DebuggerStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.debuggerKeyword; + case 1: return node.semicolonToken; + } + }, + (node: WithStatementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.withKeyword; + case 1: return node.openParenToken; + case 2: return node.condition; + case 3: return node.closeParenToken; + case 4: return node.statement; + } + }, + (node: PrefixUnaryExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.operatorToken; + case 1: return node.operand; + } + }, + (node: DeleteExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.deleteKeyword; + case 1: return node.expression; + } + }, + (node: TypeOfExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.typeOfKeyword; + case 1: return node.expression; + } + }, + (node: VoidExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.voidKeyword; + case 1: return node.expression; + } + }, + (node: ConditionalExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.condition; + case 1: return node.questionToken; + case 2: return node.whenTrue; + case 3: return node.colonToken; + case 4: return node.whenFalse; + } + }, + (node: BinaryExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.left; + case 1: return node.operatorToken; + case 2: return node.right; + } + }, + (node: PostfixUnaryExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.operand; + case 1: return node.operatorToken; + } + }, + (node: MemberAccessExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.expression; + case 1: return node.dotToken; + case 2: return node.name; + } + }, + (node: InvocationExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.expression; + case 1: return node.argumentList; + } + }, + (node: ArrayLiteralExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openBracketToken; + case 1: return node.expressions; + case 2: return node.closeBracketToken; + } + }, + (node: ObjectLiteralExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openBraceToken; + case 1: return node.propertyAssignments; + case 2: return node.closeBraceToken; + } + }, + (node: ObjectCreationExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.newKeyword; + case 1: return node.expression; + case 2: return node.argumentList; + } + }, + (node: ParenthesizedExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openParenToken; + case 1: return node.expression; + case 2: return node.closeParenToken; + } + }, + (node: ParenthesizedArrowFunctionExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.callSignature; + case 1: return node.equalsGreaterThanToken; + case 2: return node.block; + case 3: return node.expression; + } + }, + (node: SimpleArrowFunctionExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.parameter; + case 1: return node.equalsGreaterThanToken; + case 2: return node.block; + case 3: return node.expression; + } + }, + (node: CastExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.lessThanToken; + case 1: return node.type; + case 2: return node.greaterThanToken; + case 3: return node.expression; + } + }, + (node: ElementAccessExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.expression; + case 1: return node.openBracketToken; + case 2: return node.argumentExpression; + case 3: return node.closeBracketToken; + } + }, + (node: FunctionExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.functionKeyword; + case 1: return node.identifier; + case 2: return node.callSignature; + case 3: return node.block; + } + }, + (node: OmittedExpressionSyntax, index: number): ISyntaxElement => { + throw Errors.invalidOperation(); + }, + (node: TemplateExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.templateStartToken; + case 1: return node.templateClauses; + } + }, + (node: TemplateAccessExpressionSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.expression; + case 1: return node.templateExpression; + } + }, + (node: VariableDeclarationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.varKeyword; + case 1: return node.variableDeclarators; + } + }, + (node: VariableDeclaratorSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.propertyName; + case 1: return node.typeAnnotation; + case 2: return node.equalsValueClause; + } + }, + (node: ArgumentListSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.typeArgumentList; + case 1: return node.openParenToken; + case 2: return node.arguments; + case 3: return node.closeParenToken; + } + }, + (node: ParameterListSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.openParenToken; + case 1: return node.parameters; + case 2: return node.closeParenToken; + } + }, + (node: TypeArgumentListSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.lessThanToken; + case 1: return node.typeArguments; + case 2: return node.greaterThanToken; + } + }, + (node: TypeParameterListSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.lessThanToken; + case 1: return node.typeParameters; + case 2: return node.greaterThanToken; + } + }, + (node: HeritageClauseSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.extendsOrImplementsKeyword; + case 1: return node.typeNames; + } + }, + (node: EqualsValueClauseSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.equalsToken; + case 1: return node.value; + } + }, + (node: CaseSwitchClauseSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.caseKeyword; + case 1: return node.expression; + case 2: return node.colonToken; + case 3: return node.statements; + } + }, + (node: DefaultSwitchClauseSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.defaultKeyword; + case 1: return node.colonToken; + case 2: return node.statements; + } + }, + (node: ElseClauseSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.elseKeyword; + case 1: return node.statement; + } + }, + (node: CatchClauseSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.catchKeyword; + case 1: return node.openParenToken; + case 2: return node.identifier; + case 3: return node.typeAnnotation; + case 4: return node.closeParenToken; + case 5: return node.block; + } + }, + (node: FinallyClauseSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.finallyKeyword; + case 1: return node.block; + } + }, + (node: TemplateClauseSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.expression; + case 1: return node.templateMiddleOrEndToken; + } + }, + (node: TypeParameterSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.identifier; + case 1: return node.constraint; + } + }, + (node: ConstraintSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.extendsKeyword; + case 1: return node.typeOrExpression; + } + }, + (node: SimplePropertyAssignmentSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.propertyName; + case 1: return node.colonToken; + case 2: return node.expression; + } + }, + (node: FunctionPropertyAssignmentSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.propertyName; + case 1: return node.callSignature; + case 2: return node.block; + } + }, + (node: ParameterSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.dotDotDotToken; + case 1: return node.modifiers; + case 2: return node.identifier; + case 3: return node.questionToken; + case 4: return node.typeAnnotation; + case 5: return node.equalsValueClause; + } + }, + (node: EnumElementSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.propertyName; + case 1: return node.equalsValueClause; + } + }, + (node: TypeAnnotationSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.colonToken; + case 1: return node.type; + } + }, + (node: ExternalModuleReferenceSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.requireKeyword; + case 1: return node.openParenToken; + case 2: return node.stringLiteral; + case 3: return node.closeParenToken; + } + }, + (node: ModuleNameModuleReferenceSyntax, index: number): ISyntaxElement => { + switch (index) { + case 0: return node.moduleName; + } + } + ]; + export function childAt(element: ISyntaxElement, index: number): ISyntaxElement { + if (isList(element)) { return (element)[index]; } + return childAtArray[element.kind](element, index); + } + + export function getChildAtFunction(element: ISyntaxNodeOrToken): (nodeOrToken: ISyntaxElement, index: number) => ISyntaxElement { + return childAtArray[element.kind]; + } +} \ No newline at end of file diff --git a/src/services/syntax/syntaxUtilities.ts b/src/services/syntax/syntaxUtilities.ts index 406b4eafe56..65748b5e902 100644 --- a/src/services/syntax/syntaxUtilities.ts +++ b/src/services/syntax/syntaxUtilities.ts @@ -3,7 +3,7 @@ module TypeScript { export class SyntaxUtilities { public static isAnyFunctionExpressionOrDeclaration(ast: ISyntaxElement): boolean { - switch (ast.kind()) { + switch (ast.kind) { case SyntaxKind.SimpleArrowFunctionExpression: case SyntaxKind.ParenthesizedArrowFunctionExpression: case SyntaxKind.FunctionExpression: @@ -34,9 +34,10 @@ module TypeScript { public static isLeftHandSizeExpression(element: ISyntaxElement) { if (element) { - switch (element.kind()) { + switch (element.kind) { case SyntaxKind.MemberAccessExpression: case SyntaxKind.ElementAccessExpression: + case SyntaxKind.TemplateAccessExpression: case SyntaxKind.ObjectCreationExpression: case SyntaxKind.InvocationExpression: case SyntaxKind.ArrayLiteralExpression: @@ -59,48 +60,9 @@ module TypeScript { return false; } - public static isExpression(element: ISyntaxElement) { - if (element) { - switch (element.kind()) { - case SyntaxKind.IdentifierName: - case SyntaxKind.RegularExpressionLiteral: - case SyntaxKind.NumericLiteral: - case SyntaxKind.StringLiteral: - case SyntaxKind.FalseKeyword: - case SyntaxKind.NullKeyword: - case SyntaxKind.ThisKeyword: - case SyntaxKind.TrueKeyword: - case SyntaxKind.SuperKeyword: - - case SyntaxKind.PrefixUnaryExpression: - case SyntaxKind.PostfixUnaryExpression: - case SyntaxKind.BinaryExpression: - case SyntaxKind.DeleteExpression: - case SyntaxKind.TypeOfExpression: - case SyntaxKind.VoidExpression: - case SyntaxKind.ConditionalExpression: - case SyntaxKind.MemberAccessExpression: - case SyntaxKind.InvocationExpression: - case SyntaxKind.ArrayLiteralExpression: - case SyntaxKind.ObjectLiteralExpression: - case SyntaxKind.ObjectCreationExpression: - case SyntaxKind.ParenthesizedExpression: - case SyntaxKind.ParenthesizedArrowFunctionExpression: - case SyntaxKind.SimpleArrowFunctionExpression: - case SyntaxKind.CastExpression: - case SyntaxKind.ElementAccessExpression: - case SyntaxKind.FunctionExpression: - case SyntaxKind.OmittedExpression: - return true; - } - } - - return false; - } - public static isSwitchClause(element: ISyntaxElement) { if (element) { - switch (element.kind()) { + switch (element.kind) { case SyntaxKind.CaseSwitchClause: case SyntaxKind.DefaultSwitchClause: return true; @@ -112,7 +74,7 @@ module TypeScript { public static isTypeMember(element: ISyntaxElement) { if (element) { - switch (element.kind()) { + switch (element.kind) { case SyntaxKind.ConstructSignature: case SyntaxKind.MethodSignature: case SyntaxKind.IndexSignature: @@ -127,7 +89,7 @@ module TypeScript { public static isClassElement(element: ISyntaxElement) { if (element) { - switch (element.kind()) { + switch (element.kind) { case SyntaxKind.ConstructorDeclaration: case SyntaxKind.IndexMemberDeclaration: case SyntaxKind.MemberFunctionDeclaration: @@ -144,7 +106,7 @@ module TypeScript { public static isModuleElement(element: ISyntaxElement) { if (element) { - switch (element.kind()) { + switch (element.kind) { case SyntaxKind.ImportDeclaration: case SyntaxKind.ExportAssignment: case SyntaxKind.ClassDeclaration: @@ -181,7 +143,7 @@ module TypeScript { public static isStatement(element: ISyntaxElement) { if (element) { - switch (element.kind()) { + switch (element.kind) { case SyntaxKind.FunctionDeclaration: case SyntaxKind.VariableStatement: case SyntaxKind.Block: @@ -211,8 +173,8 @@ module TypeScript { public static isAngleBracket(positionedElement: ISyntaxElement): boolean { var element = positionedElement; var parent = positionedElement.parent; - if (parent && (element.kind() === SyntaxKind.LessThanToken || element.kind() === SyntaxKind.GreaterThanToken)) { - switch (parent.kind()) { + if (parent && (element.kind === SyntaxKind.LessThanToken || element.kind === SyntaxKind.GreaterThanToken)) { + switch (parent.kind) { case SyntaxKind.TypeArgumentList: case SyntaxKind.TypeParameterList: case SyntaxKind.CastExpression: @@ -226,7 +188,7 @@ module TypeScript { public static getToken(list: ISyntaxToken[], kind: SyntaxKind): ISyntaxToken { for (var i = 0, n = list.length; i < n; i++) { var token = list[i]; - if (token.kind() === kind) { + if (token.kind === kind) { return token; } } @@ -243,7 +205,7 @@ module TypeScript { } public static getExportKeyword(moduleElement: IModuleElementSyntax): ISyntaxToken { - switch (moduleElement.kind()) { + switch (moduleElement.kind) { case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.FunctionDeclaration: @@ -263,7 +225,7 @@ module TypeScript { } var node = positionNode; - switch (node.kind()) { + switch (node.kind) { case SyntaxKind.ModuleDeclaration: case SyntaxKind.ClassDeclaration: case SyntaxKind.FunctionDeclaration: diff --git a/src/services/syntax/syntaxVisitor.generated.ts b/src/services/syntax/syntaxVisitor.generated.ts index 30d3e9ec42c..c3fe7c48558 100644 --- a/src/services/syntax/syntaxVisitor.generated.ts +++ b/src/services/syntax/syntaxVisitor.generated.ts @@ -3,8 +3,7 @@ module TypeScript { export function visitNodeOrToken(visitor: ISyntaxVisitor, element: ISyntaxNodeOrToken): any { if (element === undefined) { return undefined; } - if (isToken(element)) { return visitor.visitToken(element); } - switch (element.kind()) { + switch (element.kind) { case SyntaxKind.SourceUnit: return visitor.visitSourceUnit(element); case SyntaxKind.QualifiedName: return visitor.visitQualifiedName(element); case SyntaxKind.ObjectType: return visitor.visitObjectType(element); @@ -71,6 +70,8 @@ module TypeScript { case SyntaxKind.ElementAccessExpression: return visitor.visitElementAccessExpression(element); case SyntaxKind.FunctionExpression: return visitor.visitFunctionExpression(element); case SyntaxKind.OmittedExpression: return visitor.visitOmittedExpression(element); + case SyntaxKind.TemplateExpression: return visitor.visitTemplateExpression(element); + case SyntaxKind.TemplateAccessExpression: return visitor.visitTemplateAccessExpression(element); case SyntaxKind.VariableDeclaration: return visitor.visitVariableDeclaration(element); case SyntaxKind.VariableDeclarator: return visitor.visitVariableDeclarator(element); case SyntaxKind.ArgumentList: return visitor.visitArgumentList(element); @@ -84,6 +85,7 @@ module TypeScript { case SyntaxKind.ElseClause: return visitor.visitElseClause(element); case SyntaxKind.CatchClause: return visitor.visitCatchClause(element); case SyntaxKind.FinallyClause: return visitor.visitFinallyClause(element); + case SyntaxKind.TemplateClause: return visitor.visitTemplateClause(element); case SyntaxKind.TypeParameter: return visitor.visitTypeParameter(element); case SyntaxKind.Constraint: return visitor.visitConstraint(element); case SyntaxKind.SimplePropertyAssignment: return visitor.visitSimplePropertyAssignment(element); @@ -93,9 +95,8 @@ module TypeScript { case SyntaxKind.TypeAnnotation: return visitor.visitTypeAnnotation(element); case SyntaxKind.ExternalModuleReference: return visitor.visitExternalModuleReference(element); case SyntaxKind.ModuleNameModuleReference: return visitor.visitModuleNameModuleReference(element); + default: return visitor.visitToken(element); } - - throw Errors.invalidOperation(); } export interface ISyntaxVisitor { @@ -166,6 +167,8 @@ module TypeScript { visitElementAccessExpression(node: ElementAccessExpressionSyntax): any; visitFunctionExpression(node: FunctionExpressionSyntax): any; visitOmittedExpression(node: OmittedExpressionSyntax): any; + visitTemplateExpression(node: TemplateExpressionSyntax): any; + visitTemplateAccessExpression(node: TemplateAccessExpressionSyntax): any; visitVariableDeclaration(node: VariableDeclarationSyntax): any; visitVariableDeclarator(node: VariableDeclaratorSyntax): any; visitArgumentList(node: ArgumentListSyntax): any; @@ -179,6 +182,7 @@ module TypeScript { visitElseClause(node: ElseClauseSyntax): any; visitCatchClause(node: CatchClauseSyntax): any; visitFinallyClause(node: FinallyClauseSyntax): any; + visitTemplateClause(node: TemplateClauseSyntax): any; visitTypeParameter(node: TypeParameterSyntax): any; visitConstraint(node: ConstraintSyntax): any; visitSimplePropertyAssignment(node: SimplePropertyAssignmentSyntax): any; diff --git a/src/services/syntax/syntaxWalker.generated.ts b/src/services/syntax/syntaxWalker.generated.ts index 21c1acefc7f..7fb54355ca8 100644 --- a/src/services/syntax/syntaxWalker.generated.ts +++ b/src/services/syntax/syntaxWalker.generated.ts @@ -15,14 +15,7 @@ module TypeScript { public visitList(list: ISyntaxNodeOrToken[]): void { for (var i = 0, n = list.length; i < n; i++) { - visitNodeOrToken(this, list[i]); - } - } - - public visitSeparatedList(list: ISyntaxNodeOrToken[]): void { - for (var i = 0, n = childCount(list); i < n; i++) { - var item = childAt(list, i); - visitNodeOrToken(this, item); + visitNodeOrToken(this, list[i]); } } @@ -39,7 +32,7 @@ module TypeScript { public visitObjectType(node: ObjectTypeSyntax): void { this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.typeMembers); + this.visitList(node.typeMembers); this.visitToken(node.closeBraceToken); } @@ -76,7 +69,7 @@ module TypeScript { public visitTupleType(node: TupleTypeSyntax): void { this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.types); + this.visitList(node.types); this.visitToken(node.closeBracketToken); } @@ -136,7 +129,7 @@ module TypeScript { this.visitToken(node.enumKeyword); this.visitToken(node.identifier); this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.enumElements); + this.visitList(node.enumElements); this.visitToken(node.closeBraceToken); } @@ -219,7 +212,7 @@ module TypeScript { public visitIndexSignature(node: IndexSignatureSyntax): void { this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.parameters); + this.visitList(node.parameters); this.visitToken(node.closeBracketToken); visitNodeOrToken(this, node.typeAnnotation); } @@ -414,13 +407,13 @@ module TypeScript { public visitArrayLiteralExpression(node: ArrayLiteralExpressionSyntax): void { this.visitToken(node.openBracketToken); - this.visitSeparatedList(node.expressions); + this.visitList(node.expressions); this.visitToken(node.closeBracketToken); } public visitObjectLiteralExpression(node: ObjectLiteralExpressionSyntax): void { this.visitToken(node.openBraceToken); - this.visitSeparatedList(node.propertyAssignments); + this.visitList(node.propertyAssignments); this.visitToken(node.closeBraceToken); } @@ -474,9 +467,19 @@ module TypeScript { public visitOmittedExpression(node: OmittedExpressionSyntax): void { } + public visitTemplateExpression(node: TemplateExpressionSyntax): void { + this.visitToken(node.templateStartToken); + this.visitList(node.templateClauses); + } + + public visitTemplateAccessExpression(node: TemplateAccessExpressionSyntax): void { + visitNodeOrToken(this, node.expression); + visitNodeOrToken(this, node.templateExpression); + } + public visitVariableDeclaration(node: VariableDeclarationSyntax): void { this.visitToken(node.varKeyword); - this.visitSeparatedList(node.variableDeclarators); + this.visitList(node.variableDeclarators); } public visitVariableDeclarator(node: VariableDeclaratorSyntax): void { @@ -488,31 +491,31 @@ module TypeScript { public visitArgumentList(node: ArgumentListSyntax): void { visitNodeOrToken(this, node.typeArgumentList); this.visitToken(node.openParenToken); - this.visitSeparatedList(node.arguments); + this.visitList(node.arguments); this.visitToken(node.closeParenToken); } public visitParameterList(node: ParameterListSyntax): void { this.visitToken(node.openParenToken); - this.visitSeparatedList(node.parameters); + this.visitList(node.parameters); this.visitToken(node.closeParenToken); } public visitTypeArgumentList(node: TypeArgumentListSyntax): void { this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeArguments); + this.visitList(node.typeArguments); this.visitToken(node.greaterThanToken); } public visitTypeParameterList(node: TypeParameterListSyntax): void { this.visitToken(node.lessThanToken); - this.visitSeparatedList(node.typeParameters); + this.visitList(node.typeParameters); this.visitToken(node.greaterThanToken); } public visitHeritageClause(node: HeritageClauseSyntax): void { this.visitToken(node.extendsOrImplementsKeyword); - this.visitSeparatedList(node.typeNames); + this.visitList(node.typeNames); } public visitEqualsValueClause(node: EqualsValueClauseSyntax): void { @@ -552,6 +555,11 @@ module TypeScript { visitNodeOrToken(this, node.block); } + public visitTemplateClause(node: TemplateClauseSyntax): void { + visitNodeOrToken(this, node.expression); + this.visitToken(node.templateMiddleOrEndToken); + } + public visitTypeParameter(node: TypeParameterSyntax): void { this.visitToken(node.identifier); visitNodeOrToken(this, node.constraint); diff --git a/src/services/syntax/testUtilities.ts b/src/services/syntax/testUtilities.ts index 6144c6cffb7..8a77c3f8314 100644 --- a/src/services/syntax/testUtilities.ts +++ b/src/services/syntax/testUtilities.ts @@ -1,6 +1,6 @@ module TypeScript { function assertParent(parent: ISyntaxElement, child: ISyntaxElement) { - if (child && !TypeScript.isShared(child)) { + if (child) { return Debug.assert(parent === child.parent); } } @@ -9,10 +9,10 @@ module TypeScript { if (node1 === node2) { return true; } if (!node1 || !node2) { return false; } - Debug.assert(node1.kind() === TypeScript.SyntaxKind.SourceUnit || node1.parent); - Debug.assert(node2.kind() === TypeScript.SyntaxKind.SourceUnit || node2.parent); + Debug.assert(node1.kind === TypeScript.SyntaxKind.SourceUnit || node1.parent); + Debug.assert(node2.kind === TypeScript.SyntaxKind.SourceUnit || node2.parent); - if (node1.kind() !== node2.kind()) { return false; } + if (node1.kind !== node2.kind) { return false; } if (childCount(node1) !== childCount(node2)) { return false; } for (var i = 0, n = childCount(node1); i < n; i++) { @@ -41,8 +41,8 @@ module TypeScript { return false; } - Debug.assert(node1.kind() === TypeScript.SyntaxKind.SourceUnit || node1.parent); - Debug.assert(node2.kind() === TypeScript.SyntaxKind.SourceUnit || node2.parent); + Debug.assert(node1.kind === TypeScript.SyntaxKind.SourceUnit || node1.parent); + Debug.assert(node2.kind === TypeScript.SyntaxKind.SourceUnit || node2.parent); if (TypeScript.isToken(node1)) { return TypeScript.isToken(node2) ? tokenStructuralEquals(node1, node2, text1, text2) : false; @@ -63,7 +63,7 @@ module TypeScript { Debug.assert(token1.parent); Debug.assert(token2.parent); - return token1.kind() === token2.kind() && + return token1.kind === token2.kind && TypeScript.width(token1) === TypeScript.width(token2) && token1.fullWidth() === token2.fullWidth() && token1.fullStart() === token2.fullStart() && @@ -102,8 +102,8 @@ module TypeScript { } function listStructuralEquals(list1: T[], list2: T[], checkParents: boolean, text1: ISimpleText, text2: ISimpleText): boolean { - Debug.assert(TypeScript.isShared(list1) || list1.parent); - Debug.assert(TypeScript.isShared(list2) || list2.parent); + Debug.assert(list1.parent); + Debug.assert(list2.parent); if (childCount(list1) !== childCount(list2)) { return false; @@ -118,32 +118,7 @@ module TypeScript { assertParent(list2, child2); } - if (!nodeOrTokenStructuralEquals(child1, child2, checkParents, text1, text2)) { - return false; - } - } - - return true; - } - - function separatedListStructuralEquals(list1: T[], list2: T[], checkParents: boolean, text1: ISimpleText, text2: ISimpleText): boolean { - Debug.assert(TypeScript.isShared(list1) || list1.parent); - Debug.assert(TypeScript.isShared(list2) || list2.parent); - - if (childCount(list1) !== childCount(list2)) { - return false; - } - - for (var i = 0, n = childCount(list1); i < n; i++) { - var element1 = childAt(list1, i); - var element2 = childAt(list2, i); - - if (checkParents) { - assertParent(list1, element1); - assertParent(list2, element2); - } - - if (!nodeOrTokenStructuralEquals(element1, element2, checkParents, text1, text2)) { + if (!elementStructuralEquals(child1, child2, checkParents, text1, text2)) { return false; } } @@ -160,10 +135,10 @@ module TypeScript { return false; } - Debug.assert(element1.kind() === SyntaxKind.SourceUnit || element1.parent); - Debug.assert(element2.kind() === SyntaxKind.SourceUnit || element2.parent); + Debug.assert(element1.kind === SyntaxKind.SourceUnit || element1.parent); + Debug.assert(element2.kind === SyntaxKind.SourceUnit || element2.parent); - if (element2.kind() !== element2.kind()) { + if (element2.kind !== element2.kind) { return false; } @@ -192,9 +167,6 @@ module TypeScript { else if (TypeScript.isList(element1)) { return listStructuralEquals(element1, element2, checkParents, text1, text2); } - else if (TypeScript.isSeparatedList(element1)) { - return separatedListStructuralEquals(element1, element2, checkParents, text1, text2); - } throw TypeScript.Errors.invalidOperation(); } diff --git a/src/services/syntax/utilities.generated.ts b/src/services/syntax/utilities.generated.ts new file mode 100644 index 00000000000..a01618fae48 --- /dev/null +++ b/src/services/syntax/utilities.generated.ts @@ -0,0 +1,4 @@ + var fixedWidthArray = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 4, 5, 8, 8, 7, 6, 2, 4, 5, 7, 3, 8, 2, 2, 10, 3, 4, 6, 6, 4, 5, 4, 3, 6, 3, 4, 5, 4, 5, 5, 4, 6, 7, 6, 5, 10, 9, 3, 7, 7, 9, 6, 6, 5, 3, 7, 11, 7, 3, 6, 7, 6, 3, 6, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 2, 2, 2, 1, 2]; + function fixedWidthTokenLength(kind: SyntaxKind) { + return fixedWidthArray[kind]; + } diff --git a/src/services/text/characterCodes.ts b/src/services/text/characterCodes.ts index 040e0c41c6b..91d500f1749 100644 --- a/src/services/text/characterCodes.ts +++ b/src/services/text/characterCodes.ts @@ -104,6 +104,7 @@ module TypeScript { asterisk = 42, // * at = 64, // @ backslash = 92, // \ + backtick = 96, // ` bar = 124, // | caret = 94, // ^ closeBrace = 125, // } diff --git a/src/services/text/textFactory.ts b/src/services/text/textFactory.ts index 235a451b158..c32aa3adfaf 100644 --- a/src/services/text/textFactory.ts +++ b/src/services/text/textFactory.ts @@ -12,7 +12,10 @@ module TypeScript.SimpleText { } public substr(start: number, length: number): string { - return this.value.substr(start, length); + var val = this.value; + return start === 0 && length == val.length + ? val + : val.substr(start, length); } public charCodeAt(index: number): number { diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js index f34ac61d86d..1ba54d47f1c 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js +++ b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.js @@ -50,12 +50,12 @@ var r3 = null + b; var r4 = null + 1; var r5 = null + c; var r6 = null + 0 /* a */; -var r7 = null + E['a']; +var r7 = null + 0 /* 'a' */; var r8 = b + null; var r9 = 1 + null; var r10 = c + null; var r11 = 0 /* a */ + null; -var r12 = E['a'] + null; +var r12 = 0 /* 'a' */ + null; // null + string var r13 = null + d; var r14 = null + ''; diff --git a/tests/baselines/reference/additionOperatorWithNumberAndEnum.js b/tests/baselines/reference/additionOperatorWithNumberAndEnum.js index 63e038265d6..05bca7a4c0c 100644 --- a/tests/baselines/reference/additionOperatorWithNumberAndEnum.js +++ b/tests/baselines/reference/additionOperatorWithNumberAndEnum.js @@ -29,4 +29,4 @@ var r4 = b + b; var r5 = 0 + a; var r6 = 0 /* a */ + 0; var r7 = 0 /* a */ + 1 /* b */; -var r8 = E['a'] + E['b']; +var r8 = 0 /* 'a' */ + 1 /* 'b' */; diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js index a6a1b2ef555..cb89d242a18 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.js @@ -50,12 +50,12 @@ var r3 = undefined + b; var r4 = undefined + 1; var r5 = undefined + c; var r6 = undefined + 0 /* a */; -var r7 = undefined + E['a']; +var r7 = undefined + 0 /* 'a' */; var r8 = b + undefined; var r9 = 1 + undefined; var r10 = c + undefined; var r11 = 0 /* a */ + undefined; -var r12 = E['a'] + undefined; +var r12 = 0 /* 'a' */ + undefined; // undefined + string var r13 = undefined + d; var r14 = undefined + ''; diff --git a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js index 9cd5a63912e..710af4edfa7 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js +++ b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.js @@ -30,11 +30,11 @@ var ENUM1; // enum type var var ResultIsNumber1 = ~ENUM1; // enum type expressions -var ResultIsNumber2 = ~ENUM1["A"]; -var ResultIsNumber3 = ~(0 /* A */ + ENUM1["B"]); +var ResultIsNumber2 = ~0 /* "A" */; +var ResultIsNumber3 = ~(0 /* A */ + 1 /* "B" */); // multiple ~ operators -var ResultIsNumber4 = ~~~(ENUM1["A"] + 1 /* B */); +var ResultIsNumber4 = ~~~(0 /* "A" */ + 1 /* B */); // miss assignment operators ~ENUM1; -~ENUM1["A"]; -~0 /* A */, ~ENUM1["B"]; +~0 /* "A" */; +~0 /* A */, ~1 /* "B" */; diff --git a/tests/baselines/reference/constEnumDeclarations.js b/tests/baselines/reference/constEnumDeclarations.js new file mode 100644 index 00000000000..1cbacb13bbd --- /dev/null +++ b/tests/baselines/reference/constEnumDeclarations.js @@ -0,0 +1,28 @@ +//// [constEnumDeclarations.ts] + +const enum E { + A = 1, + B = 2, + C = A | B +} + +const enum E2 { + A = 1, + B, + C +} + +//// [constEnumDeclarations.js] + + +//// [constEnumDeclarations.d.ts] +declare const enum E { + A = 1, + B = 2, + C = 3, +} +declare const enum E2 { + A = 1, + B = 2, + C = 3, +} diff --git a/tests/baselines/reference/constEnumDeclarations.types b/tests/baselines/reference/constEnumDeclarations.types new file mode 100644 index 00000000000..9dc87eadef7 --- /dev/null +++ b/tests/baselines/reference/constEnumDeclarations.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/constEnumDeclarations.ts === + +const enum E { +>E : E + + A = 1, +>A : E + + B = 2, +>B : E + + C = A | B +>C : E +>A | B : number +>A : E +>B : E +} + +const enum E2 { +>E2 : E2 + + A = 1, +>A : E2 + + B, +>B : E2 + + C +>C : E2 +} diff --git a/tests/baselines/reference/constEnumErrors.errors.txt b/tests/baselines/reference/constEnumErrors.errors.txt new file mode 100644 index 00000000000..541f814af98 --- /dev/null +++ b/tests/baselines/reference/constEnumErrors.errors.txt @@ -0,0 +1,85 @@ +tests/cases/compiler/constEnumErrors.ts(1,12): error TS2300: Duplicate identifier 'E'. +tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier 'E'. +tests/cases/compiler/constEnumErrors.ts(12,9): error TS4083: In 'const' enum declarations member initializer must be constant expression. +tests/cases/compiler/constEnumErrors.ts(14,9): error TS4083: In 'const' enum declarations member initializer must be constant expression. +tests/cases/compiler/constEnumErrors.ts(15,10): error TS4083: In 'const' enum declarations member initializer must be constant expression. +tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'. +tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'. +tests/cases/compiler/constEnumErrors.ts(26,9): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. +tests/cases/compiler/constEnumErrors.ts(27,10): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. +tests/cases/compiler/constEnumErrors.ts(32,5): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. +tests/cases/compiler/constEnumErrors.ts(40,9): error TS4086: 'const' enum member initializer was evaluated to a non-finite value. +tests/cases/compiler/constEnumErrors.ts(41,9): error TS4086: 'const' enum member initializer was evaluated to a non-finite value. +tests/cases/compiler/constEnumErrors.ts(42,9): error TS4087: 'const' enum member initializer was evaluated to disallowed value 'NaN'. + + +==== tests/cases/compiler/constEnumErrors.ts (13 errors) ==== + const enum E { + ~ +!!! error TS2300: Duplicate identifier 'E'. + A + } + + module E { + ~ +!!! error TS2300: Duplicate identifier 'E'. + var x = 1; + } + + const enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + ~ +!!! error TS4083: In 'const' enum declarations member initializer must be constant expression. + // forward reference to the element of the same enum + Y = E1.Z, + ~~~~ +!!! error TS4083: In 'const' enum declarations member initializer must be constant expression. + Y1 = E1["Z"] + ~~~~~~~ +!!! error TS4083: In 'const' enum declarations member initializer must be constant expression. + } + + const enum E2 { + A + } + + var y0 = E2[1] + ~ +!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'. + var name = "A"; + var y1 = E2[name]; + ~~~~ +!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'. + + var x = E2; + ~~ +!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. + var y = [E2]; + ~~ +!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. + + function foo(t: any): void { + } + + foo(E2); + ~~ +!!! error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. + + const enum NaNOrInfinity { + A = 9007199254740992, + B = A * A, + C = B * B, + D = C * C, + E = D * D, + F = E * E, // overflow + ~~~~~ +!!! error TS4086: 'const' enum member initializer was evaluated to a non-finite value. + G = 1 / 0, // overflow + ~~~~~ +!!! error TS4086: 'const' enum member initializer was evaluated to a non-finite value. + H = 0 / 0 // NaN + ~~~~~ +!!! error TS4087: 'const' enum member initializer was evaluated to disallowed value 'NaN'. + } \ No newline at end of file diff --git a/tests/baselines/reference/constEnumExternalModule.js b/tests/baselines/reference/constEnumExternalModule.js new file mode 100644 index 00000000000..4054ba788cb --- /dev/null +++ b/tests/baselines/reference/constEnumExternalModule.js @@ -0,0 +1,19 @@ +//// [tests/cases/compiler/constEnumExternalModule.ts] //// + +//// [m1.ts] +const enum E { + V = 100 +} + +export = E +//// [m2.ts] +import A = require('m1') +var v = A.V; + +//// [m1.js] +define(["require", "exports"], function (require, exports) { +}); +//// [m2.js] +define(["require", "exports"], function (require, exports) { + var v = 100 /* V */; +}); diff --git a/tests/baselines/reference/constEnumExternalModule.types b/tests/baselines/reference/constEnumExternalModule.types new file mode 100644 index 00000000000..9c7b43a24d4 --- /dev/null +++ b/tests/baselines/reference/constEnumExternalModule.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/m2.ts === +import A = require('m1') +>A : typeof A + +var v = A.V; +>v : A +>A.V : A +>A : typeof A +>V : A + +=== tests/cases/compiler/m1.ts === +const enum E { +>E : E + + V = 100 +>V : E +} + +export = E +>E : E + diff --git a/tests/baselines/reference/constEnums.js b/tests/baselines/reference/constEnums.js new file mode 100644 index 00000000000..4f85cc59d0e --- /dev/null +++ b/tests/baselines/reference/constEnums.js @@ -0,0 +1,223 @@ +//// [constEnums.ts] +const enum Enum1 { + A0 = 100, +} + +const enum Enum1 { + // correct cases + A, + B, + C = 10, + D = A | B, + E = A | 1, + F = 1 | A, + G = (1 & 1), + H = ~(A | B), + I = A >>> 1, + J = 1 & A, + K = ~(1 | 5), + L = ~D, + M = E << B, + N = E << 1, + O = E >> B, + P = E >> 1, + Q = -D, + R = C & 5, + S = 5 & C, + T = C | D, + U = C | 1, + V = 10 | D, + W = Enum1.V, + + // correct cases: reference to the enum member from different enum declaration + W1 = A0, + W2 = Enum1.A0, + W3 = Enum1["A0"], + W4 = Enum1["W"], +} + + +module A { + export module B { + export module C { + export const enum E { + V1 = 1, + V2 = A.B.C.E.V1 | 100 + } + } + } +} + +module A { + export module B { + export module C { + export const enum E { + V3 = A.B.C.E["V2"] & 200, + } + } + } +} + +module A1 { + export module B { + export module C { + export const enum E { + V1 = 10, + V2 = 110, + } + } + } +} + +module A2 { + export module B { + export module C { + export const enum E { + V1 = 10, + V2 = 110, + } + } + // module C will be classified as value + export module C { + var x = 1 + } + } +} + +import I = A.B.C.E; +import I1 = A1.B; +import I2 = A2.B; + +function foo0(e: I): void { + if (e === I.V1) { + } + else if (e === I.V2) { + } +} + +function foo1(e: I1.C.E): void { + if (e === I1.C.E.V1) { + } + else if (e === I1.C.E.V2) { + } +} + +function foo2(e: I2.C.E): void { + if (e === I2.C.E.V1) { + } + else if (e === I2.C.E.V2) { + } +} + + +function foo(x: Enum1) { + switch (x) { + case Enum1.A: + case Enum1.B: + case Enum1.C: + case Enum1.D: + case Enum1.E: + case Enum1.F: + case Enum1.G: + case Enum1.H: + case Enum1.I: + case Enum1.J: + case Enum1.K: + case Enum1.L: + case Enum1.M: + case Enum1.N: + case Enum1.O: + case Enum1.P: + case Enum1.Q: + case Enum1.R: + case Enum1.S: + case Enum1["T"]: + case Enum1.U: + case Enum1.V: + case Enum1.W: + case Enum1.W1: + case Enum1.W2: + case Enum1.W3: + case Enum1.W4: + break; + } +} + +function bar(e: A.B.C.E): number { + switch (e) { + case A.B.C.E.V1: return 1; + case A.B.C.E.V2: return 1; + case A.B.C.E.V3: return 1; + } +} + +//// [constEnums.js] +var A2; +(function (A2) { + var B; + (function (B) { + // module C will be classified as value + var C; + (function (C) { + var x = 1; + })(C = B.C || (B.C = {})); + })(B = A2.B || (A2.B = {})); +})(A2 || (A2 = {})); +var I2 = A2.B; +function foo0(e) { + if (e === 1 /* V1 */) { + } + else if (e === 101 /* V2 */) { + } +} +function foo1(e) { + if (e === 10 /* V1 */) { + } + else if (e === 110 /* V2 */) { + } +} +function foo2(e) { + if (e === 10 /* V1 */) { + } + else if (e === 110 /* V2 */) { + } +} +function foo(x) { + switch (x) { + case 0 /* A */: + case 1 /* B */: + case 10 /* C */: + case 1 /* D */: + case 1 /* E */: + case 1 /* F */: + case 1 /* G */: + case -2 /* H */: + case 0 /* I */: + case 0 /* J */: + case -6 /* K */: + case -2 /* L */: + case 2 /* M */: + case 2 /* N */: + case 0 /* O */: + case 0 /* P */: + case -1 /* Q */: + case 0 /* R */: + case 0 /* S */: + case 11 /* "T" */: + case 11 /* U */: + case 11 /* V */: + case 11 /* W */: + case 100 /* W1 */: + case 100 /* W2 */: + case 100 /* W3 */: + case 11 /* W4 */: + break; + } +} +function bar(e) { + switch (e) { + case 1 /* V1 */: return 1; + case 101 /* V2 */: return 1; + case 64 /* V3 */: return 1; + } +} diff --git a/tests/baselines/reference/constEnums.types b/tests/baselines/reference/constEnums.types new file mode 100644 index 00000000000..396b2e1c32b --- /dev/null +++ b/tests/baselines/reference/constEnums.types @@ -0,0 +1,556 @@ +=== tests/cases/compiler/constEnums.ts === +const enum Enum1 { +>Enum1 : Enum1 + + A0 = 100, +>A0 : Enum1 +} + +const enum Enum1 { +>Enum1 : Enum1 + + // correct cases + A, +>A : Enum1 + + B, +>B : Enum1 + + C = 10, +>C : Enum1 + + D = A | B, +>D : Enum1 +>A | B : number +>A : Enum1 +>B : Enum1 + + E = A | 1, +>E : Enum1 +>A | 1 : number +>A : Enum1 + + F = 1 | A, +>F : Enum1 +>1 | A : number +>A : Enum1 + + G = (1 & 1), +>G : Enum1 +>(1 & 1) : number +>1 & 1 : number + + H = ~(A | B), +>H : Enum1 +>~(A | B) : number +>(A | B) : number +>A | B : number +>A : Enum1 +>B : Enum1 + + I = A >>> 1, +>I : Enum1 +>A >>> 1 : number +>A : Enum1 + + J = 1 & A, +>J : Enum1 +>1 & A : number +>A : Enum1 + + K = ~(1 | 5), +>K : Enum1 +>~(1 | 5) : number +>(1 | 5) : number +>1 | 5 : number + + L = ~D, +>L : Enum1 +>~D : number +>D : Enum1 + + M = E << B, +>M : Enum1 +>E << B : number +>E : Enum1 +>B : Enum1 + + N = E << 1, +>N : Enum1 +>E << 1 : number +>E : Enum1 + + O = E >> B, +>O : Enum1 +>E >> B : number +>E : Enum1 +>B : Enum1 + + P = E >> 1, +>P : Enum1 +>E >> 1 : number +>E : Enum1 + + Q = -D, +>Q : Enum1 +>-D : number +>D : Enum1 + + R = C & 5, +>R : Enum1 +>C & 5 : number +>C : Enum1 + + S = 5 & C, +>S : Enum1 +>5 & C : number +>C : Enum1 + + T = C | D, +>T : Enum1 +>C | D : number +>C : Enum1 +>D : Enum1 + + U = C | 1, +>U : Enum1 +>C | 1 : number +>C : Enum1 + + V = 10 | D, +>V : Enum1 +>10 | D : number +>D : Enum1 + + W = Enum1.V, +>W : Enum1 +>Enum1.V : Enum1 +>Enum1 : typeof Enum1 +>V : Enum1 + + // correct cases: reference to the enum member from different enum declaration + W1 = A0, +>W1 : Enum1 +>A0 : Enum1 + + W2 = Enum1.A0, +>W2 : Enum1 +>Enum1.A0 : Enum1 +>Enum1 : typeof Enum1 +>A0 : Enum1 + + W3 = Enum1["A0"], +>W3 : Enum1 +>Enum1["A0"] : Enum1 +>Enum1 : typeof Enum1 + + W4 = Enum1["W"], +>W4 : Enum1 +>Enum1["W"] : Enum1 +>Enum1 : typeof Enum1 +} + + +module A { +>A : typeof A + + export module B { +>B : typeof B + + export module C { +>C : typeof C + + export const enum E { +>E : E + + V1 = 1, +>V1 : E + + V2 = A.B.C.E.V1 | 100 +>V2 : E +>A.B.C.E.V1 | 100 : number +>A.B.C.E.V1 : E +>A.B.C.E : typeof E +>A.B.C : typeof C +>A.B : typeof B +>A : typeof A +>B : typeof B +>C : typeof C +>E : typeof E +>V1 : E + } + } + } +} + +module A { +>A : typeof A + + export module B { +>B : typeof B + + export module C { +>C : typeof C + + export const enum E { +>E : E + + V3 = A.B.C.E["V2"] & 200, +>V3 : E +>A.B.C.E["V2"] & 200 : number +>A.B.C.E["V2"] : E +>A.B.C.E : typeof E +>A.B.C : typeof C +>A.B : typeof B +>A : typeof A +>B : typeof B +>C : typeof C +>E : typeof E + } + } + } +} + +module A1 { +>A1 : typeof A1 + + export module B { +>B : typeof B + + export module C { +>C : typeof C + + export const enum E { +>E : E + + V1 = 10, +>V1 : E + + V2 = 110, +>V2 : E + } + } + } +} + +module A2 { +>A2 : typeof A2 + + export module B { +>B : typeof B + + export module C { +>C : typeof C + + export const enum E { +>E : E + + V1 = 10, +>V1 : E + + V2 = 110, +>V2 : E + } + } + // module C will be classified as value + export module C { +>C : typeof C + + var x = 1 +>x : number + } + } +} + +import I = A.B.C.E; +>I : typeof I +>A : typeof A +>B : typeof A.B +>C : typeof A.B.C +>E : I + +import I1 = A1.B; +>I1 : typeof I1 +>A1 : typeof A1 +>B : typeof I1 + +import I2 = A2.B; +>I2 : typeof I2 +>A2 : typeof A2 +>B : typeof I2 + +function foo0(e: I): void { +>foo0 : (e: I) => void +>e : I +>I : I + + if (e === I.V1) { +>e === I.V1 : boolean +>e : I +>I.V1 : I +>I : typeof I +>V1 : I + } + else if (e === I.V2) { +>e === I.V2 : boolean +>e : I +>I.V2 : I +>I : typeof I +>V2 : I + } +} + +function foo1(e: I1.C.E): void { +>foo1 : (e: I1.C.E) => void +>e : I1.C.E +>I1 : unknown +>C : unknown +>E : I1.C.E + + if (e === I1.C.E.V1) { +>e === I1.C.E.V1 : boolean +>e : I1.C.E +>I1.C.E.V1 : I1.C.E +>I1.C.E : typeof I1.C.E +>I1.C : typeof I1.C +>I1 : typeof I1 +>C : typeof I1.C +>E : typeof I1.C.E +>V1 : I1.C.E + } + else if (e === I1.C.E.V2) { +>e === I1.C.E.V2 : boolean +>e : I1.C.E +>I1.C.E.V2 : I1.C.E +>I1.C.E : typeof I1.C.E +>I1.C : typeof I1.C +>I1 : typeof I1 +>C : typeof I1.C +>E : typeof I1.C.E +>V2 : I1.C.E + } +} + +function foo2(e: I2.C.E): void { +>foo2 : (e: I2.C.E) => void +>e : I2.C.E +>I2 : unknown +>C : unknown +>E : I2.C.E + + if (e === I2.C.E.V1) { +>e === I2.C.E.V1 : boolean +>e : I2.C.E +>I2.C.E.V1 : I2.C.E +>I2.C.E : typeof I2.C.E +>I2.C : typeof I2.C +>I2 : typeof I2 +>C : typeof I2.C +>E : typeof I2.C.E +>V1 : I2.C.E + } + else if (e === I2.C.E.V2) { +>e === I2.C.E.V2 : boolean +>e : I2.C.E +>I2.C.E.V2 : I2.C.E +>I2.C.E : typeof I2.C.E +>I2.C : typeof I2.C +>I2 : typeof I2 +>C : typeof I2.C +>E : typeof I2.C.E +>V2 : I2.C.E + } +} + + +function foo(x: Enum1) { +>foo : (x: Enum1) => void +>x : Enum1 +>Enum1 : Enum1 + + switch (x) { +>x : Enum1 + + case Enum1.A: +>Enum1.A : Enum1 +>Enum1 : typeof Enum1 +>A : Enum1 + + case Enum1.B: +>Enum1.B : Enum1 +>Enum1 : typeof Enum1 +>B : Enum1 + + case Enum1.C: +>Enum1.C : Enum1 +>Enum1 : typeof Enum1 +>C : Enum1 + + case Enum1.D: +>Enum1.D : Enum1 +>Enum1 : typeof Enum1 +>D : Enum1 + + case Enum1.E: +>Enum1.E : Enum1 +>Enum1 : typeof Enum1 +>E : Enum1 + + case Enum1.F: +>Enum1.F : Enum1 +>Enum1 : typeof Enum1 +>F : Enum1 + + case Enum1.G: +>Enum1.G : Enum1 +>Enum1 : typeof Enum1 +>G : Enum1 + + case Enum1.H: +>Enum1.H : Enum1 +>Enum1 : typeof Enum1 +>H : Enum1 + + case Enum1.I: +>Enum1.I : Enum1 +>Enum1 : typeof Enum1 +>I : Enum1 + + case Enum1.J: +>Enum1.J : Enum1 +>Enum1 : typeof Enum1 +>J : Enum1 + + case Enum1.K: +>Enum1.K : Enum1 +>Enum1 : typeof Enum1 +>K : Enum1 + + case Enum1.L: +>Enum1.L : Enum1 +>Enum1 : typeof Enum1 +>L : Enum1 + + case Enum1.M: +>Enum1.M : Enum1 +>Enum1 : typeof Enum1 +>M : Enum1 + + case Enum1.N: +>Enum1.N : Enum1 +>Enum1 : typeof Enum1 +>N : Enum1 + + case Enum1.O: +>Enum1.O : Enum1 +>Enum1 : typeof Enum1 +>O : Enum1 + + case Enum1.P: +>Enum1.P : Enum1 +>Enum1 : typeof Enum1 +>P : Enum1 + + case Enum1.Q: +>Enum1.Q : Enum1 +>Enum1 : typeof Enum1 +>Q : Enum1 + + case Enum1.R: +>Enum1.R : Enum1 +>Enum1 : typeof Enum1 +>R : Enum1 + + case Enum1.S: +>Enum1.S : Enum1 +>Enum1 : typeof Enum1 +>S : Enum1 + + case Enum1["T"]: +>Enum1["T"] : Enum1 +>Enum1 : typeof Enum1 + + case Enum1.U: +>Enum1.U : Enum1 +>Enum1 : typeof Enum1 +>U : Enum1 + + case Enum1.V: +>Enum1.V : Enum1 +>Enum1 : typeof Enum1 +>V : Enum1 + + case Enum1.W: +>Enum1.W : Enum1 +>Enum1 : typeof Enum1 +>W : Enum1 + + case Enum1.W1: +>Enum1.W1 : Enum1 +>Enum1 : typeof Enum1 +>W1 : Enum1 + + case Enum1.W2: +>Enum1.W2 : Enum1 +>Enum1 : typeof Enum1 +>W2 : Enum1 + + case Enum1.W3: +>Enum1.W3 : Enum1 +>Enum1 : typeof Enum1 +>W3 : Enum1 + + case Enum1.W4: +>Enum1.W4 : Enum1 +>Enum1 : typeof Enum1 +>W4 : Enum1 + + break; + } +} + +function bar(e: A.B.C.E): number { +>bar : (e: I) => number +>e : I +>A : unknown +>B : unknown +>C : unknown +>E : I + + switch (e) { +>e : I + + case A.B.C.E.V1: return 1; +>A.B.C.E.V1 : I +>A.B.C.E : typeof I +>A.B.C : typeof A.B.C +>A.B : typeof A.B +>A : typeof A +>B : typeof A.B +>C : typeof A.B.C +>E : typeof I +>V1 : I + + case A.B.C.E.V2: return 1; +>A.B.C.E.V2 : I +>A.B.C.E : typeof I +>A.B.C : typeof A.B.C +>A.B : typeof A.B +>A : typeof A +>B : typeof A.B +>C : typeof A.B.C +>E : typeof I +>V2 : I + + case A.B.C.E.V3: return 1; +>A.B.C.E.V3 : I +>A.B.C.E : typeof I +>A.B.C : typeof A.B.C +>A.B : typeof A.B +>A : typeof A +>B : typeof A.B +>C : typeof A.B.C +>E : typeof I +>V3 : I + } +} diff --git a/tests/baselines/reference/decrementOperatorWithEnumType.js b/tests/baselines/reference/decrementOperatorWithEnumType.js index 13947a6a948..15247ea4225 100644 --- a/tests/baselines/reference/decrementOperatorWithEnumType.js +++ b/tests/baselines/reference/decrementOperatorWithEnumType.js @@ -22,8 +22,8 @@ var ENUM1; })(ENUM1 || (ENUM1 = {})); ; // expression -var ResultIsNumber1 = --ENUM1["A"]; +var ResultIsNumber1 = --0 /* "A" */; var ResultIsNumber2 = 0 /* A */--; // miss assignment operator ---ENUM1["A"]; +--0 /* "A" */; ENUM1[A]--; diff --git a/tests/baselines/reference/deleteOperatorWithEnumType.js b/tests/baselines/reference/deleteOperatorWithEnumType.js index e694790091c..b87ab8298a7 100644 --- a/tests/baselines/reference/deleteOperatorWithEnumType.js +++ b/tests/baselines/reference/deleteOperatorWithEnumType.js @@ -39,11 +39,11 @@ var ENUM1; var ResultIsBoolean1 = delete ENUM; var ResultIsBoolean2 = delete ENUM1; // enum type expressions -var ResultIsBoolean3 = delete ENUM1["A"]; -var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]); +var ResultIsBoolean3 = delete 0 /* "A" */; +var ResultIsBoolean4 = delete (ENUM[0] + 1 /* "B" */); // multiple delete operators var ResultIsBoolean5 = delete delete ENUM; -var ResultIsBoolean6 = delete delete delete (ENUM[0] + ENUM1["B"]); +var ResultIsBoolean6 = delete delete delete (ENUM[0] + 1 /* "B" */); // miss assignment operators delete ENUM; delete ENUM1; diff --git a/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt b/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt new file mode 100644 index 00000000000..b9890e925c4 --- /dev/null +++ b/tests/baselines/reference/directDependenceBetweenTypeAliases.errors.txt @@ -0,0 +1,72 @@ +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(4,6): error TS2456: Type alias 'T0' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(6,6): error TS2456: Type alias 'T0_2' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(11,6): error TS2456: Type alias 'T1' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(14,6): error TS2456: Type alias 'T2' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(16,6): error TS2456: Type alias 'T2_1' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(19,6): error TS2456: Type alias 'T3' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(22,6): error TS2456: Type alias 'T4' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(26,6): error TS2456: Type alias 'T5' circularly references itself. +tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts(30,6): error TS2456: Type alias 'T7' circularly references itself. + + +==== tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts (9 errors) ==== + // It is an error for the type specified in a type alias to depend on that type alias + + // A type alias directly depends on the type it aliases. + type T0 = T0 + ~~ +!!! error TS2456: Type alias 'T0' circularly references itself. + type T0_1 = T0_2 + type T0_2 = T0_3 + ~~~~ +!!! error TS2456: Type alias 'T0_2' circularly references itself. + type T0_3 = T0_1 + + // A type reference directly depends on the referenced type and each of the type arguments, if any. + interface I {} + type T1 = I + ~~ +!!! error TS2456: Type alias 'T1' circularly references itself. + + // A union type directly depends on each of the constituent types. + type T2 = T2 | string + ~~ +!!! error TS2456: Type alias 'T2' circularly references itself. + class C {} + type T2_1 = T2_1[] | number + ~~~~ +!!! error TS2456: Type alias 'T2_1' circularly references itself. + + // An array type directly depends on its element type. + type T3 = T3[] + ~~ +!!! error TS2456: Type alias 'T3' circularly references itself. + + // A tuple type directly depends on each of its element types. + type T4 = [number, T4] + ~~ +!!! error TS2456: Type alias 'T4' circularly references itself. + + // A type query directly depends on the type of the referenced entity. + var x: T5[] = [] + type T5 = typeof x + ~~ +!!! error TS2456: Type alias 'T5' circularly references itself. + + class C1 {} + type T6 = T7 | number + type T7 = typeof yy + ~~ +!!! error TS2456: Type alias 'T7' circularly references itself. + var yy: [string, T8[]]; + type T8 = C + + // legal cases + type T9 = () => T9 + type T10 = { x: T10 } | { new(v: T10): string } + type T11 = T12[] + type T12 = [T13, string] + type T13 = typeof zz + var zz: { x: T11 } + + \ No newline at end of file diff --git a/tests/baselines/reference/directDependenceBetweenTypeAliases.js b/tests/baselines/reference/directDependenceBetweenTypeAliases.js new file mode 100644 index 00000000000..370e33483fc --- /dev/null +++ b/tests/baselines/reference/directDependenceBetweenTypeAliases.js @@ -0,0 +1,60 @@ +//// [directDependenceBetweenTypeAliases.ts] +// It is an error for the type specified in a type alias to depend on that type alias + +// A type alias directly depends on the type it aliases. +type T0 = T0 +type T0_1 = T0_2 +type T0_2 = T0_3 +type T0_3 = T0_1 + +// A type reference directly depends on the referenced type and each of the type arguments, if any. +interface I {} +type T1 = I + +// A union type directly depends on each of the constituent types. +type T2 = T2 | string +class C {} +type T2_1 = T2_1[] | number + +// An array type directly depends on its element type. +type T3 = T3[] + +// A tuple type directly depends on each of its element types. +type T4 = [number, T4] + +// A type query directly depends on the type of the referenced entity. +var x: T5[] = [] +type T5 = typeof x + +class C1 {} +type T6 = T7 | number +type T7 = typeof yy +var yy: [string, T8[]]; +type T8 = C + +// legal cases +type T9 = () => T9 +type T10 = { x: T10 } | { new(v: T10): string } +type T11 = T12[] +type T12 = [T13, string] +type T13 = typeof zz +var zz: { x: T11 } + + + +//// [directDependenceBetweenTypeAliases.js] +// It is an error for the type specified in a type alias to depend on that type alias +var C = (function () { + function C() { + } + return C; +})(); +// A type query directly depends on the type of the referenced entity. +var x = []; +var C1 = (function () { + function C1() { + } + return C1; +})(); +var yy; +var zz; diff --git a/tests/baselines/reference/incrementOperatorWithEnumType.js b/tests/baselines/reference/incrementOperatorWithEnumType.js index 2baa326f399..590815ffec5 100644 --- a/tests/baselines/reference/incrementOperatorWithEnumType.js +++ b/tests/baselines/reference/incrementOperatorWithEnumType.js @@ -22,8 +22,8 @@ var ENUM1; })(ENUM1 || (ENUM1 = {})); ; // expression -var ResultIsNumber1 = ++ENUM1["B"]; +var ResultIsNumber1 = ++1 /* "B" */; var ResultIsNumber2 = 1 /* B */++; // miss assignment operator -++ENUM1["B"]; +++1 /* "B" */; 1 /* B */++; diff --git a/tests/baselines/reference/logicalNotOperatorWithEnumType.js b/tests/baselines/reference/logicalNotOperatorWithEnumType.js index 69ea283051d..89ee1a14833 100644 --- a/tests/baselines/reference/logicalNotOperatorWithEnumType.js +++ b/tests/baselines/reference/logicalNotOperatorWithEnumType.js @@ -37,11 +37,11 @@ var ENUM1; // enum type var var ResultIsBoolean1 = !ENUM; // enum type expressions -var ResultIsBoolean2 = !ENUM["B"]; -var ResultIsBoolean3 = !(1 /* B */ + ENUM["C"]); +var ResultIsBoolean2 = !1 /* "B" */; +var ResultIsBoolean3 = !(1 /* B */ + 2 /* "C" */); // multiple ! operators var ResultIsBoolean4 = !!ENUM; -var ResultIsBoolean5 = !!!(ENUM["B"] + 2 /* C */); +var ResultIsBoolean5 = !!!(1 /* "B" */ + 2 /* C */); // miss assignment operators !ENUM; !ENUM1; diff --git a/tests/baselines/reference/negateOperatorWithEnumType.js b/tests/baselines/reference/negateOperatorWithEnumType.js index 876bed45cc2..77458f442df 100644 --- a/tests/baselines/reference/negateOperatorWithEnumType.js +++ b/tests/baselines/reference/negateOperatorWithEnumType.js @@ -33,10 +33,10 @@ var ENUM1; // enum type var var ResultIsNumber1 = -ENUM; // expressions -var ResultIsNumber2 = -ENUM1["B"]; -var ResultIsNumber3 = -(1 /* B */ + ENUM1[""]); +var ResultIsNumber2 = -1 /* "B" */; +var ResultIsNumber3 = -(1 /* B */ + 2 /* "" */); // miss assignment operators -ENUM; -ENUM1; --ENUM1["B"]; +-1 /* "B" */; -ENUM, ENUM1; diff --git a/tests/baselines/reference/noImplicitAnyIndexing.js b/tests/baselines/reference/noImplicitAnyIndexing.js index ebadbd9a121..91dbcae730c 100644 --- a/tests/baselines/reference/noImplicitAnyIndexing.js +++ b/tests/baselines/reference/noImplicitAnyIndexing.js @@ -61,7 +61,7 @@ var strRepresentation2 = MyEmusEnum[0 /* emu */]; // Should be implicit 'any' ; property access fails, no string indexer. var strRepresentation3 = MyEmusEnum["monehh"]; // Should be okay; should be a MyEmusEnum -var strRepresentation4 = MyEmusEnum["emu"]; +var strRepresentation4 = 0 /* "emu" */; // Should report an implicit 'any'. var x = {}["hi"]; // Should report an implicit 'any'. diff --git a/tests/baselines/reference/plusOperatorWithEnumType.js b/tests/baselines/reference/plusOperatorWithEnumType.js index 4d6eaad892e..1ce6036d5ce 100644 --- a/tests/baselines/reference/plusOperatorWithEnumType.js +++ b/tests/baselines/reference/plusOperatorWithEnumType.js @@ -35,8 +35,8 @@ var ENUM1; var ResultIsNumber1 = +ENUM; var ResultIsNumber2 = +ENUM1; // enum type expressions -var ResultIsNumber3 = +ENUM1["A"]; -var ResultIsNumber4 = +(ENUM[0] + ENUM1["B"]); +var ResultIsNumber3 = +0 /* "A" */; +var ResultIsNumber4 = +(ENUM[0] + 1 /* "B" */); // miss assignment operators +ENUM; +ENUM1; diff --git a/tests/baselines/reference/preserveConstEnums.js b/tests/baselines/reference/preserveConstEnums.js new file mode 100644 index 00000000000..3f27825283f --- /dev/null +++ b/tests/baselines/reference/preserveConstEnums.js @@ -0,0 +1,11 @@ +//// [preserveConstEnums.ts] +const enum E { + Value = 1, Value2 = Value +} + +//// [preserveConstEnums.js] +var E; +(function (E) { + E[E["Value"] = 1] = "Value"; + E[E["Value2"] = 1] = "Value2"; +})(E || (E = {})); diff --git a/tests/baselines/reference/preserveConstEnums.types b/tests/baselines/reference/preserveConstEnums.types new file mode 100644 index 00000000000..080cdbffb2b --- /dev/null +++ b/tests/baselines/reference/preserveConstEnums.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/preserveConstEnums.ts === +const enum E { +>E : E + + Value = 1, Value2 = Value +>Value : E +>Value2 : E +>Value : E +} diff --git a/tests/baselines/reference/reservedNamesInAliases.errors.txt b/tests/baselines/reference/reservedNamesInAliases.errors.txt new file mode 100644 index 00000000000..9f2d87c5409 --- /dev/null +++ b/tests/baselines/reference/reservedNamesInAliases.errors.txt @@ -0,0 +1,30 @@ +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1003: Identifier expected. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1005: ';' expected. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(2,6): error TS2457: Type alias name cannot be 'any' +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(3,6): error TS2457: Type alias name cannot be 'number' +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(4,6): error TS2457: Type alias name cannot be 'boolean' +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(5,6): error TS2457: Type alias name cannot be 'string' +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2304: Cannot find name 'I'. + + +==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (7 errors) ==== + interface I {} + type any = I; + ~~~ +!!! error TS2457: Type alias name cannot be 'any' + type number = I; + ~~~~~~ +!!! error TS2457: Type alias name cannot be 'number' + type boolean = I; + ~~~~~~~ +!!! error TS2457: Type alias name cannot be 'boolean' + type string = I; + ~~~~~~ +!!! error TS2457: Type alias name cannot be 'string' + type void = I; + ~~~~ +!!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'I'. \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationStatements.js b/tests/baselines/reference/sourceMapValidationStatements.js index 85a4dc33889..8a4b565e9b0 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.js +++ b/tests/baselines/reference/sourceMapValidationStatements.js @@ -136,22 +136,19 @@ function f() { z = 10; } switch (obj.z) { - case 0: - { - x++; - break; - } - case 1: - { - x--; - break; - } - default: - { - x *= 2; - x = 50; - break; - } + case 0: { + x++; + break; + } + case 1: { + x--; + break; + } + default: { + x *= 2; + x = 50; + break; + } } while (x < 10) { x++; diff --git a/tests/baselines/reference/sourceMapValidationStatements.js.map b/tests/baselines/reference/sourceMapValidationStatements.js.map index a8ff3d46038..02b5c0bb806 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.js.map +++ b/tests/baselines/reference/sourceMapValidationStatements.js.map @@ -1,2 +1,2 @@ //// [sourceMapValidationStatements.js.map] -{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":["f"],"mappings":"AAAA,SAAS,CAAC;IACNA,IAAIA,CAACA,CAACA;IACNA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACVA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,EAAEA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;QAC1BA,CAACA,IAAIA,CAACA,CAACA;QACPA,CAACA,IAAIA,CAACA,CAACA;IACXA,CAACA;IACDA,EAAEA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA;QACTA,CAACA,IAAIA,CAACA,CAACA;IACXA,CAACA;IAACA,IAAIA,CAACA,CAACA;QACJA,CAACA,IAAIA,EAAEA,CAACA;QACRA,CAACA,EAAEA,CAACA;IACRA,CAACA;IACDA,IAAIA,CAACA,GAAGA;QACJA,CAACA;QACDA,CAACA;QACDA,CAACA;KACJA,CAACA;IACFA,IAAIA,GAAGA,GAAGA;QACNA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,OAAOA;KACbA,CAACA;IACFA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA;QACdA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACbA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IACfA,CAACA;IACDA,IAAAA,CAACA;QACGA,GAAGA,CAACA,CAACA,GAAGA,MAAMA,CAACA;IACnBA,CAAEA;IAAAA,KAAKA,CAACA,CAACA,CAACA,CAACA,CAATA,CAACA;QACCA,EAAEA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA;YACbA,GAAGA,CAACA,CAACA,GAAGA,EAAEA,CAACA;QACfA,CAACA;QAACA,IAAIA,CAACA,CAACA;YACJA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,CAACA;QAClBA,CAACA;IACLA,CAACA;IACDA,IAAAA,CAACA;QACGA,MAAMA,IAAIA,KAAKA,EAAEA,CAACA;IACtBA,CAAEA;IAAAA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAAVA,CAACA;QACCA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IACfA,CAACA;YAACA,CAACA;QACCA,CAACA,GAAGA,EAAEA,CAACA;IACXA,CAACA;IACDA,MAAMA,GAAGA,EAAEA,CAACA;QACRA,CAACA,GAAGA,CAACA,CAACA;QACNA,CAACA,GAAGA,EAAEA,CAACA;IACXA,CAACA;IACDA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACZA,KAAKA,CAACA;YAAEA,CAACA;gBACLA,CAACA,EAAEA,CAACA;gBACJA,KAAKA,CAACA;YAEVA,CAACA;QACDA,KAAKA,CAACA;YAAEA,CAACA;gBACLA,CAACA,EAAEA,CAACA;gBACJA,KAAKA,CAACA;YAEVA,CAACA;QACDA;YAASA,CAACA;gBACNA,CAACA,IAAIA,CAACA,CAACA;gBACPA,CAACA,GAAGA,EAAEA,CAACA;gBACPA,KAAKA,CAACA;YAEVA,CAACA;IACLA,CAACA;IACDA,OAAOA,CAACA,GAAGA,EAAEA,EAAEA,CAACA;QACZA,CAACA,EAAEA,CAACA;IACRA,CAACA;IACDA,GAAGA,CAACA;QACAA,CAACA,EAAEA,CAACA;IACRA,CAACA,QAAQA,CAACA,GAAGA,CAACA,EAACA;IACfA,CAACA,GAAGA,CAACA,CAACA;IACNA,IAAIA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IACjCA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IACzBA,CAACA,KAAKA,CAACA,CAACA;IACRA,CAACA,GAAGA,CAACA,GAAGA,EAAEA,CAACA;IACXA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACVA,MAAMA,CAACA;AACXA,CAACA;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"} \ No newline at end of file +{"version":3,"file":"sourceMapValidationStatements.js","sourceRoot":"","sources":["sourceMapValidationStatements.ts"],"names":["f"],"mappings":"AAAA,SAAS,CAAC;IACNA,IAAIA,CAACA,CAACA;IACNA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACVA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,CAACA,EAAEA,CAACA,GAAGA,EAAEA,EAAEA,CAACA,EAAEA,EAAEA,CAACA;QAC1BA,CAACA,IAAIA,CAACA,CAACA;QACPA,CAACA,IAAIA,CAACA,CAACA;IACXA,CAACA;IACDA,EAAEA,CAACA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA;QACTA,CAACA,IAAIA,CAACA,CAACA;IACXA,CAACA;IAACA,IAAIA,CAACA,CAACA;QACJA,CAACA,IAAIA,EAAEA,CAACA;QACRA,CAACA,EAAEA,CAACA;IACRA,CAACA;IACDA,IAAIA,CAACA,GAAGA;QACJA,CAACA;QACDA,CAACA;QACDA,CAACA;KACJA,CAACA;IACFA,IAAIA,GAAGA,GAAGA;QACNA,CAACA,EAAEA,CAACA;QACJA,CAACA,EAAEA,OAAOA;KACbA,CAACA;IACFA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,CAACA,CAACA;QACdA,GAAGA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACbA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IACfA,CAACA;IACDA,IAAAA,CAACA;QACGA,GAAGA,CAACA,CAACA,GAAGA,MAAMA,CAACA;IACnBA,CAAEA;IAAAA,KAAKA,CAACA,CAACA,CAACA,CAACA,CAATA,CAACA;QACCA,EAAEA,CAACA,CAACA,GAAGA,CAACA,CAACA,GAAGA,EAAEA,CAACA,CAACA,CAACA;YACbA,GAAGA,CAACA,CAACA,GAAGA,EAAEA,CAACA;QACfA,CAACA;QAACA,IAAIA,CAACA,CAACA;YACJA,GAAGA,CAACA,CAACA,GAAGA,KAAKA,CAACA;QAClBA,CAACA;IACLA,CAACA;IACDA,IAAAA,CAACA;QACGA,MAAMA,IAAIA,KAAKA,EAAEA,CAACA;IACtBA,CAAEA;IAAAA,KAAKA,CAACA,CAACA,EAAEA,CAACA,CAAVA,CAACA;QACCA,IAAIA,CAACA,GAAGA,EAAEA,CAACA;IACfA,CAACA;YAACA,CAACA;QACCA,CAACA,GAAGA,EAAEA,CAACA;IACXA,CAACA;IACDA,MAAMA,GAAGA,EAAEA,CAACA;QACRA,CAACA,GAAGA,CAACA,CAACA;QACNA,CAACA,GAAGA,EAAEA,CAACA;IACXA,CAACA;IACDA,MAAMA,CAACA,CAACA,GAAGA,CAACA,CAACA,CAACA,CAACA,CAACA;QACZA,KAAKA,CAACA,EAAEA,CAACA;YACLA,CAACA,EAAEA,CAACA;YACJA,KAAKA,CAACA;QAEVA,CAACA;QACDA,KAAKA,CAACA,EAAEA,CAACA;YACLA,CAACA,EAAEA,CAACA;YACJA,KAAKA,CAACA;QAEVA,CAACA;QACDA,SAASA,CAACA;YACNA,CAACA,IAAIA,CAACA,CAACA;YACPA,CAACA,GAAGA,EAAEA,CAACA;YACPA,KAAKA,CAACA;QAEVA,CAACA;IACLA,CAACA;IACDA,OAAOA,CAACA,GAAGA,EAAEA,EAAEA,CAACA;QACZA,CAACA,EAAEA,CAACA;IACRA,CAACA;IACDA,GAAGA,CAACA;QACAA,CAACA,EAAEA,CAACA;IACRA,CAACA,QAAQA,CAACA,GAAGA,CAACA,EAACA;IACfA,CAACA,GAAGA,CAACA,CAACA;IACNA,IAAIA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IACjCA,CAACA,CAACA,IAAIA,CAACA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,GAAGA,CAACA,CAACA;IACzBA,CAACA,KAAKA,CAACA,CAACA;IACRA,CAACA,GAAGA,CAACA,GAAGA,EAAEA,CAACA;IACXA,IAAIA,CAACA,GAAGA,CAACA,CAACA;IACVA,MAAMA,CAACA;AACXA,CAACA;AACD,IAAI,CAAC,GAAG;IACJ,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACd,CAAC,CAAC;AACF,CAAC,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt b/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt index d997557cdfe..1a288e3a830 100644 --- a/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt +++ b/tests/baselines/reference/sourceMapValidationStatements.sourcemap.txt @@ -936,200 +936,191 @@ sourceFile:sourceMapValidationStatements.ts 9 >Emitted(52, 20) Source(47, 20) + SourceIndex(0) name (f) 10>Emitted(52, 21) Source(47, 21) + SourceIndex(0) name (f) --- ->>> case 0: +>>> case 0: { 1 >^^^^^^^^ 2 > ^^^^^ 3 > ^ +4 > ^^ +5 > ^ 1 > > 2 > case 3 > 0 +4 > : +5 > { 1 >Emitted(53, 9) Source(48, 9) + SourceIndex(0) name (f) 2 >Emitted(53, 14) Source(48, 14) + SourceIndex(0) name (f) 3 >Emitted(53, 15) Source(48, 15) + SourceIndex(0) name (f) +4 >Emitted(53, 17) Source(48, 17) + SourceIndex(0) name (f) +5 >Emitted(53, 18) Source(48, 18) + SourceIndex(0) name (f) --- ->>> { +>>> x++; 1 >^^^^^^^^^^^^ 2 > ^ -3 > ^^^^^^^^-> -1 >: -2 > { -1 >Emitted(54, 13) Source(48, 17) + SourceIndex(0) name (f) -2 >Emitted(54, 14) Source(48, 18) + SourceIndex(0) name (f) +3 > ^^ +4 > ^ +5 > ^^^-> +1 > + > +2 > x +3 > ++ +4 > ; +1 >Emitted(54, 13) Source(49, 13) + SourceIndex(0) name (f) +2 >Emitted(54, 14) Source(49, 14) + SourceIndex(0) name (f) +3 >Emitted(54, 16) Source(49, 16) + SourceIndex(0) name (f) +4 >Emitted(54, 17) Source(49, 17) + SourceIndex(0) name (f) --- ->>> x++; -1->^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^ -4 > ^ -5 > ^^^-> +>>> break; +1->^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ 1-> > -2 > x -3 > ++ -4 > ; -1->Emitted(55, 17) Source(49, 13) + SourceIndex(0) name (f) -2 >Emitted(55, 18) Source(49, 14) + SourceIndex(0) name (f) -3 >Emitted(55, 20) Source(49, 16) + SourceIndex(0) name (f) -4 >Emitted(55, 21) Source(49, 17) + SourceIndex(0) name (f) +2 > break +3 > ; +1->Emitted(55, 13) Source(50, 13) + SourceIndex(0) name (f) +2 >Emitted(55, 18) Source(50, 18) + SourceIndex(0) name (f) +3 >Emitted(55, 19) Source(50, 19) + SourceIndex(0) name (f) --- ->>> break; -1->^^^^^^^^^^^^^^^^ -2 > ^^^^^ -3 > ^ -1-> - > -2 > break -3 > ; -1->Emitted(56, 17) Source(50, 13) + SourceIndex(0) name (f) -2 >Emitted(56, 22) Source(50, 18) + SourceIndex(0) name (f) -3 >Emitted(56, 23) Source(50, 19) + SourceIndex(0) name (f) ---- ->>> } -1 >^^^^^^^^^^^^ -2 > ^ -3 > ^^^-> +>>> } +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^-> 1 > > > -2 > } -1 >Emitted(57, 13) Source(52, 9) + SourceIndex(0) name (f) -2 >Emitted(57, 14) Source(52, 10) + SourceIndex(0) name (f) +2 > } +1 >Emitted(56, 9) Source(52, 9) + SourceIndex(0) name (f) +2 >Emitted(56, 10) Source(52, 10) + SourceIndex(0) name (f) --- ->>> case 1: +>>> case 1: { 1->^^^^^^^^ 2 > ^^^^^ 3 > ^ +4 > ^^ +5 > ^ 1-> > 2 > case 3 > 1 -1->Emitted(58, 9) Source(53, 9) + SourceIndex(0) name (f) -2 >Emitted(58, 14) Source(53, 14) + SourceIndex(0) name (f) -3 >Emitted(58, 15) Source(53, 15) + SourceIndex(0) name (f) +4 > : +5 > { +1->Emitted(57, 9) Source(53, 9) + SourceIndex(0) name (f) +2 >Emitted(57, 14) Source(53, 14) + SourceIndex(0) name (f) +3 >Emitted(57, 15) Source(53, 15) + SourceIndex(0) name (f) +4 >Emitted(57, 17) Source(53, 17) + SourceIndex(0) name (f) +5 >Emitted(57, 18) Source(53, 18) + SourceIndex(0) name (f) --- ->>> { +>>> x--; 1 >^^^^^^^^^^^^ 2 > ^ -3 > ^^^^^^^^-> -1 >: -2 > { -1 >Emitted(59, 13) Source(53, 17) + SourceIndex(0) name (f) -2 >Emitted(59, 14) Source(53, 18) + SourceIndex(0) name (f) +3 > ^^ +4 > ^ +5 > ^^^-> +1 > + > +2 > x +3 > -- +4 > ; +1 >Emitted(58, 13) Source(54, 13) + SourceIndex(0) name (f) +2 >Emitted(58, 14) Source(54, 14) + SourceIndex(0) name (f) +3 >Emitted(58, 16) Source(54, 16) + SourceIndex(0) name (f) +4 >Emitted(58, 17) Source(54, 17) + SourceIndex(0) name (f) --- ->>> x--; -1->^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^ -4 > ^ -5 > ^^^-> +>>> break; +1->^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ 1-> > -2 > x -3 > -- -4 > ; -1->Emitted(60, 17) Source(54, 13) + SourceIndex(0) name (f) -2 >Emitted(60, 18) Source(54, 14) + SourceIndex(0) name (f) -3 >Emitted(60, 20) Source(54, 16) + SourceIndex(0) name (f) -4 >Emitted(60, 21) Source(54, 17) + SourceIndex(0) name (f) +2 > break +3 > ; +1->Emitted(59, 13) Source(55, 13) + SourceIndex(0) name (f) +2 >Emitted(59, 18) Source(55, 18) + SourceIndex(0) name (f) +3 >Emitted(59, 19) Source(55, 19) + SourceIndex(0) name (f) --- ->>> break; -1->^^^^^^^^^^^^^^^^ -2 > ^^^^^ -3 > ^ -1-> - > -2 > break -3 > ; -1->Emitted(61, 17) Source(55, 13) + SourceIndex(0) name (f) -2 >Emitted(61, 22) Source(55, 18) + SourceIndex(0) name (f) -3 >Emitted(61, 23) Source(55, 19) + SourceIndex(0) name (f) ---- ->>> } -1 >^^^^^^^^^^^^ -2 > ^ -3 > ^^^^-> +>>> } +1 >^^^^^^^^ +2 > ^ +3 > ^^^^^^^^^^-> 1 > > > -2 > } -1 >Emitted(62, 13) Source(57, 9) + SourceIndex(0) name (f) -2 >Emitted(62, 14) Source(57, 10) + SourceIndex(0) name (f) +2 > } +1 >Emitted(60, 9) Source(57, 9) + SourceIndex(0) name (f) +2 >Emitted(60, 10) Source(57, 10) + SourceIndex(0) name (f) --- ->>> default: +>>> default: { 1->^^^^^^^^ -2 > ^^^^^^-> +2 > ^^^^^^^^^ +3 > ^ +4 > ^^-> 1-> > -1->Emitted(63, 9) Source(58, 9) + SourceIndex(0) name (f) +2 > default: +3 > { +1->Emitted(61, 9) Source(58, 9) + SourceIndex(0) name (f) +2 >Emitted(61, 18) Source(58, 18) + SourceIndex(0) name (f) +3 >Emitted(61, 19) Source(58, 19) + SourceIndex(0) name (f) --- ->>> { +>>> x *= 2; 1->^^^^^^^^^^^^ 2 > ^ -3 > ^^^^^^^^^^^-> -1->default: -2 > { -1->Emitted(64, 13) Source(58, 18) + SourceIndex(0) name (f) -2 >Emitted(64, 14) Source(58, 19) + SourceIndex(0) name (f) ---- ->>> x *= 2; -1->^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^^^ -4 > ^ -5 > ^ -6 > ^-> +3 > ^^^^ +4 > ^ +5 > ^ +6 > ^-> 1-> > -2 > x -3 > *= -4 > 2 -5 > ; -1->Emitted(65, 17) Source(59, 13) + SourceIndex(0) name (f) -2 >Emitted(65, 18) Source(59, 14) + SourceIndex(0) name (f) -3 >Emitted(65, 22) Source(59, 18) + SourceIndex(0) name (f) -4 >Emitted(65, 23) Source(59, 19) + SourceIndex(0) name (f) -5 >Emitted(65, 24) Source(59, 20) + SourceIndex(0) name (f) +2 > x +3 > *= +4 > 2 +5 > ; +1->Emitted(62, 13) Source(59, 13) + SourceIndex(0) name (f) +2 >Emitted(62, 14) Source(59, 14) + SourceIndex(0) name (f) +3 >Emitted(62, 18) Source(59, 18) + SourceIndex(0) name (f) +4 >Emitted(62, 19) Source(59, 19) + SourceIndex(0) name (f) +5 >Emitted(62, 20) Source(59, 20) + SourceIndex(0) name (f) --- ->>> x = 50; -1->^^^^^^^^^^^^^^^^ -2 > ^ -3 > ^^^ -4 > ^^ -5 > ^ +>>> x = 50; +1->^^^^^^^^^^^^ +2 > ^ +3 > ^^^ +4 > ^^ +5 > ^ 1-> > -2 > x -3 > = -4 > 50 -5 > ; -1->Emitted(66, 17) Source(60, 13) + SourceIndex(0) name (f) -2 >Emitted(66, 18) Source(60, 14) + SourceIndex(0) name (f) -3 >Emitted(66, 21) Source(60, 17) + SourceIndex(0) name (f) -4 >Emitted(66, 23) Source(60, 19) + SourceIndex(0) name (f) -5 >Emitted(66, 24) Source(60, 20) + SourceIndex(0) name (f) +2 > x +3 > = +4 > 50 +5 > ; +1->Emitted(63, 13) Source(60, 13) + SourceIndex(0) name (f) +2 >Emitted(63, 14) Source(60, 14) + SourceIndex(0) name (f) +3 >Emitted(63, 17) Source(60, 17) + SourceIndex(0) name (f) +4 >Emitted(63, 19) Source(60, 19) + SourceIndex(0) name (f) +5 >Emitted(63, 20) Source(60, 20) + SourceIndex(0) name (f) --- ->>> break; -1 >^^^^^^^^^^^^^^^^ -2 > ^^^^^ -3 > ^ +>>> break; +1 >^^^^^^^^^^^^ +2 > ^^^^^ +3 > ^ 1 > > -2 > break -3 > ; -1 >Emitted(67, 17) Source(61, 13) + SourceIndex(0) name (f) -2 >Emitted(67, 22) Source(61, 18) + SourceIndex(0) name (f) -3 >Emitted(67, 23) Source(61, 19) + SourceIndex(0) name (f) +2 > break +3 > ; +1 >Emitted(64, 13) Source(61, 13) + SourceIndex(0) name (f) +2 >Emitted(64, 18) Source(61, 18) + SourceIndex(0) name (f) +3 >Emitted(64, 19) Source(61, 19) + SourceIndex(0) name (f) --- ->>> } -1 >^^^^^^^^^^^^ -2 > ^ +>>> } +1 >^^^^^^^^ +2 > ^ 1 > > > -2 > } -1 >Emitted(68, 13) Source(63, 9) + SourceIndex(0) name (f) -2 >Emitted(68, 14) Source(63, 10) + SourceIndex(0) name (f) +2 > } +1 >Emitted(65, 9) Source(63, 9) + SourceIndex(0) name (f) +2 >Emitted(65, 10) Source(63, 10) + SourceIndex(0) name (f) --- >>> } 1 >^^^^ @@ -1138,8 +1129,8 @@ sourceFile:sourceMapValidationStatements.ts 1 > > 2 > } -1 >Emitted(69, 5) Source(64, 5) + SourceIndex(0) name (f) -2 >Emitted(69, 6) Source(64, 6) + SourceIndex(0) name (f) +1 >Emitted(66, 5) Source(64, 5) + SourceIndex(0) name (f) +2 >Emitted(66, 6) Source(64, 6) + SourceIndex(0) name (f) --- >>> while (x < 10) { 1->^^^^ @@ -1157,13 +1148,13 @@ sourceFile:sourceMapValidationStatements.ts 5 > 10 6 > ) 7 > { -1->Emitted(70, 5) Source(65, 5) + SourceIndex(0) name (f) -2 >Emitted(70, 12) Source(65, 12) + SourceIndex(0) name (f) -3 >Emitted(70, 13) Source(65, 13) + SourceIndex(0) name (f) -4 >Emitted(70, 16) Source(65, 16) + SourceIndex(0) name (f) -5 >Emitted(70, 18) Source(65, 18) + SourceIndex(0) name (f) -6 >Emitted(70, 20) Source(65, 20) + SourceIndex(0) name (f) -7 >Emitted(70, 21) Source(65, 21) + SourceIndex(0) name (f) +1->Emitted(67, 5) Source(65, 5) + SourceIndex(0) name (f) +2 >Emitted(67, 12) Source(65, 12) + SourceIndex(0) name (f) +3 >Emitted(67, 13) Source(65, 13) + SourceIndex(0) name (f) +4 >Emitted(67, 16) Source(65, 16) + SourceIndex(0) name (f) +5 >Emitted(67, 18) Source(65, 18) + SourceIndex(0) name (f) +6 >Emitted(67, 20) Source(65, 20) + SourceIndex(0) name (f) +7 >Emitted(67, 21) Source(65, 21) + SourceIndex(0) name (f) --- >>> x++; 1 >^^^^^^^^ @@ -1175,10 +1166,10 @@ sourceFile:sourceMapValidationStatements.ts 2 > x 3 > ++ 4 > ; -1 >Emitted(71, 9) Source(66, 9) + SourceIndex(0) name (f) -2 >Emitted(71, 10) Source(66, 10) + SourceIndex(0) name (f) -3 >Emitted(71, 12) Source(66, 12) + SourceIndex(0) name (f) -4 >Emitted(71, 13) Source(66, 13) + SourceIndex(0) name (f) +1 >Emitted(68, 9) Source(66, 9) + SourceIndex(0) name (f) +2 >Emitted(68, 10) Source(66, 10) + SourceIndex(0) name (f) +3 >Emitted(68, 12) Source(66, 12) + SourceIndex(0) name (f) +4 >Emitted(68, 13) Source(66, 13) + SourceIndex(0) name (f) --- >>> } 1 >^^^^ @@ -1187,8 +1178,8 @@ sourceFile:sourceMapValidationStatements.ts 1 > > 2 > } -1 >Emitted(72, 5) Source(67, 5) + SourceIndex(0) name (f) -2 >Emitted(72, 6) Source(67, 6) + SourceIndex(0) name (f) +1 >Emitted(69, 5) Source(67, 5) + SourceIndex(0) name (f) +2 >Emitted(69, 6) Source(67, 6) + SourceIndex(0) name (f) --- >>> do { 1->^^^^ @@ -1199,9 +1190,9 @@ sourceFile:sourceMapValidationStatements.ts > 2 > do 3 > { -1->Emitted(73, 5) Source(68, 5) + SourceIndex(0) name (f) -2 >Emitted(73, 8) Source(68, 8) + SourceIndex(0) name (f) -3 >Emitted(73, 9) Source(68, 9) + SourceIndex(0) name (f) +1->Emitted(70, 5) Source(68, 5) + SourceIndex(0) name (f) +2 >Emitted(70, 8) Source(68, 8) + SourceIndex(0) name (f) +3 >Emitted(70, 9) Source(68, 9) + SourceIndex(0) name (f) --- >>> x--; 1->^^^^^^^^ @@ -1214,10 +1205,10 @@ sourceFile:sourceMapValidationStatements.ts 2 > x 3 > -- 4 > ; -1->Emitted(74, 9) Source(69, 9) + SourceIndex(0) name (f) -2 >Emitted(74, 10) Source(69, 10) + SourceIndex(0) name (f) -3 >Emitted(74, 12) Source(69, 12) + SourceIndex(0) name (f) -4 >Emitted(74, 13) Source(69, 13) + SourceIndex(0) name (f) +1->Emitted(71, 9) Source(69, 9) + SourceIndex(0) name (f) +2 >Emitted(71, 10) Source(69, 10) + SourceIndex(0) name (f) +3 >Emitted(71, 12) Source(69, 12) + SourceIndex(0) name (f) +4 >Emitted(71, 13) Source(69, 13) + SourceIndex(0) name (f) --- >>> } while (x > 4); 1->^^^^ @@ -1235,13 +1226,13 @@ sourceFile:sourceMapValidationStatements.ts 5 > > 6 > 4 7 > ) -1->Emitted(75, 5) Source(70, 5) + SourceIndex(0) name (f) -2 >Emitted(75, 6) Source(70, 6) + SourceIndex(0) name (f) -3 >Emitted(75, 14) Source(70, 14) + SourceIndex(0) name (f) -4 >Emitted(75, 15) Source(70, 15) + SourceIndex(0) name (f) -5 >Emitted(75, 18) Source(70, 18) + SourceIndex(0) name (f) -6 >Emitted(75, 19) Source(70, 19) + SourceIndex(0) name (f) -7 >Emitted(75, 21) Source(70, 20) + SourceIndex(0) name (f) +1->Emitted(72, 5) Source(70, 5) + SourceIndex(0) name (f) +2 >Emitted(72, 6) Source(70, 6) + SourceIndex(0) name (f) +3 >Emitted(72, 14) Source(70, 14) + SourceIndex(0) name (f) +4 >Emitted(72, 15) Source(70, 15) + SourceIndex(0) name (f) +5 >Emitted(72, 18) Source(70, 18) + SourceIndex(0) name (f) +6 >Emitted(72, 19) Source(70, 19) + SourceIndex(0) name (f) +7 >Emitted(72, 21) Source(70, 20) + SourceIndex(0) name (f) --- >>> x = y; 1 >^^^^ @@ -1256,11 +1247,11 @@ sourceFile:sourceMapValidationStatements.ts 3 > = 4 > y 5 > ; -1 >Emitted(76, 5) Source(71, 5) + SourceIndex(0) name (f) -2 >Emitted(76, 6) Source(71, 6) + SourceIndex(0) name (f) -3 >Emitted(76, 9) Source(71, 9) + SourceIndex(0) name (f) -4 >Emitted(76, 10) Source(71, 10) + SourceIndex(0) name (f) -5 >Emitted(76, 11) Source(71, 11) + SourceIndex(0) name (f) +1 >Emitted(73, 5) Source(71, 5) + SourceIndex(0) name (f) +2 >Emitted(73, 6) Source(71, 6) + SourceIndex(0) name (f) +3 >Emitted(73, 9) Source(71, 9) + SourceIndex(0) name (f) +4 >Emitted(73, 10) Source(71, 10) + SourceIndex(0) name (f) +5 >Emitted(73, 11) Source(71, 11) + SourceIndex(0) name (f) --- >>> var z = (x == 1) ? x + 1 : x - 1; 1->^^^^ @@ -1300,24 +1291,24 @@ sourceFile:sourceMapValidationStatements.ts 16> - 17> 1 18> ; -1->Emitted(77, 5) Source(72, 5) + SourceIndex(0) name (f) -2 >Emitted(77, 9) Source(72, 9) + SourceIndex(0) name (f) -3 >Emitted(77, 10) Source(72, 10) + SourceIndex(0) name (f) -4 >Emitted(77, 13) Source(72, 13) + SourceIndex(0) name (f) -5 >Emitted(77, 14) Source(72, 14) + SourceIndex(0) name (f) -6 >Emitted(77, 15) Source(72, 15) + SourceIndex(0) name (f) -7 >Emitted(77, 19) Source(72, 19) + SourceIndex(0) name (f) -8 >Emitted(77, 20) Source(72, 20) + SourceIndex(0) name (f) -9 >Emitted(77, 21) Source(72, 21) + SourceIndex(0) name (f) -10>Emitted(77, 24) Source(72, 24) + SourceIndex(0) name (f) -11>Emitted(77, 25) Source(72, 25) + SourceIndex(0) name (f) -12>Emitted(77, 28) Source(72, 28) + SourceIndex(0) name (f) -13>Emitted(77, 29) Source(72, 29) + SourceIndex(0) name (f) -14>Emitted(77, 32) Source(72, 32) + SourceIndex(0) name (f) -15>Emitted(77, 33) Source(72, 33) + SourceIndex(0) name (f) -16>Emitted(77, 36) Source(72, 36) + SourceIndex(0) name (f) -17>Emitted(77, 37) Source(72, 37) + SourceIndex(0) name (f) -18>Emitted(77, 38) Source(72, 38) + SourceIndex(0) name (f) +1->Emitted(74, 5) Source(72, 5) + SourceIndex(0) name (f) +2 >Emitted(74, 9) Source(72, 9) + SourceIndex(0) name (f) +3 >Emitted(74, 10) Source(72, 10) + SourceIndex(0) name (f) +4 >Emitted(74, 13) Source(72, 13) + SourceIndex(0) name (f) +5 >Emitted(74, 14) Source(72, 14) + SourceIndex(0) name (f) +6 >Emitted(74, 15) Source(72, 15) + SourceIndex(0) name (f) +7 >Emitted(74, 19) Source(72, 19) + SourceIndex(0) name (f) +8 >Emitted(74, 20) Source(72, 20) + SourceIndex(0) name (f) +9 >Emitted(74, 21) Source(72, 21) + SourceIndex(0) name (f) +10>Emitted(74, 24) Source(72, 24) + SourceIndex(0) name (f) +11>Emitted(74, 25) Source(72, 25) + SourceIndex(0) name (f) +12>Emitted(74, 28) Source(72, 28) + SourceIndex(0) name (f) +13>Emitted(74, 29) Source(72, 29) + SourceIndex(0) name (f) +14>Emitted(74, 32) Source(72, 32) + SourceIndex(0) name (f) +15>Emitted(74, 33) Source(72, 33) + SourceIndex(0) name (f) +16>Emitted(74, 36) Source(72, 36) + SourceIndex(0) name (f) +17>Emitted(74, 37) Source(72, 37) + SourceIndex(0) name (f) +18>Emitted(74, 38) Source(72, 38) + SourceIndex(0) name (f) --- >>> (x == 1) ? x + 1 : x - 1; 1 >^^^^ @@ -1351,21 +1342,21 @@ sourceFile:sourceMapValidationStatements.ts 13> - 14> 1 15> ; -1 >Emitted(78, 5) Source(73, 5) + SourceIndex(0) name (f) -2 >Emitted(78, 6) Source(73, 6) + SourceIndex(0) name (f) -3 >Emitted(78, 7) Source(73, 7) + SourceIndex(0) name (f) -4 >Emitted(78, 11) Source(73, 11) + SourceIndex(0) name (f) -5 >Emitted(78, 12) Source(73, 12) + SourceIndex(0) name (f) -6 >Emitted(78, 13) Source(73, 13) + SourceIndex(0) name (f) -7 >Emitted(78, 16) Source(73, 16) + SourceIndex(0) name (f) -8 >Emitted(78, 17) Source(73, 17) + SourceIndex(0) name (f) -9 >Emitted(78, 20) Source(73, 20) + SourceIndex(0) name (f) -10>Emitted(78, 21) Source(73, 21) + SourceIndex(0) name (f) -11>Emitted(78, 24) Source(73, 24) + SourceIndex(0) name (f) -12>Emitted(78, 25) Source(73, 25) + SourceIndex(0) name (f) -13>Emitted(78, 28) Source(73, 28) + SourceIndex(0) name (f) -14>Emitted(78, 29) Source(73, 29) + SourceIndex(0) name (f) -15>Emitted(78, 30) Source(73, 30) + SourceIndex(0) name (f) +1 >Emitted(75, 5) Source(73, 5) + SourceIndex(0) name (f) +2 >Emitted(75, 6) Source(73, 6) + SourceIndex(0) name (f) +3 >Emitted(75, 7) Source(73, 7) + SourceIndex(0) name (f) +4 >Emitted(75, 11) Source(73, 11) + SourceIndex(0) name (f) +5 >Emitted(75, 12) Source(73, 12) + SourceIndex(0) name (f) +6 >Emitted(75, 13) Source(73, 13) + SourceIndex(0) name (f) +7 >Emitted(75, 16) Source(73, 16) + SourceIndex(0) name (f) +8 >Emitted(75, 17) Source(73, 17) + SourceIndex(0) name (f) +9 >Emitted(75, 20) Source(73, 20) + SourceIndex(0) name (f) +10>Emitted(75, 21) Source(73, 21) + SourceIndex(0) name (f) +11>Emitted(75, 24) Source(73, 24) + SourceIndex(0) name (f) +12>Emitted(75, 25) Source(73, 25) + SourceIndex(0) name (f) +13>Emitted(75, 28) Source(73, 28) + SourceIndex(0) name (f) +14>Emitted(75, 29) Source(73, 29) + SourceIndex(0) name (f) +15>Emitted(75, 30) Source(73, 30) + SourceIndex(0) name (f) --- >>> x === 1; 1 >^^^^ @@ -1380,11 +1371,11 @@ sourceFile:sourceMapValidationStatements.ts 3 > === 4 > 1 5 > ; -1 >Emitted(79, 5) Source(74, 5) + SourceIndex(0) name (f) -2 >Emitted(79, 6) Source(74, 6) + SourceIndex(0) name (f) -3 >Emitted(79, 11) Source(74, 11) + SourceIndex(0) name (f) -4 >Emitted(79, 12) Source(74, 12) + SourceIndex(0) name (f) -5 >Emitted(79, 13) Source(74, 13) + SourceIndex(0) name (f) +1 >Emitted(76, 5) Source(74, 5) + SourceIndex(0) name (f) +2 >Emitted(76, 6) Source(74, 6) + SourceIndex(0) name (f) +3 >Emitted(76, 11) Source(74, 11) + SourceIndex(0) name (f) +4 >Emitted(76, 12) Source(74, 12) + SourceIndex(0) name (f) +5 >Emitted(76, 13) Source(74, 13) + SourceIndex(0) name (f) --- >>> x = z = 40; 1->^^^^ @@ -1402,13 +1393,13 @@ sourceFile:sourceMapValidationStatements.ts 5 > = 6 > 40 7 > ; -1->Emitted(80, 5) Source(75, 5) + SourceIndex(0) name (f) -2 >Emitted(80, 6) Source(75, 6) + SourceIndex(0) name (f) -3 >Emitted(80, 9) Source(75, 9) + SourceIndex(0) name (f) -4 >Emitted(80, 10) Source(75, 10) + SourceIndex(0) name (f) -5 >Emitted(80, 13) Source(75, 13) + SourceIndex(0) name (f) -6 >Emitted(80, 15) Source(75, 15) + SourceIndex(0) name (f) -7 >Emitted(80, 16) Source(75, 16) + SourceIndex(0) name (f) +1->Emitted(77, 5) Source(75, 5) + SourceIndex(0) name (f) +2 >Emitted(77, 6) Source(75, 6) + SourceIndex(0) name (f) +3 >Emitted(77, 9) Source(75, 9) + SourceIndex(0) name (f) +4 >Emitted(77, 10) Source(75, 10) + SourceIndex(0) name (f) +5 >Emitted(77, 13) Source(75, 13) + SourceIndex(0) name (f) +6 >Emitted(77, 15) Source(75, 15) + SourceIndex(0) name (f) +7 >Emitted(77, 16) Source(75, 16) + SourceIndex(0) name (f) --- >>> eval("y"); 1 >^^^^ @@ -1424,12 +1415,12 @@ sourceFile:sourceMapValidationStatements.ts 4 > "y" 5 > ) 6 > ; -1 >Emitted(81, 5) Source(76, 5) + SourceIndex(0) name (f) -2 >Emitted(81, 9) Source(76, 9) + SourceIndex(0) name (f) -3 >Emitted(81, 10) Source(76, 10) + SourceIndex(0) name (f) -4 >Emitted(81, 13) Source(76, 13) + SourceIndex(0) name (f) -5 >Emitted(81, 14) Source(76, 14) + SourceIndex(0) name (f) -6 >Emitted(81, 15) Source(76, 15) + SourceIndex(0) name (f) +1 >Emitted(78, 5) Source(76, 5) + SourceIndex(0) name (f) +2 >Emitted(78, 9) Source(76, 9) + SourceIndex(0) name (f) +3 >Emitted(78, 10) Source(76, 10) + SourceIndex(0) name (f) +4 >Emitted(78, 13) Source(76, 13) + SourceIndex(0) name (f) +5 >Emitted(78, 14) Source(76, 14) + SourceIndex(0) name (f) +6 >Emitted(78, 15) Source(76, 15) + SourceIndex(0) name (f) --- >>> return; 1 >^^^^ @@ -1439,9 +1430,9 @@ sourceFile:sourceMapValidationStatements.ts > 2 > return 3 > ; -1 >Emitted(82, 5) Source(77, 5) + SourceIndex(0) name (f) -2 >Emitted(82, 11) Source(77, 11) + SourceIndex(0) name (f) -3 >Emitted(82, 12) Source(77, 12) + SourceIndex(0) name (f) +1 >Emitted(79, 5) Source(77, 5) + SourceIndex(0) name (f) +2 >Emitted(79, 11) Source(77, 11) + SourceIndex(0) name (f) +3 >Emitted(79, 12) Source(77, 12) + SourceIndex(0) name (f) --- >>>} 1 > @@ -1450,8 +1441,8 @@ sourceFile:sourceMapValidationStatements.ts 1 > > 2 >} -1 >Emitted(83, 1) Source(78, 1) + SourceIndex(0) name (f) -2 >Emitted(83, 2) Source(78, 2) + SourceIndex(0) name (f) +1 >Emitted(80, 1) Source(78, 1) + SourceIndex(0) name (f) +2 >Emitted(80, 2) Source(78, 2) + SourceIndex(0) name (f) --- >>>var b = function () { 1-> @@ -1464,10 +1455,10 @@ sourceFile:sourceMapValidationStatements.ts 2 >var 3 > b 4 > = -1->Emitted(84, 1) Source(79, 1) + SourceIndex(0) -2 >Emitted(84, 5) Source(79, 5) + SourceIndex(0) -3 >Emitted(84, 6) Source(79, 6) + SourceIndex(0) -4 >Emitted(84, 9) Source(79, 9) + SourceIndex(0) +1->Emitted(81, 1) Source(79, 1) + SourceIndex(0) +2 >Emitted(81, 5) Source(79, 5) + SourceIndex(0) +3 >Emitted(81, 6) Source(79, 6) + SourceIndex(0) +4 >Emitted(81, 9) Source(79, 9) + SourceIndex(0) --- >>> var x = 10; 1->^^^^ @@ -1483,12 +1474,12 @@ sourceFile:sourceMapValidationStatements.ts 4 > = 5 > 10 6 > ; -1->Emitted(85, 5) Source(80, 5) + SourceIndex(0) -2 >Emitted(85, 9) Source(80, 9) + SourceIndex(0) -3 >Emitted(85, 10) Source(80, 10) + SourceIndex(0) -4 >Emitted(85, 13) Source(80, 13) + SourceIndex(0) -5 >Emitted(85, 15) Source(80, 15) + SourceIndex(0) -6 >Emitted(85, 16) Source(80, 16) + SourceIndex(0) +1->Emitted(82, 5) Source(80, 5) + SourceIndex(0) +2 >Emitted(82, 9) Source(80, 9) + SourceIndex(0) +3 >Emitted(82, 10) Source(80, 10) + SourceIndex(0) +4 >Emitted(82, 13) Source(80, 13) + SourceIndex(0) +5 >Emitted(82, 15) Source(80, 15) + SourceIndex(0) +6 >Emitted(82, 16) Source(80, 16) + SourceIndex(0) --- >>> x = x + 1; 1 >^^^^ @@ -1506,13 +1497,13 @@ sourceFile:sourceMapValidationStatements.ts 5 > + 6 > 1 7 > ; -1 >Emitted(86, 5) Source(81, 5) + SourceIndex(0) -2 >Emitted(86, 6) Source(81, 6) + SourceIndex(0) -3 >Emitted(86, 9) Source(81, 9) + SourceIndex(0) -4 >Emitted(86, 10) Source(81, 10) + SourceIndex(0) -5 >Emitted(86, 13) Source(81, 13) + SourceIndex(0) -6 >Emitted(86, 14) Source(81, 14) + SourceIndex(0) -7 >Emitted(86, 15) Source(81, 15) + SourceIndex(0) +1 >Emitted(83, 5) Source(81, 5) + SourceIndex(0) +2 >Emitted(83, 6) Source(81, 6) + SourceIndex(0) +3 >Emitted(83, 9) Source(81, 9) + SourceIndex(0) +4 >Emitted(83, 10) Source(81, 10) + SourceIndex(0) +5 >Emitted(83, 13) Source(81, 13) + SourceIndex(0) +6 >Emitted(83, 14) Source(81, 14) + SourceIndex(0) +7 >Emitted(83, 15) Source(81, 15) + SourceIndex(0) --- >>>}; 1 > @@ -1523,9 +1514,9 @@ sourceFile:sourceMapValidationStatements.ts > 2 >} 3 > ; -1 >Emitted(87, 1) Source(82, 1) + SourceIndex(0) -2 >Emitted(87, 2) Source(82, 2) + SourceIndex(0) -3 >Emitted(87, 3) Source(82, 3) + SourceIndex(0) +1 >Emitted(84, 1) Source(82, 1) + SourceIndex(0) +2 >Emitted(84, 2) Source(82, 2) + SourceIndex(0) +3 >Emitted(84, 3) Source(82, 3) + SourceIndex(0) --- >>>f(); 1-> @@ -1538,9 +1529,9 @@ sourceFile:sourceMapValidationStatements.ts 2 >f 3 > () 4 > ; -1->Emitted(88, 1) Source(83, 1) + SourceIndex(0) -2 >Emitted(88, 2) Source(83, 2) + SourceIndex(0) -3 >Emitted(88, 4) Source(83, 4) + SourceIndex(0) -4 >Emitted(88, 5) Source(83, 5) + SourceIndex(0) +1->Emitted(85, 1) Source(83, 1) + SourceIndex(0) +2 >Emitted(85, 2) Source(83, 2) + SourceIndex(0) +3 >Emitted(85, 4) Source(83, 4) + SourceIndex(0) +4 >Emitted(85, 5) Source(83, 5) + SourceIndex(0) --- >>>//# sourceMappingURL=sourceMapValidationStatements.js.map \ No newline at end of file diff --git a/tests/baselines/reference/switchAssignmentCompat.js b/tests/baselines/reference/switchAssignmentCompat.js index 28384f8a271..7b3f2af80bb 100644 --- a/tests/baselines/reference/switchAssignmentCompat.js +++ b/tests/baselines/reference/switchAssignmentCompat.js @@ -13,6 +13,5 @@ var Foo = (function () { return Foo; })(); switch (0) { - case Foo: - break; + case Foo: break; } diff --git a/tests/baselines/reference/switchCasesExpressionTypeMismatch.js b/tests/baselines/reference/switchCasesExpressionTypeMismatch.js index f8d5b446a8d..a35dc633e35 100644 --- a/tests/baselines/reference/switchCasesExpressionTypeMismatch.js +++ b/tests/baselines/reference/switchCasesExpressionTypeMismatch.js @@ -25,23 +25,15 @@ var Foo = (function () { return Foo; })(); switch (0) { - case Foo: - break; - case "sss": - break; - case 123: - break; - case true: - break; + case Foo: break; + case "sss": break; + case 123: break; + case true: break; } var s = 0; switch (s) { - case Foo: - break; - case "sss": - break; - case 123: - break; - case true: - break; + case Foo: break; + case "sss": break; + case 123: break; + case true: break; } diff --git a/tests/baselines/reference/switchFallThroughs.js b/tests/baselines/reference/switchFallThroughs.js index b38c6b6f0ab..53f221bd467 100644 --- a/tests/baselines/reference/switchFallThroughs.js +++ b/tests/baselines/reference/switchFallThroughs.js @@ -26,10 +26,9 @@ function R1(index) { var a = 'a'; return a; case 3: - case 4: - { - return 'b'; - } + case 4: { + return 'b'; + } case 5: default: return 'c'; diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt index 461a47c52a8..cf915f36dd8 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt @@ -1,15 +1,15 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(12,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(16,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(20,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. @@ -32,55 +32,55 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped f `abc` ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`.member ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`.member; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`["member"]; ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`["member"]; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc`[0].member `abc${1}def${2}ghi`; ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt index f6a80a73013..f6300855a1c 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts(13,21): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts (1 errors) ==== @@ -16,6 +16,6 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMember var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; ~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt index 9847ead783b..d49ec4b716d 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. @@ -32,24 +32,24 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio var u = foo ``; // number ~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var v = foo `${1}`; // string ~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var w = foo `${1}${2}`; // boolean ~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var x = foo `${1}${true}`; // boolean (with error) ~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~ !!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. var y = foo `${1}${"2"}`; // {} ~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. var z = foo `${1}${2}${3}`; // any (with error) ~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt index f813e13e8b9..a15e0cbb49b 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.errors.txt @@ -1,15 +1,15 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(3,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(5,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(7,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(9,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(11,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(13,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(15,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(17,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(19,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts(21,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts (12 errors) ==== @@ -17,47 +17,47 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTagsTypedAsAny.ts f `abc` ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f.g.h `abc` ~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f.g.h `abc${1}def${2}ghi`; ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc`.member ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`.member; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc`["member"]; ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`["member"]; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f.thisIsNotATag(`abc`); diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt index 6a38ddc278a..0e4f7a63223 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.errors.txt @@ -1,13 +1,13 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(12,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(14,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(16,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(18,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(20,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(22,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(12,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(14,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(16,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(18,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(20,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(22,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts (10 errors) ==== @@ -24,39 +24,39 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypedTags.ts(26,1 f `abc` ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc`.member ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`.member; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc`["member"]; ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`["member"]; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc`[0].member `abc${1}def${2}ghi`; ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. f.thisIsNotATag(`abc`); diff --git a/tests/baselines/reference/templateStringInModuleName.errors.txt b/tests/baselines/reference/templateStringInModuleName.errors.txt index 8b5e4eb8e14..fb6188d9d9a 100644 --- a/tests/baselines/reference/templateStringInModuleName.errors.txt +++ b/tests/baselines/reference/templateStringInModuleName.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1005: ';' expected. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,21): error TS1005: ';' expected. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1005: ';' expected. -tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,24): error TS1005: ';' expected. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,1): error TS2304: Cannot find name 'declare'. tests/cases/conformance/es6/templates/templateStringInModuleName.ts(1,9): error TS2304: Cannot find name 'module'. @@ -15,7 +15,7 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error ~~~~~~ !!! error TS1005: ';' expected. ~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS1005: ';' expected. ~~~~~~~ @@ -28,7 +28,7 @@ tests/cases/conformance/es6/templates/templateStringInModuleName.ts(4,9): error ~~~~~~ !!! error TS1005: ';' expected. ~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~ !!! error TS1005: ';' expected. ~~~~~~~ diff --git a/tests/baselines/reference/templateStringInObjectLiteral.errors.txt b/tests/baselines/reference/templateStringInObjectLiteral.errors.txt index 29580e2fa77..b510e46ba6a 100644 --- a/tests/baselines/reference/templateStringInObjectLiteral.errors.txt +++ b/tests/baselines/reference/templateStringInObjectLiteral.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(1,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,8): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,10): error TS1134: Variable declaration expected. @@ -15,7 +15,7 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(1,9): err ~~~~~~~~~~~~~~~~~~~~~~~~ `b`: 321 ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInPropertyName1.errors.txt b/tests/baselines/reference/templateStringInPropertyName1.errors.txt index 80742d2871e..c0b89e02d68 100644 --- a/tests/baselines/reference/templateStringInPropertyName1.errors.txt +++ b/tests/baselines/reference/templateStringInPropertyName1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(1,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,8): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,10): error TS1134: Variable declaration expected. @@ -12,7 +12,7 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(1,9): err ~ `a`: 321 ~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInPropertyName2.errors.txt b/tests/baselines/reference/templateStringInPropertyName2.errors.txt index 61260395969..d9302d25fa9 100644 --- a/tests/baselines/reference/templateStringInPropertyName2.errors.txt +++ b/tests/baselines/reference/templateStringInPropertyName2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(1,9): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(1,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,32): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,34): error TS1134: Variable declaration expected. @@ -12,7 +12,7 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(1,9): err ~ `abc${ 123 }def${ 456 }ghi`: 321 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt index be6fccbe1bc..b70af797c5c 100644 --- a/tests/baselines/reference/templateStringInYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringInYieldKeyword.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,9): error TS1003: Identifier expected. tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,15): error TS1005: ';' expected. -tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(1,11): error TS2304: Cannot find name 'gen'. tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): error TS2304: Cannot find name 'yield'. @@ -16,7 +16,7 @@ tests/cases/conformance/es6/templates/templateStringInYieldKeyword.ts(3,13): err // Once this is supported, the inner expression does not need to be parenthesized. var x = yield `abc${ x }def`; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. ~~~~~ !!! error TS2304: Cannot find name 'yield'. } diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt index e5f159a0a13..b9e803a8a14 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeyword.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,9): error TS1003: Identifier expected. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,15): error TS1005: ';' expected. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,26): error TS1159: Invalid template literal; expected '}' -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,30): error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,26): error TS1158: Invalid template literal; expected '}' +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,30): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(5,1): error TS1126: Unexpected end of text. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(1,11): error TS2304: Cannot find name 'gen'. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts(3,20): error TS2304: Cannot find name 'yield'. @@ -19,7 +19,7 @@ tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts( // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; ~~ -!!! error TS1159: Invalid template literal; expected '}' +!!! error TS1158: Invalid template literal; expected '}' ~~~~~ ~~~~~ !!! error TS2304: Cannot find name 'yield'. @@ -29,6 +29,6 @@ tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeyword.ts( ~ -!!! error TS1160: Tagged templates are only available when targeting ECMAScript 6 and higher. +!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher. !!! error TS1126: Unexpected end of text. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt index 45142cd02d9..6cae5332517 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,9): error TS1003: Identifier expected. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,17): error TS1005: ';' expected. -tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,26): error TS1159: Invalid template literal; expected '}' +tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,26): error TS1158: Invalid template literal; expected '}' tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(5,1): error TS1126: Unexpected end of text. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(1,11): error TS2304: Cannot find name 'gen'. tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts(3,20): error TS2304: Cannot find name 'yield'. @@ -18,7 +18,7 @@ tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6. // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; ~~ -!!! error TS1159: Invalid template literal; expected '}' +!!! error TS1158: Invalid template literal; expected '}' ~~~~~ !!! error TS2304: Cannot find name 'yield'. ~~~ diff --git a/tests/baselines/reference/typeAliases.js b/tests/baselines/reference/typeAliases.js new file mode 100644 index 00000000000..0cf0dd92402 --- /dev/null +++ b/tests/baselines/reference/typeAliases.js @@ -0,0 +1,126 @@ +//// [typeAliases.ts] +// Writing a reference to a type alias has exactly the same effect as writing the aliased type itself. + +type T1 = number; +var x1: number; +var x1: T1; + +type T2 = string; +var x2: string; +var x2: T2; + +type T3 = boolean; +var x3: boolean; +var x3: T3; + +type T4 = void; +var x4: void; +var x4: T4; + +type T5 = any; +var x5: any; +var x5: T5; + +interface I6 { x : string } +type T6 = I6; +var x6: I6; +var x6: T6; + +class C7 { x: boolean } +type T7 = C7; +var x7: C7; +var x7: T7; + +type T8 = string | boolean; +var x8: string | boolean; +var x8: T8; + +type T9 = () => string; +var x9: () => string; +var x9: T9; + +type T10 = { x: number }; +var x10: { x: number }; +var x10: T10; + +type T11 = { new(): boolean }; +var x11: { new(): boolean }; +var x11: T11; + +interface I13 { x: string }; +type T13 = I13; +var x13_1: I13; +var x13_2: T13 + +declare function foo13(t1: T1, t2: T13): void; +foo13(x13_1, x13_2); +foo13(x13_2, x13_1); + +type T14 = string; +var x14: T14; + +declare function foo14_1(x: T14): void; + +declare function foo14_2(x: "click"): void; +declare function foo14_2(x: T14): void; + +type Meters = number + +enum E { x = 10 } + +declare function f15(a: string): boolean; +declare function f15(a: Meters): string; +f15(E.x).toLowerCase(); + +type StringAndBoolean = [string, boolean] +declare function f16(s: StringAndBoolean): string; +var x: [string, boolean]; +f16(x); + +var y: StringAndBoolean = ["1", false]; +y[0].toLowerCase(); + +//// [typeAliases.js] +// Writing a reference to a type alias has exactly the same effect as writing the aliased type itself. +var x1; +var x1; +var x2; +var x2; +var x3; +var x3; +var x4; +var x4; +var x5; +var x5; +var x6; +var x6; +var C7 = (function () { + function C7() { + } + return C7; +})(); +var x7; +var x7; +var x8; +var x8; +var x9; +var x9; +var x10; +var x10; +var x11; +var x11; +; +var x13_1; +var x13_2; +foo13(x13_1, x13_2); +foo13(x13_2, x13_1); +var x14; +var E; +(function (E) { + E[E["x"] = 10] = "x"; +})(E || (E = {})); +f15(10 /* x */).toLowerCase(); +var x; +f16(x); +var y = ["1", false]; +y[0].toLowerCase(); diff --git a/tests/baselines/reference/typeAliases.types b/tests/baselines/reference/typeAliases.types new file mode 100644 index 00000000000..f6e4afd571e --- /dev/null +++ b/tests/baselines/reference/typeAliases.types @@ -0,0 +1,241 @@ +=== tests/cases/conformance/types/typeAliases/typeAliases.ts === +// Writing a reference to a type alias has exactly the same effect as writing the aliased type itself. + +type T1 = number; +>T1 : number + +var x1: number; +>x1 : number + +var x1: T1; +>x1 : number +>T1 : number + +type T2 = string; +>T2 : string + +var x2: string; +>x2 : string + +var x2: T2; +>x2 : string +>T2 : string + +type T3 = boolean; +>T3 : boolean + +var x3: boolean; +>x3 : boolean + +var x3: T3; +>x3 : boolean +>T3 : boolean + +type T4 = void; +>T4 : void + +var x4: void; +>x4 : void + +var x4: T4; +>x4 : void +>T4 : void + +type T5 = any; +>T5 : any + +var x5: any; +>x5 : any + +var x5: T5; +>x5 : any +>T5 : any + +interface I6 { x : string } +>I6 : I6 +>x : string + +type T6 = I6; +>T6 : I6 +>I6 : I6 + +var x6: I6; +>x6 : I6 +>I6 : I6 + +var x6: T6; +>x6 : I6 +>T6 : I6 + +class C7 { x: boolean } +>C7 : C7 +>x : boolean + +type T7 = C7; +>T7 : C7 +>C7 : C7 + +var x7: C7; +>x7 : C7 +>C7 : C7 + +var x7: T7; +>x7 : C7 +>T7 : C7 + +type T8 = string | boolean; +>T8 : string | boolean + +var x8: string | boolean; +>x8 : string | boolean + +var x8: T8; +>x8 : string | boolean +>T8 : string | boolean + +type T9 = () => string; +>T9 : () => string + +var x9: () => string; +>x9 : () => string + +var x9: T9; +>x9 : () => string +>T9 : () => string + +type T10 = { x: number }; +>T10 : { x: number; } +>x : number + +var x10: { x: number }; +>x10 : { x: number; } +>x : number + +var x10: T10; +>x10 : { x: number; } +>T10 : { x: number; } + +type T11 = { new(): boolean }; +>T11 : new () => boolean + +var x11: { new(): boolean }; +>x11 : new () => boolean + +var x11: T11; +>x11 : new () => boolean +>T11 : new () => boolean + +interface I13 { x: string }; +>I13 : I13 +>x : string + +type T13 = I13; +>T13 : I13 +>I13 : I13 + +var x13_1: I13; +>x13_1 : I13 +>I13 : I13 + +var x13_2: T13 +>x13_2 : I13 +>T13 : I13 + +declare function foo13(t1: T1, t2: T13): void; +>foo13 : (t1: T1, t2: I13) => void +>T1 : T1 +>I13 : I13 +>T2 : T2 +>T13 : I13 +>t1 : T1 +>T1 : T1 +>t2 : I13 +>T13 : I13 + +foo13(x13_1, x13_2); +>foo13(x13_1, x13_2) : void +>foo13 : (t1: T1, t2: I13) => void +>x13_1 : I13 +>x13_2 : I13 + +foo13(x13_2, x13_1); +>foo13(x13_2, x13_1) : void +>foo13 : (t1: T1, t2: I13) => void +>x13_2 : I13 +>x13_1 : I13 + +type T14 = string; +>T14 : string + +var x14: T14; +>x14 : string +>T14 : string + +declare function foo14_1(x: T14): void; +>foo14_1 : (x: string) => void +>x : string +>T14 : string + +declare function foo14_2(x: "click"): void; +>foo14_2 : { (x: "click"): void; (x: string): void; } +>x : "click" + +declare function foo14_2(x: T14): void; +>foo14_2 : { (x: "click"): void; (x: string): void; } +>x : string +>T14 : string + +type Meters = number +>Meters : number + +enum E { x = 10 } +>E : E +>x : E + +declare function f15(a: string): boolean; +>f15 : { (a: string): boolean; (a: number): string; } +>a : string + +declare function f15(a: Meters): string; +>f15 : { (a: string): boolean; (a: number): string; } +>a : number +>Meters : number + +f15(E.x).toLowerCase(); +>f15(E.x).toLowerCase() : string +>f15(E.x).toLowerCase : () => string +>f15(E.x) : string +>f15 : { (a: string): boolean; (a: number): string; } +>E.x : E +>E : typeof E +>x : E +>toLowerCase : () => string + +type StringAndBoolean = [string, boolean] +>StringAndBoolean : [string, boolean] + +declare function f16(s: StringAndBoolean): string; +>f16 : (s: [string, boolean]) => string +>s : [string, boolean] +>StringAndBoolean : [string, boolean] + +var x: [string, boolean]; +>x : [string, boolean] + +f16(x); +>f16(x) : string +>f16 : (s: [string, boolean]) => string +>x : [string, boolean] + +var y: StringAndBoolean = ["1", false]; +>y : [string, boolean] +>StringAndBoolean : [string, boolean] +>["1", false] : [string, boolean] + +y[0].toLowerCase(); +>y[0].toLowerCase() : string +>y[0].toLowerCase : () => string +>y[0] : string +>y : [string, boolean] +>toLowerCase : () => string + diff --git a/tests/baselines/reference/typeAliasesForObjectTypes.errors.txt b/tests/baselines/reference/typeAliasesForObjectTypes.errors.txt new file mode 100644 index 00000000000..d957b589953 --- /dev/null +++ b/tests/baselines/reference/typeAliasesForObjectTypes.errors.txt @@ -0,0 +1,39 @@ +tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(14,8): error TS1005: '=' expected. +tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(14,12): error TS1005: '(' expected. +tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(4,22): error TS2312: An interface may only extend a class or another interface. +tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(5,21): error TS2422: A class may only implement another class or interface. +tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(10,6): error TS2300: Duplicate identifier 'T2'. +tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(11,6): error TS2300: Duplicate identifier 'T2'. +tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts(14,19): error TS2304: Cannot find name 'T'. + + +==== tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts (7 errors) ==== + type T1 = { x: string } + + // An interface can be named in an extends or implements clause, but a type alias for an object type literal cannot. + interface I1 extends T1 { y: string } + ~~ +!!! error TS2312: An interface may only extend a class or another interface. + class C1 implements T1 { + ~~ +!!! error TS2422: A class may only implement another class or interface. + x: string; + } + + // An interface can have multiple merged declarations, but a type alias for an object type literal cannot. + type T2 = { x: string } + ~~ +!!! error TS2300: Duplicate identifier 'T2'. + type T2 = { y: number } + ~~ +!!! error TS2300: Duplicate identifier 'T2'. + + // An interface can have type parameters, but a type alias for an object type literal cannot. + type T3 = { x: T } + ~ +!!! error TS1005: '=' expected. + ~ +!!! error TS1005: '(' expected. + ~ +!!! error TS2304: Cannot find name 'T'. + \ No newline at end of file diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.js b/tests/baselines/reference/typeofOperatorWithEnumType.js index 272feacf63d..900b610cef4 100644 --- a/tests/baselines/reference/typeofOperatorWithEnumType.js +++ b/tests/baselines/reference/typeofOperatorWithEnumType.js @@ -44,15 +44,15 @@ var ENUM1; var ResultIsString1 = typeof ENUM; var ResultIsString2 = typeof ENUM1; // enum type expressions -var ResultIsString3 = typeof ENUM1["A"]; -var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); +var ResultIsString3 = typeof 0 /* "A" */; +var ResultIsString4 = typeof (ENUM[0] + 1 /* "B" */); // multiple typeof operators var ResultIsString5 = typeof typeof ENUM; var ResultIsString6 = typeof typeof typeof (ENUM[0] + 1 /* B */); // miss assignment operators typeof ENUM; typeof ENUM1; -typeof ENUM1["B"]; +typeof 1 /* "B" */; typeof ENUM, ENUM1; // use typeof in type query var z; diff --git a/tests/baselines/reference/voidOperatorWithEnumType.js b/tests/baselines/reference/voidOperatorWithEnumType.js index 8d20842ea7b..478ac85651b 100644 --- a/tests/baselines/reference/voidOperatorWithEnumType.js +++ b/tests/baselines/reference/voidOperatorWithEnumType.js @@ -39,13 +39,13 @@ var ENUM1; var ResultIsAny1 = void ENUM; var ResultIsAny2 = void ENUM1; // enum type expressions -var ResultIsAny3 = void ENUM1["A"]; -var ResultIsAny4 = void (ENUM[0] + ENUM1["B"]); +var ResultIsAny3 = void 0 /* "A" */; +var ResultIsAny4 = void (ENUM[0] + 1 /* "B" */); // multiple void operators var ResultIsAny5 = void void ENUM; var ResultIsAny6 = void void void (ENUM[0] + 1 /* B */); // miss assignment operators void ENUM; void ENUM1; -void ENUM1["B"]; +void 1 /* "B" */; void ENUM, ENUM1; diff --git a/tests/cases/compiler/constEnumDeclarations.ts b/tests/cases/compiler/constEnumDeclarations.ts new file mode 100644 index 00000000000..c3c11f55aa3 --- /dev/null +++ b/tests/cases/compiler/constEnumDeclarations.ts @@ -0,0 +1,13 @@ +// @declaration: true + +const enum E { + A = 1, + B = 2, + C = A | B +} + +const enum E2 { + A = 1, + B, + C +} \ No newline at end of file diff --git a/tests/cases/compiler/constEnumErrors.ts b/tests/cases/compiler/constEnumErrors.ts new file mode 100644 index 00000000000..87e6b7ccb98 --- /dev/null +++ b/tests/cases/compiler/constEnumErrors.ts @@ -0,0 +1,43 @@ +const enum E { + A +} + +module E { + var x = 1; +} + +const enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +const enum E2 { + A +} + +var y0 = E2[1] +var name = "A"; +var y1 = E2[name]; + +var x = E2; +var y = [E2]; + +function foo(t: any): void { +} + +foo(E2); + +const enum NaNOrInfinity { + A = 9007199254740992, + B = A * A, + C = B * B, + D = C * C, + E = D * D, + F = E * E, // overflow + G = 1 / 0, // overflow + H = 0 / 0 // NaN +} \ No newline at end of file diff --git a/tests/cases/compiler/constEnumExternalModule.ts b/tests/cases/compiler/constEnumExternalModule.ts new file mode 100644 index 00000000000..d15240fe64d --- /dev/null +++ b/tests/cases/compiler/constEnumExternalModule.ts @@ -0,0 +1,10 @@ +//@module: amd +//@Filename: m1.ts +const enum E { + V = 100 +} + +export = E +//@Filename: m2.ts +import A = require('m1') +var v = A.V; \ No newline at end of file diff --git a/tests/cases/compiler/constEnums.ts b/tests/cases/compiler/constEnums.ts new file mode 100644 index 00000000000..72b75a3f31e --- /dev/null +++ b/tests/cases/compiler/constEnums.ts @@ -0,0 +1,151 @@ +const enum Enum1 { + A0 = 100, +} + +const enum Enum1 { + // correct cases + A, + B, + C = 10, + D = A | B, + E = A | 1, + F = 1 | A, + G = (1 & 1), + H = ~(A | B), + I = A >>> 1, + J = 1 & A, + K = ~(1 | 5), + L = ~D, + M = E << B, + N = E << 1, + O = E >> B, + P = E >> 1, + Q = -D, + R = C & 5, + S = 5 & C, + T = C | D, + U = C | 1, + V = 10 | D, + W = Enum1.V, + + // correct cases: reference to the enum member from different enum declaration + W1 = A0, + W2 = Enum1.A0, + W3 = Enum1["A0"], + W4 = Enum1["W"], +} + + +module A { + export module B { + export module C { + export const enum E { + V1 = 1, + V2 = A.B.C.E.V1 | 100 + } + } + } +} + +module A { + export module B { + export module C { + export const enum E { + V3 = A.B.C.E["V2"] & 200, + } + } + } +} + +module A1 { + export module B { + export module C { + export const enum E { + V1 = 10, + V2 = 110, + } + } + } +} + +module A2 { + export module B { + export module C { + export const enum E { + V1 = 10, + V2 = 110, + } + } + // module C will be classified as value + export module C { + var x = 1 + } + } +} + +import I = A.B.C.E; +import I1 = A1.B; +import I2 = A2.B; + +function foo0(e: I): void { + if (e === I.V1) { + } + else if (e === I.V2) { + } +} + +function foo1(e: I1.C.E): void { + if (e === I1.C.E.V1) { + } + else if (e === I1.C.E.V2) { + } +} + +function foo2(e: I2.C.E): void { + if (e === I2.C.E.V1) { + } + else if (e === I2.C.E.V2) { + } +} + + +function foo(x: Enum1) { + switch (x) { + case Enum1.A: + case Enum1.B: + case Enum1.C: + case Enum1.D: + case Enum1.E: + case Enum1.F: + case Enum1.G: + case Enum1.H: + case Enum1.I: + case Enum1.J: + case Enum1.K: + case Enum1.L: + case Enum1.M: + case Enum1.N: + case Enum1.O: + case Enum1.P: + case Enum1.Q: + case Enum1.R: + case Enum1.S: + case Enum1["T"]: + case Enum1.U: + case Enum1.V: + case Enum1.W: + case Enum1.W1: + case Enum1.W2: + case Enum1.W3: + case Enum1.W4: + break; + } +} + +function bar(e: A.B.C.E): number { + switch (e) { + case A.B.C.E.V1: return 1; + case A.B.C.E.V2: return 1; + case A.B.C.E.V3: return 1; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/preserveConstEnums.ts b/tests/cases/compiler/preserveConstEnums.ts new file mode 100644 index 00000000000..d83c84b403d --- /dev/null +++ b/tests/cases/compiler/preserveConstEnums.ts @@ -0,0 +1,4 @@ +// @preserveConstEnums: true +const enum E { + Value = 1, Value2 = Value +} \ No newline at end of file diff --git a/tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts b/tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts new file mode 100644 index 00000000000..049a0101f5d --- /dev/null +++ b/tests/cases/conformance/types/typeAliases/directDependenceBetweenTypeAliases.ts @@ -0,0 +1,41 @@ +// It is an error for the type specified in a type alias to depend on that type alias + +// A type alias directly depends on the type it aliases. +type T0 = T0 +type T0_1 = T0_2 +type T0_2 = T0_3 +type T0_3 = T0_1 + +// A type reference directly depends on the referenced type and each of the type arguments, if any. +interface I {} +type T1 = I + +// A union type directly depends on each of the constituent types. +type T2 = T2 | string +class C {} +type T2_1 = T2_1[] | number + +// An array type directly depends on its element type. +type T3 = T3[] + +// A tuple type directly depends on each of its element types. +type T4 = [number, T4] + +// A type query directly depends on the type of the referenced entity. +var x: T5[] = [] +type T5 = typeof x + +class C1 {} +type T6 = T7 | number +type T7 = typeof yy +var yy: [string, T8[]]; +type T8 = C + +// legal cases +type T9 = () => T9 +type T10 = { x: T10 } | { new(v: T10): string } +type T11 = T12[] +type T12 = [T13, string] +type T13 = typeof zz +var zz: { x: T11 } + diff --git a/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts b/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts new file mode 100644 index 00000000000..3b115573830 --- /dev/null +++ b/tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts @@ -0,0 +1,6 @@ +interface I {} +type any = I; +type number = I; +type boolean = I; +type string = I; +type void = I; \ No newline at end of file diff --git a/tests/cases/conformance/types/typeAliases/typeAliases.ts b/tests/cases/conformance/types/typeAliases/typeAliases.ts new file mode 100644 index 00000000000..b9d28f4cc35 --- /dev/null +++ b/tests/cases/conformance/types/typeAliases/typeAliases.ts @@ -0,0 +1,80 @@ +// Writing a reference to a type alias has exactly the same effect as writing the aliased type itself. + +type T1 = number; +var x1: number; +var x1: T1; + +type T2 = string; +var x2: string; +var x2: T2; + +type T3 = boolean; +var x3: boolean; +var x3: T3; + +type T4 = void; +var x4: void; +var x4: T4; + +type T5 = any; +var x5: any; +var x5: T5; + +interface I6 { x : string } +type T6 = I6; +var x6: I6; +var x6: T6; + +class C7 { x: boolean } +type T7 = C7; +var x7: C7; +var x7: T7; + +type T8 = string | boolean; +var x8: string | boolean; +var x8: T8; + +type T9 = () => string; +var x9: () => string; +var x9: T9; + +type T10 = { x: number }; +var x10: { x: number }; +var x10: T10; + +type T11 = { new(): boolean }; +var x11: { new(): boolean }; +var x11: T11; + +interface I13 { x: string }; +type T13 = I13; +var x13_1: I13; +var x13_2: T13 + +declare function foo13(t1: T1, t2: T13): void; +foo13(x13_1, x13_2); +foo13(x13_2, x13_1); + +type T14 = string; +var x14: T14; + +declare function foo14_1(x: T14): void; + +declare function foo14_2(x: "click"): void; +declare function foo14_2(x: T14): void; + +type Meters = number + +enum E { x = 10 } + +declare function f15(a: string): boolean; +declare function f15(a: Meters): string; +f15(E.x).toLowerCase(); + +type StringAndBoolean = [string, boolean] +declare function f16(s: StringAndBoolean): string; +var x: [string, boolean]; +f16(x); + +var y: StringAndBoolean = ["1", false]; +y[0].toLowerCase(); \ No newline at end of file diff --git a/tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts b/tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts new file mode 100644 index 00000000000..f1fd2a58bac --- /dev/null +++ b/tests/cases/conformance/types/typeAliases/typeAliasesForObjectTypes.ts @@ -0,0 +1,14 @@ +type T1 = { x: string } + +// An interface can be named in an extends or implements clause, but a type alias for an object type literal cannot. +interface I1 extends T1 { y: string } +class C1 implements T1 { + x: string; +} + +// An interface can have multiple merged declarations, but a type alias for an object type literal cannot. +type T2 = { x: string } +type T2 = { y: number } + +// An interface can have type parameters, but a type alias for an object type literal cannot. +type T3 = { x: T }