diff --git a/tests/baselines/reference/unionTypeLiterals.js b/tests/baselines/reference/unionTypeLiterals.js new file mode 100644 index 0000000000..3e23d47d15 --- /dev/null +++ b/tests/baselines/reference/unionTypeLiterals.js @@ -0,0 +1,29 @@ +//// [unionTypeLiterals.ts] +// basic valid forms of union literals + +var simpleUnion: string | number; +var unionOfUnion: string | number | boolean; + +var arrayOfUnions: (string | number)[]; +var arrayOfUnions: Array; + +var unionOfFunctionType: (() => string) | (() => number); +var unionOfFunctionType: { (): string } | { (): number }; +var unionOfFunctionType: () => string | number; + +var unionOfConstructorType: (new () => string) | (new () => number); +var unionOfConstructorType: { new (): string } | { new (): number }; +var unionOfConstructorType: new () => string | number; + +//// [unionTypeLiterals.js] +// basic valid forms of union literals +var simpleUnion; +var unionOfUnion; +var arrayOfUnions; +var arrayOfUnions; +var unionOfFunctionType; +var unionOfFunctionType; +var unionOfFunctionType; +var unionOfConstructorType; +var unionOfConstructorType; +var unionOfConstructorType; diff --git a/tests/baselines/reference/unionTypeLiterals.types b/tests/baselines/reference/unionTypeLiterals.types new file mode 100644 index 0000000000..90bc4649aa --- /dev/null +++ b/tests/baselines/reference/unionTypeLiterals.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/unionTypeLiterals.ts === +// basic valid forms of union literals + +var simpleUnion: string | number; +>simpleUnion : string | number + +var unionOfUnion: string | number | boolean; +>unionOfUnion : string | number | boolean + +var arrayOfUnions: (string | number)[]; +>arrayOfUnions : (string | number)[] + +var arrayOfUnions: Array; +>arrayOfUnions : (string | number)[] +>Array : T[] + +var unionOfFunctionType: (() => string) | (() => number); +>unionOfFunctionType : (() => string) | (() => number) + +var unionOfFunctionType: { (): string } | { (): number }; +>unionOfFunctionType : (() => string) | (() => number) + +var unionOfFunctionType: () => string | number; +>unionOfFunctionType : (() => string) | (() => number) + +var unionOfConstructorType: (new () => string) | (new () => number); +>unionOfConstructorType : (new () => string) | (new () => number) + +var unionOfConstructorType: { new (): string } | { new (): number }; +>unionOfConstructorType : (new () => string) | (new () => number) + +var unionOfConstructorType: new () => string | number; +>unionOfConstructorType : (new () => string) | (new () => number) + diff --git a/tests/cases/conformance/types/specifyingTypes/typeLiterals/unionTypeLiterals.ts b/tests/cases/conformance/types/specifyingTypes/typeLiterals/unionTypeLiterals.ts new file mode 100644 index 0000000000..7d52182beb --- /dev/null +++ b/tests/cases/conformance/types/specifyingTypes/typeLiterals/unionTypeLiterals.ts @@ -0,0 +1,15 @@ +// basic valid forms of union literals + +var simpleUnion: string | number; +var unionOfUnion: string | number | boolean; + +var arrayOfUnions: (string | number)[]; +var arrayOfUnions: Array; + +var unionOfFunctionType: (() => string) | (() => number); +var unionOfFunctionType: { (): string } | { (): number }; +var unionOfFunctionType: () => string | number; + +var unionOfConstructorType: (new () => string) | (new () => number); +var unionOfConstructorType: { new (): string } | { new (): number }; +var unionOfConstructorType: new () => string | number; \ No newline at end of file