You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then lingua-franca tests will fail, and __tests__/bank.ts will error.
Specifically, this.d.allWritable(this.d.port((member) => member.o)); will experience typing error. While tsc can correctly infer the lambda type to be function(member: MultiPeriodic): OutMultiPort<number>, it infers port to be Bank<MultiPeriodic, unknown>.port<Port<unknown> | MultiPort<unknown>>(selector: (reactor: MultiPeriodic) => Port<unknown> | MultiPort<unknown>): (Port<unknown> | MultiPort<unknown>)[]; the generic types are unknown instead of number`.
The issue specifically is
Type 'OutMultiPort<number>' is not assignable to type 'Port<unknown> | MultiPort<unknown>'.
Type 'OutMultiPort<number>' is not assignable to type 'MultiPort<unknown>'.
The types returned by 'channels()' are incompatible between these types.
Type 'OutPort<number>[]' is not assignable to type 'IOPort<unknown>[]'.
Type 'OutPort<number>' is not assignable to type 'IOPort<unknown>'.
The types of 'asWritable(...).getPort().getManager(...).addReceiver' are incompatible between these types.
Type '(port: WritablePort<number>) => void' is not assignable to type '(port: WritablePort<unknown>) => void'.
Types of parameters 'port' and 'port' are incompatible.
Type 'WritablePort<unknown>' is not assignable to type 'WritablePort<number>'.
The types returned by 'get()' are incompatible between these types.
Type 'unknown' is not assignable to type 'number | undefined'.
Failed LF tests include NestedMulti.ts where similar error message could be observed:
src/NestedBanks.ts(429,28): error TS2345: Argument of type '(Port<unknown> | MultiPort<unknown>)[]' is not assignable to parameter of type '(MultiPort<number> | IOPort<number>)[]'.
Type 'Port<unknown> | MultiPort<unknown>' is not assignable to type 'MultiPort<number> | IOPort<number>'.
Type 'Port<unknown>' is not assignable to type 'MultiPort<number> | IOPort<number>'.
Type 'Port<unknown>' is missing the following properties from type 'IOPort<number>': get, asWritable, writer, manager
src/NestedBanks.ts(429,50): error TS2322: Type 'OutMultiPort<number>' is not assignable to type 'Port<unknown> | MultiPort<unknown>'.
Type 'OutMultiPort<number>' is not assignable to type 'MultiPort<unknown>'.
The types returned by 'channels()' are incompatible between these types.
Type 'OutPort<number>[]' is not assignable to type 'IOPort<unknown>[]'.
Type 'OutPort<number>' is not assignable to type 'IOPort<unknown>'.
The types of 'asWritable(...).getPort().getManager(...).addReceiver' are incompatible between these types.
Type '(port: WritablePort<number>) => void' is not assignable to type '(port: WritablePort<unknown>) => void'.
Types of parameters 'port' and 'port' are incompatible.
Type 'WritablePort<unknown>' is not assignable to type 'WritablePort<number>'.
The types returned by 'get()' are incompatible between these types.
Type 'unknown' is not assignable to type 'number | undefined'.
Based on my observation, a lot of Port-related places also requires type assertion to compile with error after this change. While I think these assertion are safe to make and it is okay to keep them, I think this is a situation that is worth attention.
Issue
In
port.ts
, if the following change is made according to ESLint suggestion:Then lingua-franca tests will fail, and
__tests__/bank.ts
will error.Specifically,
this.d.allWritable(this.d.port((member) => member.o));
will experience typing error. Whiletsc
can correctly infer the lambda type to befunction(member: MultiPeriodic): OutMultiPort<number>
, it infersport
to beBank<MultiPeriodic, unknown>.port<Port<unknown> | MultiPort<unknown>>(selector: (reactor: MultiPeriodic) => Port<unknown> | MultiPort<unknown>): (Port<unknown> | MultiPort<unknown>)[]
; the generic types areunknown instead of
number`.The issue specifically is
Failed LF tests include
NestedMulti.ts
where similar error message could be observed:Based on my observation, a lot of
Port
-related places also requires type assertion to compile with error after this change. While I think these assertion are safe to make and it is okay to keep them, I think this is a situation that is worth attention.See Also
#162
#175
microsoft/TypeScript#40855
The text was updated successfully, but these errors were encountered: