Search code examples
webstormcode-templates

Customize interface implementation using WebStorm


WebStorm has a handy feature that allows you to quickly implement methods declared by interface. For example:

deserialize: (key: string, value: string) => ISearchFilter;

will get auto-implemented to

deserialize(key: string, value: string): ISearchFilter {
    return undefined;
}

Is there a way to instruct WebStorm on how the method should be created? In my case, I'd love to see an implemented method throw an error. For example:

deserialize(key: string, value: string): ISearchFilter {
    throw new Error(classname+":deserialize not yet implemented");
    return undefined;
}

Is is possible to create such stubs with WebStorm?


Solution

  • You can try changing the TypeScript Implemented Method Body template in Settings | Editor | File and Code Templates, Code accordingly