1//// [stringLiteralTypeIsSubtypeOfString.ts] 2// string literal types are subtypes of string, any 3 4// ok 5function f1(x: 'a'); 6function f1(x: string); 7function f1(x: string) { } 8 9// ok 10function f2(x: 'a'); 11function f2(x: any); 12function f2(x: any) { } 13 14// errors 15function f3(x: 'a'); 16function f3(x: Object); 17function f3(x: any) { } 18 19function f4(x: 'a'); 20function f4(x: {}); 21function f4(x: any) { } 22 23function f5(x: 'a'); 24function f5(x: number); 25function f5(x: any) { } 26 27function f6(x: 'a'); 28function f6(x: boolean); 29function f6(x: any) { } 30 31function f7(x: 'a'); 32function f7(x: Date); 33function f7(x: any) { } 34 35function f8(x: 'a'); 36function f8(x: RegExp); 37function f8(x: any) { } 38 39function f9(x: 'a'); 40function f9(x: () => {}); 41function f9(x: any) { } 42 43class C implements String { 44 toString(): string { return null; } 45 charAt(pos: number): string { return null; } 46 charCodeAt(index: number): number { return null; } 47 concat(...strings: string[]): string { return null; } 48 indexOf(searchString: string, position?: number): number { return null; } 49 lastIndexOf(searchString: string, position?: number): number { return null; } 50 localeCompare(that: string): number { return null; } 51 match(regexp: any): RegExpMatchArray { return null; } 52 replace(searchValue: any, replaceValue: any): string { return null; } 53 search(regexp: any): number { return null; } 54 slice(start?: number, end?: number): string { return null; } 55 split(separator: any, limit?: number): string[] { return null; } 56 substring(start: number, end?: number): string { return null; } 57 toLowerCase(): string { return null; } 58 toLocaleLowerCase(): string { return null; } 59 toUpperCase(): string { return null; } 60 toLocaleUpperCase(): string { return null; } 61 trim(): string { return null; } 62 length: number; 63 substr(from: number, length?: number): string { return null; } 64 valueOf(): string { return null; } 65 [index: number]: string; 66} 67 68// BUG 831846 69function f10(x: 'a'); 70function f10(x: C); 71function f10(x: any) { } 72 73interface I extends String { 74 foo: string; 75} 76 77// BUG 831846 78function f11(x: 'a'); 79function f11(x: I); 80function f11(x: any) { } 81 82function f12<T>(x: 'a'); 83function f12<T>(x: T); 84function f12<T>(x: any) { } 85 86function f13<T extends String>(x: 'a'); 87function f13<T extends String>(x: T); 88function f13<T extends String>(x: any) { } 89 90enum E { A } 91function f14(x: 'a'); 92function f14(x: E); 93function f14(x: any) { } 94 95function f15<T, U extends T>(x: 'a'); 96function f15<T, U extends T>(x: U); 97function f15<T, U extends T>(x: any) { } 98 99function f16<T extends String, U extends T>(x: 'a'); 100function f16<T extends String, U extends T>(x: U); 101function f16<T extends String, U extends T>(x: any) { } 102 103 104//// [stringLiteralTypeIsSubtypeOfString.js] 105// string literal types are subtypes of string, any 106function f1(x) { } 107function f2(x) { } 108function f3(x) { } 109function f4(x) { } 110function f5(x) { } 111function f6(x) { } 112function f7(x) { } 113function f8(x) { } 114function f9(x) { } 115var C = /** @class */ (function () { 116 function C() { 117 } 118 C.prototype.toString = function () { return null; }; 119 C.prototype.charAt = function (pos) { return null; }; 120 C.prototype.charCodeAt = function (index) { return null; }; 121 C.prototype.concat = function () { 122 var strings = []; 123 for (var _i = 0; _i < arguments.length; _i++) { 124 strings[_i] = arguments[_i]; 125 } 126 return null; 127 }; 128 C.prototype.indexOf = function (searchString, position) { return null; }; 129 C.prototype.lastIndexOf = function (searchString, position) { return null; }; 130 C.prototype.localeCompare = function (that) { return null; }; 131 C.prototype.match = function (regexp) { return null; }; 132 C.prototype.replace = function (searchValue, replaceValue) { return null; }; 133 C.prototype.search = function (regexp) { return null; }; 134 C.prototype.slice = function (start, end) { return null; }; 135 C.prototype.split = function (separator, limit) { return null; }; 136 C.prototype.substring = function (start, end) { return null; }; 137 C.prototype.toLowerCase = function () { return null; }; 138 C.prototype.toLocaleLowerCase = function () { return null; }; 139 C.prototype.toUpperCase = function () { return null; }; 140 C.prototype.toLocaleUpperCase = function () { return null; }; 141 C.prototype.trim = function () { return null; }; 142 C.prototype.substr = function (from, length) { return null; }; 143 C.prototype.valueOf = function () { return null; }; 144 return C; 145}()); 146function f10(x) { } 147function f11(x) { } 148function f12(x) { } 149function f13(x) { } 150var E; 151(function (E) { 152 E[E["A"] = 0] = "A"; 153})(E || (E = {})); 154function f14(x) { } 155function f15(x) { } 156function f16(x) { } 157