This commit is contained in:
Yuichi Nukiyama 2016-08-20 21:36:17 +09:00
Родитель 0c01874b31
Коммит bc0c137a89
3 изменённых файлов: 17 добавлений и 4 удалений

Просмотреть файл

@ -6275,7 +6275,6 @@ namespace ts {
(globalNumberType === source && numberType === target) ||
(globalBooleanType === source && booleanType === target) ||
(getGlobalESSymbolType() === source && esSymbolType === target)) {
console.log(source);console.log(target);
reportError(Diagnostics._0_is_a_primitive_type_while_1_is_a_boxed_object_Prefer_using_0_when_possible, targetType, sourceType);
}
}

Просмотреть файл

@ -4,9 +4,10 @@ tests/cases/compiler/nativeToBoxedTypes.ts(7,1): error TS2322: Type 'String' is
'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible.
tests/cases/compiler/nativeToBoxedTypes.ts(11,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'.
'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible.
tests/cases/compiler/nativeToBoxedTypes.ts(14,10): error TS2304: Cannot find name 'Symbol'.
==== tests/cases/compiler/nativeToBoxedTypes.ts (3 errors) ====
==== tests/cases/compiler/nativeToBoxedTypes.ts (4 errors) ====
var N = new Number();
var n = 100;
n = N;
@ -26,4 +27,10 @@ tests/cases/compiler/nativeToBoxedTypes.ts(11,1): error TS2322: Type 'Boolean' i
b = B;
~
!!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'.
!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible.
!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible.
var sym: symbol;
var Sym: Symbol;
~~~~~~
!!! error TS2304: Cannot find name 'Symbol'.
sym = Sym;

Просмотреть файл

@ -9,7 +9,11 @@ s = S;
var B = new Boolean();
var b = true;
b = B;
b = B;
var sym: symbol;
var Sym: Symbol;
sym = Sym;
//// [nativeToBoxedTypes.js]
var N = new Number();
@ -21,3 +25,6 @@ s = S;
var B = new Boolean();
var b = true;
b = B;
var sym;
var Sym;
sym = Sym;