VsCode IntelliSente for Enonic project

I’d like some advice on how to enable VsCode’s IntelliSense for Enonic’s libs and project’s files.

Is this possible? Is anyone uses it and how to configure it?

2 Likes

Hey Wally,

If you use the webpack starter, you can use the enonic-types library to get TypeScript-types for every library in XP 7.

The TypeScript-types works with both JavaScript and TypeScript. (I recommend trying TypeScript. :wink: )

We have also created a Gradle plugin that can generate JSDoc with @typedef (orTypeScript interfaces) from your projects xml-files. So that you can get code completion and type checking on data from XP too.

We are saving a lot of time using this + our code is very robust!

Example:

2 Likes

Thanks, @tom. I’d love to use typescript in Enonic, but it seems that it wasnt so accepted by the community. Looks like even the starter sttoped to be maintained: https://github.com/enonic/starter-typescript.

The starter-webpack comes with TypeScript-support. And it is maintained. So we are using it to great success. :slight_smile:

1 Like

@wally Let me know if you need help to get started. Either here, or you can find me on the Enonic Community Slack as Tom Arild Jakobsen (Item).

1 Like

Yeah, thanks very much man. I think we’ve talked before on #dev channel.
I’m going to make some tests here to learn and i’ll contact you if I have any trouble.

We do main our starters. :wink: If there is a problem with any startes, feel free to message us about it.
Especially if you are using/going to use them.

I asked around about this. And we do mainting our starters, but only for the newest version xp7.
So the xp6 starter is not maintained anymore, but we combined it with other starters and are mainting an typescript for xp7.

1 Like

@pkw, are we able to enable some kind of development mode with the “Webpack Starter” with typescript? Like, while changing a controller/service it automatically “deploys” it.

@wally Yes, what i usually use is gradle deploy -t (-t continuous build)
Gradle will listen for changes and deploy them as soon as you save the file.
You can access the gradle command within the enonic cli with enonic project shell

If you are using CLI then you can start your sandbox in development mode as described here. This will hot-deploy your server-side assets without you having to rebuild.

Well, thenI dont know whats wrong because I always use enonic sandbox start myBox --dev, but in this case, it did not work.
I started testing with the webapp controller that comes with the example project, and changing the controller of this webapp did not hot-deploy the app. I had to manually deploy it.
I’m using the sandbox with XP version 7.5.

If your controllers are written in EcmaScript which has to be transpiled by Webpack then dev mode won’t help you, you have to run gradlew in the continuous build/deploy mode as @pkw mentioned above. For plain-JS server-side code the dev mode should be sufficient.