diff --git a/TypeScript b/TypeScript index 93de502..ddb5a00 160000 --- a/TypeScript +++ b/TypeScript @@ -1 +1 @@ -Subproject commit 93de502656a7a0cdf30737513d29bcb396c79662 +Subproject commit ddb5a00410d695d35b55c5482876a16f7c696c4b diff --git a/bin/ntypescript.d.ts b/bin/ntypescript.d.ts index 824f2d5..2968657 100644 --- a/bin/ntypescript.d.ts +++ b/bin/ntypescript.d.ts @@ -5837,6 +5837,12 @@ declare namespace ts { key: string; message: string; }; + _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Import_declaration_0_is_using_private_name_1: { code: number; category: DiagnosticCategory; diff --git a/bin/ntypescript.js b/bin/ntypescript.js index 400750c..80bfa1d 100644 --- a/bin/ntypescript.js +++ b/bin/ntypescript.js @@ -6265,6 +6265,7 @@ var ts; Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, + _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "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: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -22222,6 +22223,16 @@ var ts; } reportError(message, sourceType, targetType); } + function tryElaborateErrorsForPrimitivesAndObjects(source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if ((globalStringType === source && stringType === target) || + (globalNumberType === source && numberType === target) || + (globalBooleanType === source && booleanType === target) || + (getGlobalESSymbolType() === source && esSymbolType === target)) { + reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); + } + } // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -22335,6 +22346,9 @@ var ts; } } if (reportErrors) { + if (source.flags & 2588672 /* ObjectType */ && target.flags & 8190 /* Primitive */) { + tryElaborateErrorsForPrimitivesAndObjects(source, target); + } reportRelationError(headMessage, source, target); } return 0 /* False */; diff --git a/bin/typescript.d.ts b/bin/typescript.d.ts index c4db57d..70ea655 100644 --- a/bin/typescript.d.ts +++ b/bin/typescript.d.ts @@ -5837,6 +5837,12 @@ declare namespace ts { key: string; message: string; }; + _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { + code: number; + category: DiagnosticCategory; + key: string; + message: string; + }; Import_declaration_0_is_using_private_name_1: { code: number; category: DiagnosticCategory; diff --git a/bin/typescript.js b/bin/typescript.js index 8d2388b..5616657 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -6265,6 +6265,7 @@ var ts; Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, + _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: ts.DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "Import declaration '{0}' is using private name '{1}'." }, Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: { code: 4002, category: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", message: "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: ts.DiagnosticCategory.Error, key: "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, @@ -22222,6 +22223,16 @@ var ts; } reportError(message, sourceType, targetType); } + function tryElaborateErrorsForPrimitivesAndObjects(source, target) { + var sourceType = typeToString(source); + var targetType = typeToString(target); + if ((globalStringType === source && stringType === target) || + (globalNumberType === source && numberType === target) || + (globalBooleanType === source && booleanType === target) || + (getGlobalESSymbolType() === source && esSymbolType === target)) { + reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); + } + } // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -22335,6 +22346,9 @@ var ts; } } if (reportErrors) { + if (source.flags & 2588672 /* ObjectType */ && target.flags & 8190 /* Primitive */) { + tryElaborateErrorsForPrimitivesAndObjects(source, target); + } reportRelationError(headMessage, source, target); } return 0 /* False */; diff --git a/kicktravis b/kicktravis index 95770d5..f8a90c1 100644 --- a/kicktravis +++ b/kicktravis @@ -1 +1 @@ -2016-08-23 [ci skip] Version: 1.201608230008.1+93de502656a7a0cdf30737513d29bcb396c79662 +2016-08-24 [ci skip] Version: 1.201608240006.1+ddb5a00410d695d35b55c5482876a16f7c696c4b diff --git a/package.json b/package.json index cb588d5..238913c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ntypescript", - "version": "1.201608230008.1+93de502656a7a0cdf30737513d29bcb396c79662", + "version": "1.201608240006.1+ddb5a00410d695d35b55c5482876a16f7c696c4b", "description": "A nicer version of microsoft/typescript packaged and released for API developers", "main": "./bin/ntypescript.js", "bin": { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3708024..3d74190 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6300,6 +6300,18 @@ namespace ts { reportError(message, sourceType, targetType); } + function tryElaborateErrorsForPrimitivesAndObjects(source: Type, target: Type) { + const sourceType = typeToString(source); + const targetType = typeToString(target); + + if ((globalStringType === source && stringType === target) || + (globalNumberType === source && numberType === target) || + (globalBooleanType === source && booleanType === target) || + (getGlobalESSymbolType() === source && esSymbolType === target)) { + reportError(Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); + } + } + // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -6423,6 +6435,9 @@ namespace ts { } if (reportErrors) { + if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) { + tryElaborateErrorsForPrimitivesAndObjects(source, target); + } reportRelationError(headMessage, source, target); } return Ternary.False; diff --git a/src/compiler/diagnosticInformationMap.generated.ts b/src/compiler/diagnosticInformationMap.generated.ts index 81f95f2..77613f9 100644 --- a/src/compiler/diagnosticInformationMap.generated.ts +++ b/src/compiler/diagnosticInformationMap.generated.ts @@ -492,6 +492,7 @@ namespace ts { Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, A_class_must_be_declared_after_its_base_class: { code: 2690, category: DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, + _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, Import_declaration_0_is_using_private_name_1: { code: 4000, category: DiagnosticCategory.Error, key: "Import_declaration_0_is_using_private_name_1_4000", message: "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_4002", message: "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_4004", message: "Type parameter '{0}' of exported interface has or is using private name '{1}'." }, diff --git a/src/compiler/diagnosticMessages.generated.json b/src/compiler/diagnosticMessages.generated.json index f827a6c..c7cc9e6 100644 --- a/src/compiler/diagnosticMessages.generated.json +++ b/src/compiler/diagnosticMessages.generated.json @@ -488,6 +488,7 @@ "Cannot_extend_an_interface_0_Did_you_mean_implements_2689" : "Cannot extend an interface '{0}'. Did you mean 'implements'?", "A_class_must_be_declared_after_its_base_class_2690" : "A class must be declared after its base class.", "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691" : "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead.", + "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692" : "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible.", "Import_declaration_0_is_using_private_name_1_4000" : "Import declaration '{0}' is using private name '{1}'.", "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002" : "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_4004" : "Type parameter '{0}' of exported interface has or is using private name '{1}'.", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6210a20..b8978b3 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1955,6 +1955,10 @@ "category": "Error", "code": 2691 }, + "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible.": { + "category": "Error", + "code": 2692 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000