Microsoft/TypeScript

Definite assignment assertion in JS not flagged

Open

#48,446 opened on Mar 27, 2022

View on GitHub
 (2 comments) (0 reactions) (0 assignees)TypeScript (6,726 forks)batch import
BugDomain: JavaScriptHelp Wanted

Repository metrics

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

Description

Bug Report

Noted by someone on Discord.

🔎 Search Terms

non null assertion javascript error

Related https://github.com/microsoft/TypeScript/issues/17222

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

💻 Code

const a = { a!: 1 };

🙁 Actual behavior

There's no error; crashes at runtime

🙂 Expected behavior

There should be an error

Contributor guide