Commit 5a7b7838 authored by Robert Knight's avatar Robert Knight

Replace obsolete `notNull` helper with `!` operator

parent c8c1e6fd
...@@ -12,7 +12,6 @@ import { withServices } from '../service-context'; ...@@ -12,7 +12,6 @@ import { withServices } from '../service-context';
import type { ToastMessengerService } from '../services/toast-messenger'; import type { ToastMessengerService } from '../services/toast-messenger';
import { useSidebarStore } from '../store'; import { useSidebarStore } from '../store';
import { copyText } from '../util/copy-to-clipboard'; import { copyText } from '../util/copy-to-clipboard';
import { notNull } from '../util/typing';
import ShareLinks from './ShareLinks'; import ShareLinks from './ShareLinks';
import SidebarPanel from './SidebarPanel'; import SidebarPanel from './SidebarPanel';
...@@ -68,7 +67,7 @@ function ShareAnnotationsPanel({ toastMessenger }: ShareAnnotationPanelProps) { ...@@ -68,7 +67,7 @@ function ShareAnnotationsPanel({ toastMessenger }: ShareAnnotationPanelProps) {
className="text-color-text font-medium" className="text-color-text font-medium"
data-testid="sharing-intro" data-testid="sharing-intro"
> >
{notNull(focusedGroup).type === 'private' ? ( {focusedGroup!.type === 'private' ? (
<p> <p>
Use this link to share these annotations with other group Use this link to share these annotations with other group
members: members:
...@@ -94,16 +93,16 @@ function ShareAnnotationsPanel({ toastMessenger }: ShareAnnotationPanelProps) { ...@@ -94,16 +93,16 @@ function ShareAnnotationsPanel({ toastMessenger }: ShareAnnotationPanelProps) {
</InputGroup> </InputGroup>
</div> </div>
<p data-testid="sharing-details"> <p data-testid="sharing-details">
{notNull(focusedGroup).type === 'private' ? ( {focusedGroup!.type === 'private' ? (
<span> <span>
Annotations in the private group{' '} Annotations in the private group{' '}
<em>{notNull(focusedGroup).name}</em> are only visible to <em>{focusedGroup.name}</em> are only visible to group
group members. members.
</span> </span>
) : ( ) : (
<span> <span>
Anyone using this link may view the annotations in the group{' '} Anyone using this link may view the annotations in the group{' '}
<em>{notNull(focusedGroup).name}</em>. <em>{focusedGroup.name}</em>.
</span> </span>
)}{' '} )}{' '}
<span> <span>
......
import type { Annotation } from '../../types/api'; import type { Annotation } from '../../types/api';
import { notNull } from '../util/typing';
import type { Thread } from './build-thread'; import type { Thread } from './build-thread';
/** /**
...@@ -63,7 +62,7 @@ export function rootAnnotations(threads: Thread[]): Annotation[] { ...@@ -63,7 +62,7 @@ export function rootAnnotations(threads: Thread[]): Annotation[] {
// those annotations // those annotations
const threadAnnotations = threads const threadAnnotations = threads
.filter(thread => !!thread.annotation) .filter(thread => !!thread.annotation)
.map(thread => notNull(thread.annotation)); .map(thread => thread.annotation!);
if (threadAnnotations.length) { if (threadAnnotations.length) {
return threadAnnotations; return threadAnnotations;
......
/**
* Helper function for cases in which logically a reference is definitely
* not nullish, but TS can't infer that correctly. This will cast the `arg`
* and appease type-checking.
*
* @template T
* @param {T} arg
*/
export function notNull(arg) {
return /** @type {NonNullable<T>} */ (arg);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment