TypeScript/tests/baselines/reference/divergentAccessorsTypes2.errors.txt
Ryan Cavanaugh ff233a9ac2
Variant accessors (#42425)
Allows accessors to have different access modifiers and types

Fixes #2845, #2521
2021-03-26 20:11:02 -07:00

17 lines
524 B
Plaintext

tests/cases/compiler/divergentAccessorsTypes2.ts(10,1): error TS2322: Type '42' is not assignable to type 'string | undefined'.
==== tests/cases/compiler/divergentAccessorsTypes2.ts (1 errors) ====
class Test1<T> {
get foo(): T { return null as any }
set foo(s: T | undefined ) {
}
}
const s = new Test1<string>();
s.foo = undefined;
s.foo = "hello";
s.foo = 42;
~~~~~
!!! error TS2322: Type '42' is not assignable to type 'string | undefined'.