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
exportclassCompareFileModel{publicgetid(): string{returnthis.fileId.toString().concat('-',this.revision||'');}publicfileId: number=0;publicrevision: string='';publicconstructor(init?: Partial<CompareFileModel>){Object.assign(this,init);}publicclone(): CompareFileModel{returnnewCompareFileModel({fileId: this.fileId,// id is getter property. It should not allow setting getter propertyid: 's'});}}
Yeah, duplicate of #9726, even though it doesn't look like it at first. The lack of a setter is irrelevant at the point you expect an error since you're just initializing an object literal, which wouldn't call it anyway. Even if there was a setter for id you'd probably still want to exclude that property from init if the setter did anything more complex than this._id = val.
Even if #9726 were implemented, mapped types like Partial would still include non-enumerable properties. Really you'd want an entirely new kind of distinction here, since I don't think the non-enumerability of id is the real crux -- if getters were enumerable tomorrow, the code would still be wrong. You'd want something like Settable<T> that was a mapped type that only produced settable properties, but we don't have write semantics anywhere in relatability.
Bug Report
π Version & Regression Information
4.6.4
β― Playground Link
Playground link with relevant code](https://www.typescriptlang.org/dev/bug-workbench/?ts=4.6.4#code/KYDwDg9gTgLgBAYwDYEMDOa4GEIFswpTABiAlksALIQAmwScA3gFDNxxgCuARkqQnADmweKRoAKAJQAuOGhhRSAO0FM27OERicoSuDAAWpNADoAZuWABJGiZgQAyguWCpJhBCUIUMcQHIAWj8AGn0jUyIAN2NSTzgAH3i4Pz9JAG51AF9Wdi5efjgLChtZJU5cbmAoOABeOAAGDNyePgEomM9ZeUUVWuS-DPU81sRPbs4EeyhxZVIYAH5ZAAVCGFIUJAAeHHxCEktqOiQAPkk1DTgAeW4AK2BJk3Q0UkElcUNjUNmYdKycjhaBWQnmAUlkOwIRDIFEO9HOGi0Oj0SmAAHdsHhIfsYbR6OIWBd2EVrDRZB9TMSbMF1BcxLI-Gg-DS4JlfuxstkgA))
π» Code
Workbench Repro
π Actual behavior
Typescript reported there is no error.
π Expected behavior
Code should not compile, as we're setting getter property
The text was updated successfully, but these errors were encountered: