Skip to content

fix: read an inherited property's readonly-ness from the base type that supplies it - #1057

Open
YevheniiKotyrlo wants to merge 1 commit into
typescript-eslint:mainfrom
YevheniiKotyrlo:fix/readonly-inherited-mapped-property
Open

YevheniiKotyrlo wants to merge 1 commit into
typescript-eslint:mainfrom
YevheniiKotyrlo:fix/readonly-inherited-mapped-property

Conversation

@YevheniiKotyrlo

Copy link
Copy Markdown

PR Checklist

Overview

An interface inherits a mapped type's property symbol as-is, so isPropertyReadonlyInType asked the interface — which isn't the mapped type — and fell back to the declaration the mapped type mapped.
For a class or interface, isReadonlyPropertyFromBaseType now finds the base type that supplies the same symbol (typeChecker.getBaseTypes) and asks about that base type instead, after the mapped-type check.

The new tests cover Readonly<Box>, Readonly<Pick<Box, "value">>, a chain of two interfaces, the readonly base among several base types, a -readonly mapping of a readonly declaration, and Partial<Box>; the first five fail without the change.
All CI steps pass locally on Node 26, with the suite also run on TypeScript 5.5.4 and 5.9.3.

#1056 isn't triaged yet, so the second and third boxes stay unchecked; I'm sending the fix now so it can be read alongside the report.

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Bug: isPropertyReadonlyInType misreads a property an interface inherits from a mapped type

2 participants