Description
What rule do you want to change?
no-dynamic-keys
Does this change cause the rule to produce more or fewer warnings?
Fewer.
How will the change be implemented? (New option, new default behavior, etc.)?
When concatenating a string with a const, typescript knows the possible strings which this expression can result in. For this reason, this rule could be extended to allow dynamic keys, when they result in a fixed list of strings. Those strings would then have to be taken into consideration for other rules as well (e.g. no-missing-keys-in-other-locales
).
Please provide some example code that this change will affect:
<script lang="ts" setup>
const searchFilter = ref<
| "All"
| "Speeches"
| "Music"
| "Albums"
| "Contributors"
| "Podcasts"
| "Playlists"
>("All");
</script>
<template>
<div>{{ t(searchFilter) }}</div>
</template>
What does the rule currently do for this code?
It reports the code.
What will the rule do after it's changed?
It won't report the code.
Additional context
Might be problematic that even typescript itself doesn't resolve string-manipulation...
const searchFilter = ref<
| "All"
| "Speeches"
| "Music"
>("All");
// The type of this variable is `string`, even though it could be determined as `test-All`, `test-Speeches` or `test-Music`...
const searchFilter2 = `test-${searchFilter}`