@@ -32,7 +32,7 @@ export type OpaqueRefMethods<T> = {
3232 set ( value : Opaque < T > | T ) : void ;
3333 key < K extends keyof T > ( key : K ) : OpaqueRef < T [ K ] > ;
3434 setDefault ( value : Opaque < T > | T ) : void ;
35- setPreExisting ( ref : any ) : void ;
35+ setPreExisting ( ref : unknown ) : void ;
3636 setName ( name : string ) : void ;
3737 setSchema ( schema : JSONSchema ) : void ;
3838 connect ( node : NodeRef ) : void ;
@@ -42,7 +42,7 @@ export type OpaqueRefMethods<T> = {
4242 value ?: Opaque < T > ;
4343 defaultValue ?: Opaque < T > ;
4444 nodes : Set < NodeRef > ;
45- external ?: any ;
45+ external ?: unknown ;
4646 name ?: string ;
4747 schema ?: JSONSchema ;
4848 rootSchema ?: JSONSchema ;
@@ -60,16 +60,17 @@ export type OpaqueRefMethods<T> = {
6060 array : T ,
6161 ) => Opaque < S > ,
6262 ) : Opaque < S [ ] > ;
63- toJSON ( ) : any ;
63+ toJSON ( ) : unknown ;
6464 [ Symbol . iterator ] ( ) : Iterator < T > ;
6565 [ Symbol . toPrimitive ] ( hint : string ) : T ;
6666 [ isOpaqueRefMarker ] : true ;
6767} ;
6868
6969export const isOpaqueRefMarker = Symbol ( "isOpaqueRef" ) ;
7070
71- export function isOpaqueRef ( value : any ) : value is OpaqueRef < any > {
72- return value && typeof value [ isOpaqueRefMarker ] === "boolean" ;
71+ export function isOpaqueRef < T = any > ( value : unknown ) : value is OpaqueRef < T > {
72+ return ! ! value &&
73+ typeof ( value as OpaqueRef < T > ) [ isOpaqueRefMarker ] === "boolean" ;
7374}
7475
7576export type NodeRef = {
@@ -80,7 +81,7 @@ export type NodeRef = {
8081} ;
8182
8283export type toJSON = {
83- toJSON ( ) : any ;
84+ toJSON ( ) : unknown ;
8485} ;
8586
8687export type NodeFactory < T , R > =
@@ -118,16 +119,16 @@ export interface JSONObject extends Record<string, JSONValue> {}
118119// Annotations when writing data that help determine the entity id. They are
119120// removed before sending to storage.
120121export interface IDFields {
121- [ ID ] ?: any ;
122- [ ID_FIELD ] ?: any ;
122+ [ ID ] ?: unknown ;
123+ [ ID_FIELD ] ?: unknown ;
123124}
124125
125126// TODO(@ubik2) When specifying a JSONSchema, you can often use a boolean
126127// This is particularly useful for specifying the schema of a property.
127128// That will require reworking some things, so for now, I'm not doing it
128129export type JSONSchema = {
129- readonly [ ID ] ?: any ;
130- readonly [ ID_FIELD ] ?: any ;
130+ readonly [ ID ] ?: unknown ;
131+ readonly [ ID_FIELD ] ?: unknown ;
131132 readonly type ?:
132133 | "object"
133134 | "array"
@@ -158,14 +159,14 @@ export type JSONSchemaMutable = Mutable<JSONSchema>;
158159
159160export type Alias = {
160161 $alias : {
161- cell ?: any ;
162+ cell ?: unknown ;
162163 path : PropertyKey [ ] ;
163164 schema ?: JSONSchema ;
164165 rootSchema ?: JSONSchema ;
165166 } ;
166167} ;
167168
168- export function isAlias ( value : any ) : value is Alias {
169+ export function isAlias ( value : unknown ) : value is Alias {
169170 return isObject ( value ) && "$alias" in value && isObject ( value . $alias ) &&
170171 "path" in value . $alias &&
171172 Array . isArray ( value . $alias . path ) ;
@@ -175,8 +176,8 @@ export type StreamAlias = {
175176 $stream : true ;
176177} ;
177178
178- export function isStreamAlias ( value : any ) : value is StreamAlias {
179- return ! ! value && typeof value . $stream === "boolean" && value . $stream ;
179+ export function isStreamAlias ( value : unknown ) : value is StreamAlias {
180+ return isObject ( value ) && " $stream" in value && value . $stream === true ;
180181}
181182
182183export type Module = {
@@ -191,10 +192,10 @@ export type Handler<T = any, R = any> = Module & {
191192 with : ( inputs : Opaque < T > ) => OpaqueRef < R > ;
192193} ;
193194
194- export function isModule ( value : any ) : value is Module {
195+ export function isModule ( value : unknown ) : value is Module {
195196 return (
196197 ( typeof value === "function" || typeof value === "object" ) &&
197- typeof value . type === "string"
198+ value !== null && typeof ( value as unknown as Module ) . type === "string"
198199 ) ;
199200}
200201
@@ -221,24 +222,24 @@ export type Recipe = {
221222 [ unsafe_materializeFactory ] ?: ( log : any ) => ( path : PropertyKey [ ] ) => any ;
222223} ;
223224
224- export function isRecipe ( value : any ) : value is Recipe {
225+ export function isRecipe ( value : unknown ) : value is Recipe {
225226 return (
226227 ( typeof value === "function" || typeof value === "object" ) &&
227228 value !== null &&
228- ! ! value . argumentSchema &&
229- ! ! value . resultSchema &&
230- ! ! value . nodes &&
231- Array . isArray ( value . nodes )
229+ ! ! ( value as any ) . argumentSchema &&
230+ ! ! ( value as any ) . resultSchema &&
231+ ! ! ( value as any ) . nodes &&
232+ Array . isArray ( ( value as any ) . nodes )
232233 ) ;
233234}
234235
235236type CanBeOpaqueRef = { [ toOpaqueRef ] : ( ) => OpaqueRef < any > } ;
236237
237- export function canBeOpaqueRef ( value : any ) : value is CanBeOpaqueRef {
238+ export function canBeOpaqueRef ( value : unknown ) : value is CanBeOpaqueRef {
238239 return (
239240 ( typeof value === "object" || typeof value === "function" ) &&
240241 value !== null &&
241- typeof value [ toOpaqueRef ] === "function"
242+ typeof ( value as any ) [ toOpaqueRef ] === "function"
242243 ) ;
243244}
244245
@@ -252,12 +253,13 @@ export type ShadowRef = {
252253 shadowOf : OpaqueRef < any > | ShadowRef ;
253254} ;
254255
255- export function isShadowRef ( value : any ) : value is ShadowRef {
256+ export function isShadowRef ( value : unknown ) : value is ShadowRef {
256257 return (
257258 ! ! value &&
258259 typeof value === "object" &&
259260 "shadowOf" in value &&
260- ( isOpaqueRef ( value . shadowOf ) || isShadowRef ( value . shadowOf ) )
261+ ( isOpaqueRef ( ( value as ShadowRef ) . shadowOf ) ||
262+ isShadowRef ( ( value as ShadowRef ) . shadowOf ) )
261263 ) ;
262264}
263265
@@ -269,7 +271,7 @@ export type UnsafeBinding = {
269271
270272export type Frame = {
271273 parent ?: Frame ;
272- cause ?: any ;
274+ cause ?: unknown ;
273275 generatedIdCounter : number ;
274276 opaqueRefs : Set < OpaqueRef < any > > ;
275277 unsafe_binding ?: UnsafeBinding ;
@@ -281,12 +283,12 @@ export type Static = {
281283 [ isStaticMarker ] : true ;
282284} ;
283285
284- export function isStatic ( value : any ) : value is Static {
286+ export function isStatic ( value : unknown ) : value is Static {
285287 return typeof value === "object" && value !== null &&
286- value [ isStaticMarker ] === true ;
288+ ( value as any ) [ isStaticMarker ] === true ;
287289}
288290
289- export function markAsStatic ( value : any ) : any {
290- value [ isStaticMarker ] = true ;
291+ export function markAsStatic ( value : unknown ) : unknown {
292+ ( value as any ) [ isStaticMarker ] = true ;
291293 return value ;
292294}
0 commit comments