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

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 #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.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 19 (10 by maintainers)

Most upvoted comments

--noUncheckedIndexedAccess

--safeIndexAccess

--pedanticIndexSignatures

–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).

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

--includeUndefinedInIndexAccess

--noImplicitBounds

--undefinedIndexSignatures

--includeUndefinedInIndexSignatures

--skepticalIndexAccesses

--checkIndexedAccess

--soundIndexedAccess

--rigorousIndexAccess

We have a winner 🥇

--uncertainIndexAccess

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

--partialIndexedAccess