typescript-pipeline-operator icon indicating copy to clipboard operation
typescript-pipeline-operator copied to clipboard

[Discussion] Typechecking still fails

Open MiracleBlue opened this issue 6 years ago • 6 comments

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 😢

MiracleBlue avatar Mar 16 '19 01:03 MiracleBlue

+1 from me

hacker-DOM avatar Aug 31 '19 13:08 hacker-DOM

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. 😕

Dabolus avatar Sep 23 '19 19:09 Dabolus

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.

jedwards1211 avatar Apr 30 '20 23:04 jedwards1211

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! 😅

mimshwright avatar Oct 27 '20 06:10 mimshwright

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.

hyoretsu avatar Jun 29 '21 21:06 hyoretsu

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

gavr123456789 avatar Jan 15 '22 12:01 gavr123456789