Earlier quoted context omitted.
This is true, but a lot of projects are now starting with TS, and maybe could benefit from intentional limitations on inference, at least locally. I’m pretty sure most folks start new projects with strict enabled as is.
In my experience a lot of people don’t necessarily start projects with strict mode — and they _really really_ should ... most people I’ve talked to who couldn’t figure out how to use typescript never figured things out because they ended up somehow with a compiler configured with noImplicitAny: false — typescript really needs to find a way to change the default here ...
Google Feedback on TypeScript 3.5
131–140 of 149 posts
Re: Google Feedback on TypeScript 3.5
#132Earlier quoted context omitted.
Good luck untangling re-native built on re-frame built on Reagent built on shadow-cljs built on React native built on React built on Android/iOS when one of those parts change.
so in that equation applies to all of JS transpilers. Why this a clojurescript specific complaint?
Re: Google Feedback on TypeScript 3.5
#133Earlier quoted context omitted.
No and on that basis it's unusable. However that's because it downloads the whole runtime. Eventually MS intend to load only your compiled code.
You can avoid that issue with the Server Side Blazor concept for business side portions of your application. Depending on the application you can get extremely far with just using HTTP requests to an API for anything business logic related. A lot of apps over complicate themselves by trying to force a JS framework on the front end with no benefit to the user. I seem to prefer using non-SPAs these days over SPAs becau…
Re: Google Feedback on TypeScript 3.5
#134Earlier quoted context omitted.
I don't have a significant amount of experience with TypeScript, but even from my limited experience I agree that it's a fantastic product. That said, at $JOB we (unfortunately) have a fair amount of production code written in TypeScript 0.9 which nobody has ever upgraded, and simply won't compile on a more recent version. It's been that way for years now, and every attempt to bring it up to date has been met with fa…
You can see a list of all changes in the "What's New in TypeScript" document on GitHub: https://github.com/Microsoft/TypeScript/wiki/What's-new-in-T... And a list of breaking changes here: https://github.com/microsoft/TypeScript/wiki/Breaking-Change... They both go back until v1.1. For older changes you can check the blog: https://devblogs.microsoft.com/typescript/announcing-typescr... https://devblogs.microsoft.com/…
Related to this, the TypeScript pre-1.0 import/export syntax for "external modules" was grandfathered in, but the semantics changed alongside the "internal modules" changes in 1.5. So pre-1.0 import/exports still mostly "compile" in post-1.5, but have very different semantics and that can often cause a lot of downstream module shape headaches, depending (and exacerbated by) the module format you are targeting.
A first pass making sure to rewrite all import/require/export statements can save you a lot of work later, even though it won't directly cause compile errors. You can get some compile errors by making sure you try to compile to a "proper" post-ES2015 module format (--module esm or --module es2015 or --module esnext even). There's also tslint rules such as "no-import-requires".
Re: Google Feedback on TypeScript 3.5
#135So happy to see the attention Typescript is getting lately. Absolutely love the language, and have been using it since it got released.
I tried using it with Angular, but it doesn't seem to help much. For example, if you have something like: And then a TypeScript function like: login(email: string, pass: string) { } TypeScript can't help you at all here because all the typing is determined at runtime by Angular. Even if `email` is a number or a boolean, no problem, it will just happily pass it in. What benefit, then, does TypeScript provide? I unders…
Disclaimer: I have heard about the above enough to dig up a random blog post about it but I don't know a lot about how it works.
I think in JSX (and I've seen experiments with lit too) there is also integration between the template and type checker.
Re: Google Feedback on TypeScript 3.5
#136Earlier quoted context omitted.
Yes, we use that to use TS together with Closure for all our TS code at Google. It's a bit difficult to hook up though, and we haven't had the cycles to make the open source version user friendly, I'm afraid :-(
It would be really cool to see the user-friendly version (though that might lead to a rabbit hole on the Closure side, too). The Closure compiler remains awesome, just difficult to make use of successfully.
Re: Google Feedback on TypeScript 3.5
#137Earlier quoted context omitted.
Why do you say so?
One reason: This isn't TS-specific; it's common in Python too: coercing to Bool has language semantics (for whatever language you are in) which often don't match the application semantics of your program. Application programmers don't (and shouldn't have to, but for the language's over-eager coercions) always think about the boolean semantics of all their objects. In particular, None and empty/zero object are both Fa…
Boolean itself I've not had trouble with, but things like map(parseInt) is the big one that bites a lot of junior developers all the time in TS/JS. (parseInt takes an optional second argument for radix, so in cases where the second argument returned by map is an index count, which is likely, you get it parsing in base-0, base-1, base-2, … which is almost never something you'd do intentionally.)
Re: Google Feedback on TypeScript 3.5
#138Earlier quoted context omitted.
Another interesting bit with the monorepo is the one-version-policy: https://opensource.google.com/docs/thirdparty/oneversion/ That's why the typescript upgrade was so hard for them. We (attempt) to enforce a single version of a library/toolchain to be checked into the codebase at any given time. You can have multiple in during an upgrade, but it's highly discouraged.
On the contrary, having multiple-versions could have made the upgrade much worse, by deferring compatibility problems from submit time to deploy time.
So to upgrade I would have to fix all users of the library to upgrade. While this is better overall for the codebase, it can put a lot of work on others for a not well maintained third-party library. Something like TS has people that help keep it updated. But for something more obscure, it'll be on someone else who cares enough to put in the work.
Re: Google Feedback on TypeScript 3.5
#139> (I might suggest the underlying problem in this code is relying on inference too much, but the threshold for "too much" is difficult to communicate to users.) This is a very outstandingly interesting line out the whole writeup. I like the writeup in its entirety for being very balanced and thoughtful, but this line in particular really stands out to me as worth more thought for anyone interested in language and typ…
IIRC there are a couple of Rust write ups about this. In Rust, inference is limited within functions. The language doesn't allow inferring the argument or return types of functions to avoid this kind of action at a distance. The function API is just one of the many arbitrary places where one can limit inference and require users to provide types. In other languages the module boundary might also be an appropriate pla…
This way, when you write
const f = (a, b) => a + b
the compiler can tell you to write: const f => (a: T, b: T): T => a + b
or const f : (a: T, b: T) => T
= (a, b) => a + b
This would be effectively like GHC's typeholes, where the compiler will tell you what to write when you say f :: _
f a b = a b
except that rather than being an optional step by a developer, it's a mandatory standard.(Well, I don't think typescript infers that type for that function, but whatever it actually infers, that's what should be there in the error message.)
Re: Google Feedback on TypeScript 3.5
#140Earlier quoted context omitted.
Thanks for highlighting this bit, I also find it very interesting to think about! Here's a related property I've also discovered of 'advanced' type systems. In my understanding of how unification happens in systems like H-M, you first give every expression its own type variable, then perform a search to produce assignments to those that remain valid and leave the remainders generic. But as your type system gets fanci…
That problem has a simple solution: you, the programmer, should write type signatures in appropriate places as a combination of what documentation and assert statements do in other languages. No compiler today could be reasonably expected to guess which inferences the human brain will find surprising, which is why it's up to the programmer.