File: recursiveTypeRelations.errors.txt

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (55 lines) | stat: -rw-r--r-- 2,812 bytes parent folder | download | duplicates (2)
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
tests/cases/compiler/recursiveTypeRelations.ts(8,5): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/recursiveTypeRelations.ts(27,38): error TS2304: Cannot find name 'ClassNameObject'.
tests/cases/compiler/recursiveTypeRelations.ts(27,55): error TS2345: Argument of type '(obj: any, key: keyof S) => any' is not assignable to parameter of type '(previousValue: any, currentValue: string, currentIndex: number, array: string[]) => any'.
  Types of parameters 'key' and 'currentValue' are incompatible.
    Type 'string' is not assignable to type 'keyof S'.
tests/cases/compiler/recursiveTypeRelations.ts(27,61): error TS2304: Cannot find name 'ClassNameObject'.


==== tests/cases/compiler/recursiveTypeRelations.ts (4 errors) ====
    // Repro from #14896
    
    type Attributes<Keys extends keyof any> = {
        [Key in Keys]: string;
    }
    
    class Query<A extends Attributes<keyof A>> {
        multiply<B extends Attributes<keyof B>>(x: B): Query<A & B>;
        ~~~~~~~~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
    }
    
    // Repro from #14940
    
    type ClassName<S> = keyof S;
    type ClassNameMap<S> = { [K in keyof S]?: boolean }
    type ClassNameObjectMap<S> = object & ClassNameMap<S>;
    type ClassNameArg<S> = ClassName<S> | ClassNameObjectMap<S>;
    
    export function css<S extends { [K in keyof S]: string }>(styles: S, ...classNames: ClassNameArg<S>[]): string {
      const args = classNames.map(arg => {
        if (arg == null) {
          return null;
        }
        if (typeof arg == "string") {
          return styles[arg];
        }
        if (typeof arg == "object") {
          return Object.keys(arg).reduce<ClassNameObject>((obj: ClassNameObject, key: keyof S) => {
                                         ~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'ClassNameObject'.
                                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '(obj: any, key: keyof S) => any' is not assignable to parameter of type '(previousValue: any, currentValue: string, currentIndex: number, array: string[]) => any'.
!!! error TS2345:   Types of parameters 'key' and 'currentValue' are incompatible.
!!! error TS2345:     Type 'string' is not assignable to type 'keyof S'.
                                                                ~~~~~~~~~~~~~~~
!!! error TS2304: Cannot find name 'ClassNameObject'.
            const exportedClassName = styles[key];
            obj[exportedClassName] = (arg as ClassNameMap<S>)[key]; 
            return obj;
          }, {});
        }
      });
      return "";
    }