TypeScript/tests/baselines/reference/intrinsicTypes.errors.txt

86 lines
4.4 KiB
Plaintext

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>; // string
type TU4 = Uppercase<any>; // 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>; // string
type TL4 = Lowercase<any>; // 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>; // string
type TC4 = Capitalize<any>; // 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>; // string
type TN4 = Uncapitalize<any>; // 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);
}