Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ interface StringConstructor {
declare var String: StringConstructor;

interface Boolean {
/** Returns the primitive value of the specified object. */
valueOf(): boolean;
}

interface BooleanConstructor {
Expand Down
11 changes: 10 additions & 1 deletion tests/baselines/reference/assignFromBooleanInterface2.errors.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(14,1): error TS2322: Type 'NotBoolean' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => Object' is not assignable to type '() => boolean'.
Type 'Object' is not assignable to type 'boolean'.
tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(19,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'.
tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(20,1): error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'.


==== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts (2 errors) ====
==== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts (3 errors) ====
interface Boolean {
doStuff(): string;
}
Expand All @@ -17,6 +21,11 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(

a = x;
a = b;
~
!!! error TS2322: Type 'NotBoolean' is not assignable to type 'Boolean'.
!!! error TS2322: Types of property 'valueOf' are incompatible.
!!! error TS2322: Type '() => Object' is not assignable to type '() => boolean'.
!!! error TS2322: Type 'Object' is not assignable to type 'boolean'.

b = a;
b = x;
Expand Down
38 changes: 38 additions & 0 deletions tests/baselines/reference/booleanAssignment.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
tests/cases/compiler/booleanAssignment.ts(2,1): error TS2322: Type 'number' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => Object' is not assignable to type '() => boolean'.
Type 'Object' is not assignable to type 'boolean'.
tests/cases/compiler/booleanAssignment.ts(3,1): error TS2322: Type 'string' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => Object' is not assignable to type '() => boolean'.
tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not assignable to type 'Boolean'.
Types of property 'valueOf' are incompatible.
Type '() => Object' is not assignable to type '() => boolean'.


==== tests/cases/compiler/booleanAssignment.ts (3 errors) ====
var b = new Boolean();
b = 1; // Error
~
!!! error TS2322: Type 'number' is not assignable to type 'Boolean'.
!!! error TS2322: Types of property 'valueOf' are incompatible.
!!! error TS2322: Type '() => Object' is not assignable to type '() => boolean'.
!!! error TS2322: Type 'Object' is not assignable to type 'boolean'.
b = "a"; // Error
~
!!! error TS2322: Type 'string' is not assignable to type 'Boolean'.
!!! error TS2322: Types of property 'valueOf' are incompatible.
!!! error TS2322: Type '() => Object' is not assignable to type '() => boolean'.
b = {}; // Error
~
!!! error TS2322: Type '{}' is not assignable to type 'Boolean'.
!!! error TS2322: Types of property 'valueOf' are incompatible.
!!! error TS2322: Type '() => Object' is not assignable to type '() => boolean'.

var o = {};
o = b; // OK

b = true; // OK

var b2:boolean;
b = b2; // OK
24 changes: 24 additions & 0 deletions tests/baselines/reference/booleanAssignment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//// [booleanAssignment.ts]
var b = new Boolean();
b = 1; // Error
b = "a"; // Error
b = {}; // Error

var o = {};
o = b; // OK

b = true; // OK

var b2:boolean;
b = b2; // OK

//// [booleanAssignment.js]
var b = new Boolean();
b = 1; // Error
b = "a"; // Error
b = {}; // Error
var o = {};
o = b; // OK
b = true; // OK
var b2;
b = b2; // OK
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(10,3): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
lib.d.ts(513,11): error TS2300: Duplicate identifier 'TemplateStringsArray'.
lib.d.ts(515,11): error TS2300: Duplicate identifier 'TemplateStringsArray'.
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'.
tests/cases/compiler/templateStringsArrayTypeDefinedInES5Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
Property 'raw' is missing in type '{ [x: number]: undefined; }'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib.d.ts(513,11): error TS2300: Duplicate identifier 'TemplateStringsArray'.
lib.d.ts(515,11): error TS2300: Duplicate identifier 'TemplateStringsArray'.
tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(2,7): error TS2300: Duplicate identifier 'TemplateStringsArray'.
tests/cases/compiler/templateStringsArrayTypeRedefinedInES6Mode.ts(8,3): error TS2345: Argument of type '{ [x: number]: undefined; }' is not assignable to parameter of type 'TemplateStringsArray'.
Property 'raw' is missing in type '{ [x: number]: undefined; }'.
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/compiler/booleanAssignment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var b = new Boolean();
b = 1; // Error
b = "a"; // Error
b = {}; // Error

var o = {};
o = b; // OK

b = true; // OK

var b2:boolean;
b = b2; // OK