Microsoft/TypeScript
Vedi su GitHubObject.defineProperty(variable) does not error in `.js` files if `variable` does not exist
Open
#61.165 aperta il 12 feb 2025
BugDomain: JavaScriptHelp Wanted
Metriche repository
- Star
- (48.455 star)
- Metriche merge PR
- (Merge medio 6g 17h) (9 PR mergiate in 30 g)
Descrizione
🔎 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