Coder Social home page Coder Social logo

Update @babel/parser about abracadabra HOT 8 CLOSED

nicoespeon avatar nicoespeon commented on June 5, 2024 1
Update @babel/parser

from abracadabra.

Comments (8)

nicoespeon avatar nicoespeon commented on June 5, 2024 1

That's fair. It's an important issue to tackle if we want to keep the extension useful.

Fabien and I weren't available to work on this in the last few weeks for personal reasons (+ conferences on my side). I'm still busy next week but we might find some time to tackle this next Thursday!

Otherwise we will tackle it in 2 weeks. Not ideal, but it will do.

From what you said, we should upgrade the version and fix the compiler errors that happens (because some function we use have changed their signatures, hopefully just a few of them).

from abracadabra.

nicoespeon avatar nicoespeon commented on June 5, 2024 1

Released in version 3.2.2.

Thank you @David-Else 👍

from abracadabra.

nicoespeon avatar nicoespeon commented on June 5, 2024

@David-Else thanks for being on top of the latest features and letting us know, that really helps 👍

Yes, I guess upgrading the dependency should do the work. Maybe there's a new plugin to use here:

plugins: [
"asyncGenerators",
"bigInt",
"classPrivateMethods",
"classPrivateProperties",
"classProperties",
"decorators-legacy",
"doExpressions",
"dynamicImport",
"exportDefaultFrom",
"exportNamespaceFrom",
"functionBind",
"functionSent",
"importMeta",
"nullishCoalescingOperator",
"numericSeparator",
"objectRestSpread",
"optionalCatchBinding",
"optionalChaining",
["pipelineOperator", { proposal: "minimal" }],
"throwExpressions",
"jsx",
"typescript"
]

Hopefully, any regression should be caught by our unit tests, so it's a safe move to make.

Can you take care of it? Otherwise, @fabien0102 and I will likely do it next week 😉

from abracadabra.

David-Else avatar David-Else commented on June 5, 2024

This article goes deep on what needs to be done:

https://www.infoq.com/news/2020/01/babel-typescript-await/

I spent a while reading about how Babel works, and it seems I would need a few days to really get a grip on things. Would be cool is fabian sorted it :)

In my reading I found https://github.com/alangpierce/sucrase which is 20x faster than babel and a drop in replacement. VS Code runs a fixed version of V8/Electron for long periods of time, so abracadabra should not need all the extra babel baggage?

I don't quite know how babel stays updated with the latest typescript features, but 3.8 has import type coming too https://www.infoworld.com/article/3513938/typescript-38-unveils-new-syntax-for-type-only-imports.html

from abracadabra.

David-Else avatar David-Else commented on June 5, 2024

Just as an update, VS Code 1.42 came out yesterday. It has support built in for TS 3.8 new features for JS and TS, but ships with TS 3.7.5. To use the new feature (inc top level await and JS private properties) you need to either:

npm install -g typescript@rc

settings.json (main global file, link will be different depending on your package manager)

"typescript.tsdk": "/home/user/.nvm/versions/node/v12.15.0/pnpm-global/3/node_modules/typescript/lib"
  • or just install typescript@rc in your project and select to use it in the VS Code interface bottom right.

from abracadabra.

David-Else avatar David-Else commented on June 5, 2024

I had a go at updating babel to the latest, so this was the only change I made:

    "@babel/parser": "^7.8.4",
    "@babel/traverse": "^7.8.4",
    "@babel/types": "^7.8.3",

On running the tests I get many failure which all relate to this function in convert-to-template-literal.ts

function createTemplateLiteral(template: Template): t.TemplateLiteral {
  return t.templateLiteral(
    // Intermediate interpolated quasis shouldn't be part of the final template.
    template.quasis.filter(quasi => !isInterpolated(quasi) || quasi.tail),
    template.expressions
  );
}

Here is the first error of many, I am afraid I don't know how to fix this problem.

 FAIL  src/refactorings/convert-to-template-literal/convert-to-template-literal.test.ts
  ● Convert To Template Literal › should convert to template literal › concatenation with number, cursor on string

    TypeError: Property value of TemplateElement expected to have the following:
    Property raw expected type of string but got number
    Property cooked expected type of string but got number

      61 |  */
      62 | function templateElement(value: string | number | boolean): t.TemplateElement {
    > 63 |   return t.templateElement({
         |            ^
      64 |     raw: value,
      65 |     cooked: value
      66 |   });

      at Object.validate (node_modules/.pnpm/registry.npmjs.org/@babel/types/7.8.3/node_modules/@babel/types/lib/definitions/utils.js:185:13)
      at validateField (node_modules/.pnpm/registry.npmjs.org/@babel/types/7.8.3/node_modules/@babel/types/lib/validators/validate.js:24:9)
      at validate (node_modules/.pnpm/registry.npmjs.org/@babel/types/7.8.3/node_modules/@babel/types/lib/validators/validate.js:17:3)
      at builder (node_modules/.pnpm/registry.npmjs.org/@babel/types/7.8.3/node_modules/@babel/types/lib/builders/builder.js:38:27)
      at Object.TemplateElement (node_modules/.pnpm/registry.npmjs.org/@babel/types/7.8.3/node_modules/@babel/types/lib/builders/generated/index.js:538:31)
      at Object.templateElement (src/ast/domain.ts:63:12)
      at PrimitiveTemplate.get quasis [as quasis] (src/refactorings/convert-to-template-literal/convert-to-template-literal.ts:186:15)
      at CompositeTemplate.get quasis [as quasis] (src/refactorings/convert-to-template-literal/convert-to-template-literal.ts:135:48)
      at createTemplateLiteral (src/refactorings/convert-to-template-literal/convert-to-template-literal.ts:113:14)
      at BinaryExpression (src/refactorings/convert-to-template-literal/convert-to-template-literal.ts:64:24)

from abracadabra.

nicoespeon avatar nicoespeon commented on June 5, 2024

The signature of templateElement() probably changed. We'll need to double check the changelog to see if the differences are documented =)

from abracadabra.

David-Else avatar David-Else commented on June 5, 2024

VS Code with TypeScript 3.8 built in is out tomorrow... No pressure :) abracadabra is currently not working with any new TypeScript language features, TS 3.8 has been out a couple of weeks now:

https://devblogs.microsoft.com/typescript/announcing-typescript-3-8/

@David-Else thanks for being on top of the latest features and letting us know, that really helps +1

As well as full support for top level await/private fields there is now a built in convert-to-template-string-refactoring refactoring, so maybe the abracadabra one is not needed now?

https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_43.md#convert-to-template-string-refactoring.

I won't keep hassling you I promise, this will be the last reminder. I don't think the next TS 3.9 will have any new language features, you should not have to deal with any out-dating for quite a long time :)

from abracadabra.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.