Compare commits
18 commits
main
...
disallow-u
Author | SHA1 | Date | |
---|---|---|---|
|
1c5f699994 | ||
|
003d041515 | ||
|
030c768d91 | ||
|
a645ca9839 | ||
|
6a066b9a7e | ||
|
e0ddced06c | ||
|
5ee327185c | ||
|
6408d7abe6 | ||
|
810f923d54 | ||
|
fcf0ff1dfd | ||
|
a8f4610743 | ||
|
f11f2beb5e | ||
|
2e5f57ce2b | ||
|
2916c29204 | ||
|
868624293d | ||
|
feb0fb6dc4 | ||
|
70a15bdeeb | ||
|
ac96739777 |
|
@ -29443,7 +29443,6 @@ namespace ts {
|
|||
}
|
||||
|
||||
function checkKindsOfPropertyMemberOverrides(type: InterfaceType, baseType: BaseType): void {
|
||||
|
||||
// TypeScript 1.0 spec (April 2014): 8.2.3
|
||||
// A derived class inherits all members from its base class it doesn't override.
|
||||
// Inheritance means that a derived class implicitly contains all non - overridden members of the base class.
|
||||
|
@ -29477,7 +29476,6 @@ namespace ts {
|
|||
// type declaration, derived and base resolve to the same symbol even in the case of generic classes.
|
||||
if (derived === base) {
|
||||
// derived class inherits base without override/redeclaration
|
||||
|
||||
const derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol)!;
|
||||
|
||||
// It is an error to inherit an abstract member without implementing it or being declared abstract.
|
||||
|
@ -29514,10 +29512,31 @@ namespace ts {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (isPrototypeProperty(base) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) {
|
||||
if (isPrototypeProperty(base)) {
|
||||
// method is overridden with method or property/accessor is overridden with property/accessor - correct case
|
||||
continue;
|
||||
}
|
||||
if (base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) {
|
||||
const uninitialized = find(derived.declarations, d => d.kind === SyntaxKind.PropertyDeclaration && !(d as PropertyDeclaration).initializer);
|
||||
if (uninitialized
|
||||
&& !(base.valueDeclaration && base.valueDeclaration.parent.kind === SyntaxKind.InterfaceDeclaration)
|
||||
&& !(derived.flags & SymbolFlags.Transient)
|
||||
&& !(baseDeclarationFlags & ModifierFlags.Abstract)
|
||||
&& !(derivedDeclarationFlags & ModifierFlags.Abstract)
|
||||
&& !derived.declarations.some(d => d.flags & NodeFlags.Ambient)) {
|
||||
const constructor = findConstructorDeclaration(getClassLikeDeclarationOfSymbol(type.symbol)!);
|
||||
const propName = (uninitialized as PropertyDeclaration).name;
|
||||
if ((uninitialized as PropertyDeclaration).exclamationToken
|
||||
|| !constructor
|
||||
|| !isIdentifier(propName)
|
||||
|| !strictNullChecks
|
||||
|| !isPropertyInitializedInConstructor(propName, type, constructor)) {
|
||||
const errorMessage = Diagnostics.Property_0_will_overwrite_the_base_property_in_1_Add_a_declare_modifier_or_an_initializer_to_avoid_this;
|
||||
error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, symbolToString(base), typeToString(baseType));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
let errorMessage: DiagnosticMessage;
|
||||
if (isPrototypeProperty(base)) {
|
||||
|
@ -29583,6 +29602,9 @@ namespace ts {
|
|||
}
|
||||
const constructor = findConstructorDeclaration(node);
|
||||
for (const member of node.members) {
|
||||
if (getModifierFlags(member) & ModifierFlags.Ambient) {
|
||||
continue;
|
||||
}
|
||||
if (isInstancePropertyWithoutInitializer(member)) {
|
||||
const propName = (<PropertyDeclaration>member).name;
|
||||
if (isIdentifier(propName)) {
|
||||
|
@ -32507,7 +32529,7 @@ namespace ts {
|
|||
else if (flags & ModifierFlags.Async) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
|
||||
}
|
||||
else if (isClassLike(node.parent)) {
|
||||
else if (isClassLike(node.parent) && !isPropertyDeclaration(node)) {
|
||||
return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare");
|
||||
}
|
||||
else if (node.kind === SyntaxKind.Parameter) {
|
||||
|
|
|
@ -2204,6 +2204,10 @@
|
|||
"category": "Error",
|
||||
"code": 2609
|
||||
},
|
||||
"Property '{0}' will overwrite the base property in '{1}'. Add a 'declare' modifier or an initializer to avoid this.": {
|
||||
"category": "Error",
|
||||
"code": 2610
|
||||
},
|
||||
"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
|
||||
"category": "Error",
|
||||
"code": 2649
|
||||
|
@ -5144,6 +5148,14 @@
|
|||
"category": "Message",
|
||||
"code": 95093
|
||||
},
|
||||
"Prefix with 'declare'": {
|
||||
"category": "Message",
|
||||
"code": 95094
|
||||
},
|
||||
"Prefix all incorrect property declarations with 'declare'": {
|
||||
"category": "Message",
|
||||
"code": 95095
|
||||
},
|
||||
|
||||
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
|
||||
"category": "Error",
|
||||
|
|
|
@ -5982,8 +5982,16 @@ namespace ts {
|
|||
token() === SyntaxKind.NumericLiteral ||
|
||||
token() === SyntaxKind.AsteriskToken ||
|
||||
token() === SyntaxKind.OpenBracketToken) {
|
||||
|
||||
return parsePropertyOrMethodDeclaration(<PropertyDeclaration | MethodDeclaration>node);
|
||||
const isAmbient = node.modifiers && some(node.modifiers, isDeclareModifier);
|
||||
if (isAmbient) {
|
||||
for (const m of node.modifiers!) {
|
||||
m.flags |= NodeFlags.Ambient;
|
||||
}
|
||||
return doInsideOfContext(NodeFlags.Ambient, () => parsePropertyOrMethodDeclaration(node as PropertyDeclaration | MethodDeclaration));
|
||||
}
|
||||
else {
|
||||
return parsePropertyOrMethodDeclaration(node as PropertyDeclaration | MethodDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
if (node.decorators || node.modifiers) {
|
||||
|
|
34
src/services/codefixes/addMissingDeclareProperty.ts
Normal file
34
src/services/codefixes/addMissingDeclareProperty.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* @internal */
|
||||
namespace ts.codefix {
|
||||
const fixId = "addMissingDeclareProperty";
|
||||
const errorCodes = [
|
||||
Diagnostics.Property_0_will_overwrite_the_base_property_in_1_Add_a_declare_modifier_or_an_initializer_to_avoid_this.code,
|
||||
];
|
||||
|
||||
registerCodeFix({
|
||||
errorCodes,
|
||||
getCodeActions: (context) => {
|
||||
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span.start));
|
||||
if (changes.length > 0) {
|
||||
return [createCodeFixAction(fixId, changes, Diagnostics.Prefix_with_declare, fixId, Diagnostics.Prefix_all_incorrect_property_declarations_with_declare)];
|
||||
}
|
||||
},
|
||||
fixIds: [fixId],
|
||||
getAllCodeActions: context => {
|
||||
const fixedNodes = new NodeSet();
|
||||
return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag.start, fixedNodes));
|
||||
},
|
||||
});
|
||||
|
||||
function makeChange(changeTracker: textChanges.ChangeTracker, sourceFile: SourceFile, pos: number, fixedNodes?: NodeSet<Node>) {
|
||||
const token = getTokenAtPosition(sourceFile, pos);
|
||||
if (!isIdentifier(token)) {
|
||||
return;
|
||||
}
|
||||
const declaration = token.parent;
|
||||
if (declaration.kind === SyntaxKind.PropertyDeclaration &&
|
||||
(!fixedNodes || fixedNodes.tryAdd(declaration))) {
|
||||
changeTracker.insertModifierBefore(sourceFile, SyntaxKind.DeclareKeyword, declaration);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -339,7 +339,6 @@ namespace ts {
|
|||
}
|
||||
|
||||
class TokenObject<TKind extends SyntaxKind> extends TokenOrIdentifierObject implements Token<TKind> {
|
||||
public symbol!: Symbol;
|
||||
public kind: TKind;
|
||||
|
||||
constructor(kind: TKind, pos: number, end: number) {
|
||||
|
@ -349,9 +348,8 @@ namespace ts {
|
|||
}
|
||||
|
||||
class IdentifierObject extends TokenOrIdentifierObject implements Identifier {
|
||||
public kind!: SyntaxKind.Identifier;
|
||||
public kind: SyntaxKind.Identifier = SyntaxKind.Identifier;
|
||||
public escapedText!: __String;
|
||||
public symbol!: Symbol;
|
||||
public autoGenerateFlags!: GeneratedIdentifierFlags;
|
||||
_primaryExpressionBrand: any;
|
||||
_memberExpressionBrand: any;
|
||||
|
@ -541,7 +539,7 @@ namespace ts {
|
|||
}
|
||||
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public kind!: SyntaxKind.SourceFile;
|
||||
public kind: SyntaxKind.SourceFile = SyntaxKind.SourceFile;
|
||||
public _declarationBrand: any;
|
||||
public fileName!: string;
|
||||
public path!: Path;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
"codefixes/addConvertToUnknownForNonOverlappingTypes.ts",
|
||||
"codefixes/addMissingAwait.ts",
|
||||
"codefixes/addMissingConst.ts",
|
||||
"codefixes/addMissingDeclareProperty.ts",
|
||||
"codefixes/addMissingInvocationForDecorator.ts",
|
||||
"codefixes/addNameToNamelessParameter.ts",
|
||||
"codefixes/annotateWithTypeFromJSDoc.ts",
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(10,5): error TS2416: Property 'x' in type 'Derived<U>' is not assignable to the same property in base type 'Base<string>'.
|
||||
Type 'String' is not assignable to type 'string'.
|
||||
'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible.
|
||||
tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(10,5): error TS2610: Property 'x' will overwrite the base property in 'Base<string>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(20,5): error TS2610: Property 'x' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (1 errors) ====
|
||||
==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (3 errors) ====
|
||||
// subtype checks use the apparent type of the target type
|
||||
// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S:
|
||||
|
||||
|
@ -18,6 +20,8 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi
|
|||
!!! error TS2416: Property 'x' in type 'Derived<U>' is not assignable to the same property in base type 'Base<string>'.
|
||||
!!! error TS2416: Type 'String' is not assignable to type 'string'.
|
||||
!!! error TS2416: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible.
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'Base<string>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class Base2 {
|
||||
|
@ -28,4 +32,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi
|
|||
// is U extends String (S) a subtype of String (T)? Apparent type of U is String so it succeeds
|
||||
class Derived2<U extends String> extends Base2 { // error because of the prototype's not matching, not because of the instance side
|
||||
x: U;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'Base2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -2,9 +2,10 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty
|
|||
Type 'U' is not assignable to type 'string'.
|
||||
Type 'String' is not assignable to type 'string'.
|
||||
'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible.
|
||||
tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts(10,5): error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (1 errors) ====
|
||||
==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (2 errors) ====
|
||||
// subtype checks use the apparent type of the target type
|
||||
// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S:
|
||||
|
||||
|
@ -20,4 +21,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty
|
|||
!!! error TS2416: Type 'U' is not assignable to type 'string'.
|
||||
!!! error TS2416: Type 'String' is not assignable to type 'string'.
|
||||
!!! error TS2416: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible.
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -5,6 +5,7 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2416: Prop
|
|||
Types of property 'n' are incompatible.
|
||||
Type 'string | Derived' is not assignable to type 'string | Base'.
|
||||
Type 'Derived' is not assignable to type 'string | Base'.
|
||||
tests/cases/compiler/baseClassImprovedMismatchErrors.ts(8,5): error TS2610: Property 'n' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/baseClassImprovedMismatchErrors.ts(9,5): error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'.
|
||||
Type '() => string | number' is not assignable to type '() => number'.
|
||||
Type 'string | number' is not assignable to type 'number'.
|
||||
|
@ -22,7 +23,7 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Pro
|
|||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/baseClassImprovedMismatchErrors.ts (4 errors) ====
|
||||
==== tests/cases/compiler/baseClassImprovedMismatchErrors.ts (5 errors) ====
|
||||
class Base {
|
||||
n: Base | string;
|
||||
fn() {
|
||||
|
@ -39,6 +40,8 @@ tests/cases/compiler/baseClassImprovedMismatchErrors.ts(15,5): error TS2416: Pro
|
|||
!!! error TS2416: Types of property 'n' are incompatible.
|
||||
!!! error TS2416: Type 'string | Derived' is not assignable to type 'string | Base'.
|
||||
!!! error TS2416: Type 'Derived' is not assignable to type 'string | Base'.
|
||||
~
|
||||
!!! error TS2610: Property 'n' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
fn() {
|
||||
~~
|
||||
!!! error TS2416: Property 'fn' in type 'Derived' is not assignable to the same property in base type 'Base'.
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
tests/cases/compiler/classExpressionPropertyModifiers.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
tests/cases/compiler/classExpressionPropertyModifiers.ts(2,36): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/compiler/classExpressionPropertyModifiers.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element.
|
||||
|
||||
|
||||
==== tests/cases/compiler/classExpressionPropertyModifiers.ts (2 errors) ====
|
||||
const a = class Cat {
|
||||
declare [Symbol.toStringTag] = "uh";
|
||||
~~~~~~~
|
||||
!!! error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
~~~~
|
||||
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
||||
export foo = 1;
|
||||
~~~~~~
|
||||
!!! error TS1031: 'export' modifier cannot appear on a class element.
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(6,5): error TS2610: Property 'foo' will overwrite the base property in 'Base<{ bar: string; }>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(12,5): error TS2416: Property 'foo' in type 'Derived2' is not assignable to the same property in base type 'Base<{ bar: string; }>'.
|
||||
Type '{ bar?: string; }' is not assignable to type '{ bar: string; }'.
|
||||
Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'.
|
||||
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(12,5): error TS2610: Property 'foo' will overwrite the base property in 'Base<{ bar: string; }>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (1 errors) ====
|
||||
==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (3 errors) ====
|
||||
class Base<T> {
|
||||
foo: T;
|
||||
}
|
||||
|
||||
class Derived extends Base<{ bar: string; }> {
|
||||
foo: {
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<{ bar: string; }>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
bar: string; baz: number; // ok
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +24,8 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla
|
|||
!!! error TS2416: Property 'foo' in type 'Derived2' is not assignable to the same property in base type 'Base<{ bar: string; }>'.
|
||||
!!! error TS2416: Type '{ bar?: string; }' is not assignable to type '{ bar: string; }'.
|
||||
!!! error TS2416: Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<{ bar: string; }>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
bar?: string; // error
|
||||
}
|
||||
}
|
159
tests/baselines/reference/commentsInheritance.errors.txt
Normal file
159
tests/baselines/reference/commentsInheritance.errors.txt
Normal file
|
@ -0,0 +1,159 @@
|
|||
tests/cases/compiler/commentsInheritance.ts(90,12): error TS2610: Property 'p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/commentsInheritance.ts(98,12): error TS2610: Property 'nc_p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/commentsInheritance.ts (2 errors) ====
|
||||
/** i1 is interface with properties*/
|
||||
interface i1 {
|
||||
/** i1_p1*/
|
||||
i1_p1: number;
|
||||
/** i1_f1*/
|
||||
i1_f1(): void;
|
||||
/** i1_l1*/
|
||||
i1_l1: () => void;
|
||||
// il_nc_p1
|
||||
i1_nc_p1: number;
|
||||
i1_nc_f1(): void;
|
||||
i1_nc_l1: () => void;
|
||||
p1: number;
|
||||
f1(): void;
|
||||
l1: () => void;
|
||||
nc_p1: number;
|
||||
nc_f1(): void;
|
||||
nc_l1: () => void;
|
||||
}
|
||||
class c1 implements i1 {
|
||||
public i1_p1: number;
|
||||
// i1_f1
|
||||
public i1_f1() {
|
||||
}
|
||||
public i1_l1: () => void;
|
||||
public i1_nc_p1: number;
|
||||
public i1_nc_f1() {
|
||||
}
|
||||
public i1_nc_l1: () => void;
|
||||
/** c1_p1*/
|
||||
public p1: number;
|
||||
/** c1_f1*/
|
||||
public f1() {
|
||||
}
|
||||
/** c1_l1*/
|
||||
public l1: () => void;
|
||||
/** c1_nc_p1*/
|
||||
public nc_p1: number;
|
||||
/** c1_nc_f1*/
|
||||
public nc_f1() {
|
||||
}
|
||||
/** c1_nc_l1*/
|
||||
public nc_l1: () => void;
|
||||
}
|
||||
var i1_i: i1;
|
||||
var c1_i = new c1();
|
||||
// assign to interface
|
||||
i1_i = c1_i;
|
||||
class c2 {
|
||||
/** c2 c2_p1*/
|
||||
public c2_p1: number;
|
||||
/** c2 c2_f1*/
|
||||
public c2_f1() {
|
||||
}
|
||||
/** c2 c2_prop*/
|
||||
public get c2_prop() {
|
||||
return 10;
|
||||
}
|
||||
public c2_nc_p1: number;
|
||||
public c2_nc_f1() {
|
||||
}
|
||||
public get c2_nc_prop() {
|
||||
return 10;
|
||||
}
|
||||
/** c2 p1*/
|
||||
public p1: number;
|
||||
/** c2 f1*/
|
||||
public f1() {
|
||||
}
|
||||
/** c2 prop*/
|
||||
public get prop() {
|
||||
return 10;
|
||||
}
|
||||
public nc_p1: number;
|
||||
public nc_f1() {
|
||||
}
|
||||
public get nc_prop() {
|
||||
return 10;
|
||||
}
|
||||
/** c2 constructor*/
|
||||
constructor(a: number) {
|
||||
this.c2_p1 = a;
|
||||
}
|
||||
}
|
||||
class c3 extends c2 {
|
||||
constructor() {
|
||||
super(10);
|
||||
}
|
||||
/** c3 p1*/
|
||||
public p1: number;
|
||||
~~
|
||||
!!! error TS2610: Property 'p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
/** c3 f1*/
|
||||
public f1() {
|
||||
}
|
||||
/** c3 prop*/
|
||||
public get prop() {
|
||||
return 10;
|
||||
}
|
||||
public nc_p1: number;
|
||||
~~~~~
|
||||
!!! error TS2610: Property 'nc_p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
public nc_f1() {
|
||||
}
|
||||
public get nc_prop() {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
var c2_i = new c2(10);
|
||||
var c3_i = new c3();
|
||||
// assign
|
||||
c2_i = c3_i;
|
||||
class c4 extends c2 {
|
||||
}
|
||||
var c4_i = new c4(10);
|
||||
interface i2 {
|
||||
/** i2_p1*/
|
||||
i2_p1: number;
|
||||
/** i2_f1*/
|
||||
i2_f1(): void;
|
||||
/** i2_l1*/
|
||||
i2_l1: () => void;
|
||||
// i2_nc_p1
|
||||
i2_nc_p1: number;
|
||||
i2_nc_f1(): void;
|
||||
i2_nc_l1: () => void;
|
||||
/** i2 p1*/
|
||||
p1: number;
|
||||
/** i2 f1*/
|
||||
f1(): void;
|
||||
/** i2 l1*/
|
||||
l1: () => void;
|
||||
nc_p1: number;
|
||||
nc_f1(): void;
|
||||
nc_l1: () => void;
|
||||
}
|
||||
interface i3 extends i2 {
|
||||
/** i3 p1 */
|
||||
p1: number;
|
||||
/**
|
||||
* i3 f1
|
||||
*/
|
||||
f1(): void;
|
||||
/** i3 l1*/
|
||||
l1: () => void;
|
||||
nc_p1: number;
|
||||
nc_f1(): void;
|
||||
nc_l1: () => void;
|
||||
}
|
||||
var i2_i: i2;
|
||||
var i3_i: i3;
|
||||
// assign to interface
|
||||
i2_i = i3_i;
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
tests/cases/compiler/declarationEmitProtectedMembers.ts(34,5): error TS2610: Property 'x' will overwrite the base property in 'C2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/declarationEmitProtectedMembers.ts (1 errors) ====
|
||||
// Class with protected members
|
||||
class C1 {
|
||||
protected x: number;
|
||||
|
||||
protected f() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
protected set accessor(a: number) { }
|
||||
protected get accessor() { return 0; }
|
||||
|
||||
protected static sx: number;
|
||||
|
||||
protected static sf() {
|
||||
return this.sx;
|
||||
}
|
||||
|
||||
protected static set staticSetter(a: number) { }
|
||||
protected static get staticGetter() { return 0; }
|
||||
}
|
||||
|
||||
// Derived class overriding protected members
|
||||
class C2 extends C1 {
|
||||
protected f() {
|
||||
return super.f() + this.x;
|
||||
}
|
||||
protected static sf() {
|
||||
return super.sf() + this.sx;
|
||||
}
|
||||
}
|
||||
|
||||
// Derived class making protected members public
|
||||
class C3 extends C2 {
|
||||
x: number;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'C2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
static sx: number;
|
||||
f() {
|
||||
return super.f();
|
||||
}
|
||||
static sf() {
|
||||
return super.sf();
|
||||
}
|
||||
|
||||
static get staticGetter() { return 1; }
|
||||
}
|
||||
|
||||
// Protected properties in constructors
|
||||
class C4 {
|
||||
constructor(protected a: number, protected b) { }
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(21,15): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts(25,15): error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers.ts (2 errors) ====
|
||||
var x: { foo: string; }
|
||||
var y: { foo: string; bar: string; }
|
||||
|
||||
class Base {
|
||||
protected a: typeof x;
|
||||
protected b(a: typeof x) { }
|
||||
protected get c() { return x; }
|
||||
protected set c(v: typeof x) { }
|
||||
protected d: (a: typeof x) => void;
|
||||
|
||||
protected static r: typeof x;
|
||||
protected static s(a: typeof x) { }
|
||||
protected static get t() { return x; }
|
||||
protected static set t(v: typeof x) { }
|
||||
protected static u: (a: typeof x) => void;
|
||||
|
||||
constructor(a: typeof x) { }
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
protected a: typeof y;
|
||||
~
|
||||
!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
protected b(a: typeof y) { }
|
||||
protected get c() { return y; }
|
||||
protected set c(v: typeof y) { }
|
||||
protected d: (a: typeof y) => void;
|
||||
~
|
||||
!!! error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
protected static r: typeof y;
|
||||
protected static s(a: typeof y) { }
|
||||
protected static get t() { return y; }
|
||||
protected static set t(a: typeof y) { }
|
||||
protected static u: (a: typeof y) => void;
|
||||
|
||||
constructor(a: typeof y) { super(x) }
|
||||
}
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(22,5): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts(26,5): error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers2.ts (2 errors) ====
|
||||
var x: { foo: string; }
|
||||
var y: { foo: string; bar: string; }
|
||||
|
||||
class Base {
|
||||
protected a: typeof x;
|
||||
protected b(a: typeof x) { }
|
||||
protected get c() { return x; }
|
||||
protected set c(v: typeof x) { }
|
||||
protected d: (a: typeof x) => void ;
|
||||
|
||||
protected static r: typeof x;
|
||||
protected static s(a: typeof x) { }
|
||||
protected static get t() { return x; }
|
||||
protected static set t(v: typeof x) { }
|
||||
protected static u: (a: typeof x) => void ;
|
||||
|
||||
constructor(a: typeof x) { }
|
||||
}
|
||||
|
||||
// Increase visibility of all protected members to public
|
||||
class Derived extends Base {
|
||||
a: typeof y;
|
||||
~
|
||||
!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
b(a: typeof y) { }
|
||||
get c() { return y; }
|
||||
set c(v: typeof y) { }
|
||||
d: (a: typeof y) => void;
|
||||
~
|
||||
!!! error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
static r: typeof y;
|
||||
static s(a: typeof y) { }
|
||||
static get t() { return y; }
|
||||
static set t(a: typeof y) { }
|
||||
static u: (a: typeof y) => void;
|
||||
|
||||
constructor(a: typeof y) { super(a); }
|
||||
}
|
||||
|
||||
var d: Derived = new Derived(y);
|
||||
var r1 = d.a;
|
||||
var r2 = d.b(y);
|
||||
var r3 = d.c;
|
||||
var r3a = d.d;
|
||||
d.c = y;
|
||||
var r4 = Derived.r;
|
||||
var r5 = Derived.s(y);
|
||||
var r6 = Derived.t;
|
||||
var r6a = Derived.u;
|
||||
Derived.t = y;
|
||||
|
||||
class Base2 {
|
||||
[i: string]: Object;
|
||||
[i: number]: typeof x;
|
||||
}
|
||||
|
||||
class Derived2 extends Base2 {
|
||||
[i: string]: typeof x;
|
||||
[i: number]: typeof y;
|
||||
}
|
||||
|
||||
var d2: Derived2;
|
||||
var r7 = d2[''];
|
||||
var r8 = d2[1];
|
||||
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(22,7): error TS2415: Class 'Derived1' incorrectly extends base class 'Base'.
|
||||
Property 'a' is protected in type 'Derived1' but public in type 'Base'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(23,15): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(27,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Base'.
|
||||
Property 'b' is protected in type 'Derived2' but public in type 'Base'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(32,7): error TS2415: Class 'Derived3' incorrectly extends base class 'Base'.
|
||||
|
@ -8,6 +9,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
Property 'c' is protected in type 'Derived4' but public in type 'Base'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(42,7): error TS2415: Class 'Derived5' incorrectly extends base class 'Base'.
|
||||
Property 'd' is protected in type 'Derived5' but public in type 'Base'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(43,15): error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(47,7): error TS2417: Class static side 'typeof Derived6' incorrectly extends base class static side 'typeof Base'.
|
||||
Property 'r' is protected in type 'typeof Derived6' but public in type 'typeof Base'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts(52,7): error TS2417: Class static side 'typeof Derived7' incorrectly extends base class static side 'typeof Base'.
|
||||
|
@ -20,7 +22,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
Property 'u' is protected in type 'typeof Derived10' but public in type 'typeof Base'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts (10 errors) ====
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers3.ts (12 errors) ====
|
||||
var x: { foo: string; }
|
||||
var y: { foo: string; bar: string; }
|
||||
|
||||
|
@ -47,6 +49,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
!!! error TS2415: Class 'Derived1' incorrectly extends base class 'Base'.
|
||||
!!! error TS2415: Property 'a' is protected in type 'Derived1' but public in type 'Base'.
|
||||
protected a: typeof x;
|
||||
~
|
||||
!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
constructor(a: typeof x) { super(a); }
|
||||
}
|
||||
|
||||
|
@ -79,6 +83,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
!!! error TS2415: Class 'Derived5' incorrectly extends base class 'Base'.
|
||||
!!! error TS2415: Property 'd' is protected in type 'Derived5' but public in type 'Base'.
|
||||
protected d: (a: typeof x) => void ;
|
||||
~
|
||||
!!! error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
constructor(a: typeof x) { super(a); }
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(9,12): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(12,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Derived1'.
|
||||
Property 'a' is protected in type 'Derived2' but public in type 'Derived1'.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts(13,15): error TS2610: Property 'a' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts (1 errors) ====
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesProtectedMembers4.ts (3 errors) ====
|
||||
var x: { foo: string; }
|
||||
var y: { foo: string; bar: string; }
|
||||
|
||||
|
@ -12,6 +14,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
|
||||
class Derived1 extends Base {
|
||||
public a: typeof x;
|
||||
~
|
||||
!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class Derived2 extends Derived1 {
|
||||
|
@ -19,4 +23,6 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
!!! error TS2415: Class 'Derived2' incorrectly extends base class 'Derived1'.
|
||||
!!! error TS2415: Property 'a' is protected in type 'Derived2' but public in type 'Derived1'.
|
||||
protected a: typeof x; // Error, parent was public
|
||||
~
|
||||
!!! error TS2610: Property 'a' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -2,13 +2,15 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(8,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(13,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(14,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(21,5): error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(23,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(24,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(25,5): error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(29,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts(30,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts (8 errors) ====
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesPublicMembers.ts (10 errors) ====
|
||||
var x: { foo: string; }
|
||||
var y: { foo: string; bar: string; }
|
||||
|
||||
|
@ -38,6 +40,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
|
||||
class Derived extends Base {
|
||||
a: typeof y;
|
||||
~
|
||||
!!! error TS2610: Property 'a' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
b(a: typeof y) { }
|
||||
get c() { return y; }
|
||||
~
|
||||
|
@ -46,6 +50,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOve
|
|||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
d: (a: typeof y) => void;
|
||||
~
|
||||
!!! error TS2610: Property 'd' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
static r: typeof y;
|
||||
static s(a: typeof y) { }
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts(8,5): error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassOverridesWithoutSubtype.ts (1 errors) ====
|
||||
class Base {
|
||||
x: {
|
||||
foo: string;
|
||||
}
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
x: {
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
foo: any;
|
||||
}
|
||||
}
|
||||
|
||||
class Base2 {
|
||||
static y: {
|
||||
foo: string;
|
||||
}
|
||||
}
|
||||
|
||||
class Derived2 extends Base2 {
|
||||
static y: {
|
||||
foo: any;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(18,5): error TS2610: Property 'x' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(19,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(27,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(37,5): error TS2610: Property 'x' will overwrite the base property in 'D'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(38,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(44,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts(57,1): error TS2322: Type 'E' is not assignable to type 'C'.
|
||||
|
@ -9,7 +11,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit
|
|||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts (7 errors) ====
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWithAny.ts (9 errors) ====
|
||||
class C {
|
||||
x: number;
|
||||
get X(): number { return 1; }
|
||||
|
@ -32,6 +34,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit
|
|||
|
||||
class D extends C {
|
||||
x: any;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
get X(): any {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
@ -55,6 +59,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedClassWit
|
|||
// if D is a valid class definition than E is now not safe tranisitively through C
|
||||
class E extends D {
|
||||
x: string;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'D'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
get X(): string{ return ''; }
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(10,5): error TS2610: Property 'x' will overwrite the base property in 'C<number>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(29,5): error TS2610: Property 'x' will overwrite the base property in 'D'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts(30,18): error TS2322: Type '""' is not assignable to type 'T'.
|
||||
'""' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'string'.
|
||||
|
@ -11,7 +13,7 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC
|
|||
Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts (7 errors) ====
|
||||
==== tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericClassWithAny.ts (9 errors) ====
|
||||
class C<T extends number> {
|
||||
x: T;
|
||||
get X(): T { return null; }
|
||||
|
@ -24,6 +26,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC
|
|||
|
||||
class D extends C<number> {
|
||||
x: any;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'C<number>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
get X(): any {
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
@ -47,6 +51,8 @@ tests/cases/conformance/classes/members/inheritanceAndOverriding/derivedGenericC
|
|||
// if D is a valid class definition than E is now not safe tranisitively through C
|
||||
class E<T extends string> extends D {
|
||||
x: T;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'D'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
get X(): T { return ''; } // error
|
||||
~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(6,5): error TS2610: Property 'property' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(12,21): error TS1255: A definite assignment assertion '!' is not permitted in this context.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,5): error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(15,17): error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(17,24): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(24,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(27,5): error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(39,5): error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts(65,5): error TS2610: Property 'r' will overwrite the base property in 'J'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts (10 errors) ====
|
||||
class A {
|
||||
property = 'x';
|
||||
m() { return 1 }
|
||||
}
|
||||
class B extends A {
|
||||
property: any; // error
|
||||
~~~~~~~~
|
||||
!!! error TS2610: Property 'property' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
class BD extends A {
|
||||
declare property: any; // ok because it's implicitly initialised
|
||||
}
|
||||
class BDBang extends A {
|
||||
declare property!: any; // ! is not allowed, this is an ambient declaration
|
||||
~
|
||||
!!! error TS1255: A definite assignment assertion '!' is not permitted in this context.
|
||||
}
|
||||
class BOther extends A {
|
||||
declare m() { return 2 } // not allowed on methods
|
||||
~~~~~~~
|
||||
!!! error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
~
|
||||
!!! error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
declare nonce: any; // ok, even though it's not in the base
|
||||
declare property = 'y' // initialiser not allowed with declare
|
||||
~~~
|
||||
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
||||
}
|
||||
class U {
|
||||
declare nonce: any; // ok, even though there's no base
|
||||
}
|
||||
|
||||
class C {
|
||||
p: string;
|
||||
~
|
||||
!!! error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor.
|
||||
}
|
||||
class D extends C {
|
||||
p: 'hi'; // error
|
||||
~
|
||||
!!! error TS2564: Property 'p' has no initializer and is not definitely assigned in the constructor.
|
||||
~
|
||||
!!! error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
class DD extends C {
|
||||
declare p: 'bye'; // ok
|
||||
}
|
||||
|
||||
|
||||
declare class E {
|
||||
p1: string
|
||||
p2: string
|
||||
}
|
||||
class F extends E {
|
||||
p1!: 'z'
|
||||
~~
|
||||
!!! error TS2610: Property 'p1' will overwrite the base property in 'E'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
declare p2: 'alpha'
|
||||
}
|
||||
|
||||
class G extends E {
|
||||
p1: 'z'
|
||||
constructor() {
|
||||
super()
|
||||
this.p1 = 'z'
|
||||
}
|
||||
}
|
||||
|
||||
abstract class H extends E {
|
||||
abstract p1: 'a' | 'b' | 'c'
|
||||
declare abstract p2: 'a' | 'b' | 'c'
|
||||
}
|
||||
|
||||
interface I {
|
||||
q: number
|
||||
}
|
||||
interface J extends I { }
|
||||
class J {
|
||||
r = 5
|
||||
}
|
||||
class K extends J {
|
||||
q!: 1 | 2 | 3 // ok, extends a property from an interface
|
||||
r!: 4 | 5 // error, from class
|
||||
~
|
||||
!!! error TS2610: Property 'r' will overwrite the base property in 'J'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
|
@ -0,0 +1,182 @@
|
|||
//// [derivedUninitializedPropertyDeclaration.ts]
|
||||
class A {
|
||||
property = 'x';
|
||||
m() { return 1 }
|
||||
}
|
||||
class B extends A {
|
||||
property: any; // error
|
||||
}
|
||||
class BD extends A {
|
||||
declare property: any; // ok because it's implicitly initialised
|
||||
}
|
||||
class BDBang extends A {
|
||||
declare property!: any; // ! is not allowed, this is an ambient declaration
|
||||
}
|
||||
class BOther extends A {
|
||||
declare m() { return 2 } // not allowed on methods
|
||||
declare nonce: any; // ok, even though it's not in the base
|
||||
declare property = 'y' // initialiser not allowed with declare
|
||||
}
|
||||
class U {
|
||||
declare nonce: any; // ok, even though there's no base
|
||||
}
|
||||
|
||||
class C {
|
||||
p: string;
|
||||
}
|
||||
class D extends C {
|
||||
p: 'hi'; // error
|
||||
}
|
||||
class DD extends C {
|
||||
declare p: 'bye'; // ok
|
||||
}
|
||||
|
||||
|
||||
declare class E {
|
||||
p1: string
|
||||
p2: string
|
||||
}
|
||||
class F extends E {
|
||||
p1!: 'z'
|
||||
declare p2: 'alpha'
|
||||
}
|
||||
|
||||
class G extends E {
|
||||
p1: 'z'
|
||||
constructor() {
|
||||
super()
|
||||
this.p1 = 'z'
|
||||
}
|
||||
}
|
||||
|
||||
abstract class H extends E {
|
||||
abstract p1: 'a' | 'b' | 'c'
|
||||
declare abstract p2: 'a' | 'b' | 'c'
|
||||
}
|
||||
|
||||
interface I {
|
||||
q: number
|
||||
}
|
||||
interface J extends I { }
|
||||
class J {
|
||||
r = 5
|
||||
}
|
||||
class K extends J {
|
||||
q!: 1 | 2 | 3 // ok, extends a property from an interface
|
||||
r!: 4 | 5 // error, from class
|
||||
}
|
||||
|
||||
|
||||
//// [derivedUninitializedPropertyDeclaration.js]
|
||||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var A = /** @class */ (function () {
|
||||
function A() {
|
||||
this.property = 'x';
|
||||
}
|
||||
A.prototype.m = function () { return 1; };
|
||||
return A;
|
||||
}());
|
||||
var B = /** @class */ (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return B;
|
||||
}(A));
|
||||
var BD = /** @class */ (function (_super) {
|
||||
__extends(BD, _super);
|
||||
function BD() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return BD;
|
||||
}(A));
|
||||
var BDBang = /** @class */ (function (_super) {
|
||||
__extends(BDBang, _super);
|
||||
function BDBang() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return BDBang;
|
||||
}(A));
|
||||
var BOther = /** @class */ (function (_super) {
|
||||
__extends(BOther, _super);
|
||||
function BOther() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.property = 'y'; // initialiser not allowed with declare
|
||||
return _this;
|
||||
}
|
||||
BOther.prototype.m = function () { return 2; }; // not allowed on methods
|
||||
return BOther;
|
||||
}(A));
|
||||
var U = /** @class */ (function () {
|
||||
function U() {
|
||||
}
|
||||
return U;
|
||||
}());
|
||||
var C = /** @class */ (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
}());
|
||||
var D = /** @class */ (function (_super) {
|
||||
__extends(D, _super);
|
||||
function D() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return D;
|
||||
}(C));
|
||||
var DD = /** @class */ (function (_super) {
|
||||
__extends(DD, _super);
|
||||
function DD() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return DD;
|
||||
}(C));
|
||||
var F = /** @class */ (function (_super) {
|
||||
__extends(F, _super);
|
||||
function F() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return F;
|
||||
}(E));
|
||||
var G = /** @class */ (function (_super) {
|
||||
__extends(G, _super);
|
||||
function G() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.p1 = 'z';
|
||||
return _this;
|
||||
}
|
||||
return G;
|
||||
}(E));
|
||||
var H = /** @class */ (function (_super) {
|
||||
__extends(H, _super);
|
||||
function H() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return H;
|
||||
}(E));
|
||||
var J = /** @class */ (function () {
|
||||
function J() {
|
||||
this.r = 5;
|
||||
}
|
||||
return J;
|
||||
}());
|
||||
var K = /** @class */ (function (_super) {
|
||||
__extends(K, _super);
|
||||
function K() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return K;
|
||||
}(J));
|
|
@ -0,0 +1,149 @@
|
|||
=== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts ===
|
||||
class A {
|
||||
>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0))
|
||||
|
||||
property = 'x';
|
||||
>property : Symbol(A.property, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 9))
|
||||
|
||||
m() { return 1 }
|
||||
>m : Symbol(A.m, Decl(derivedUninitializedPropertyDeclaration.ts, 1, 19))
|
||||
}
|
||||
class B extends A {
|
||||
>B : Symbol(B, Decl(derivedUninitializedPropertyDeclaration.ts, 3, 1))
|
||||
>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0))
|
||||
|
||||
property: any; // error
|
||||
>property : Symbol(B.property, Decl(derivedUninitializedPropertyDeclaration.ts, 4, 19))
|
||||
}
|
||||
class BD extends A {
|
||||
>BD : Symbol(BD, Decl(derivedUninitializedPropertyDeclaration.ts, 6, 1))
|
||||
>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0))
|
||||
|
||||
declare property: any; // ok because it's implicitly initialised
|
||||
>property : Symbol(BD.property, Decl(derivedUninitializedPropertyDeclaration.ts, 7, 20))
|
||||
}
|
||||
class BDBang extends A {
|
||||
>BDBang : Symbol(BDBang, Decl(derivedUninitializedPropertyDeclaration.ts, 9, 1))
|
||||
>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0))
|
||||
|
||||
declare property!: any; // ! is not allowed, this is an ambient declaration
|
||||
>property : Symbol(BDBang.property, Decl(derivedUninitializedPropertyDeclaration.ts, 10, 24))
|
||||
}
|
||||
class BOther extends A {
|
||||
>BOther : Symbol(BOther, Decl(derivedUninitializedPropertyDeclaration.ts, 12, 1))
|
||||
>A : Symbol(A, Decl(derivedUninitializedPropertyDeclaration.ts, 0, 0))
|
||||
|
||||
declare m() { return 2 } // not allowed on methods
|
||||
>m : Symbol(BOther.m, Decl(derivedUninitializedPropertyDeclaration.ts, 13, 24))
|
||||
|
||||
declare nonce: any; // ok, even though it's not in the base
|
||||
>nonce : Symbol(BOther.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 14, 28))
|
||||
|
||||
declare property = 'y' // initialiser not allowed with declare
|
||||
>property : Symbol(BOther.property, Decl(derivedUninitializedPropertyDeclaration.ts, 15, 23))
|
||||
}
|
||||
class U {
|
||||
>U : Symbol(U, Decl(derivedUninitializedPropertyDeclaration.ts, 17, 1))
|
||||
|
||||
declare nonce: any; // ok, even though there's no base
|
||||
>nonce : Symbol(U.nonce, Decl(derivedUninitializedPropertyDeclaration.ts, 18, 9))
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1))
|
||||
|
||||
p: string;
|
||||
>p : Symbol(C.p, Decl(derivedUninitializedPropertyDeclaration.ts, 22, 9))
|
||||
}
|
||||
class D extends C {
|
||||
>D : Symbol(D, Decl(derivedUninitializedPropertyDeclaration.ts, 24, 1))
|
||||
>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1))
|
||||
|
||||
p: 'hi'; // error
|
||||
>p : Symbol(D.p, Decl(derivedUninitializedPropertyDeclaration.ts, 25, 19))
|
||||
}
|
||||
class DD extends C {
|
||||
>DD : Symbol(DD, Decl(derivedUninitializedPropertyDeclaration.ts, 27, 1))
|
||||
>C : Symbol(C, Decl(derivedUninitializedPropertyDeclaration.ts, 20, 1))
|
||||
|
||||
declare p: 'bye'; // ok
|
||||
>p : Symbol(DD.p, Decl(derivedUninitializedPropertyDeclaration.ts, 28, 20))
|
||||
}
|
||||
|
||||
|
||||
declare class E {
|
||||
>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1))
|
||||
|
||||
p1: string
|
||||
>p1 : Symbol(E.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 33, 17))
|
||||
|
||||
p2: string
|
||||
>p2 : Symbol(E.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 34, 14))
|
||||
}
|
||||
class F extends E {
|
||||
>F : Symbol(F, Decl(derivedUninitializedPropertyDeclaration.ts, 36, 1))
|
||||
>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1))
|
||||
|
||||
p1!: 'z'
|
||||
>p1 : Symbol(F.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 37, 19))
|
||||
|
||||
declare p2: 'alpha'
|
||||
>p2 : Symbol(F.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 38, 12))
|
||||
}
|
||||
|
||||
class G extends E {
|
||||
>G : Symbol(G, Decl(derivedUninitializedPropertyDeclaration.ts, 40, 1))
|
||||
>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1))
|
||||
|
||||
p1: 'z'
|
||||
>p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19))
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
>super : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1))
|
||||
|
||||
this.p1 = 'z'
|
||||
>this.p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19))
|
||||
>this : Symbol(G, Decl(derivedUninitializedPropertyDeclaration.ts, 40, 1))
|
||||
>p1 : Symbol(G.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 42, 19))
|
||||
}
|
||||
}
|
||||
|
||||
abstract class H extends E {
|
||||
>H : Symbol(H, Decl(derivedUninitializedPropertyDeclaration.ts, 48, 1))
|
||||
>E : Symbol(E, Decl(derivedUninitializedPropertyDeclaration.ts, 30, 1))
|
||||
|
||||
abstract p1: 'a' | 'b' | 'c'
|
||||
>p1 : Symbol(H.p1, Decl(derivedUninitializedPropertyDeclaration.ts, 50, 28))
|
||||
|
||||
declare abstract p2: 'a' | 'b' | 'c'
|
||||
>p2 : Symbol(H.p2, Decl(derivedUninitializedPropertyDeclaration.ts, 51, 32))
|
||||
}
|
||||
|
||||
interface I {
|
||||
>I : Symbol(I, Decl(derivedUninitializedPropertyDeclaration.ts, 53, 1))
|
||||
|
||||
q: number
|
||||
>q : Symbol(I.q, Decl(derivedUninitializedPropertyDeclaration.ts, 55, 13))
|
||||
}
|
||||
interface J extends I { }
|
||||
>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25))
|
||||
>I : Symbol(I, Decl(derivedUninitializedPropertyDeclaration.ts, 53, 1))
|
||||
|
||||
class J {
|
||||
>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25))
|
||||
|
||||
r = 5
|
||||
>r : Symbol(J.r, Decl(derivedUninitializedPropertyDeclaration.ts, 59, 9))
|
||||
}
|
||||
class K extends J {
|
||||
>K : Symbol(K, Decl(derivedUninitializedPropertyDeclaration.ts, 61, 1))
|
||||
>J : Symbol(J, Decl(derivedUninitializedPropertyDeclaration.ts, 57, 1), Decl(derivedUninitializedPropertyDeclaration.ts, 58, 25))
|
||||
|
||||
q!: 1 | 2 | 3 // ok, extends a property from an interface
|
||||
>q : Symbol(K.q, Decl(derivedUninitializedPropertyDeclaration.ts, 62, 19))
|
||||
|
||||
r!: 4 | 5 // error, from class
|
||||
>r : Symbol(K.r, Decl(derivedUninitializedPropertyDeclaration.ts, 63, 17))
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
=== tests/cases/conformance/classes/propertyMemberDeclarations/derivedUninitializedPropertyDeclaration.ts ===
|
||||
class A {
|
||||
>A : A
|
||||
|
||||
property = 'x';
|
||||
>property : string
|
||||
>'x' : "x"
|
||||
|
||||
m() { return 1 }
|
||||
>m : () => number
|
||||
>1 : 1
|
||||
}
|
||||
class B extends A {
|
||||
>B : B
|
||||
>A : A
|
||||
|
||||
property: any; // error
|
||||
>property : any
|
||||
}
|
||||
class BD extends A {
|
||||
>BD : BD
|
||||
>A : A
|
||||
|
||||
declare property: any; // ok because it's implicitly initialised
|
||||
>property : any
|
||||
}
|
||||
class BDBang extends A {
|
||||
>BDBang : BDBang
|
||||
>A : A
|
||||
|
||||
declare property!: any; // ! is not allowed, this is an ambient declaration
|
||||
>property : any
|
||||
}
|
||||
class BOther extends A {
|
||||
>BOther : BOther
|
||||
>A : A
|
||||
|
||||
declare m() { return 2 } // not allowed on methods
|
||||
>m : () => number
|
||||
>2 : 2
|
||||
|
||||
declare nonce: any; // ok, even though it's not in the base
|
||||
>nonce : any
|
||||
|
||||
declare property = 'y' // initialiser not allowed with declare
|
||||
>property : string
|
||||
>'y' : "y"
|
||||
}
|
||||
class U {
|
||||
>U : U
|
||||
|
||||
declare nonce: any; // ok, even though there's no base
|
||||
>nonce : any
|
||||
}
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
p: string;
|
||||
>p : string
|
||||
}
|
||||
class D extends C {
|
||||
>D : D
|
||||
>C : C
|
||||
|
||||
p: 'hi'; // error
|
||||
>p : "hi"
|
||||
}
|
||||
class DD extends C {
|
||||
>DD : DD
|
||||
>C : C
|
||||
|
||||
declare p: 'bye'; // ok
|
||||
>p : "bye"
|
||||
}
|
||||
|
||||
|
||||
declare class E {
|
||||
>E : E
|
||||
|
||||
p1: string
|
||||
>p1 : string
|
||||
|
||||
p2: string
|
||||
>p2 : string
|
||||
}
|
||||
class F extends E {
|
||||
>F : F
|
||||
>E : E
|
||||
|
||||
p1!: 'z'
|
||||
>p1 : "z"
|
||||
|
||||
declare p2: 'alpha'
|
||||
>p2 : "alpha"
|
||||
}
|
||||
|
||||
class G extends E {
|
||||
>G : G
|
||||
>E : E
|
||||
|
||||
p1: 'z'
|
||||
>p1 : "z"
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
>super() : void
|
||||
>super : typeof E
|
||||
|
||||
this.p1 = 'z'
|
||||
>this.p1 = 'z' : "z"
|
||||
>this.p1 : "z"
|
||||
>this : this
|
||||
>p1 : "z"
|
||||
>'z' : "z"
|
||||
}
|
||||
}
|
||||
|
||||
abstract class H extends E {
|
||||
>H : H
|
||||
>E : E
|
||||
|
||||
abstract p1: 'a' | 'b' | 'c'
|
||||
>p1 : "a" | "b" | "c"
|
||||
|
||||
declare abstract p2: 'a' | 'b' | 'c'
|
||||
>p2 : "a" | "b" | "c"
|
||||
}
|
||||
|
||||
interface I {
|
||||
q: number
|
||||
>q : number
|
||||
}
|
||||
interface J extends I { }
|
||||
class J {
|
||||
>J : J
|
||||
|
||||
r = 5
|
||||
>r : number
|
||||
>5 : 5
|
||||
}
|
||||
class K extends J {
|
||||
>K : K
|
||||
>J : J
|
||||
|
||||
q!: 1 | 2 | 3 // ok, extends a property from an interface
|
||||
>q : 1 | 2 | 3
|
||||
|
||||
r!: 4 | 5 // error, from class
|
||||
>r : 5 | 4
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
tests/cases/compiler/genericPrototypeProperty2.ts(7,5): error TS2610: Property 'target' will overwrite the base property in 'BaseEvent'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/genericPrototypeProperty2.ts(14,5): error TS2610: Property 't' will overwrite the base property in 'BaseEventWrapper'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericPrototypeProperty2.ts (2 errors) ====
|
||||
interface EventTarget { x }
|
||||
class BaseEvent {
|
||||
target: EventTarget;
|
||||
}
|
||||
|
||||
class MyEvent<T extends EventTarget> extends BaseEvent {
|
||||
target: T;
|
||||
~~~~~~
|
||||
!!! error TS2610: Property 'target' will overwrite the base property in 'BaseEvent'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
class BaseEventWrapper {
|
||||
t: BaseEvent;
|
||||
}
|
||||
|
||||
class MyEventWrapper extends BaseEventWrapper {
|
||||
t: MyEvent<any>; // any satisfies constraint and passes assignability check between 'target' properties
|
||||
~
|
||||
!!! error TS2610: Property 't' will overwrite the base property in 'BaseEventWrapper'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
tests/cases/compiler/genericPrototypeProperty3.ts(6,5): error TS2610: Property 'target' will overwrite the base property in 'BaseEvent'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/genericPrototypeProperty3.ts(13,5): error TS2610: Property 't' will overwrite the base property in 'BaseEventWrapper'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/genericPrototypeProperty3.ts (2 errors) ====
|
||||
class BaseEvent {
|
||||
target: {};
|
||||
}
|
||||
|
||||
class MyEvent<T> extends BaseEvent { // T is instantiated to any in the prototype, which is assignable to {}
|
||||
target: T;
|
||||
~~~~~~
|
||||
!!! error TS2610: Property 'target' will overwrite the base property in 'BaseEvent'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
class BaseEventWrapper {
|
||||
t: BaseEvent;
|
||||
}
|
||||
|
||||
class MyEventWrapper extends BaseEventWrapper {
|
||||
t: MyEvent<any>;
|
||||
~
|
||||
!!! error TS2610: Property 't' will overwrite the base property in 'BaseEventWrapper'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
tests/cases/compiler/illegalModifiersOnClassElements.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
tests/cases/compiler/illegalModifiersOnClassElements.ts(2,19): error TS1039: Initializers are not allowed in ambient contexts.
|
||||
tests/cases/compiler/illegalModifiersOnClassElements.ts(3,5): error TS1031: 'export' modifier cannot appear on a class element.
|
||||
|
||||
|
||||
==== tests/cases/compiler/illegalModifiersOnClassElements.ts (2 errors) ====
|
||||
class C {
|
||||
declare foo = 1;
|
||||
~~~~~~~
|
||||
!!! error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
~
|
||||
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
||||
export bar = 1;
|
||||
~~~~~~
|
||||
!!! error TS1031: 'export' modifier cannot appear on a class element.
|
||||
|
|
|
@ -10,9 +10,10 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte
|
|||
Property 'y' is missing in type 'Bar5' but required in type 'I'.
|
||||
tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(29,7): error TS2420: Class 'Bar6' incorrectly implements interface 'I'.
|
||||
Property 'y' is protected in type 'Bar6' but public in type 'I'.
|
||||
tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts(38,5): error TS2610: Property 'x' will overwrite the base property in 'Foo'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts (6 errors) ====
|
||||
==== tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInterfaceExtendingClassWithProtecteds.ts (7 errors) ====
|
||||
class Foo {
|
||||
protected x: string;
|
||||
}
|
||||
|
@ -71,6 +72,8 @@ tests/cases/conformance/interfaces/interfacesExtendingClasses/implementingAnInte
|
|||
|
||||
class Bar8 extends Foo implements I {
|
||||
x: string;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'Foo'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
y: number;
|
||||
}
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
tests/cases/compiler/inheritance.ts(22,12): error TS2610: Property 'y' will overwrite the base property in 'N'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/inheritance.ts(31,12): error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function.
|
||||
tests/cases/compiler/inheritance.ts(32,12): error TS2416: Property 'g' in type 'Baad' is not assignable to the same property in base type 'Good'.
|
||||
Type '(n: number) => number' is not assignable to type '() => number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/inheritance.ts (2 errors) ====
|
||||
==== tests/cases/compiler/inheritance.ts (3 errors) ====
|
||||
class B1 {
|
||||
public x;
|
||||
}
|
||||
|
@ -26,6 +27,8 @@ tests/cases/compiler/inheritance.ts(32,12): error TS2416: Property 'g' in type '
|
|||
|
||||
class ND extends N { // any is assignable to number
|
||||
public y;
|
||||
~
|
||||
!!! error TS2610: Property 'y' will overwrite the base property in 'N'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class Good {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(12,5): error TS2610: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts (2 errors) ====
|
||||
==== tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts (3 errors) ====
|
||||
class a {
|
||||
private __x: () => string;
|
||||
get x() {
|
||||
|
@ -19,4 +20,6 @@ tests/cases/compiler/inheritanceMemberPropertyOverridingAccessor.ts(6,9): error
|
|||
|
||||
class b extends a {
|
||||
x: () => string;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts(6,5): error TS2610: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/inheritanceMemberPropertyOverridingProperty.ts (1 errors) ====
|
||||
class a {
|
||||
x: () => string;
|
||||
}
|
||||
|
||||
class b extends a {
|
||||
x: () => string;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'a'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2416: Property 'x' in type 'C2<T>' is not assignable to the same property in base type 'C1<T>'.
|
||||
Type 'string' is not assignable to type 'C2<T>'.
|
||||
tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2610: Property 'x' will overwrite the base property in 'C1<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/instanceSubtypeCheck2.ts (1 errors) ====
|
||||
==== tests/cases/compiler/instanceSubtypeCheck2.ts (2 errors) ====
|
||||
class C1<T> {
|
||||
x: C2<T>;
|
||||
}
|
||||
|
@ -12,4 +13,6 @@ tests/cases/compiler/instanceSubtypeCheck2.ts(6,5): error TS2416: Property 'x' i
|
|||
~
|
||||
!!! error TS2416: Property 'x' in type 'C2<T>' is not assignable to the same property in base type 'C1<T>'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'C2<T>'.
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'C1<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -16,14 +16,18 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
|
|||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,38): error TS2416: Property 'a' in type 'C1' is not assignable to the same property in base type 'T1'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(16,38): error TS2610: Property 'a' will overwrite the base property in 'T1'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2416: Property 'b' in type 'C2' is not assignable to the same property in base type 'T2'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(17,38): error TS2610: Property 'b' will overwrite the base property in 'T2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(18,38): error TS2416: Property 'length' in type 'C3' is not assignable to the same property in base type 'number[]'.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2416: Property '0' in type 'C4' is not assignable to the same property in base type '[string, number]'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(19,38): error TS2610: Property '0' will overwrite the base property in '[string, number]'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,38): error TS2416: Property 'c' in type 'C5' is not assignable to the same property in base type 'T5'.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(20,38): error TS2610: Property 'c' will overwrite the base property in 'T5'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(30,11): error TS2430: Interface 'I10' incorrectly extends interface 'typeof CX'.
|
||||
Types of property 'a' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
@ -55,7 +59,7 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
|
|||
tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts(47,26): error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
|
||||
|
||||
|
||||
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (23 errors) ====
|
||||
==== tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersectionErrors.ts (27 errors) ====
|
||||
type T1 = { a: number };
|
||||
type T2 = T1 & { b: number };
|
||||
type T3 = number[];
|
||||
|
@ -96,10 +100,14 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
|
|||
~
|
||||
!!! error TS2416: Property 'a' in type 'C1' is not assignable to the same property in base type 'T1'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2610: Property 'a' will overwrite the base property in 'T1'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
class C2 extends Constructor<T2>() { b: string }
|
||||
~
|
||||
!!! error TS2416: Property 'b' in type 'C2' is not assignable to the same property in base type 'T2'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'number'.
|
||||
~
|
||||
!!! error TS2610: Property 'b' will overwrite the base property in 'T2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
class C3 extends Constructor<T3>() { length: string }
|
||||
~~~~~~
|
||||
!!! error TS2416: Property 'length' in type 'C3' is not assignable to the same property in base type 'number[]'.
|
||||
|
@ -108,10 +116,14 @@ tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectI
|
|||
~
|
||||
!!! error TS2416: Property '0' in type 'C4' is not assignable to the same property in base type '[string, number]'.
|
||||
!!! error TS2416: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2610: Property '0' will overwrite the base property in '[string, number]'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
class C5 extends Constructor<T5>() { c: number }
|
||||
~
|
||||
!!! error TS2416: Property 'c' in type 'C5' is not assignable to the same property in base type 'T5'.
|
||||
!!! error TS2416: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2610: Property 'c' will overwrite the base property in 'T5'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
declare class CX { static a: string }
|
||||
declare enum EX { A, B, C }
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
tests/cases/compiler/multipleInheritance.ts(9,21): error TS1174: Classes can only extend a single class.
|
||||
tests/cases/compiler/multipleInheritance.ts(18,21): error TS1174: Classes can only extend a single class.
|
||||
tests/cases/compiler/multipleInheritance.ts(26,12): error TS2610: Property 'y' will overwrite the base property in 'N'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/multipleInheritance.ts(35,12): error TS2425: Class 'Good' defines instance member property 'f', but extended class 'Baad' defines it as instance member function.
|
||||
tests/cases/compiler/multipleInheritance.ts(36,12): error TS2416: Property 'g' in type 'Baad' is not assignable to the same property in base type 'Good'.
|
||||
Type '(n: number) => number' is not assignable to type '() => number'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/multipleInheritance.ts (4 errors) ====
|
||||
==== tests/cases/compiler/multipleInheritance.ts (5 errors) ====
|
||||
class B1 {
|
||||
public x;
|
||||
}
|
||||
|
@ -36,6 +37,8 @@ tests/cases/compiler/multipleInheritance.ts(36,12): error TS2416: Property 'g' i
|
|||
|
||||
class ND extends N { // any is assignable to number
|
||||
public y;
|
||||
~
|
||||
!!! error TS2610: Property 'y' will overwrite the base property in 'N'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class Good {
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
tests/cases/compiler/mutuallyRecursiveInference.ts(9,5): error TS2610: Property 'a' will overwrite the base property in 'L<X>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/mutuallyRecursiveInference.ts(10,5): error TS2610: Property 'b' will overwrite the base property in 'L<X>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/mutuallyRecursiveInference.ts (2 errors) ====
|
||||
class T<A> {
|
||||
a: A;
|
||||
b: any
|
||||
}
|
||||
class L<RT extends { a: 'a' | 'b', b: any }> extends T<RT[RT['a']]> {
|
||||
m() { this.a }
|
||||
}
|
||||
class X extends L<X> {
|
||||
a: 'a' | 'b'
|
||||
~
|
||||
!!! error TS2610: Property 'a' will overwrite the base property in 'L<X>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
b: number
|
||||
~
|
||||
!!! error TS2610: Property 'b' will overwrite the base property in 'L<X>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
m2() {
|
||||
this.a
|
||||
}
|
||||
}
|
||||
|
|
@ -3,12 +3,14 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(85,16): error TS10
|
|||
tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(94,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(100,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(111,25): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(114,12): error TS2610: Property 'p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(119,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(122,12): error TS2610: Property 'nc_p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(125,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts (8 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts (10 errors) ====
|
||||
/** i1 is interface with properties*/
|
||||
interface i1 {
|
||||
/** i1_p1*/
|
||||
|
@ -133,6 +135,8 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2
|
|||
}
|
||||
/** c3 p1*/
|
||||
public p1: number;
|
||||
~~
|
||||
!!! error TS2610: Property 'p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
/** c3 f1*/
|
||||
public f1() {
|
||||
}
|
||||
|
@ -143,6 +147,8 @@ tests/cases/conformance/parser/ecmascript5/parserAstSpans1.ts(217,24): error TS2
|
|||
return 10;
|
||||
}
|
||||
public nc_p1: number;
|
||||
~~~~~
|
||||
!!! error TS2610: Property 'nc_p1' will overwrite the base property in 'c2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
public nc_f1() {
|
||||
}
|
||||
public get nc_prop() {
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,5): error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts(2,19): error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (1 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/MemberFunctionDeclarations/parserMemberFunctionDeclaration5.ts (2 errors) ====
|
||||
class C {
|
||||
declare Foo() { }
|
||||
~~~~~~~
|
||||
!!! error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
~
|
||||
!!! error TS1183: An implementation cannot be declared in ambient contexts.
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts(2,3): error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/MemberVariableDeclarations/parserMemberVariableDeclaration5.ts (1 errors) ====
|
||||
class C {
|
||||
declare Foo;
|
||||
~~~~~~~
|
||||
!!! error TS1031: 'declare' modifier cannot appear on a class element.
|
||||
}
|
|
@ -288,6 +288,8 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1095,29): error
|
|||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1098,56): error TS2304: Cannot find name 'FncFlags'.
|
||||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1098,79): error TS2304: Cannot find name 'FncFlags'.
|
||||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1111,33): error TS2304: Cannot find name 'IFileReference'.
|
||||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1120,16): error TS2610: Property 'vars' will overwrite the base property in 'FuncDecl'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1121,16): error TS2610: Property 'scopes' will overwrite the base property in 'FuncDecl'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1127,84): error TS2304: Cannot find name 'NodeType'.
|
||||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1132,36): error TS2304: Cannot find name 'TypeFlow'.
|
||||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(1144,42): error TS2304: Cannot find name 'NodeType'.
|
||||
|
@ -511,7 +513,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,30): error
|
|||
tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error TS2304: Cannot find name 'TokenID'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts (511 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts (513 errors) ====
|
||||
// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0.
|
||||
// See LICENSE.txt in the project root for complete license information.
|
||||
|
||||
|
@ -2212,7 +2214,11 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource11.ts(2356,48): error
|
|||
public leftCurlyCount = 0;
|
||||
public rightCurlyCount = 0;
|
||||
public vars: ASTList;
|
||||
~~~~
|
||||
!!! error TS2610: Property 'vars' will overwrite the base property in 'FuncDecl'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
public scopes: ASTList;
|
||||
~~~~~~
|
||||
!!! error TS2610: Property 'scopes' will overwrite the base property in 'FuncDecl'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
// Remember if the script contains Unicode chars, that is needed when generating code for this script object to decide the output file correct encoding.
|
||||
public containsUnicodeChar = false;
|
||||
public containsUnicodeCharInComment = false;
|
||||
|
|
|
@ -12,6 +12,10 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(347,13): e
|
|||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(351,17): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'?
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,17): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'?
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(354,35): error TS2662: Cannot find name 'errorHandlerStack'. Did you mean the static member 'Runnable.errorHandlerStack'?
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(359,16): error TS2610: Property 'description' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(360,16): error TS2610: Property 'block' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(402,16): error TS2610: Property 'description' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(403,16): error TS2610: Property 'block' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(691,50): error TS2304: Cannot find name 'ITextWriter'.
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(716,47): error TS2503: Cannot find namespace 'TypeScript'.
|
||||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(721,62): error TS2304: Cannot find name 'ITextWriter'.
|
||||
|
@ -110,7 +114,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(1787,68):
|
|||
tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): error TS2304: Cannot find name 'Diff'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts (110 errors) ====
|
||||
==== tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts (114 errors) ====
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
|
@ -498,7 +502,11 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32):
|
|||
}
|
||||
export class TestCase extends Runnable {
|
||||
public description: string;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2610: Property 'description' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
public block;
|
||||
~~~~~
|
||||
!!! error TS2610: Property 'block' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
constructor(description: string, block: any) {
|
||||
super(description, block);
|
||||
|
@ -541,7 +549,11 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32):
|
|||
|
||||
export class Scenario extends Runnable {
|
||||
public description: string;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2610: Property 'description' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
public block;
|
||||
~~~~~
|
||||
!!! error TS2610: Property 'block' will overwrite the base property in 'Runnable'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
constructor(description: string, block: any) {
|
||||
super(description, block);
|
||||
|
|
|
@ -6,6 +6,7 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce
|
|||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(52,19): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(53,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(55,20): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(63,15): error TS2610: Property 'x' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(73,19): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(74,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(75,20): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
|
||||
|
@ -21,7 +22,7 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce
|
|||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts(114,4): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts (21 errors) ====
|
||||
==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinNestedSubclass1.ts (22 errors) ====
|
||||
class Base {
|
||||
protected x: string;
|
||||
method() {
|
||||
|
@ -101,6 +102,8 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce
|
|||
|
||||
class Derived3 extends Derived1 {
|
||||
protected x: string;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
method3() {
|
||||
class D {
|
||||
method3d() {
|
||||
|
|
|
@ -6,6 +6,7 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce
|
|||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(42,11): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(43,12): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived2'.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(45,12): error TS2445: Property 'x' is protected and only accessible within class 'Derived3' and its subclasses.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(51,15): error TS2610: Property 'x' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(59,11): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(60,12): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
|
||||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(61,12): error TS2446: Property 'x' is protected and only accessible through an instance of class 'Derived3'.
|
||||
|
@ -21,7 +22,7 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce
|
|||
tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts(94,4): error TS2445: Property 'x' is protected and only accessible within class 'Base' and its subclasses.
|
||||
|
||||
|
||||
==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts (21 errors) ====
|
||||
==== tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAccessibleWithinSubclass2.ts (22 errors) ====
|
||||
class Base {
|
||||
protected x: string;
|
||||
method() {
|
||||
|
@ -89,6 +90,8 @@ tests/cases/conformance/classes/members/accessibility/protectedClassPropertyAcce
|
|||
|
||||
class Derived3 extends Derived1 {
|
||||
protected x: string;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'Derived1'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
method3() {
|
||||
var b: Base;
|
||||
var d1: Derived1;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
tests/cases/compiler/protectedMembers.ts(25,5): error TS2610: Property 'x' will overwrite the base property in 'C2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/protectedMembers.ts(40,4): error TS2445: Property 'x' is protected and only accessible within class 'C1' and its subclasses.
|
||||
tests/cases/compiler/protectedMembers.ts(41,4): error TS2445: Property 'f' is protected and only accessible within class 'C1' and its subclasses.
|
||||
tests/cases/compiler/protectedMembers.ts(42,4): error TS2445: Property 'sx' is protected and only accessible within class 'C1' and its subclasses.
|
||||
|
@ -12,11 +13,13 @@ tests/cases/compiler/protectedMembers.ts(97,1): error TS2322: Type 'B1' is not a
|
|||
Property 'x' is protected but type 'B1' is not a class derived from 'A1'.
|
||||
tests/cases/compiler/protectedMembers.ts(98,1): error TS2322: Type 'A1' is not assignable to type 'B1'.
|
||||
Property 'x' is protected in type 'A1' but public in type 'B1'.
|
||||
tests/cases/compiler/protectedMembers.ts(104,5): error TS2610: Property 'x' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorrectly extends base class 'A3'.
|
||||
Property 'x' is protected in type 'B3' but public in type 'A3'.
|
||||
tests/cases/compiler/protectedMembers.ts(112,15): error TS2610: Property 'x' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/protectedMembers.ts (13 errors) ====
|
||||
==== tests/cases/compiler/protectedMembers.ts (16 errors) ====
|
||||
// Class with protected members
|
||||
class C1 {
|
||||
protected x: number;
|
||||
|
@ -42,6 +45,8 @@ tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorr
|
|||
// Derived class making protected members public
|
||||
class C3 extends C2 {
|
||||
x: number;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'C2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
static sx: number;
|
||||
f() {
|
||||
return super.f();
|
||||
|
@ -147,6 +152,8 @@ tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorr
|
|||
}
|
||||
class B2 extends A2 {
|
||||
x;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class A3 {
|
||||
|
@ -158,6 +165,8 @@ tests/cases/compiler/protectedMembers.ts(111,7): error TS2415: Class 'B3' incorr
|
|||
!!! error TS2415: Class 'B3' incorrectly extends base class 'A3'.
|
||||
!!! error TS2415: Property 'x' is protected in type 'B3' but public in type 'A3'.
|
||||
protected x;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
tests/cases/compiler/scopeTests.ts(2,7): error TS2415: Class 'D' incorrectly extends base class 'C'.
|
||||
Property 'v' is private in type 'C' but not in type 'D'.
|
||||
tests/cases/compiler/scopeTests.ts(4,10): error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/scopeTests.ts (1 errors) ====
|
||||
==== tests/cases/compiler/scopeTests.ts (2 errors) ====
|
||||
class C { private v; public p; static s; }
|
||||
class D extends C {
|
||||
~
|
||||
|
@ -10,6 +11,8 @@ tests/cases/compiler/scopeTests.ts(2,7): error TS2415: Class 'D' incorrectly ext
|
|||
!!! error TS2415: Property 'v' is private in type 'C' but not in type 'D'.
|
||||
public v: number;
|
||||
public p: number
|
||||
~
|
||||
!!! error TS2610: Property 'p' will overwrite the base property in 'C'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
constructor() {
|
||||
super()
|
||||
this.v = 1;
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2416: Property 'foo' in type 'D1<T, U>' is not assignable to the same property in base type 'C3<T>'.
|
||||
Type 'U' is not assignable to type 'T'.
|
||||
'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts(8,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (1 errors) ====
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameter.ts (2 errors) ====
|
||||
// checking whether other types are subtypes of type parameters
|
||||
|
||||
class C3<T> {
|
||||
|
@ -16,6 +17,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D1<T, U>' is not assignable to the same property in base type 'C3<T>'.
|
||||
!!! error TS2416: Type 'U' is not assignable to type 'T'.
|
||||
!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
function f1<T, U>(x: T, y: U) {
|
||||
|
|
|
@ -1,21 +1,39 @@
|
|||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(9,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(14,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2416: Property 'foo' in type 'D3<T, U>' is not assignable to the same property in base type 'C3<T>'.
|
||||
Type 'U' is not assignable to type 'T'.
|
||||
'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(19,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(24,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(33,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(38,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(43,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2416: Property 'foo' in type 'D8<T, U, V>' is not assignable to the same property in base type 'C3<T>'.
|
||||
Type 'U' is not assignable to type 'T'.
|
||||
'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
Type 'V' is not assignable to type 'T'.
|
||||
'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(50,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(55,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(60,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2416: Property 'foo' in type 'D11<T, U, V>' is not assignable to the same property in base type 'C3<T>'.
|
||||
Type 'V' is not assignable to type 'T'.
|
||||
'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(67,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2416: Property 'foo' in type 'D12<T, U, V>' is not assignable to the same property in base type 'C3<U>'.
|
||||
Type 'V' is not assignable to type 'U'.
|
||||
'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(72,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(77,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(85,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<Date>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(90,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(95,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(100,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(107,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<Date>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2416: Property 'foo' in type 'D19<T, U, V>' is not assignable to the same property in base type 'C3<T>'.
|
||||
Type 'U' is not assignable to type 'T'.
|
||||
|
@ -24,33 +42,44 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
Type 'Date' is not assignable to type 'T'.
|
||||
'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(112,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(117,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(122,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(129,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<Date>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2416: Property 'foo' in type 'D23<T, U, V>' is not assignable to the same property in base type 'C3<T>'.
|
||||
Type 'V' is not assignable to type 'T'.
|
||||
'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
Type 'Date' is not assignable to type 'T'.
|
||||
'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(134,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2416: Property 'foo' in type 'D24<T, U, V>' is not assignable to the same property in base type 'C3<U>'.
|
||||
Type 'V' is not assignable to type 'U'.
|
||||
'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'.
|
||||
Type 'Date' is not assignable to type 'U'.
|
||||
'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(139,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(144,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(151,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<Date>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2416: Property 'foo' in type 'D27<T, U, V>' is not assignable to the same property in base type 'C3<T>'.
|
||||
Type 'Date' is not assignable to type 'T'.
|
||||
'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(156,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2416: Property 'foo' in type 'D28<T, U, V>' is not assignable to the same property in base type 'C3<U>'.
|
||||
Type 'Date' is not assignable to type 'U'.
|
||||
'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(161,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2411: Property 'foo' of type 'Date' is not assignable to string index type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2416: Property 'foo' in type 'D29<T, U, V>' is not assignable to the same property in base type 'C3<V>'.
|
||||
Type 'Date' is not assignable to type 'V'.
|
||||
'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts(166,5): error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts (20 errors) ====
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints.ts (49 errors) ====
|
||||
// checking whether other types are subtypes of type parameters with constraints
|
||||
|
||||
class C3<T> {
|
||||
|
@ -60,11 +89,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
class D1<T extends U, U> extends C3<T> {
|
||||
[x: string]: T;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D2<T extends U, U> extends C3<U> {
|
||||
[x: string]: U;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D3<T extends U, U> extends C3<T> {
|
||||
|
@ -76,11 +109,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D3<T, U>' is not assignable to the same property in base type 'C3<T>'.
|
||||
!!! error TS2416: Type 'U' is not assignable to type 'T'.
|
||||
!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D4<T extends U, U> extends C3<U> {
|
||||
[x: string]: U;
|
||||
foo: U; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
|
@ -90,16 +127,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
class D5<T extends U, U extends V, V> extends C3<T> {
|
||||
[x: string]: T;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D6<T extends U, U extends V, V> extends C3<U> {
|
||||
[x: string]: U;
|
||||
foo: T;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D7<T extends U, U extends V, V> extends C3<V> {
|
||||
[x: string]: V;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
// test if U is a subtype of T, U, V
|
||||
|
@ -115,16 +158,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'T'.
|
||||
!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D9<T extends U, U extends V, V> extends C3<U> {
|
||||
[x: string]: U;
|
||||
foo: U; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D10<T extends U, U extends V, V> extends C3<V> {
|
||||
[x: string]: V;
|
||||
foo: U; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
// test if V is a subtype of T, U, V
|
||||
|
@ -138,6 +187,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D11<T, U, V>' is not assignable to the same property in base type 'C3<T>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'T'.
|
||||
!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D12<T extends U, U extends V, V> extends C3<U> {
|
||||
|
@ -149,11 +200,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D12<T, U, V>' is not assignable to the same property in base type 'C3<U>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'U'.
|
||||
!!! error TS2416: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint '{}'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D13<T extends U, U extends V, V> extends C3<V> {
|
||||
[x: string]: V;
|
||||
foo: V; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
// Date > V > U > T
|
||||
|
@ -162,21 +217,29 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
class D14<T extends U, U extends V, V extends Date> extends C3<Date> {
|
||||
[x: string]: Date;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<Date>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D15<T extends U, U extends V, V extends Date> extends C3<T> {
|
||||
[x: string]: T;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D16<T extends U, U extends V, V extends Date> extends C3<U> {
|
||||
[x: string]: U;
|
||||
foo: T;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D17<T extends U, U extends V, V extends Date> extends C3<V> {
|
||||
[x: string]: V;
|
||||
foo: T;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
// test if U is a subtype of T, U, V, Date
|
||||
|
@ -184,6 +247,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
class D18<T extends U, U extends V, V extends Date> extends C3<Date> {
|
||||
[x: string]: Date;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<Date>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D19<T extends U, U extends V, V extends Date> extends C3<T> {
|
||||
|
@ -199,16 +264,22 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
!!! error TS2416: Type 'Date' is not assignable to type 'T'.
|
||||
!!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D20<T extends U, U extends V, V extends Date> extends C3<U> {
|
||||
[x: string]: U;
|
||||
foo: U; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D21<T extends U, U extends V, V extends Date> extends C3<V> {
|
||||
[x: string]: V;
|
||||
foo: U;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
// test if V is a subtype of T, U, V, Date
|
||||
|
@ -216,6 +287,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
class D22<T extends U, U extends V, V extends Date> extends C3<Date> {
|
||||
[x: string]: Date;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<Date>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D23<T extends U, U extends V, V extends Date> extends C3<T> {
|
||||
|
@ -229,6 +302,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: 'V' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
!!! error TS2416: Type 'Date' is not assignable to type 'T'.
|
||||
!!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D24<T extends U, U extends V, V extends Date> extends C3<U> {
|
||||
|
@ -242,11 +317,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: 'V' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'.
|
||||
!!! error TS2416: Type 'Date' is not assignable to type 'U'.
|
||||
!!! error TS2416: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D25<T extends U, U extends V, V extends Date> extends C3<V> {
|
||||
[x: string]: V;
|
||||
foo: V; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
// test if Date is a subtype of T, U, V, Date
|
||||
|
@ -254,6 +333,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
class D26<T extends U, U extends V, V extends Date> extends C3<Date> {
|
||||
[x: string]: Date;
|
||||
foo: Date; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<Date>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D27<T extends U, U extends V, V extends Date> extends C3<T> {
|
||||
|
@ -265,6 +346,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D27<T, U, V>' is not assignable to the same property in base type 'C3<T>'.
|
||||
!!! error TS2416: Type 'Date' is not assignable to type 'T'.
|
||||
!!! error TS2416: 'Date' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Date'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D28<T extends U, U extends V, V extends Date> extends C3<U> {
|
||||
|
@ -276,6 +359,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D28<T, U, V>' is not assignable to the same property in base type 'C3<U>'.
|
||||
!!! error TS2416: Type 'Date' is not assignable to type 'U'.
|
||||
!!! error TS2416: 'Date' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Date'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D29<T extends U, U extends V, V extends Date> extends C3<V> {
|
||||
|
@ -287,4 +372,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D29<T, U, V>' is not assignable to the same property in base type 'C3<V>'.
|
||||
!!! error TS2416: Type 'Date' is not assignable to type 'V'.
|
||||
!!! error TS2416: 'Date' is assignable to the constraint of type 'V', but 'V' could be instantiated with a different subtype of constraint 'Date'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'C3<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -1,27 +1,36 @@
|
|||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(37,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<Foo>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(42,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<Foo>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'Foo'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2416: Property 'foo' in type 'D3<T, U, V>' is not assignable to the same property in base type 'B1<Foo>'.
|
||||
Type 'V' is not assignable to type 'Foo'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(47,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<Foo>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(52,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2416: Property 'foo' in type 'D5<T, U, V>' is not assignable to the same property in base type 'B1<T>'.
|
||||
Type 'U' is not assignable to type 'T'.
|
||||
'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'.
|
||||
Type 'Foo' is not assignable to type 'T'.
|
||||
'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(57,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2416: Property 'foo' in type 'D6<T, U, V>' is not assignable to the same property in base type 'B1<T>'.
|
||||
Type 'V' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(62,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2416: Property 'foo' in type 'D7<T, U, V>' is not assignable to the same property in base type 'B1<U>'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'.
|
||||
Type 'Foo' is not assignable to type 'U'.
|
||||
'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(67,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(72,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2416: Property 'foo' in type 'D9<T, U, V>' is not assignable to the same property in base type 'B1<U>'.
|
||||
Type 'V' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts(77,5): error TS2610: Property 'foo' will overwrite the base property in 'B1<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (10 errors) ====
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithConstraints4.ts (19 errors) ====
|
||||
// checking whether other types are subtypes of type parameters with constraints
|
||||
|
||||
class Foo { foo: number; }
|
||||
|
@ -59,11 +68,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
class D1<T extends Foo, U extends Foo, V> extends B1<Foo> {
|
||||
[x: string]: Foo;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<Foo>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D2<T extends Foo, U extends Foo, V> extends B1<Foo> {
|
||||
[x: string]: Foo;
|
||||
foo: U; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<Foo>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D3<T extends Foo, U extends Foo, V> extends B1<Foo> {
|
||||
|
@ -74,11 +87,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
~~~
|
||||
!!! error TS2416: Property 'foo' in type 'D3<T, U, V>' is not assignable to the same property in base type 'B1<Foo>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'Foo'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<Foo>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D4<T extends Foo, U extends Foo, V> extends B1<T> {
|
||||
[x: string]: T;
|
||||
foo: T; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D5<T extends Foo, U extends Foo, V> extends B1<T> {
|
||||
|
@ -92,6 +109,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: 'U' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'.
|
||||
!!! error TS2416: Type 'Foo' is not assignable to type 'T'.
|
||||
!!! error TS2416: 'Foo' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'Foo'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D6<T extends Foo, U extends Foo, V> extends B1<T> {
|
||||
|
@ -102,6 +121,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
~~~
|
||||
!!! error TS2416: Property 'foo' in type 'D6<T, U, V>' is not assignable to the same property in base type 'B1<T>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'T'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D7<T extends Foo, U extends Foo, V> extends B1<U> {
|
||||
|
@ -115,11 +136,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: 'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'.
|
||||
!!! error TS2416: Type 'Foo' is not assignable to type 'U'.
|
||||
!!! error TS2416: 'Foo' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'Foo'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D8<T extends Foo, U extends Foo, V> extends B1<U> {
|
||||
[x: string]: U;
|
||||
foo: U; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D9<T extends Foo, U extends Foo, V> extends B1<U> {
|
||||
|
@ -130,4 +155,6 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
~~~
|
||||
!!! error TS2416: Property 'foo' in type 'D9<T, U, V>' is not assignable to the same property in base type 'B1<U>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'U'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'B1<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
|
@ -1,66 +1,84 @@
|
|||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(63,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2416: Property 'foo' in type 'D2<T, U, V>' is not assignable to the same property in base type 'Base<T>'.
|
||||
Type 'U' is not assignable to type 'T'.
|
||||
Type 'Foo<T>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(68,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2416: Property 'foo' in type 'D3<T, U, V>' is not assignable to the same property in base type 'Base<T>'.
|
||||
Type 'V' is not assignable to type 'T'.
|
||||
Type 'Foo<V>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(73,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2416: Property 'foo' in type 'D4<T, U, V>' is not assignable to the same property in base type 'Base<U>'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
Type 'Foo<U>' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(78,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(83,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2416: Property 'foo' in type 'D6<T, U, V>' is not assignable to the same property in base type 'Base<U>'.
|
||||
Type 'V' is not assignable to type 'U'.
|
||||
Type 'Foo<V>' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(88,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2416: Property 'foo' in type 'D7<T, U, V>' is not assignable to the same property in base type 'Base<V>'.
|
||||
Type 'T' is not assignable to type 'V'.
|
||||
Type 'Foo<U>' is not assignable to type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(93,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2416: Property 'foo' in type 'D8<T, U, V>' is not assignable to the same property in base type 'Base<V>'.
|
||||
Type 'U' is not assignable to type 'V'.
|
||||
Type 'Foo<T>' is not assignable to type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(98,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(103,9): error TS2610: Property 'foo' will overwrite the base property in 'Base<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(115,9): error TS2416: Property 'foo' in type 'D1<T, U, V>' is not assignable to the same property in base type 'Base2<T>'.
|
||||
Type 'T' is not assignable to type 'Foo<T>'.
|
||||
Type 'Foo<U>' is not assignable to type 'Foo<T>'.
|
||||
Type 'U' is not assignable to type 'T'.
|
||||
Type 'Foo<T>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(115,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(120,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(120,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2416: Property 'foo' in type 'D3<T, U, V>' is not assignable to the same property in base type 'Base2<T>'.
|
||||
Type 'V' is not assignable to type 'Foo<T>'.
|
||||
Type 'Foo<V>' is not assignable to type 'Foo<T>'.
|
||||
Type 'V' is not assignable to type 'T'.
|
||||
Type 'Foo<V>' is not assignable to type 'T'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(125,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(130,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(130,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(135,9): error TS2416: Property 'foo' in type 'D5<T, U, V>' is not assignable to the same property in base type 'Base2<U>'.
|
||||
Type 'U' is not assignable to type 'Foo<U>'.
|
||||
Type 'Foo<T>' is not assignable to type 'Foo<U>'.
|
||||
Type 'T' is not assignable to type 'U'.
|
||||
Type 'Foo<U>' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(135,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2411: Property 'foo' of type 'V' is not assignable to string index type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2416: Property 'foo' in type 'D6<T, U, V>' is not assignable to the same property in base type 'Base2<U>'.
|
||||
Type 'V' is not assignable to type 'Foo<U>'.
|
||||
Type 'Foo<V>' is not assignable to type 'Foo<U>'.
|
||||
Type 'V' is not assignable to type 'U'.
|
||||
Type 'Foo<V>' is not assignable to type 'U'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(140,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2416: Property 'foo' in type 'D7<T, U, V>' is not assignable to the same property in base type 'Base2<V>'.
|
||||
Type 'T' is not assignable to type 'Foo<V>'.
|
||||
Type 'Foo<U>' is not assignable to type 'Foo<V>'.
|
||||
Type 'U' is not assignable to type 'V'.
|
||||
Type 'Foo<T>' is not assignable to type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(145,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2416: Property 'foo' in type 'D8<T, U, V>' is not assignable to the same property in base type 'Base2<V>'.
|
||||
Type 'U' is not assignable to type 'Foo<V>'.
|
||||
Type 'Foo<T>' is not assignable to type 'Foo<V>'.
|
||||
Type 'T' is not assignable to type 'V'.
|
||||
Type 'Foo<U>' is not assignable to type 'V'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(150,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts(155,9): error TS2610: Property 'foo' will overwrite the base property in 'Base2<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (24 errors) ====
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfTypeParameterWithRecursiveConstraints.ts (42 errors) ====
|
||||
// checking whether other types are subtypes of type parameters with constraints
|
||||
|
||||
class Foo<T> { foo: T; }
|
||||
|
@ -124,6 +142,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
class D1<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<T> {
|
||||
[x: string]: T;
|
||||
foo: T
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D2<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<T> {
|
||||
|
@ -135,6 +155,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D2<T, U, V>' is not assignable to the same property in base type 'Base<T>'.
|
||||
!!! error TS2416: Type 'U' is not assignable to type 'T'.
|
||||
!!! error TS2416: Type 'Foo<T>' is not assignable to type 'T'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D3<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<T> {
|
||||
|
@ -146,6 +168,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D3<T, U, V>' is not assignable to the same property in base type 'Base<T>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'T'.
|
||||
!!! error TS2416: Type 'Foo<V>' is not assignable to type 'T'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D4<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<U> {
|
||||
|
@ -157,11 +181,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D4<T, U, V>' is not assignable to the same property in base type 'Base<U>'.
|
||||
!!! error TS2416: Type 'T' is not assignable to type 'U'.
|
||||
!!! error TS2416: Type 'Foo<U>' is not assignable to type 'U'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D5<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<U> {
|
||||
[x: string]: U;
|
||||
foo: U
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D6<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<U> {
|
||||
|
@ -173,6 +201,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D6<T, U, V>' is not assignable to the same property in base type 'Base<U>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'U'.
|
||||
!!! error TS2416: Type 'Foo<V>' is not assignable to type 'U'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D7<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<V> {
|
||||
|
@ -184,6 +214,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D7<T, U, V>' is not assignable to the same property in base type 'Base<V>'.
|
||||
!!! error TS2416: Type 'T' is not assignable to type 'V'.
|
||||
!!! error TS2416: Type 'Foo<U>' is not assignable to type 'V'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D8<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<V> {
|
||||
|
@ -195,11 +227,15 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Property 'foo' in type 'D8<T, U, V>' is not assignable to the same property in base type 'Base<V>'.
|
||||
!!! error TS2416: Type 'U' is not assignable to type 'V'.
|
||||
!!! error TS2416: Type 'Foo<T>' is not assignable to type 'V'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D9<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base<V> {
|
||||
[x: string]: V;
|
||||
foo: V
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,6 +254,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Type 'Foo<U>' is not assignable to type 'Foo<T>'.
|
||||
!!! error TS2416: Type 'U' is not assignable to type 'T'.
|
||||
!!! error TS2416: Type 'Foo<T>' is not assignable to type 'T'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D2<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base2<T> {
|
||||
|
@ -225,6 +263,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
foo: U
|
||||
~~~
|
||||
!!! error TS2411: Property 'foo' of type 'U' is not assignable to string index type 'T'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D3<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base2<T> {
|
||||
|
@ -238,6 +278,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Type 'Foo<V>' is not assignable to type 'Foo<T>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'T'.
|
||||
!!! error TS2416: Type 'Foo<V>' is not assignable to type 'T'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<T>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D4<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base2<U> {
|
||||
|
@ -245,6 +287,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
foo: T
|
||||
~~~
|
||||
!!! error TS2411: Property 'foo' of type 'T' is not assignable to string index type 'U'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D5<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base2<U> {
|
||||
|
@ -256,6 +300,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Type 'Foo<T>' is not assignable to type 'Foo<U>'.
|
||||
!!! error TS2416: Type 'T' is not assignable to type 'U'.
|
||||
!!! error TS2416: Type 'Foo<U>' is not assignable to type 'U'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D6<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base2<U> {
|
||||
|
@ -269,6 +315,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Type 'Foo<V>' is not assignable to type 'Foo<U>'.
|
||||
!!! error TS2416: Type 'V' is not assignable to type 'U'.
|
||||
!!! error TS2416: Type 'Foo<V>' is not assignable to type 'U'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<U>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D7<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base2<V> {
|
||||
|
@ -282,6 +330,8 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Type 'Foo<U>' is not assignable to type 'Foo<V>'.
|
||||
!!! error TS2416: Type 'U' is not assignable to type 'V'.
|
||||
!!! error TS2416: Type 'Foo<T>' is not assignable to type 'V'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D8<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base2<V> {
|
||||
|
@ -295,10 +345,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOf
|
|||
!!! error TS2416: Type 'Foo<T>' is not assignable to type 'Foo<V>'.
|
||||
!!! error TS2416: Type 'T' is not assignable to type 'V'.
|
||||
!!! error TS2416: Type 'Foo<U>' is not assignable to type 'V'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D9<T extends Foo<U>, U extends Foo<T>, V extends Foo<V>> extends Base2<V> {
|
||||
[x: string]: V;
|
||||
foo: V
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base2<V>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
}
|
28
tests/baselines/reference/subtypingTransitivity.errors.txt
Normal file
28
tests/baselines/reference/subtypingTransitivity.errors.txt
Normal file
|
@ -0,0 +1,28 @@
|
|||
tests/cases/compiler/subtypingTransitivity.ts(6,12): error TS2610: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/compiler/subtypingTransitivity.ts(9,12): error TS2610: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/compiler/subtypingTransitivity.ts (2 errors) ====
|
||||
class B {
|
||||
x: Object;
|
||||
}
|
||||
|
||||
class D extends B {
|
||||
public x: string;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
class D2 extends B {
|
||||
public x: number;
|
||||
~
|
||||
!!! error TS2610: Property 'x' will overwrite the base property in 'B'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
var b: B;
|
||||
var d: D;
|
||||
var d2: D2;
|
||||
|
||||
d.x = '';
|
||||
b = d;
|
||||
b.x = 1; // assigned number to string
|
||||
|
|
@ -1,18 +1,30 @@
|
|||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(13,5): error TS2610: Property 'foo' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(14,5): error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'.
|
||||
Type 'string' is not assignable to type 'Base'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(14,5): error TS2610: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(23,5): error TS2610: Property '1' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(24,5): error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'.
|
||||
Type 'string' is not assignable to type 'Base'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(24,5): error TS2610: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(33,5): error TS2610: Property ''1'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(34,5): error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'.
|
||||
Type 'string' is not assignable to type 'Base'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(34,5): error TS2610: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(44,9): error TS2610: Property 'foo' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(45,9): error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'.
|
||||
Type 'string' is not assignable to type 'Base'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(45,9): error TS2610: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(54,9): error TS2610: Property '1' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(55,9): error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'.
|
||||
Type 'string' is not assignable to type 'Base'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(55,9): error TS2610: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(64,9): error TS2610: Property ''1'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(65,9): error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'.
|
||||
Type 'string' is not assignable to type 'Base'.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts(65,9): error TS2610: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts (6 errors) ====
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers.ts (18 errors) ====
|
||||
class Base { foo: string; }
|
||||
class Derived extends Base { bar: string; }
|
||||
class Derived2 extends Derived { baz: string; }
|
||||
|
@ -26,10 +38,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
|
|||
|
||||
class B extends A {
|
||||
foo: Derived; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
bar: string; // error
|
||||
~~~
|
||||
!!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'Base'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class A2 {
|
||||
|
@ -39,10 +55,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
|
|||
|
||||
class B2 extends A2 {
|
||||
1: Derived; // ok
|
||||
~
|
||||
!!! error TS2610: Property '1' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
2: string; // error
|
||||
~
|
||||
!!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'Base'.
|
||||
~
|
||||
!!! error TS2610: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class A3 {
|
||||
|
@ -52,10 +72,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
|
|||
|
||||
class B3 extends A3 {
|
||||
'1': Derived; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property ''1'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
'2.0': string; // error
|
||||
~~~~~
|
||||
!!! error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'Base'.
|
||||
~~~~~
|
||||
!!! error TS2610: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
module TwoLevels {
|
||||
|
@ -66,10 +90,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
|
|||
|
||||
class B extends A {
|
||||
foo: Derived2; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
bar: string; // error
|
||||
~~~
|
||||
!!! error TS2416: Property 'bar' in type 'B' is not assignable to the same property in base type 'A'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'Base'.
|
||||
~~~
|
||||
!!! error TS2610: Property 'bar' will overwrite the base property in 'A'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class A2 {
|
||||
|
@ -79,10 +107,14 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
|
|||
|
||||
class B2 extends A2 {
|
||||
1: Derived2; // ok
|
||||
~
|
||||
!!! error TS2610: Property '1' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
2: string; // error
|
||||
~
|
||||
!!! error TS2416: Property '2' in type 'B2' is not assignable to the same property in base type 'A2'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'Base'.
|
||||
~
|
||||
!!! error TS2610: Property '2.0' will overwrite the base property in 'A2'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class A3 {
|
||||
|
@ -92,9 +124,13 @@ tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingW
|
|||
|
||||
class B3 extends A3 {
|
||||
'1': Derived2; // ok
|
||||
~~~
|
||||
!!! error TS2610: Property ''1'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
'2.0': string; // error
|
||||
~~~~~
|
||||
!!! error TS2416: Property ''2.0'' in type 'B3' is not assignable to the same property in base type 'A3'.
|
||||
!!! error TS2416: Type 'string' is not assignable to type 'Base'.
|
||||
~~~~~
|
||||
!!! error TS2610: Property ''2.0'' will overwrite the base property in 'A3'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Property 'props' will overwrite the base property in 'Component<U, {}>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
class B1<T extends { x: string }> extends React.Component<T, {}> {
|
||||
render() {
|
||||
return <div>hi</div>;
|
||||
}
|
||||
}
|
||||
class B<U> extends React.Component<U, {}> {
|
||||
props: U;
|
||||
~~~~~
|
||||
!!! error TS2610: Property 'props' will overwrite the base property in 'Component<U, {}>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
render() {
|
||||
return <B1 {...this.props} x="hi" />;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
tests/cases/conformance/jsx/file.tsx(9,5): error TS2610: Property 'props' will overwrite the base property in 'Component<U, {}>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/file.tsx (1 errors) ====
|
||||
import React = require('react');
|
||||
|
||||
class B1<T extends { x: string } = { x:string } > extends React.Component<T, {}> {
|
||||
render() {
|
||||
return <div>hi</div>;
|
||||
}
|
||||
}
|
||||
class B<U> extends React.Component<U, {}> {
|
||||
props: U;
|
||||
~~~~~
|
||||
!!! error TS2610: Property 'props' will overwrite the base property in 'Component<U, {}>'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
render() {
|
||||
return <B1 {...this.props} x="hi" />;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,190 @@
|
|||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(8,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(12,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(16,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(20,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(25,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(29,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(34,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(38,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(43,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(47,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(52,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(56,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(61,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(68,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(73,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(78,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(86,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(95,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(100,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(105,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(114,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts(119,5): error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
|
||||
|
||||
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/undefinedIsSubtypeOfEverything.ts (22 errors) ====
|
||||
// undefined is a subtype of every other types, no errors expected below
|
||||
|
||||
class Base {
|
||||
foo: typeof undefined;
|
||||
}
|
||||
|
||||
class D0 extends Base {
|
||||
foo: any;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class DA extends Base {
|
||||
foo: typeof undefined;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D1 extends Base {
|
||||
foo: string;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D1A extends Base {
|
||||
foo: String;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D2 extends Base {
|
||||
foo: number;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D2A extends Base {
|
||||
foo: Number;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D3 extends Base {
|
||||
foo: boolean;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D3A extends Base {
|
||||
foo: Boolean;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D4 extends Base {
|
||||
foo: RegExp;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D5 extends Base {
|
||||
foo: Date;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D6 extends Base {
|
||||
foo: number[];
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
class D7 extends Base {
|
||||
foo: { bar: number };
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D8 extends Base {
|
||||
foo: D7;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
interface I1 {
|
||||
bar: string;
|
||||
}
|
||||
class D9 extends Base {
|
||||
foo: I1;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D10 extends Base {
|
||||
foo: () => number;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
enum E { A }
|
||||
class D11 extends Base {
|
||||
foo: E;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
function f() { }
|
||||
module f {
|
||||
export var bar = 1;
|
||||
}
|
||||
class D12 extends Base {
|
||||
foo: typeof f;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class c { baz: string }
|
||||
module c {
|
||||
export var bar = 1;
|
||||
}
|
||||
class D13 extends Base {
|
||||
foo: typeof c;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D14<T> extends Base {
|
||||
foo: T;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D15<T, U> extends Base {
|
||||
foo: U;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
//class D15<T, U extends T> extends Base {
|
||||
// foo: U;
|
||||
//}
|
||||
|
||||
|
||||
class D16 extends Base {
|
||||
foo: Object;
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
||||
|
||||
class D17 extends Base {
|
||||
foo: {};
|
||||
~~~
|
||||
!!! error TS2610: Property 'foo' will overwrite the base property in 'Base'. Add a 'declare' modifier or an initializer to avoid this.
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
// @strict: true
|
||||
class A {
|
||||
property = 'x';
|
||||
m() { return 1 }
|
||||
}
|
||||
class B extends A {
|
||||
property: any; // error
|
||||
}
|
||||
class BD extends A {
|
||||
declare property: any; // ok because it's implicitly initialised
|
||||
}
|
||||
class BDBang extends A {
|
||||
declare property!: any; // ! is not allowed, this is an ambient declaration
|
||||
}
|
||||
class BOther extends A {
|
||||
declare m() { return 2 } // not allowed on methods
|
||||
declare nonce: any; // ok, even though it's not in the base
|
||||
declare property = 'y' // initialiser not allowed with declare
|
||||
}
|
||||
class U {
|
||||
declare nonce: any; // ok, even though there's no base
|
||||
}
|
||||
|
||||
class C {
|
||||
p: string;
|
||||
}
|
||||
class D extends C {
|
||||
p: 'hi'; // error
|
||||
}
|
||||
class DD extends C {
|
||||
declare p: 'bye'; // ok
|
||||
}
|
||||
|
||||
|
||||
declare class E {
|
||||
p1: string
|
||||
p2: string
|
||||
}
|
||||
class F extends E {
|
||||
p1!: 'z'
|
||||
declare p2: 'alpha'
|
||||
}
|
||||
|
||||
class G extends E {
|
||||
p1: 'z'
|
||||
constructor() {
|
||||
super()
|
||||
this.p1 = 'z'
|
||||
}
|
||||
}
|
||||
|
||||
abstract class H extends E {
|
||||
abstract p1: 'a' | 'b' | 'c'
|
||||
declare abstract p2: 'a' | 'b' | 'c'
|
||||
}
|
||||
|
||||
interface I {
|
||||
q: number
|
||||
}
|
||||
interface J extends I { }
|
||||
class J {
|
||||
r = 5
|
||||
}
|
||||
class K extends J {
|
||||
q!: 1 | 2 | 3 // ok, extends a property from an interface
|
||||
r!: 4 | 5 // error, from class
|
||||
}
|
18
tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts
Normal file
18
tests/cases/fourslash/codeFixAddMissingDeclareProperty.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class B {
|
||||
//// p = 1
|
||||
////}
|
||||
////class C extends B {
|
||||
//// p: number
|
||||
////}
|
||||
|
||||
verify.codeFix({
|
||||
description: "Prefix with 'declare'",
|
||||
newFileContent: `class B {
|
||||
p = 1
|
||||
}
|
||||
class C extends B {
|
||||
declare p: number
|
||||
}`
|
||||
});
|
25
tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts
Normal file
25
tests/cases/fourslash/codeFixAddMissingDeclareProperty2.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class B {
|
||||
//// p = 1
|
||||
////}
|
||||
////class C extends B {
|
||||
//// p: number
|
||||
////}
|
||||
////class D extends B {
|
||||
//// p: 1 | 2 | 3
|
||||
////}
|
||||
|
||||
verify.codeFixAll({
|
||||
fixId: "addMissingDeclareProperty",
|
||||
fixAllDescription: "Prefix all incorrect property declarations with 'declare'",
|
||||
newFileContent: `class B {
|
||||
p = 1
|
||||
}
|
||||
class C extends B {
|
||||
declare p: number
|
||||
}
|
||||
class D extends B {
|
||||
declare p: 1 | 2 | 3
|
||||
}`
|
||||
});
|
|
@ -13,7 +13,7 @@
|
|||
////}
|
||||
|
||||
////class DbSet<TEntity extends Entity> extends BaseCollection<TEntity> { // error
|
||||
//// _itemsByKey: { [key: string]: TEntity; };
|
||||
//// _itemsByKey: { [key: string]: TEntity; } = {};
|
||||
////}
|
||||
|
||||
////var a: BaseCollection<CollectionItem>;
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
// Squiggle for implementing a derived class with an incompatible override is too large
|
||||
|
||||
//// class Foo { xyz: string; }
|
||||
//// class Bar extends Foo { /*1*/xyz/*2*/: number; }
|
||||
//// class Baz extends Foo { public /*3*/xyz/*4*/: number; }
|
||||
//// class Bar extends Foo { /*1*/xyz/*2*/: number = 1; }
|
||||
//// class Baz extends Foo { public /*3*/xyz/*4*/: number = 2; }
|
||||
//// class /*5*/Baf/*6*/ extends Foo {
|
||||
//// constructor(public xyz: number) {
|
||||
//// super();
|
||||
|
@ -14,4 +14,4 @@
|
|||
verify.errorExistsBetweenMarkers('1', '2');
|
||||
verify.errorExistsBetweenMarkers('3', '4');
|
||||
verify.errorExistsBetweenMarkers('5', '6');
|
||||
verify.numberOfErrorsInCurrentFile(3);
|
||||
verify.numberOfErrorsInCurrentFile(3);
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
////}
|
||||
////
|
||||
////class Bar extends Foo {
|
||||
//// public /*1*/x/*2*/: string;
|
||||
//// public /*1*/x/*2*/: string = 'hi';
|
||||
////}
|
||||
|
||||
verify.errorExistsBetweenMarkers("1", "2");
|
||||
verify.numberOfErrorsInCurrentFile(1);
|
||||
verify.numberOfErrorsInCurrentFile(1);
|
||||
|
|
Loading…
Reference in a new issue