-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report the errors for static incompatibility only if instance types a…
…re assignable Fixes #26138
- Loading branch information
1 parent
07dbd8b
commit f30e73f
Showing
6 changed files
with
119 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/baselines/reference/staticMismatchBecauseOfPrototype.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
tests/cases/compiler/staticMismatchBecauseOfPrototype.ts(10,5): error TS2416: Property 'n' in type 'B' is not assignable to the same property in base type 'A'. | ||
Type 'string' is not assignable to type 'number'. | ||
|
||
|
||
==== tests/cases/compiler/staticMismatchBecauseOfPrototype.ts (1 errors) ==== | ||
interface A { | ||
n: number; | ||
} | ||
declare var A: { | ||
prototype: A; | ||
new(): A; | ||
}; | ||
|
||
class B extends A { | ||
n = ""; | ||
~ | ||
!!! error TS2416: Property 'n' in type 'B' is not assignable to the same property in base type 'A'. | ||
!!! error TS2416: Type 'string' is not assignable to type 'number'. | ||
} |
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/staticMismatchBecauseOfPrototype.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//// [staticMismatchBecauseOfPrototype.ts] | ||
interface A { | ||
n: number; | ||
} | ||
declare var A: { | ||
prototype: A; | ||
new(): A; | ||
}; | ||
|
||
class B extends A { | ||
n = ""; | ||
} | ||
|
||
//// [staticMismatchBecauseOfPrototype.js] | ||
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 B = /** @class */ (function (_super) { | ||
__extends(B, _super); | ||
function B() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.n = ""; | ||
return _this; | ||
} | ||
return B; | ||
}(A)); |
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/staticMismatchBecauseOfPrototype.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
=== tests/cases/compiler/staticMismatchBecauseOfPrototype.ts === | ||
interface A { | ||
>A : Symbol(A, Decl(staticMismatchBecauseOfPrototype.ts, 0, 0), Decl(staticMismatchBecauseOfPrototype.ts, 3, 11)) | ||
|
||
n: number; | ||
>n : Symbol(A.n, Decl(staticMismatchBecauseOfPrototype.ts, 0, 13)) | ||
} | ||
declare var A: { | ||
>A : Symbol(A, Decl(staticMismatchBecauseOfPrototype.ts, 0, 0), Decl(staticMismatchBecauseOfPrototype.ts, 3, 11)) | ||
|
||
prototype: A; | ||
>prototype : Symbol(prototype, Decl(staticMismatchBecauseOfPrototype.ts, 3, 16)) | ||
>A : Symbol(A, Decl(staticMismatchBecauseOfPrototype.ts, 0, 0), Decl(staticMismatchBecauseOfPrototype.ts, 3, 11)) | ||
|
||
new(): A; | ||
>A : Symbol(A, Decl(staticMismatchBecauseOfPrototype.ts, 0, 0), Decl(staticMismatchBecauseOfPrototype.ts, 3, 11)) | ||
|
||
}; | ||
|
||
class B extends A { | ||
>B : Symbol(B, Decl(staticMismatchBecauseOfPrototype.ts, 6, 2)) | ||
>A : Symbol(A, Decl(staticMismatchBecauseOfPrototype.ts, 0, 0), Decl(staticMismatchBecauseOfPrototype.ts, 3, 11)) | ||
|
||
n = ""; | ||
>n : Symbol(B.n, Decl(staticMismatchBecauseOfPrototype.ts, 8, 19)) | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/baselines/reference/staticMismatchBecauseOfPrototype.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
=== tests/cases/compiler/staticMismatchBecauseOfPrototype.ts === | ||
interface A { | ||
n: number; | ||
>n : number | ||
} | ||
declare var A: { | ||
>A : { new (): A; prototype: A; } | ||
|
||
prototype: A; | ||
>prototype : A | ||
|
||
new(): A; | ||
}; | ||
|
||
class B extends A { | ||
>B : B | ||
>A : A | ||
|
||
n = ""; | ||
>n : string | ||
>"" : "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
interface A { | ||
n: number; | ||
} | ||
declare var A: { | ||
prototype: A; | ||
new(): A; | ||
}; | ||
|
||
class B extends A { | ||
n = ""; | ||
} |