Finally enonic-types has support for using the `import` keyword

Hey Enonic-friends!

I got so enthusiastic by doing the webinar about TypeScript in Enonic XP on Tuesday, that set out to fix the largest remaining problem.

And I did it! After more then a year of trying ā€“ I finally did it! :tada: I added support for automatically getting types when using the import keyword!

Here is a demo of code completion using JavaScript (it would be almost the same in TypeScript).

enonic-types-0.2.0


To enable this support you have to have the enonic-types library installed, and you need to add the following to your tsconfig.json or tsconfig.server.json file.

{
  "compilerOptions": {
    ...
    "types": [
      "node",
      "enonic-types"
    ]
  } 
}

My original plan had been to release the 1.0.0 version of enonic-types when I got import to work.

But if there is a chance that enonic-types can become part of core XP. Iā€™m going to save 1.0.0 a little bit longer. :wink:

core


Btw, now is the perfect time to start using TypeScript in your XP-project! It is awesome!

8 Likes

Here is an example of a migration that enables and uses import from my example project.

1 Like