diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 07bccf4a5ef..648724ad94e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -38,6 +38,16 @@ namespace ts { name: "inlineSources", type: "boolean", }, + { + name: "jsx", + type: { + "preserve": JsxEmit.Preserve, + "react": JsxEmit.React + }, + paramType: Diagnostics.KIND, + description: Diagnostics.Specifies_how_to_transform_JSX_syntax_during_compilation, + error: Diagnostics.Argument_for_jsx_must_be_preserve_or_react + }, { name: "listFiles", type: "boolean", @@ -408,10 +418,21 @@ namespace ts { } else { var exclude = json["exclude"] instanceof Array ? map(json["exclude"], normalizeSlashes) : undefined; - var sysFiles = host.readDirectory(basePath, ".ts", exclude); + var sysFiles = host.readDirectory(basePath, ".ts", exclude).concat(host.readDirectory(basePath, ".tsx", exclude)); for (var i = 0; i < sysFiles.length; i++) { var name = sysFiles[i]; - if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) { + if (fileExtensionIs(name, ".d.ts")) { + let baseName = name.substr(0, name.length - ".d.ts".length); + if (!contains(sysFiles, baseName + ".tsx") && !contains(sysFiles, baseName + ".ts")) { + fileNames.push(name); + } + } + else if (fileExtensionIs(name, ".ts")) { + if (!contains(sysFiles, name + "x")) { + fileNames.push(name) + } + } + else { fileNames.push(name); } } diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 09b009711fe..bd3737ee4bf 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -389,6 +389,17 @@ namespace ts { No_base_constructor_has_the_specified_number_of_type_arguments: { code: 2508, category: DiagnosticCategory.Error, key: "No base constructor has the specified number of type arguments." }, Base_constructor_return_type_0_is_not_a_class_or_interface_type: { code: 2509, category: DiagnosticCategory.Error, key: "Base constructor return type '{0}' is not a class or interface type." }, Base_constructors_must_all_have_the_same_return_type: { code: 2510, category: DiagnosticCategory.Error, key: "Base constructors must all have the same return type." }, + JSX_element_attributes_type_0_must_be_an_object_type: { code: 2600, category: DiagnosticCategory.Error, key: "JSX element attributes type '{0}' must be an object type." }, + The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: { code: 2601, category: DiagnosticCategory.Error, key: "The return type of a JSX element constructor must return an object type." }, + The_global_type_JSX_Element_must_exist_when_using_JSX: { code: 2602, category: DiagnosticCategory.Error, key: "The global type 'JSX.Element' must exist when using JSX." }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: DiagnosticCategory.Error, key: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + JSX_element_0_is_not_a_constructor_function: { code: 2604, category: DiagnosticCategory.Error, key: "JSX element '{0}' is not a constructor function." }, + JSX_element_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: DiagnosticCategory.Error, key: "JSX element '{0}' is not a constructor function for JSX elements." }, + Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: DiagnosticCategory.Error, key: "Property '{0}' of JSX spread attribute is not assignable to target property." }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: DiagnosticCategory.Error, key: "JSX element class does not support attributes because it does not have a '{0}' property" }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: DiagnosticCategory.Error, key: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 2609, category: DiagnosticCategory.Error, key: "JSX element implicitly has type 'any' because no interface JSX.{0} exists" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: DiagnosticCategory.Error, key: "Cannot emit namespaced JSX elements in React" }, 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_private_name_1: { code: 4002, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported class has or is using private name '{1}'." }, Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: { code: 4004, category: DiagnosticCategory.Error, key: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -531,6 +542,8 @@ namespace ts { Specifies_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix: { code: 6060, category: DiagnosticCategory.Message, key: "Specifies the end of line sequence to be used when emitting files: 'CRLF' (dos) or 'LF' (unix)." }, NEWLINE: { code: 6061, category: DiagnosticCategory.Message, key: "NEWLINE" }, Argument_for_newLine_option_must_be_CRLF_or_LF: { code: 6062, category: DiagnosticCategory.Error, key: "Argument for '--newLine' option must be 'CRLF' or 'LF'." }, + Specifies_how_to_transform_JSX_syntax_during_compilation: { code: 6080, category: DiagnosticCategory.Message, key: "Specifies how to transform JSX syntax during compilation." }, + Argument_for_jsx_must_be_preserve_or_react: { code: 6081, category: DiagnosticCategory.Message, key: "Argument for --jsx must be 'preserve' or 'react'." }, Option_experimentalDecorators_must_also_be_specified_when_option_emitDecoratorMetadata_is_specified: { code: 6064, category: DiagnosticCategory.Error, key: "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified." }, Enables_experimental_support_for_ES7_decorators: { code: 6065, category: DiagnosticCategory.Message, key: "Enables experimental support for ES7 decorators." }, Enables_experimental_support_for_emitting_type_metadata_for_decorators: { code: 6066, category: DiagnosticCategory.Message, key: "Enables experimental support for emitting type metadata for decorators." }, @@ -569,5 +582,11 @@ namespace ts { decorators_can_only_be_used_in_a_ts_file: { code: 8017, category: DiagnosticCategory.Error, key: "'decorators' can only be used in a .ts file." }, Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clauses: { code: 9002, category: DiagnosticCategory.Error, key: "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clauses." }, class_expressions_are_not_currently_supported: { code: 9003, category: DiagnosticCategory.Error, key: "'class' expressions are not currently supported." }, + class_declarations_are_only_supported_directly_inside_a_module_or_as_a_top_level_declaration: { code: 9004, category: DiagnosticCategory.Error, key: "'class' declarations are only supported directly inside a module or as a top level declaration." }, + JSX_attributes_must_only_be_assigned_a_non_empty_expression: { code: 17000, category: DiagnosticCategory.Error, key: "JSX attributes must only be assigned a non-empty 'expression'." }, + JSX_elements_cannot_have_multiple_attributes_with_the_same_name: { code: 17001, category: DiagnosticCategory.Error, key: "JSX elements cannot have multiple attributes with the same name." }, + Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: DiagnosticCategory.Error, key: "Expected corresponding JSX closing tag for '{0}'." }, + JSX_attribute_expected: { code: 17003, category: DiagnosticCategory.Error, key: "JSX attribute expected." }, + Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: DiagnosticCategory.Error, key: "Cannot use JSX unless the '--jsx' flag is provided." }, }; } \ No newline at end of file diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fee46a84c1e..23ab3b89f70 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -686,7 +686,7 @@ "Experimental support for decorators is a feature that is subject to change in a future release. Specify '--experimentalDecorators' to remove this warning.": { "category": "Error", "code": 1219 - }, + }, "Generators are only available when targeting ECMAScript 6 or higher.": { "category": "Error", "code": 1220 @@ -1546,6 +1546,52 @@ "code": 2510 }, + "JSX element attributes type '{0}' must be an object type.": { + "category": "Error", + "code": 2600 + }, + "The return type of a JSX element constructor must return an object type.": { + "category": "Error", + "code": 2601 + }, + "The global type 'JSX.Element' must exist when using JSX.": { + "category": "Error", + "code": 2602 + }, + "Property '{0}' in type '{1}' is not assignable to type '{2}'": { + "category": "Error", + "code": 2603 + }, + "JSX element '{0}' is not a constructor function.": { + "category": "Error", + "code": 2604 + }, + "JSX element '{0}' is not a constructor function for JSX elements.": { + "category": "Error", + "code": 2605 + }, + "Property '{0}' of JSX spread attribute is not assignable to target property.": { + "category": "Error", + "code": 2606 + }, + "JSX element class does not support attributes because it does not have a '{0}' property": { + "category": "Error", + "code": 2607 + }, + "The global type 'JSX.{0}' may not have more than one property": { + "category": "Error", + "code": 2608 + }, + "JSX element implicitly has type 'any' because no interface JSX.{0} exists": { + "category": "Error", + "code": 2609 + }, + + "Cannot emit namespaced JSX elements in React": { + "category": "Error", + "code": 2650 + }, + "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -1914,7 +1960,7 @@ "category": "Error", "code": 5050 }, - "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { + "Option 'inlineSources' can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided.": { "category": "Error", "code": 5051 }, @@ -2107,14 +2153,22 @@ "category": "Message", "code": 6060 }, - "NEWLINE": { - "category": "Message", + "NEWLINE": { + "category": "Message", "code": 6061 }, "Argument for '--newLine' option must be 'CRLF' or 'LF'.": { - "category": "Error", + "category": "Error", "code": 6062 }, + "Specifies how to transform JSX syntax during compilation.": { + "category": "Message", + "code": 6080 + }, + "Argument for --jsx must be 'preserve' or 'react'.": { + "category": "Message", + "code": 6081 + }, "Option 'experimentalDecorators' must also be specified when option 'emitDecoratorMetadata' is specified.": { "category": "Error", "code": 6064 @@ -2268,5 +2322,29 @@ "'class' expressions are not currently supported.": { "category": "Error", "code": 9003 + }, + "'class' declarations are only supported directly inside a module or as a top level declaration.": { + "category": "Error", + "code": 9004 + }, + "JSX attributes must only be assigned a non-empty 'expression'.": { + "category": "Error", + "code": 17000 + }, + "JSX elements cannot have multiple attributes with the same name.": { + "category": "Error", + "code": 17001 + }, + "Expected corresponding JSX closing tag for '{0}'.": { + "category": "Error", + "code": 17002 + }, + "JSX attribute expected.": { + "category": "Error", + "code": 17003 + }, + "Cannot use JSX unless the '--jsx' flag is provided.": { + "category": "Error", + "code": 17004 } }