From 7efd93a9655b44562642f49292a05169d9a7cadf Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 2 May 2015 16:57:18 -0700 Subject: [PATCH] Adding test --- .../circularTypeofWithVarOrFunc.errors.txt | 28 +++++++++++++++++++ .../reference/circularTypeofWithVarOrFunc.js | 17 +++++++++++ .../circularTypeofWithVarOrFunc.ts | 9 ++++++ 3 files changed, 54 insertions(+) create mode 100644 tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt create mode 100644 tests/baselines/reference/circularTypeofWithVarOrFunc.js create mode 100644 tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts diff --git a/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt b/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt new file mode 100644 index 0000000000..26bff709ae --- /dev/null +++ b/tests/baselines/reference/circularTypeofWithVarOrFunc.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(1,6): error TS2456: Type alias 'typeAlias1' circularly references itself. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(2,5): error TS2502: 'varOfAliasedType1' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(4,5): error TS2502: 'varOfAliasedType2' is referenced directly or indirectly in its own type annotation. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(5,6): error TS2456: Type alias 'typeAlias2' circularly references itself. +tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts(9,6): error TS2456: Type alias 'typeAlias3' circularly references itself. + + +==== tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts (5 errors) ==== + type typeAlias1 = typeof varOfAliasedType1; + ~~~~~~~~~~ +!!! error TS2456: Type alias 'typeAlias1' circularly references itself. + var varOfAliasedType1: typeAlias1; + ~~~~~~~~~~~~~~~~~ +!!! error TS2502: 'varOfAliasedType1' is referenced directly or indirectly in its own type annotation. + + var varOfAliasedType2: typeAlias2; + ~~~~~~~~~~~~~~~~~ +!!! error TS2502: 'varOfAliasedType2' is referenced directly or indirectly in its own type annotation. + type typeAlias2 = typeof varOfAliasedType2; + ~~~~~~~~~~ +!!! error TS2456: Type alias 'typeAlias2' circularly references itself. + + function func(): typeAlias3 { return null; } + var varOfAliasedType3 = func(); + type typeAlias3 = typeof varOfAliasedType3; + ~~~~~~~~~~ +!!! error TS2456: Type alias 'typeAlias3' circularly references itself. + \ No newline at end of file diff --git a/tests/baselines/reference/circularTypeofWithVarOrFunc.js b/tests/baselines/reference/circularTypeofWithVarOrFunc.js new file mode 100644 index 0000000000..9d569a3d21 --- /dev/null +++ b/tests/baselines/reference/circularTypeofWithVarOrFunc.js @@ -0,0 +1,17 @@ +//// [circularTypeofWithVarOrFunc.ts] +type typeAlias1 = typeof varOfAliasedType1; +var varOfAliasedType1: typeAlias1; + +var varOfAliasedType2: typeAlias2; +type typeAlias2 = typeof varOfAliasedType2; + +function func(): typeAlias3 { return null; } +var varOfAliasedType3 = func(); +type typeAlias3 = typeof varOfAliasedType3; + + +//// [circularTypeofWithVarOrFunc.js] +var varOfAliasedType1; +var varOfAliasedType2; +function func() { return null; } +var varOfAliasedType3 = func(); diff --git a/tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts b/tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts new file mode 100644 index 0000000000..e3483aa27d --- /dev/null +++ b/tests/cases/conformance/types/specifyingTypes/typeQueries/circularTypeofWithVarOrFunc.ts @@ -0,0 +1,9 @@ +type typeAlias1 = typeof varOfAliasedType1; +var varOfAliasedType1: typeAlias1; + +var varOfAliasedType2: typeAlias2; +type typeAlias2 = typeof varOfAliasedType2; + +function func(): typeAlias3 { return null; } +var varOfAliasedType3 = func(); +type typeAlias3 = typeof varOfAliasedType3;