-
Notifications
You must be signed in to change notification settings - Fork 12.2k
/
circularReferenceInReturnType2.errors.txt
61 lines (50 loc) · 2.23 KB
/
circularReferenceInReturnType2.errors.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
circularReferenceInReturnType2.ts(39,7): error TS7022: 'A' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
circularReferenceInReturnType2.ts(41,3): error TS7023: 'fields' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
==== circularReferenceInReturnType2.ts (2 errors) ====
type ObjectType<Source> = {
kind: "object";
__source: (source: Source) => void;
};
type Field<Source, Key extends string> = {
__key: (key: Key) => void;
__source: (source: Source) => void;
};
declare const object: <Source>() => <
Fields extends {
[Key in keyof Fields]: Field<Source, Key & string>;
}
>(config: {
name: string;
fields: Fields | (() => Fields);
}) => ObjectType<Source>;
type InferValueFromObjectType<Type extends ObjectType<any>> =
Type extends ObjectType<infer Source> ? Source : never;
type FieldResolver<Source, TType extends ObjectType<any>> = (
source: Source
) => InferValueFromObjectType<TType>;
type FieldFuncArgs<Source, Type extends ObjectType<any>> = {
type: Type;
resolve: FieldResolver<Source, Type>;
};
declare const field: <Source, Type extends ObjectType<any>, Key extends string>(
field: FieldFuncArgs<Source, Type>
) => Field<Source, Key>;
type Something = { foo: number };
// inference fails here, but ideally should not
const A = object<Something>()({
~
!!! error TS7022: 'A' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
name: "A",
fields: () => ({
~~~~~~
!!! error TS7023: 'fields' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions.
a: field({
type: A,
resolve() {
return {
foo: 100,
};
},
}),
}),
});