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';
import type { ToastMessengerService } from '../services/toast-messenger';
import { useSidebarStore } from '../store';
import { copyText } from '../util/copy-to-clipboard';
import { notNull } from '../util/typing';
import ShareLinks from './ShareLinks';
import SidebarPanel from './SidebarPanel';
......@@ -68,7 +67,7 @@ function ShareAnnotationsPanel({ toastMessenger }: ShareAnnotationPanelProps) {
className="text-color-text font-medium"
data-testid="sharing-intro"
>
{notNull(focusedGroup).type === 'private' ? (
{focusedGroup!.type === 'private' ? (
<p>
Use this link to share these annotations with other group
members:
......@@ -94,16 +93,16 @@ function ShareAnnotationsPanel({ toastMessenger }: ShareAnnotationPanelProps) {
</InputGroup>
</div>
<p data-testid="sharing-details">
{notNull(focusedGroup).type === 'private' ? (
{focusedGroup!.type === 'private' ? (
<span>
Annotations in the private group{' '}
<em>{notNull(focusedGroup).name}</em> are only visible to
group members.
<em>{focusedGroup.name}</em> are only visible to group
members.
</span>
) : (
<span>
Anyone using this link may view the annotations in the group{' '}
<em>{notNull(focusedGroup).name}</em>.
<em>{focusedGroup.name}</em>.
</span>
)}{' '}
<span>
......
import type { Annotation } from '../../types/api';
import { notNull } from '../util/typing';
import type { Thread } from './build-thread';
/**
......@@ -63,7 +62,7 @@ export function rootAnnotations(threads: Thread[]): Annotation[] {
// those annotations
const threadAnnotations = threads
.filter(thread => !!thread.annotation)
.map(thread => notNull(thread.annotation));
.map(thread => thread.annotation!);
if (threadAnnotations.length) {
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