Commit 916a4aa
committed
web: fix TypeScript conflicts with TextEncoder and TextDecoder
In TypeScript, TextEncoder and TextDecoder are global types when
targeting the DOM environment, causing conflicts when importing these
classes from Node’s util module. To avoid these conflicts, TextEncoder
and TextDecoder from util have been imported with different names
(NodeTextEncoder, NodeTextDecoder) and assigned to globalThis with
explicit type assertions.
* MDN
- https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder
- https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder
* StackOverflow
- https://stackoverflow.com/a/77752064
* TypeScript types
- https://github.com/microsoft/TypeScript/blob/efca03ffed10dccede4fbc8dd8a624374e5424d9/src/lib/dom.generated.d.ts#L323781 parent 1878d87 commit 916a4aa
1 file changed
+3
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
| 11 | + | |
| 12 | + | |
13 | 13 | | |
0 commit comments