File: intrinsicTypes.errors.txt

package info (click to toggle)
node-typescript 4.9.5%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 533,908 kB
  • sloc: javascript: 2,018,330; makefile: 7; sh: 1
file content (86 lines) | stat: -rw-r--r-- 4,588 bytes parent folder | download | duplicates (3)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(6,22): error TS2344: Type 'number' does not satisfy the constraint 'string'.
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(13,22): error TS2344: Type 'number' does not satisfy the constraint 'string'.
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(20,23): error TS2344: Type 'number' does not satisfy the constraint 'string'.
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(27,25): error TS2344: Type 'number' does not satisfy the constraint 'string'.
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(35,38): error TS2795: The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types.
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(40,5): error TS2322: Type 'string' is not assignable to type 'Uppercase<T>'.
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(42,5): error TS2322: Type 'string' is not assignable to type 'Uppercase<U>'.
tests/cases/conformance/types/typeAliases/intrinsicTypes.ts(43,5): error TS2322: Type 'Uppercase<T>' is not assignable to type 'Uppercase<U>'.
  Type 'T' is not assignable to type 'U'.
    'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string'.


==== tests/cases/conformance/types/typeAliases/intrinsicTypes.ts (8 errors) ====
    type TU1 = Uppercase<'hello'>;  // "HELLO"
    type TU2 = Uppercase<'foo' | 'bar'>;  // "FOO" | "BAR"
    type TU3 = Uppercase<string>;  // Uppercase<string>
    type TU4 = Uppercase<any>;  // Uppercase<`${any}`>
    type TU5 = Uppercase<never>;  // never
    type TU6 = Uppercase<42>;  // Error
                         ~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'string'.
    
    type TL1 = Lowercase<'HELLO'>;  // "hello"
    type TL2 = Lowercase<'FOO' | 'BAR'>;  // "foo" | "bar"
    type TL3 = Lowercase<string>;  // Lowercase<string>
    type TL4 = Lowercase<any>;  // Lowercase<`${any}`>
    type TL5 = Lowercase<never>;  // never
    type TL6 = Lowercase<42>;  // Error
                         ~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'string'.
    
    type TC1 = Capitalize<'hello'>;  // "Hello"
    type TC2 = Capitalize<'foo' | 'bar'>;  // "Foo" | "Bar"
    type TC3 = Capitalize<string>;  // Capitalize<string>
    type TC4 = Capitalize<any>;  // Capitalize<`${any}`>
    type TC5 = Capitalize<never>;  // never
    type TC6 = Capitalize<42>;  // Error
                          ~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'string'.
    
    type TN1 = Uncapitalize<'Hello'>;  // "hello"
    type TN2 = Uncapitalize<'Foo' | 'Bar'>;  // "foo" | "bar"
    type TN3 = Uncapitalize<string>;  // Uncapitalize<string>
    type TN4 = Uncapitalize<any>;  // Uncapitalize<`${any}`>
    type TN5 = Uncapitalize<never>;  // never
    type TN6 = Uncapitalize<42>;  // Error
                            ~~
!!! error TS2344: Type 'number' does not satisfy the constraint 'string'.
    
    type TX1<S extends string> = Uppercase<`aB${S}`>;
    type TX2 = TX1<'xYz'>;  // "ABXYZ"
    type TX3<S extends string> = Lowercase<`aB${S}`>;
    type TX4 = TX3<'xYz'>;  // "abxyz"
    type TX5 = `${Uppercase<'abc'>}${Lowercase<'XYZ'>}`;  // "ABCxyz"
    
    type MyUppercase<S extends string> = intrinsic;  // Error
                                         ~~~~~~~~~
!!! error TS2795: The 'intrinsic' keyword can only be used to declare compiler provided intrinsic types.
    
    function foo1<T extends string, U extends T>(s: string, x: Uppercase<T>, y: Uppercase<U>) {
        s = x;
        s = y;
        x = s;  // Error
        ~
!!! error TS2322: Type 'string' is not assignable to type 'Uppercase<T>'.
        x = y;
        y = s;  // Error
        ~
!!! error TS2322: Type 'string' is not assignable to type 'Uppercase<U>'.
        y = x;  // Error
        ~
!!! error TS2322: Type 'Uppercase<T>' is not assignable to type 'Uppercase<U>'.
!!! error TS2322:   Type 'T' is not assignable to type 'U'.
!!! error TS2322:     'T' is assignable to the constraint of type 'U', but 'U' could be instantiated with a different subtype of constraint 'string'.
    }
    
    function foo2<T extends 'foo' | 'bar'>(x: Uppercase<T>) {
        let s: 'FOO' | 'BAR' = x;
    }
    
    declare function foo3<T extends string>(x: Uppercase<T>): T;
    
    function foo4<U extends string>(x: Uppercase<U>) {
        return foo3(x);
    }