Ondrej-Douda commented on code in PR #6079:
URL: https://github.com/apache/netbeans/pull/6079#discussion_r1234123578


##########
java/java.lsp.server/vscode/src/typesUtil.ts:
##########
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Licensed under the Universal Permissive License v 1.0 as shown at 
https://oss.oracle.com/licenses/upl.
+ */
+
+export type IsType<T> = (obj: unknown) => obj is T;
+
+function assertType<T>(obj: unknown, isTypeTest: IsType<T>, errorMessage?: 
string): asserts obj is T {
+    if (!isTypeTest(obj))
+        throw new Error(errorMessage || "Object isn't of expected type.");
+}
+
+export type Constructor<T> = new (...args: any) => T;
+
+export function isClass<T>(cls: Constructor<T>, obj: unknown): obj is T {
+    return obj instanceof cls;
+}
+export function isClassTest<T>(cls: Constructor<T>): ((obj: unknown) => obj is 
T) {
+    return (obj: unknown): obj is T => isClass(cls, obj);
+}
+export function asClass<T>(cls: Constructor<T>, obj: unknown, errorMessage?: 
string): T {
+    assertType(obj, isClassTest(cls), errorMessage);
+    return obj;
+}
+
+export function isError(obj: unknown): obj is Error {
+    return obj instanceof Error;
+}
+
+export function assertNever(_obj: never, errorMessage?: string): never {
+    throw new Error(errorMessage || "Shouldn't reach here.");
+}
+
+export type KeyOfArray<T> = TupleUnion<keyof T>;
+export type TupleUnion<U extends PropertyKey, R extends PropertyKey[] = []> = {

Review Comment:
   Removed this type...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to