diff --git a/tests/baselines/reference/readonlyArraysAndTuples.errors.txt b/tests/baselines/reference/readonlyArraysAndTuples.errors.txt index dd973def9a2..aa196e25993 100644 --- a/tests/baselines/reference/readonlyArraysAndTuples.errors.txt +++ b/tests/baselines/reference/readonlyArraysAndTuples.errors.txt @@ -1,13 +1,16 @@ -tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(10,5): error TS2740: Type 'readonly string[]' is missing the following properties from type 'string[]': pop, push, reverse, shift, and 3 more. -tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(12,5): error TS2740: Type 'readonly [string, string]' is missing the following properties from type 'string[]': pop, push, reverse, shift, and 3 more. -tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(16,5): error TS2739: Type 'string[]' is missing the following properties from type '[string, string]': 0, 1 -tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(17,5): error TS2740: Type 'readonly string[]' is missing the following properties from type '[string, string]': 0, 1, pop, push, and 5 more. -tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(18,5): error TS2740: Type 'readonly [string, string]' is missing the following properties from type '[string, string]': pop, push, reverse, shift, and 3 more. -tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(19,5): error TS2739: Type 'string[]' is missing the following properties from type 'readonly [string, string]': 0, 1 -tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(20,5): error TS2739: Type 'readonly string[]' is missing the following properties from type 'readonly [string, string]': 0, 1 +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(9,12): error TS1354: 'readonly' type modifier is only permitted on array and tuple types. +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(10,15): error TS1354: 'readonly' type modifier is only permitted on array and tuple types. +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(11,12): error TS1354: 'readonly' type modifier is only permitted on array and tuple types. +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(14,5): error TS2740: Type 'readonly string[]' is missing the following properties from type 'string[]': pop, push, reverse, shift, and 3 more. +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(16,5): error TS2740: Type 'readonly [string, string]' is missing the following properties from type 'string[]': pop, push, reverse, shift, and 3 more. +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(20,5): error TS2739: Type 'string[]' is missing the following properties from type '[string, string]': 0, 1 +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(21,5): error TS2740: Type 'readonly string[]' is missing the following properties from type '[string, string]': 0, 1, pop, push, and 5 more. +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(22,5): error TS2740: Type 'readonly [string, string]' is missing the following properties from type '[string, string]': pop, push, reverse, shift, and 3 more. +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(23,5): error TS2739: Type 'string[]' is missing the following properties from type 'readonly [string, string]': 0, 1 +tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(24,5): error TS2739: Type 'readonly string[]' is missing the following properties from type 'readonly [string, string]': 0, 1 -==== tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts (7 errors) ==== +==== tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts (10 errors) ==== type T10 = string[]; type T11 = Array; type T12 = readonly string[]; @@ -16,6 +19,16 @@ tests/cases/conformance/types/tuple/readonlyArraysAndTuples.ts(20,5): error TS27 type T20 = [number, number]; type T21 = readonly [number, number]; + type T30 = readonly string; // Error + ~~~~~~~~ +!!! error TS1354: 'readonly' type modifier is only permitted on array and tuple types. + type T31 = readonly T; // Error + ~~~~~~~~ +!!! error TS1354: 'readonly' type modifier is only permitted on array and tuple types. + type T32 = readonly readonly string[]; // Error + ~~~~~~~~ +!!! error TS1354: 'readonly' type modifier is only permitted on array and tuple types. + function f1(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) { ma = ra; // Error ~~ diff --git a/tests/baselines/reference/readonlyArraysAndTuples.js b/tests/baselines/reference/readonlyArraysAndTuples.js index 769ff504251..5eccff64197 100644 --- a/tests/baselines/reference/readonlyArraysAndTuples.js +++ b/tests/baselines/reference/readonlyArraysAndTuples.js @@ -7,6 +7,10 @@ type T13 = ReadonlyArray; type T20 = [number, number]; type T21 = readonly [number, number]; +type T30 = readonly string; // Error +type T31 = readonly T; // Error +type T32 = readonly readonly string[]; // Error + function f1(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) { ma = ra; // Error ma = mt; diff --git a/tests/baselines/reference/readonlyArraysAndTuples.symbols b/tests/baselines/reference/readonlyArraysAndTuples.symbols index 1d6c7dd1dfa..d8b383be479 100644 --- a/tests/baselines/reference/readonlyArraysAndTuples.symbols +++ b/tests/baselines/reference/readonlyArraysAndTuples.symbols @@ -19,59 +19,70 @@ type T20 = [number, number]; type T21 = readonly [number, number]; >T21 : Symbol(T21, Decl(readonlyArraysAndTuples.ts, 5, 28)) +type T30 = readonly string; // Error +>T30 : Symbol(T30, Decl(readonlyArraysAndTuples.ts, 6, 37)) + +type T31 = readonly T; // Error +>T31 : Symbol(T31, Decl(readonlyArraysAndTuples.ts, 8, 27)) +>T : Symbol(T, Decl(readonlyArraysAndTuples.ts, 9, 9)) +>T : Symbol(T, Decl(readonlyArraysAndTuples.ts, 9, 9)) + +type T32 = readonly readonly string[]; // Error +>T32 : Symbol(T32, Decl(readonlyArraysAndTuples.ts, 9, 25)) + function f1(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) { ->f1 : Symbol(f1, Decl(readonlyArraysAndTuples.ts, 6, 37)) ->ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 8, 12)) ->ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 8, 25)) ->mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 8, 48)) ->rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 8, 70)) +>f1 : Symbol(f1, Decl(readonlyArraysAndTuples.ts, 10, 38)) +>ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 12, 12)) +>ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 12, 25)) +>mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 12, 48)) +>rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 12, 70)) ma = ra; // Error ->ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 8, 12)) ->ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 8, 25)) +>ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 12, 12)) +>ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 12, 25)) ma = mt; ->ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 8, 12)) ->mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 8, 48)) +>ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 12, 12)) +>mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 12, 48)) ma = rt; // Error ->ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 8, 12)) ->rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 8, 70)) +>ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 12, 12)) +>rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 12, 70)) ra = ma; ->ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 8, 25)) ->ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 8, 12)) +>ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 12, 25)) +>ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 12, 12)) ra = mt; ->ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 8, 25)) ->mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 8, 48)) +>ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 12, 25)) +>mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 12, 48)) ra = rt; ->ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 8, 25)) ->rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 8, 70)) +>ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 12, 25)) +>rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 12, 70)) mt = ma; // Error ->mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 8, 48)) ->ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 8, 12)) +>mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 12, 48)) +>ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 12, 12)) mt = ra; // Error ->mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 8, 48)) ->ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 8, 25)) +>mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 12, 48)) +>ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 12, 25)) mt = rt; // Error ->mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 8, 48)) ->rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 8, 70)) +>mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 12, 48)) +>rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 12, 70)) rt = ma; // Error ->rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 8, 70)) ->ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 8, 12)) +>rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 12, 70)) +>ma : Symbol(ma, Decl(readonlyArraysAndTuples.ts, 12, 12)) rt = ra; // Error ->rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 8, 70)) ->ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 8, 25)) +>rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 12, 70)) +>ra : Symbol(ra, Decl(readonlyArraysAndTuples.ts, 12, 25)) rt = mt; ->rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 8, 70)) ->mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 8, 48)) +>rt : Symbol(rt, Decl(readonlyArraysAndTuples.ts, 12, 70)) +>mt : Symbol(mt, Decl(readonlyArraysAndTuples.ts, 12, 48)) } diff --git a/tests/baselines/reference/readonlyArraysAndTuples.types b/tests/baselines/reference/readonlyArraysAndTuples.types index a7917f5da2b..c2509785a9b 100644 --- a/tests/baselines/reference/readonlyArraysAndTuples.types +++ b/tests/baselines/reference/readonlyArraysAndTuples.types @@ -17,6 +17,15 @@ type T20 = [number, number]; type T21 = readonly [number, number]; >T21 : readonly [number, number] +type T30 = readonly string; // Error +>T30 : string + +type T31 = readonly T; // Error +>T31 : T + +type T32 = readonly readonly string[]; // Error +>T32 : readonly string[] + function f1(ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) { >f1 : (ma: string[], ra: readonly string[], mt: [string, string], rt: readonly [string, string]) => void >ma : string[]