File tree Expand file tree Collapse file tree 4 files changed +18
-19
lines changed
packages/signals/signals-runtime/src Expand file tree Collapse file tree 4 files changed +18
-19
lines changed Original file line number Diff line number Diff line change 1- interface BaseSignal {
2- index ?: number
3- type : string
4- time : number
5- }
6-
7- export type SignalOfType <
8- AllSignals extends BaseSignal ,
9- SignalType extends AllSignals [ 'type' ]
10- > = AllSignals & { type : SignalType }
1+ import { BaseSignal , SignalOfType } from './types/shared'
112
123/**
134 * SignalsRuntime class to manage signals
Original file line number Diff line number Diff line change 1+ export interface BaseSignal {
2+ type : string
3+ }
4+
5+ export type SignalOfType <
6+ AllSignals extends BaseSignal ,
7+ SignalType extends AllSignals [ 'type' ]
8+ > = AllSignals & { type : SignalType }
Original file line number Diff line number Diff line change 1+ import type { BaseSignal , SignalOfType } from '../shared'
2+
13export type JSONPrimitive = string | number | boolean | null
24export type JSONValue = JSONPrimitive | JSONObject | JSONArray
35export type JSONObject = { [ member : string ] : JSONValue }
@@ -97,8 +99,6 @@ export interface UserDefinedSignalData {
9799
98100export type UserDefinedSignal = AppSignal < 'userDefined' , UserDefinedSignalData >
99101
100- export type SignalOfType < T extends SignalTypes > = Signal & { type : T }
101-
102102export type Signal =
103103 | InteractionSignal
104104 | NavigationSignal
@@ -111,10 +111,10 @@ export interface SegmentEvent {
111111 [ key : string ] : any
112112}
113113
114- export interface SignalsRuntimeAPI {
115- find : < T extends SignalTypes > (
114+ export interface ISignalsRuntime < Signal extends BaseSignal > {
115+ find : < SignalType extends Signal [ 'type' ] > (
116116 fromSignal : Signal ,
117- signalType : T ,
118- predicate ?: ( signal : SignalOfType < T > ) => boolean
119- ) => SignalOfType < T > | undefined
117+ signalType : SignalType ,
118+ predicate ?: ( signal : SignalOfType < Signal , SignalType > ) => boolean
119+ ) => SignalOfType < Signal , SignalType > | undefined
120120}
Original file line number Diff line number Diff line change 11// all import directives will be removed in the final build
2- import { SignalsRuntimeAPI } from './types/ web/signals '
2+ import { ISignalsRuntime , Signal } from './web-exports '
33
44// This will be appended to the generated code - dts-bundle-generator will not write declare const for whatever reason.
5- declare const signals : SignalsRuntimeAPI
5+ declare const signals : ISignalsRuntime < Signal >
66declare const SignalType : {
77 Interaction : 'interaction'
88 Navigation : 'navigation'
You can’t perform that action at this time.
0 commit comments