Typescript const assertion shows as a syntax error

I am using a const assertion (from TypeScript 3.4) in an Angular guard that works with an observable.  I have specified that the return type of the guard method return Observable<true | UrlTree> because I intend to have the guard method either return true based on a value from some service or return an UrlTree in case of an error, which instructs it to navigate to a different URL.  I came up with this code that the TypeScript compiler does not report an error on, but Resharper does:

if (someCondition) {
return this.myService.myMethodThatReturnsAnObservable(aParameter)
.pipe(
map(() => true as const),
catchError(error => { /* some code that returns an Observable<UrlTree> */),
// etc.
);
} else {
// other logic
}

Resharper shows a red squiggly after "as" saying Type name expected.  It also dims out everything after the as to the closing brace of the pipe() and reports "Code is unreachable" and "; is expected" after the "const".  It also shows further errors after the pipe().

Are const assertions something that Resharper doesn't currently support?

(Sorry, I did not know which Topic to choose.)

1 comment
Comment actions Permalink
Official comment

Hello,

 

Const assertion currently isn't supported by ReSharper, please follow the corresponding feature request - https://youtrack.jetbrains.com/issue/RSRP-481145.

You are welcome to comment or vote for it.

Thank you.

Please sign in to leave a comment.