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 149 150 151 152 153 154 155 156 157 158 159 160
|
tests/cases/compiler/unspecializedConstraints.ts(84,44): error TS2552: Cannot find name 'TypeParameter'. Did you mean 'Parameter'?
==== tests/cases/compiler/unspecializedConstraints.ts (1 errors) ====
module ts {
interface Map<T> {
[index: string]: T;
}
interface Equals<T> {
equals(other: T): boolean;
}
class Symbol {
}
class Type extends Symbol {
equals(that: Type): boolean {
if (this === that) return true;
if (!(this.isObjectType() && that.isObjectType())) return false;
var propCount = that.getPropertyCount();
if (propCount !== this.getPropertyCount()) return false;
var sigCount = that.getSignatureCount();
if (sigCount !== this.getSignatureCount()) return false;
if (propCount) {
for (var i = 0; i < propCount; i++) {
var thisProp = this.getProperty(i);
var thatProp = that.getPropertyByName(thisProp.name);
if (!(thatProp && thisProp.flags === thatProp.flags && thisProp.type.equals(thatProp.type))) return false;
}
}
if (sigCount) {
if (!setEquals(this.getSignatures(), that.getSignatures())) return false;
}
return true;
}
getProperties(): Property[] {
return [];
}
getProperty(index: number): Property {
return undefined;
}
getPropertyByName(name: string): Property {
return undefined;
}
getPropertyCount(): number {
return 0;
}
getSignature(index: number): Signature {
return undefined;
}
getSignatureCount(): number {
return 0;
}
getSignatures(): Signature[] {
return [];
}
isPrimitive(): boolean {
return false;
}
isObjectType(): boolean {
return false;
}
isTypeParameter(): boolean {
return false;
}
isSubTypeOf(type: Type) {
}
}
class Property extends Symbol {
constructor(public name: string, public type: Type, public flags: PropertyFlags) {
super();
}
equals(other: Property): boolean {
return this.name === other.name &&
this.flags === other.flags &&
this.type.equals(other.type);
}
}
enum PropertyFlags {
Optional = 1,
Private = 2
}
class Signature extends Symbol {
constructor(public typeParameters: TypeParameter[], public parameters: Parameter[], public returnType: Type) {
~~~~~~~~~~~~~
!!! error TS2552: Cannot find name 'TypeParameter'. Did you mean 'Parameter'?
!!! related TS2728 tests/cases/compiler/unspecializedConstraints.ts:99:11: 'Parameter' is declared here.
super();
}
equalsNoReturn(other: Signature): boolean {
return this.parameters.length === other.parameters.length &&
this.typeParameters.length === other.typeParameters.length &&
arrayEquals(this.parameters, other.parameters) &&
arrayEquals(this.typeParameters, other.typeParameters);
}
equals(other: Signature): boolean {
return this.equalsNoReturn(other) &&
this.returnType.equals(other.returnType);
}
}
class Parameter extends Symbol {
constructor(public name: string, public type: Type, public flags: ParameterFlags) {
super();
}
equals(other: Parameter) {
return this.name === other.name &&
this.flags === other.flags &&
this.type.equals(other.type);
}
}
enum ParameterFlags {
Optional = 1,
Rest = 2
}
var hasOwnProperty = Object.prototype.hasOwnProperty;
function getProperty<T>(map: Map<T>, key: string): T {
if (!hasOwnProperty.call(map, key)) return undefined;
return map[key];
}
function hasProperty<T>(map: Map<T>, key: string): boolean {
return hasOwnProperty.call(map, key);
}
function arrayContains<T extends Equals<T>>(a: T[], item: T): boolean {
var len = a.length;
for (var i = 0; i < len; i++) {
if (item.equals(a[i])) return true;
}
return false;
}
function arrayEquals<T extends Equals<T>>(a: T[], b: T[]): boolean {
var len = a.length;
if (b.length !== len) return false;
for (var i = 0; i < len; i++) {
if (!a[i].equals(b[i])) return false;
}
return true;
}
function setEquals<T extends Equals<T>>(a: T[], b: T[]): boolean {
var len = a.length;
if (b.length !== len) return false;
for (var i = 0; i < len; i++) {
if (!arrayContains(b, a[i])) return false;
}
return true;
}
}
|