TypeScript/tests/baselines/reference/variance.js
Wenlu Wang dc237b317e
Change static fields emits (#43114)
* use emit into iife

* Update emit

* Revert un-related changes

* Allow super in static context

* Allow this and super in static property declaration

* Add more tests

* Avoid errors

* Accept baseline

* Accept baseline

* Add decorated classes test

* Add errors

* Avoid this in emitter

* make lint happy

* Add class expression tests

* Add computed name test

* Avoid super if target below es6

* Adjust function boundary

* Add internal

* Fix minor CR issues

* accept baseline

* Update behavior

* Avoid spaces

* Make lint happy

* Avoid function boundary utils

* Update baseline

* Avoid errors

* Accept baseline

* Accept baseline

* Accept baseline

* Accept baseline

* Use substitutions

* Full coverage for super, this, merge static and private context

* Fix use-before-def in static fields

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2021-06-25 15:49:27 -07:00

47 lines
954 B
TypeScript

//// [variance.ts]
// Test cases for parameter variances affected by conditional types.
// Repro from #30047
interface Foo<T> {
prop: T extends unknown ? true : false;
}
const foo = { prop: true } as const;
const x: Foo<1> = foo;
const y: Foo<number> = foo;
const z: Foo<number> = x;
// Repro from #30118
class Bar<T extends string> {
private static instance: Bar<string>[] = [];
cast(_name: ([T] extends [string] ? string : string)) { }
pushThis() {
Bar.instance.push(this);
}
}
//// [variance.js]
"use strict";
// Test cases for parameter variances affected by conditional types.
var foo = { prop: true };
var x = foo;
var y = foo;
var z = x;
// Repro from #30118
var Bar = /** @class */ (function () {
function Bar() {
}
Bar.prototype.cast = function (_name) { };
Bar.prototype.pushThis = function () {
Bar.instance.push(this);
};
Bar.instance = [];
return Bar;
}());