Repository: TypeScript
Issue: Do not allow surrounding spaces to be counted as part of ${number} templates in template index strings 
Labels: Needs Investigation,Rescheduled

# Suggestion

<!--
  Please fill in each section completely. Thank you!
-->

## 🔍 Search Terms

<!--
  💡 Did you know? TypeScript has over 2,000 open suggestions!
  🔎 Please search thoroughly before logging new feature requests as most common ideas already have a proposal in progress.
  The "Common Feature Requests" section of the FAQ lists many popular requests: https://github.com/Microsoft/TypeScript/wiki/FAQ#common-feature-requests

  Replace the text below:
-->

Template String Pattern Index Signatures
Template Index Strings


## ✅ Viability Checklist

<!--
   Suggestions that don't meet all these criteria are very, very unlikely to be accepted.
   We always recommend reviewing the TypeScript design goals before investing time writing
   a proposal for ideas outside the scope of the project.
-->
My suggestion meets these guidelines:

* [ ] This wouldn't be a breaking change in existing TypeScript/JavaScript code
* [x] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).

Actually it would change the typescript behavior as it was released - maybe better now than later?
The current behavior might be more bug than feature.

## ⭐ Suggestion

Not allowing spaces would reduce typing mistakes.

<!-- A summary of what you'd like to see added or changed -->

## 📃 Motivating Example

Modification of the [example feature explanation in  the handbook](https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#symbol-template-signatures):

```typescript
interface Options {
    width?: number;
    height?: number;
}

let a: Options = {
    width: 100,
    height: 100,
    "data-1": true, // Error! 'data-blah' wasn't declared in 'Options'.
};

interface OptionsWithDataProps extends Options {
    // Permit any property matching 'data-${number}'.
    [optName: `data-${number}`]: unknown;
}

let b: OptionsWithDataProps = {
    width: 100,
    height: 100,
    "data-1": true,       // Works!
    "data- 1": true,       // Passes but might be better off failing
    "data-1 ": true,       // Passes but might be better off failing
    "data- 1 ": true,       // Passes but might be better off failing
    "data- ": true,       // Passes but might be better off failing  (no number at all)

    "unknown-property": true,  // Error! 'unknown-property' wasn't declared in 'OptionsWithDataProps'.
};
```
[playground](https://www.typescriptlang.org/play?#code/FDCWDsBcFMCcDMCGBjaACA8gB0qA9uAM5oDewaFaA7qACaQAWA-AFxrgCuAtgEZwDc5Sg2igA5g0it23PrEEBfEABtokNIjbZcBYgF5SQijXoM2ARgAMlgDRG0I8ZIvW7lNACJaiSIgC05h5skLAc0DZoAPSRaACisLB4sACEaADk3r5+PMqIDGnUiITgaeq00Mi5sNC0aBDp2vhEaQB0wAqCYFBwSKiYOE2EAOqgjAAiPogAColYxNAAHjDgtMSNuobu0WhTcFyjGuAAnmhYs3CQJ1w+yAwQYumZ-gAkJJy8cAqt9gDaeDgAOUQXGgbAABk8-K93nIFGCALpsDjgADW4DwVHAihUajQPC0A10I3Gkxm-30m0oJkYLls9kcEkgtLclC8kwCQTQITCEXcFG2QySKMIyXsbKyaECwVC4T5-JiUyKhGgxB4HHU+0ZePQfEgMFgaDw8HgaCQoGU9zFkPMnmlPLlUQVSpVePVaE1km12r1cENxtNiHNlvc4v8kttXJlvL520VhGVqrdHvUfG9+r9JrNFvAYit7Ij3NlctjzsTGqcKZ1anTRszgezubFyLRGPAfjO-wuR05hd523iiRS6Wb6Mx7fOsEuBSoRRKZQqVRqdXADUJRGJDAmvjJc2+HRAQA)

## 💻 Use Cases

Using it to catch unintended key entries.