Customize interface implementation using WebStorm

33 Views Asked by At

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?

1

There are 1 best solutions below

0
lena On BEST ANSWER

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