typescript-pipeline-operator
typescript-pipeline-operator copied to clipboard
[Discussion] Typechecking still fails
Howdy,
Although yes, it certainly would compile in this case, it would still break the typechecker since the typechecker doesn't yet understand the pipeline syntax. When babel compiles, it doesn't actually run the typechecker; it will simply remove all the typescript syntax and then compile as if it were all normal javascript.
As much as I and many others desperately want pipeline support in TS, there is no solution that doesn't involve changes to the typechecker as far as I can tell 😢
+1 from me
Hi,
As you said, unfortunately currently there's no way to add pipeline support to TS, and considering that the pipeline operator is still on stage 1, it will not be available that soon (TS only implements stage 3 proposals).
This repo just demonstrates how it is possible to use it with TS, but I myself wouldn't suggest to use this approach.
If someone has any idea to add type checking, feel free to write it down here or open a PR, but I'm quite sure it's just impossible for now. 😕
Yeah I had made some codemod tools check if someone was using @babel/preset-typescript and if so, parse the code to transform with babel instead of typescript...but then I realized, wait a minute, who would want to make their code unparseable by typescript.
Luckily I looked at this issue before trying this out... @Dabolus I would like to suggest you add a comment in your Readme file that talks more about how this works so that people don't get their hopes up! 😅
This, the closest I found to using TC39 features. But then, @babel/eslint-parser hasn't been formatting my code for some reason, so I can't even disable VSCode's TS validation.
pipeline operator is now on stage 2
arr, I cant wait
https://github.com/tc39/proposal-pipeline-operator
Also there are a pipe function that was done on typescript, so typechecking works https://github.com/katis/pipe/blob/master/src/index.ts