1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
|
tests/cases/conformance/salsa/a.js(14,13): error TS7008: Member 'inMethodNullable' implicitly has an 'any' type.
tests/cases/conformance/salsa/a.js(20,9): error TS2322: Type '"string"' is not assignable to type 'number'.
tests/cases/conformance/salsa/a.js(39,9): error TS2322: Type 'false' is not assignable to type 'number'.
tests/cases/conformance/salsa/a.js(93,13): error TS2334: 'this' cannot be referenced in a static property initializer.
tests/cases/conformance/salsa/a.js(96,13): error TS2334: 'this' cannot be referenced in a static property initializer.
==== tests/cases/conformance/salsa/a.js (5 errors) ====
class C {
constructor() {
if (Math.random()) {
this.inConstructor = 0;
}
else {
this.inConstructor = "string"
}
this.inMultiple = 0;
}
method() {
if (Math.random()) {
this.inMethod = 0;
this.inMethodNullable = null;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS7008: Member 'inMethodNullable' implicitly has an 'any' type.
}
else {
this.inMethod = "string"
this.inMethodNullable = undefined;
}
this.inMultiple = "string";
~~~~~~~~~~~~~~~
!!! error TS2322: Type '"string"' is not assignable to type 'number'.
this.inMultipleMethods = "string";
var action = () => {
if (Math.random()) {
this.inNestedArrowFunction = 0;
}
else {
this.inNestedArrowFunction = "string"
}
};
}
get() {
if (Math.random()) {
this.inGetter = 0;
}
else {
this.inGetter = "string"
}
this.inMultiple = false;
~~~~~~~~~~~~~~~
!!! error TS2322: Type 'false' is not assignable to type 'number'.
this.inMultipleMethods = false;
}
set() {
if (Math.random()) {
this.inSetter = 0;
}
else {
this.inSetter = "string"
}
}
prop = () => {
if (Math.random()) {
this.inPropertyDeclaration = 0;
}
else {
this.inPropertyDeclaration = "string"
}
}
static method() {
if (Math.random()) {
this.inStaticMethod = 0;
}
else {
this.inStaticMethod = "string"
}
var action = () => {
if (Math.random()) {
this.inStaticNestedArrowFunction = 0;
}
else {
this.inStaticNestedArrowFunction = "string"
}
};
}
static get() {
if (Math.random()) {
this.inStaticGetter = 0;
}
else {
this.inStaticGetter = "string"
}
}
static set() {
if (Math.random()) {
this.inStaticSetter = 0;
}
else {
this.inStaticSetter = "string"
}
}
static prop = () => {
if (Math.random()) {
this.inStaticPropertyDeclaration = 0;
~~~~
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
}
else {
this.inStaticPropertyDeclaration = "string"
~~~~
!!! error TS2334: 'this' cannot be referenced in a static property initializer.
}
}
}
==== tests/cases/conformance/salsa/b.ts (0 errors) ====
var c = new C();
var stringOrNumber: string | number;
var stringOrNumber = c.inConstructor;
var stringOrNumberOrUndefined: string | number | undefined;
var stringOrNumberOrUndefined = c.inMethod;
var stringOrNumberOrUndefined = c.inGetter;
var stringOrNumberOrUndefined = c.inSetter;
var stringOrNumberOrUndefined = c.inPropertyDeclaration;
var stringOrNumberOrUndefined = c.inNestedArrowFunction
var stringOrNumberOrBoolean: string | number | boolean;
var number: number;
var number = c.inMultiple;
var stringOrBooleanOrUndefined : string | boolean | undefined;
var stringOrBooleanOrUndefined = c.inMultipleMethods;
var any: any;
var any = c.inMethodNullable;
var stringOrNumberOrUndefined = C.inStaticMethod;
var stringOrNumberOrUndefined = C.inStaticGetter;
var stringOrNumberOrUndefined = C.inStaticSetter;
var stringOrNumberOrUndefined = C.inStaticPropertyDeclaration;
var stringOrNumberOrUndefined = C.inStaticNestedArrowFunction;
|