142 lines
No EOL
11 KiB
Text
142 lines
No EOL
11 KiB
Text
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(16,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(18,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(19,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(20,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(21,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(22,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(23,5): error TS2411: Property 'foo11' of type 'A2<number>' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(24,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(25,5): error TS2411: Property 'foo13' of type '<T>(x: T) => T' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(26,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(27,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(28,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(29,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(30,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'string | number'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(35,5): error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(37,5): error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(39,5): error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(40,5): error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(41,5): error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(42,5): error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(43,5): error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(44,5): error TS2411: Property 'foo11' of type 'A2<number>' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(45,5): error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(46,5): error TS2411: Property 'foo13' of type '<T>(x: T) => T' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(47,5): error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(48,5): error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(49,5): error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(50,5): error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number | E'.
|
|
tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts(51,5): error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number | E'.
|
|
|
|
|
|
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypesOfUnion.ts (29 errors) ====
|
|
enum E { e1, e2 }
|
|
interface I8 { [x: string]: number[]; }
|
|
class A { foo: number; }
|
|
class A2<T> { foo: T; }
|
|
function f() { }
|
|
module f { export var bar = 1; }
|
|
class c { baz: string }
|
|
module c { export var bar = 1; }
|
|
|
|
// A type T is a subtype of a union type U if T is a subtype of any type in U.
|
|
interface I1<T> {
|
|
[x: string]: string | number;
|
|
foo: any; // ok
|
|
foo2: string; // ok
|
|
foo3: number; // ok
|
|
foo4: boolean; // error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'string | number'.
|
|
foo5: E; // ok - subtype of number
|
|
foo6: Date; // error
|
|
~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'string | number'.
|
|
foo7: RegExp; // error
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'string | number'.
|
|
foo8: { bar: number }; // error
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'string | number'.
|
|
foo9: I8; // error
|
|
~~~~~~~~~
|
|
!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'string | number'.
|
|
foo10: A; // error
|
|
~~~~~~~~~
|
|
!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'string | number'.
|
|
foo11: A2<number>; // error
|
|
~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo11' of type 'A2<number>' is not assignable to string index type 'string | number'.
|
|
foo12: (x) => number; //error
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'string | number'.
|
|
foo13: <T>(x: T) => T; // error
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo13' of type '<T>(x: T) => T' is not assignable to string index type 'string | number'.
|
|
foo14: typeof f; // error
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'string | number'.
|
|
foo15: typeof c; // error
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'string | number'.
|
|
foo16: T; // error
|
|
~~~~~~~~~
|
|
!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'string | number'.
|
|
foo17: Object; // error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'string | number'.
|
|
foo18: {}; // error
|
|
~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'string | number'.
|
|
}
|
|
interface I2<T> {
|
|
[x: string]: E | number;
|
|
foo: any; // ok
|
|
foo2: string; // error
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo2' of type 'string' is not assignable to string index type 'number | E'.
|
|
foo3: number; // ok
|
|
foo4: boolean; // error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo4' of type 'boolean' is not assignable to string index type 'number | E'.
|
|
foo5: E; // ok
|
|
foo6: Date; // error
|
|
~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo6' of type 'Date' is not assignable to string index type 'number | E'.
|
|
foo7: RegExp; // error
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo7' of type 'RegExp' is not assignable to string index type 'number | E'.
|
|
foo8: { bar: number }; // error
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo8' of type '{ bar: number; }' is not assignable to string index type 'number | E'.
|
|
foo9: I8; // error
|
|
~~~~~~~~~
|
|
!!! error TS2411: Property 'foo9' of type 'I8' is not assignable to string index type 'number | E'.
|
|
foo10: A; // error
|
|
~~~~~~~~~
|
|
!!! error TS2411: Property 'foo10' of type 'A' is not assignable to string index type 'number | E'.
|
|
foo11: A2<number>; // error
|
|
~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo11' of type 'A2<number>' is not assignable to string index type 'number | E'.
|
|
foo12: (x) => number; //error
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo12' of type '(x: any) => number' is not assignable to string index type 'number | E'.
|
|
foo13: <T>(x: T) => T; // error
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo13' of type '<T>(x: T) => T' is not assignable to string index type 'number | E'.
|
|
foo14: typeof f; // error
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo14' of type 'typeof f' is not assignable to string index type 'number | E'.
|
|
foo15: typeof c; // error
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo15' of type 'typeof c' is not assignable to string index type 'number | E'.
|
|
foo16: T; // error
|
|
~~~~~~~~~
|
|
!!! error TS2411: Property 'foo16' of type 'T' is not assignable to string index type 'number | E'.
|
|
foo17: Object; // error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo17' of type 'Object' is not assignable to string index type 'number | E'.
|
|
foo18: {}; // error
|
|
~~~~~~~~~~
|
|
!!! error TS2411: Property 'foo18' of type '{}' is not assignable to string index type 'number | E'.
|
|
} |