Microsoft/TypeScript
Auf GitHub ansehen[isolatedDeclarations] Type of const variable declared with template literal expression containing only literals still requires explicit annotation
Open
#59.157 geöffnet am 6. Juli 2024
Domain: flag: isolatedDeclarationsHelp WantedPossible Improvement
Repository-Metriken
- Stars
- (48.455 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)
Beschreibung
🔎 Search Terms
isolated declarations template literal expression
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
export let foo = `${''}`;
export const bar = `${''}`;
export function baz() {
return `${''}`;
}
🙁 Actual behavior
bar has a type error:
Variable must have an explicit type annotation with --isolatedDeclarations.(9010)
input.tsx(3, 14): Add a type annotation to the variable bar.
foo would also have a type error if as const was added to the expression.
🙂 Expected behavior
No type error
Additional information about the issue
fun fact: I accidentally discovered this behavior when I found that oxc-transform has type errors for both const, let, and return types.