Skip to content

Poll: Name a compiler option for including undefined when a property resolves to an index signature #40435

Closed

Description

We need a name for the option described in #13778

The exact behavior that this flag would enable is, briefly:

  • Read expressions of the form expr[i] will now be T | undefined where T is the index signature type
  • Read expressions of the form expr.prop will now be T | undefined where T is the index signature type if an index signature on expr exists but not a declared property named prop
  • string and number index signatures are both subjected to this treatment
  • Write expressions expr[i] = v and expr.prop = v are unaffected
  • Type expressions TypeName[number] and TypeName["prop"] are unaffected

Good candidate flag names should follow these rules and goals:

  • Do not start with strict since this flag would not get turned on by the global --strict setting
  • Follow an existing convention (see the list at (https://aka.ms/tsconfig.json)
  • Convey the intent of the flag along with its behavior, somehow
  • Avoid problematic terms (e.g. do not reference mental illnesses)

This is an open-ended approval voting issue. Rules:

  • Use 👍 reaction on as many as you like
    • Top-upvoted options will be given the most consideration
    • This is an advisory vote; final say is still up to the TypeScript team
  • You may propose new options; comments must be of exactly the form `--proposedOptionName`
    • Follow the above guidance - no --strictFoo!
  • No discussion here; discuss in Suggestion: option to include undefined in index signatures #13778. Non-option comments will be deleted
  • Sharing this link on social media is encouraged!

I will seed this with some of the names suggested at our last meeting. We may also cull options that aren't receiving a lot of votes to help keep the comment count manageable.

Activity

  1. added
    Meta-Issue
    on Sep 8, 2020
  2. RyanCavanaugh commented on Sep 8, 2020

    @RyanCavanaugh
    MemberAuthor

    --pedanticIndexSignatures

  3. RyanCavanaugh commented on Sep 8, 2020

    @RyanCavanaugh
    MemberAuthor

    --noUncheckedIndexedAccess

  4. RyanCavanaugh commented on Sep 8, 2020

    @RyanCavanaugh
    MemberAuthor

    --undefinedIndexSignatures

  5. RyanCavanaugh commented on Sep 8, 2020

    @RyanCavanaugh
    MemberAuthor

    --skepticalIndexAccesses

  6. RyanCavanaugh commented on Sep 8, 2020

    @RyanCavanaugh
    MemberAuthor

    --noImplicitBounds

  7. orta commented on Sep 8, 2020

    @orta
    Contributor

    --rigorousIndexAccess

  8. danvk commented on Sep 8, 2020

    @danvk
    Contributor

    --carefulIndexAccess

  9. jack-williams commented on Sep 8, 2020

    @jack-williams
    Collaborator

    --partialIndexedAccess

  10. awinograd commented on Sep 8, 2020

    @awinograd

    --maybeIndexAccess

  11. OliverJAsh commented on Sep 8, 2020

    @OliverJAsh
    Contributor

    --indexNullChecks (like --strictNullChecks but for index access)

  12. kirillgroshkov commented on Sep 8, 2020

    @kirillgroshkov

    --safeIndexAccess

  13. danvk commented on Sep 8, 2020

    @danvk
    Contributor

    --soundIndexedAccess

  14. patrickkunka commented on Sep 8, 2020

    @patrickkunka

    --uncertainIndexAccess

    Personally I feel the name should highlight the aspect of uncertainty introduced here, rather than the aspect of strictness.

  15. thw0rted commented on Sep 9, 2020

    @thw0rted

    --includeUndefinedInIndexSignatures

  16. thw0rted commented on Sep 9, 2020

    @thw0rted

    --includeUndefinedInIndexAccess

  17. alex-okrushko commented on Sep 10, 2020

    @alex-okrushko

    --noUncheckedIndexedAccess

    I think this one nails it, however I'd adjust it to --noUncheckedIndexAccess (uncheck-ed and index-ed it a feels a bit too much of -ed).

  18. zeusdeux commented on Sep 10, 2020

    @zeusdeux

    --checkIndexedAccess

  19. RyanCavanaugh commented on Sep 12, 2020

    @RyanCavanaugh
    MemberAuthor

    We have a winner 🥇

  20. johnnyreilly commented on Sep 12, 2020

    @johnnyreilly

    Are you rolling with --noUncheckedIndexedAccess or Alex Okrushko (@alex-okrushko)'s suggested tweak of --noUncheckedIndexAccess?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Meta-Issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions