Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Typescript and plugin-proposal-optional-chaining #727

Closed
JasCodes opened this issue Dec 2, 2018 · 10 comments
Closed

Typescript and plugin-proposal-optional-chaining #727

JasCodes opened this issue Dec 2, 2018 · 10 comments

Comments

@JasCodes
Copy link

JasCodes commented Dec 2, 2018

.babelrc

{
    "presets": [
        "@babel/typescript"
    ],
    "plugins": [
        "@babel/plugin-proposal-optional-chaining"
    ]
}

Will this work now or in future?
I tried g-plane/pluggable-babel-eslint
but still can't do optional chaining with typescript

@kaicataldo
Copy link
Member

babel-eslint doesn't currently read your Babel config file when parsing. There is work being done to change this, but it's a work in progress at the moment.

@JasCodes
Copy link
Author

JasCodes commented Dec 3, 2018

Hey @kaicataldo
Thx for taking time for replying.

So once #711 is done, i can do optional chaining with typescript?

@kaicataldo
Copy link
Member

kaicataldo commented Dec 3, 2018

Once #711 lands and is released, babel-eslint will read your Babel config file for parsing (no guarantees all the rules will work immediately, but it'll be able to parse everything Babel does!).

@JasCodes
Copy link
Author

JasCodes commented Dec 3, 2018

@kaicataldo Thx for that reply.
So as I understand typescript preset is used to strip types and convert it to javascript; when does the plugins apply. I was trying to do optional chaining on typescript using babel-node. I would images tsc will not work but if the plugins are applied after type striping then optional chainging plugin should work?

@kaicataldo
Copy link
Member

tsc is running TypeScript's internal parser, and it's up to the TypeScript team when to implement support for any new language features. I believe TypeScript generally only adds features once they are stage 3 (optional chaining is stage 0), though it's been a while since I checked on that.

@JasCodes
Copy link
Author

JasCodes commented Dec 3, 2018

@kaicataldo
Its at stage 1; thought I was under impression typescript roll out features at stage-2 ( heard in some talk; vaguely remember ).
Anyways was just asking once #711 lands can I be able to use preset-typescript and plugin-optional-chaining; without typescript official support arriving?
Thx

@kaicataldo
Copy link
Member

Once #711 lands babel-eslint will be able to parse anything your configuration of Babel is able to parse.

@JasCodes JasCodes closed this as completed Dec 4, 2018
@RWOverdijk
Copy link

It's done, but there's no way to tell typescript this is fine now. So, webstorm for example will still complain that it does not know what you're talking about but the feature works fine.

@micaww
Copy link

micaww commented Feb 18, 2019

@RWOverdijk Have you found a way to force Web/PhpStorm to ignore this "TS: Expression expected" language service error altogether? I use the same setup and Babel compiles it fine, but I almost don't want to use optional chaining at all if all my files are covered in these errors. I assume there's no need to use tsc (which would fail in this case) if Webstorm can accurately report issues without it.

@RWOverdijk
Copy link

@micaww What I did was disable the TS language services and tell webstorm I'm using babel. I can't remember where... But it's not worth it for me, as I lose all other checks. I guess the only thing left is.. Wait. Or help push the proposal. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants