This website requires JavaScript.
Explore
Help
Sign in
foster
/
denoland-deno
Watch
1
Star
0
Fork
You've already forked denoland-deno
0
mirror of
https://github.com/denoland/deno.git
synced
2024-11-29 16:30:56 -05:00
Code
Issues
Packages
1
Wiki
Activity
300eeb343e
denoland-deno
/
cli
/
tests
/
testdata
/
run
/
webstorage
/
logger.ts
2 lines
38 B
TypeScript
Raw
Normal View
History
Unescape
Escape
feat: deprecate `window` global (#22057) This commit deprecates `window` global and adds deprecation notice on each use of `window`. We decided to proceed with removal of `window` global variable in Deno 2.0. There's a lot of code in the wild that uses pattern like this: ``` if (typeof window !== "undefined) { ... } ``` to check if the code is being run in browser. However, this check passes fine in Deno and most often libraries that do this check try to access some browser API that is not available in Deno, or use DOM APIs (which are also not available in Deno). This situation has occurred multiple times already and it's unfeasible to expect the whole ecosystem to migrate to new check (and even if that happened there's a ton of code that's already shipped and won't change). The migration is straightfoward - replace all usages of `window` with `globalThis` or `self`. When Deno encounters use of `window` global it will now issue a warning, steering users towards required changes: ``` Warning ├ Use of deprecated "window" API. │ ├ This API will be removed in Deno 2.0. Make sure to upgrade to a stable API before then. │ ├ Suggestion: Use `globalThis` or `self` instead. │ ├ Suggestion: You can provide `window` in the current scope with: `const window = globalThis`. │ └ Stack trace: └─ at file:///Users/ib/dev/deno/foo.js:7:1 ``` Ref https://github.com/denoland/deno/issues/13367.
2024-01-24 08:20:51 -05:00
console
.
log
(
globalThis
.
localStorage
)
;
Copy permalink