webstormlive-templates

How to add an autoimport to WebStorm Live Templates


I have a live template useS for

const [$VAR1$, set$VAR2$] = useState($END$);

where useState is an external variable that has to be imported like so:

import { useState } from "react";

Whenever this template is used, the import should be automatically added to the current file at the top.

The template is used within JS functions, therefore I can not just add an import to the live template, since the import will be placed inline then.

Is there a special pattern for that?


Solution

  • Doesn't work currently, please follow WEB-37425 for updates