Microsoft/TypeScript

[ID] `--isolatedDeclarations` disallows `const` initialized with a regex literal

Open

#58,383 opened on May 1, 2024

View on GitHub
 (5 comments) (0 reactions) (0 assignees)TypeScript (6,726 forks)batch import
BugDomain: flag: isolatedDeclarationsHelp Wanted

Repository metrics

Stars
 (48,455 stars)
PR merge metrics
 (Avg merge 6d 17h) (9 merged PRs in 30d)

Description

🔍 Search Terms

  • isolatedDeclarations
  • isolated declaration

✅ Viability Checklist

⭐ Suggestion

I an unsure if it is a bug or a feature request...

An exported const without type annotation and initialized with a regex literal triggers the following error error TS9010: Variable must have an explicit type annotation with --isolatedDeclarations. in isolated declaration mode.

If I understand correctly, isolated declaration should allow unannotated const initialized with any literal?

📃 Motivating Example

See an example on the playground.

💻 Use Cases

This could avoid a trivial type annotation.

Contributor guide