-
-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does ts-node/register work for destructuring? #43
Comments
What TypeScript version are you using it with? Can you post a reproducible test case? That's a JavaScript error, so I think you're using this with a JavaScript file instead of a TypeScript file. Can you confirm that? Otherwise, I'd say it's the target output in |
@blakeembrey This is a problem with my mocha tests. As per some instructions I found somewhere, I added And, yes I'm using node 4.2.1 which doesn't support destructuring by default yet. |
Are the tests written in TypeScript or JavaScript. What about your I'm not sure there's a solution if node doesn't support destructuring but does support things like |
Following up quickly, check out https://kangax.github.io/compat-table/es6/#test-destructuring. Looks like this is an issue, TypeScript will only compile "all" ES6 for us but node can't handle destructuring (maybe other things). |
My tests are written in typescript. As far as I can tell, By the way, thanks for your work on the typings module, it's been a better solution that tsd for me so far. |
You're right, I had to investigate and found that node currently doesn't support destructuring. I wish there wasn't something we could do here since that's a trivial issue for the compiler to handle, but TypeScript doesn't support feature flags. An existing discussion can be found at microsoft/TypeScript#4692, but it looks like it might have been derailed - I'll check in and see what's happening since this is a pretty helpful use-case.
Thanks so much! I'm glad it works for you, I haven't had a lot of feedback yet so it's hard to tell if I'm confusing people or if it's communicating the message correctly. There's a need for more corrected typings, so if you get a chance 😄 |
Yeah, I want to add some more typings because I'm having to install a lot of definitelytyped I remember having a discussion when definitelytyped first came out that it would be better to have had each typing as a separate repo, but that met with a lot of resistance, so I'm really glad that you went in that direction...especially with the 1,385 folders that definitelytyped now handles. |
Haha, yeah, you're probably correct. I originally had that parity, but removed it from typings before release. I can simply add it back, ambient dependencies aren't included with any installation anyway - they are just for environment "reference" here.
I'll look at adding one for you (or to the FAQ in the README), but it's mostly straightforward - just moving everything inside the ambient You can always create the files/repos under your own user too, then just add them to the registry 😄 Supporting DefinitelyTyped as ambient is a nice use-case too, which I've avoided documenting but perhaps I should if people are discovering it anyway. It would probably solve all the TSD woes. |
I'm going to reopen this for visibility or until it's fixed upstream in TypeScript |
FYI - If you are using mocha you can enable destructuring and default parameters using
|
Closing as answered, as far as I can tell it won't ever be fixed in TypeScript. Thankfully, ES6 works with node 6. |
I'm getting this error right now when I use destructuring in my typescript code:
Otherwise, it has been great.
The text was updated successfully, but these errors were encountered: