Microsoft/TypeScript
GitHub ã§èŠãObject.defineProperty(variable) does not error in `.js` files if `variable` does not exist
Open
#61,165 opened on 2025幎2æ12æ¥
BugDomain: JavaScriptHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð Search Terms
defineProperty, cannot find namee
ð Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about
defineProperty
⯠Playground Link
ð» Code
// javascript.js
// @ts-check
// Does not error unless in `.ts` file.
Object.defineProperty(foo, "name", { value: "default", writable: false });
ð Actual behavior
No error in .js files
ð Expected behavior
Errors in .js files with TS2304: Cannot find name 'foo'.
Additional information about the issue
Full repro: https://github.com/eps1lon/tsc-object-define-property