ipatalas / vscode-postfix-ts

Postfix notation for TypeScript/Javascript - extension for VS Code
MIT License
159 stars 43 forks source link

feat: Infer variable names #65

Closed zardoy closed 2 years ago

zardoy commented 2 years ago

fixes #63

You can look at tests to see what I got for you. You can also look for published files here. I'm really really happy with that, but I'm planning to also derive name from JSDoc param (to let lib maitainers override name) and type information e.g. const elem = document.querySelector() (elem for ParentNode['querySelector']). I'm still not sure how I should maintain extractor and map for types, so I'm not going to do this at the moment.

As you can see I was also experimenting with public API. It is extremely simple and not the best one, but I left it enabled here so we can continue experimenting with the deriving const names. I can remove this all (but we will continue to use patched extension in this case).

No magic, everything is simple. Only regexs, so everything should be also fast. Feel free to ask.

zardoy commented 2 years ago

As I can see we don't use bundled version for testing so I think publishing CJS instead of ESM would be simplest solution to fix tests.

ipatalas commented 2 years ago

As I can see we don't use bundled version for testing so I think publishing CJS instead of ESM would be simplest solution to fix tests.

Most tests break when run with bundled version. Part of the behavior I'm using for integration tests doesn't work correctly when bundled - I even checked that on a simple PoC extension built from scratch just to make sure it's nothing related specifically to this extension. See here for details. If I get a proper solution for that I will start using bundled version for tests as well but for now value of having the tests working is much bigger than of using bundled version for testing.