←back to thread

517 points bkolobara | 1 comments | | HN request time: 0s | source
Show context
gedy ◴[] No.45042251[source]
> Assigning a value to 'window.location.href' doesn't immediately redirect you, like I thought it would.

That's not a "Typescript" or language issue, that's a DOM/browser API weirdness

replies(3): >>45042856 #>>45043364 #>>45045727 #
love2read ◴[] No.45043364[source]
*though it could have been fixed by typescript had they cared.
replies(1): >>45043549 #
morcus ◴[] No.45043549[source]
How could Typescript have fixed this?
replies(1): >>45044233 #
love2read ◴[] No.45044233[source]
they could have provided a seperate api over top of this and error’d on use? It’s a clearly error-prone api.
replies(2): >>45044494 #>>45049887 #
1. extraisland ◴[] No.45049887{3}[source]
No 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.