Giter Club home page Giter Club logo

Comments (3)

ahejlsberg avatar ahejlsberg commented on April 30, 2024

This is working as intended. We consider an element access to be read-only when all applicable index signatures have a readonly modifier. In the example, the string "head-haha-tail" matches three index signatures, two of which are not read-only. Therefore, the assignment is permitted. A similar thing happens when resolving the properties of the Pick<Example, keyof Example> mapped type. For each generated index signature we query the combined read-only-ness of applicable index signatures in the source type, and `head-${string}-tail` matches three, two of which aren't read-only.

from typescript.

13OnTheCode avatar 13OnTheCode commented on April 30, 2024

@ahejlsberg I appreciate your response.

Sorry I didn't make it clear before, I understand that the behavior is working as expected, but my confusion is:

The string index head-${string}-tail matches three index signatures, two of which are not read-only. So, when we try to add readonly to head-${string}-tail only, there should be an error prompt, but the actual situation seems to be correct.

微信截图_20240414192355

from typescript.

typescript-bot avatar typescript-bot commented on April 30, 2024

This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

from typescript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.