Skip to content

Commit

Permalink
Improve missing implementations error by mentioning missing names (#3972
Browse files Browse the repository at this point in the history
)

* Improve missing implementations error by mentioning missing names

* Typo

* add changeset

---------

Co-authored-by: David Khourshid <davidkpiano@gmail.com>
  • Loading branch information
Andarist and davidkpiano committed Apr 26, 2023
1 parent 534f31d commit 2b9583a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/tough-windows-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'xstate': patch
---

The "Some implementations missing" type-level error will now mention what implementations are missing.
3 changes: 2 additions & 1 deletion packages/core/src/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import * as serviceScope from './serviceScope';
import { spawnBehavior } from './behaviors';
import {
AreAllImplementationsAssumedToBeProvided,
MissingImplementationsError,
TypegenDisabled
} from './typegenTypes';

Expand Down Expand Up @@ -1645,7 +1646,7 @@ export function interpret<
any,
TResolvedTypesMeta
>
: 'Some implementations missing',
: MissingImplementationsError<TResolvedTypesMeta>,
options?: InterpreterOptions
) {
const interpreter = new Interpreter<
Expand Down
26 changes: 20 additions & 6 deletions packages/core/src/typegenTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
Values,
IsAny,
ServiceMap,
Cast
Cast,
Compute
} from './types';

export interface TypegenDisabled {
Expand Down Expand Up @@ -108,16 +109,29 @@ export type AreAllImplementationsAssumedToBeProvided<
? true
: TResolvedTypesMeta extends TypegenEnabled
? IsNever<
Values<
{
[K in keyof TMissingImplementations]: TMissingImplementations[K];
}
>
Values<{
[K in keyof TMissingImplementations]: TMissingImplementations[K];
}>
> extends true
? true
: false
: true;

export type MissingImplementationsError<
TResolvedTypesMeta,
TMissingImplementations = Prop<
Prop<TResolvedTypesMeta, 'resolved'>,
'missingImplementations'
>
> = Compute<
[
'Some implementations missing',
Values<{
[K in keyof TMissingImplementations]: TMissingImplementations[K];
}>
]
>;

interface AllImplementationsProvided {
missingImplementations: {
actions: never;
Expand Down

0 comments on commit 2b9583a

Please sign in to comment.