Earlier quoted context omitted.
It's true that it's another dependency, but this is the entire contents of a file I drop into my project root called `raw-loader.d.ts`: ``` declare module '*?raw' { const rawFileContent: string export default rawFileContent } ``` Then, when I add the file to my types property array of my tsconfig's compilerOptions, I can import anything I want into a typescript file as a string, so long as I add "?raw" to the end of…
right, but typescript sees that as a `string`, and not a string literal and thus cannot be parsed by this project or others like it.
Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
51–60 of 80 posts
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#52Earlier quoted context omitted.
> there's no runtime assurance that a string is actually a string. As someone who's written a lot of Typescript in fairly large projects: in practice this isn't really an issue if you 1. ban casting and 'any' via eslint, 2. use something like io-ts at http api/storage boundaries to validate data coming in/out of your system without a risk of validator/type mismatch. But you have to have total buy in from everyone, an…
I know, but it's that last bit: it shouldn't be possible to bypass it. C# actually got itself into a similar issue despite being a proper static language, because when it added "nullable reference types" (where you can't assign null to a variable of type `Foo` unless it's explicitly typed as `Foo?`) they did it like TypeScript using purely static analysis to avoid having to change the language at a lower level (for c…
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#53Earlier quoted context omitted.
The criticisms were valid then, too. C (including the preprocessor of course) is still not fully parseable if you include things like token concatenation.
I make no representation as to soundness, then or now. Not till I figure out where my copy of the UNIX-HATERS Handbook has got to, at any rate. I've had cause reasonably recently to reread the X and sendmail chapters, not so much this one.
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#54Earlier quoted context omitted.
right, but typescript sees that as a `string`, and not a string literal and thus cannot be parsed by this project or others like it.
That's simply not true. A loader can do whatever it wants. It translates the raw file contents into anything. Granted, at that point you'd might as well have the loader just be a traditional protobuf compiler, but the point still stands that this isn't an invalid solution.
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#55Earlier quoted context omitted.
I make no representation as to soundness, then or now. Not till I figure out where my copy of the UNIX-HATERS Handbook has got to, at any rate. I've had cause reasonably recently to reread the X and sendmail chapters, not so much this one.
X and sendmail are not really very relevant today.
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#56Earlier quoted context omitted.
I make no representation as to soundness, then or now. Not till I figure out where my copy of the UNIX-HATERS Handbook has got to, at any rate. I've had cause reasonably recently to reread the X and sendmail chapters, not so much this one.
X and sendmail are not really very relevant today.
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#57It’s pretty rad how flexible template literal types are, but I can’t imagine wanting this kind of shenanigans hanging out in a production app slowing down compile times. I prefer to define types in TypeScript and generate proto from that, since the TypeScript type system is so much more powerful than the Protobuf system. Types are much more composable in TS.
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#58Earlier quoted context omitted.
[flagged]
I was hoping to hear how are php types better than TS instead of another rant about how Rust is the greatest. Anyone? By the way, having lived in Scala 2 for a few years, Rust is half-assed. Type system leaks through the fingers when working with async collections. Future.sequence from Scala makes great cli apps. Scala collections are a work horse. The only thing from Rust I like is the shorthand question mark return…
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#59Also, been building something in a different space (LeetCode prep tool), but the idea of removing build steps for dev speed really resonates. Would love to see how this could plug into a lightweight frontend setup.
Re: Show HN: Zero-codegen, no-compile TypeScript type inference from Protobufs
#60Earlier quoted context omitted.
That's simply not true. A loader can do whatever it wants. It translates the raw file contents into anything. Granted, at that point you'd might as well have the loader just be a traditional protobuf compiler, but the point still stands that this isn't an invalid solution.
You’re talking about runtime, I’m talking about at compile time
It would be awfully silly to do this at runtime because typescript doesn't exist at runtime, which is sort of the whole point of the library.