typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
110 stars 51 forks source link

Misleading error message when accessing a property in violation of noPropertyAccessFromIndexSignature #512

Closed bwbuchanan closed 1 year ago

bwbuchanan commented 1 year ago

When the noPropertyAccessFromIndexSignature TypeScript compiler option is enabled and a template attempts a property access that fails this check, the error message is misleading.

Example:


const record: Record<string, string> = {};

<template>
  {{record.foo}}
</template>

Error message:

error TS4111: Property 'foo' comes from an index signature, so it must be accessed with ['foo'].

It is not possible to write {{record['foo']}} in a handlebars template because this is not valid syntax, so the error message should be rewritten to suggest the {{get}} helper instead.