tbonelee commented on code in PR #5109:
URL: https://github.com/apache/zeppelin/pull/5109#discussion_r2452941377


##########
zeppelin-web-angular/projects/zeppelin-sdk/src/interfaces/message-data-type-map.interface.ts:
##########
@@ -84,7 +84,7 @@ import { JobManagerDisabled, ListNoteJobs, ListUpdateNoteJobs 
} from './message-
 import { InterpreterBindings, InterpreterSetting } from 
'./message-interpreter.interface';
 import { OP } from './message-operator.interface';
 
-export type MixMessageDataTypeMap = MessageSendDataTypeMap & 
MessageReceiveDataTypeMap;
+export type MessageDataTypeMap = MessageSendDataTypeMap | 
MessageReceiveDataTypeMap;

Review Comment:
   - After upgrading to TS4, using an intersection of send/receive maps caused 
overlapping `OP` keys (e.g. `LIST_NOTE_JOBS`) to intersect their payload types 
(e.g. `undefined & ListNoteJobs`), producing `never`.
   - This broke `WebSocketMessage<keyof MessageSendDataTypeMap>` because 
`MixMessageTypeMap[K]` evaluated to `never` for some `K`, leading to generic 
constraint errors (TS2344) and lost inference.
   - Switching `MixMessageTypeMap` to a union `(Send | Receive)` restores 
correct indexed access `(Send[K] | Receive[K])` and fixes the errors.
   - Also updated `WebSocketMessage` to a discriminated-union friendly form for 
stable inference. (Type-only change; no runtime impact.)
   
   ### Note
   To learn how applying `keyof` operator to union type or intersection type 
works, see https://effectivetypescript.com/2024/08/30/keyof-puzzle/



-- 
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]

Reply via email to