mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
34 lines
686 B
TypeScript
34 lines
686 B
TypeScript
//// [tests/cases/compiler/classVarianceCircularity.ts] ////
|
|
|
|
//// [classVarianceCircularity.ts]
|
|
// Issue #52813
|
|
|
|
function f() {
|
|
const b = new Bar();
|
|
// Uncomment to create error
|
|
console.log(b.Value);
|
|
}
|
|
|
|
class Bar<T> {
|
|
num!: number;
|
|
// Or swap these two lines
|
|
Field: number = (this as Bar<any>).num;
|
|
Value = (this as Bar<any>).num;
|
|
}
|
|
|
|
//// [classVarianceCircularity.js]
|
|
"use strict";
|
|
// Issue #52813
|
|
function f() {
|
|
const b = new Bar();
|
|
// Uncomment to create error
|
|
console.log(b.Value);
|
|
}
|
|
class Bar {
|
|
constructor() {
|
|
// Or swap these two lines
|
|
this.Field = this.num;
|
|
this.Value = this.num;
|
|
}
|
|
}
|