You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"use strict"interfacefoo{// members are defined read-writebar: numberbaz: number}functionzero(f: foo){f.bar=0f.baz=0}classbugimplementsfoo{// members implemented read-onlygetbar(){return0}readonlybaz=0}constnewBug=newbug()zero(newBug)
Expected behavior:
It should not compile.
Actual behavior:
It compiles, resulting in runtime error "Cannot set property bar of # which has only a getter"
class bug does not actually implemented interface foo. class bug provides a readonly bar: number, which does not satisfy the required bar: number in interface foo.
TypeScript Version: 3.9.2, 3.9.7 and 4.0.0-beta
Search Terms:
interface, readonly
Code
Expected behavior:
It should not compile.
Actual behavior:
It compiles, resulting in runtime error "Cannot set property bar of # which has only a getter"
Playground Link:
https://www.typescriptlang.org/play?ts=4.0.0-beta#code/EQVwzgpgBGAuBOBLAxrYAoRA7WF4DMBDZafAezKgG90o6oB6BqAWwhYCM8wpD5oAJhHzYIAqP0ICAtAHckuWvQ58AXFCwhOeJXRUAvdZu3x0AX3Tp8ILKkRksUfXjIAKfOvJkAlNV1R8ADoVeCgAXigABn8gg3Co80tkABtCMB4OEABzKEQWAAdk9ggcHi8-ekZmNhMePMLinDEJCClpB2SAT38siFgoENdfKn5YEHhHSItKyQEOzoHCfXjoi2QHOA0IWQAhbPisbYHsofRneDdD3ezvIA
Related Issues:
#39871, but simpler
The text was updated successfully, but these errors were encountered: