9 ms·
How could Typescript have fixed this?
by morcus 1y ago
How could Typescript have fixed this?
- love2read 1y agothey could have provided a seperate api over top of this and error’d on use? It’s a clearly error-prone api.
- morcus 1y agoI genuinely don't understand - how could Typescript provide a separate API on top of this? I usually do not expect Typescript to start generating code and APIs for me. Also, Typescript is adding types on top of the JavaScript language, not the DOM API.
- extraisland 1y agoNo they shouldn't have done. The Browser API Implementation doesn't exist in TypeScript. It exists in the browser. TypeScript shouldn't be fixing how the browser behaves. Think about what is happening. When you build to the browser as a target, TSC basically transpiles the TypeScript code to JavaScript. The Browser APIs that Typescript provides are a bunch of type definitions. When it transpiles the code the only thing it can really do is check the types match up.