8000 Improved support for read-only arrays and tuples by ahejlsberg · Pull Request #29435 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content

Improved support for read-only arrays and tuples #29435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
903863a
Respect readonly mapped type modifier when mapping arrays and tuples
ahejlsberg Jan 12, 2019
bb8378f
Support 'readonly' type modifier on array and tuple types
ahejlsberg Jan 15, 2019
7b00a29
Accept new baselines
ahejlsberg Jan 15, 2019
db840f4
Update array/tuple relationship checking
ahejlsberg Jan 15, 2019
cff7874
Add tests
ahejlsberg Jan 15, 2019
a7ca7f4
Accept new baselines
ahejlsberg Jan 15, 2019
2256f91
Fix typo
ahejlsberg Jan 16, 2019
2ccc106
Add more tests
ahejlsberg Jan 16, 2019
b611a51
Accept new baselines
ahejlsberg Jan 16, 2019
0eac506
Add .d.ts generation test
ahejlsberg Jan 16, 2019
d24a63d
Accept new baselines
ahejlsberg Jan 16, 2019
e581649
Allow rest parameter type to be a readonly array or tuple
ahejlsberg Jan 17, 2019
2200d35
Add tests
ahejlsberg Jan 18, 2019
ef89d26
Accept new baselines
ahejlsberg Jan 18, 2019
4706a06
Merge branch 'master' into readonlyArrayTuple
ahejlsberg Jan 26, 2019
e290559
Add tests for decorators and declaration emit from error free source
ahejlsberg Jan 26, 2019
cd1f289
Accept new baselines
ahejlsberg Jan 26, 2019
4335f44
Tuples are known to be covaraint
ahejlsberg Jan 28, 2019
ea38146
Error on union types that are too complex to represent
ahejlsberg Jan 28, 2019
e727845
Higher complexity limit for unions of primitives only
ahejlsberg Jan 28, 2019
d86612c
Accept new baselines
ahejlsberg Jan 28, 2019
45af34d
Add subtype reduction complexity limit test
ahejlsberg Jan 28, 2019
54ba2cc
Accept new baselines
ahejlsberg Jan 28, 2019
151fac9
Merge branch 'master' into readonlyArrayTuple
ahejlsberg Jan 28, 2019
ff42c3d
Handle readonly arrays and tuples in decorator metadata serialization
ahejlsberg Jan 29, 2019
815f133
Accept new baselines
ahejlsberg Jan 29, 2019
3324684
Fix lint error
ahejlsberg Jan 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accept new baselines
  • Loading branch information
ahejlsberg committed Jan 15, 2019
commit 7b00a29b1c6a3bd68c8924e4d74ce62be7d4835c
7 changes: 4 additions & 3 deletions tests/baselines/reference/api/tsserverlibrary.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ declare namespace ts {
}
interface TypeOperatorNode extends TypeNode {
kind: SyntaxKind.TypeOperator;
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword;
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword;
type: TypeNode;
}
interface IndexedAccessTypeNode extends TypeNode {
Expand Down Expand Up @@ -2282,6 +2282,7 @@ declare namespace ts {
interface TupleType extends GenericType {
minLength: number;
hasRestElement: boolean;
readonly: boolean;
associatedNames?: __String[];
}
interface TupleTypeReference extends TypeReference {
Expand Down Expand Up @@ -3754,7 +3755,7 @@ declare namespace ts {
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
function createThisTypeNode(): ThisTypeNode;
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode;
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode;
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
Expand Down Expand Up @@ -8326,7 +8327,7 @@ declare namespace ts.server {
excludedFiles: ReadonlyArray<NormalizedPath>;
private typeAcquisition;
updateGraph(): boolean;
getExcludedFiles(): ReadonlyArray<NormalizedPath>;
getExcludedFiles(): readonly NormalizedPath[];
getTypeAcquisition(): TypeAcquisition;
setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void;
}
Expand Down
5 changes: 3 additions & 2 deletions tests/baselines/reference/api/typescript.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ declare namespace ts {
}
interface TypeOperatorNode extends TypeNode {
kind: SyntaxKind.TypeOperator;
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword;
operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword;
type: TypeNode;
}
interface IndexedAccessTypeNode extends TypeNode {
Expand Down Expand Up @@ -2282,6 +2282,7 @@ declare namespace ts {
interface TupleType extends GenericType {
minLength: number;
hasRestElement: boolean;
readonly: boolean;
associatedNames?: __String[];
}
interface TupleTypeReference extends TypeReference {
Expand Down Expand Up @@ -3754,7 +3755,7 @@ declare namespace ts {
function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode;
function createThisTypeNode(): ThisTypeNode;
function createTypeOperatorNode(type: TypeNode): TypeOperatorNode;
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword, type: TypeNode): TypeOperatorNode;
function createTypeOperatorNode(operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode;
function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode;
function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode;
Expand Down
10 changes: 5 additions & 5 deletions tests/baselines/reference/arrayFind.types
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ const foundNumber: number | undefined = arrayOfStringsNumbersAndBooleans.find(is
>isNumber : (x: any) => x is number

const readonlyArrayOfStringsNumbersAndBooleans = arrayOfStringsNumbersAndBooleans as ReadonlyArray<string | number | boolean>;
>readonlyArrayOfStringsNumbersAndBooleans : ReadonlyArray<string | number | boolean>
>arrayOfStringsNumbersAndBooleans as ReadonlyArray<string | number | boolean> : ReadonlyArray<string | number | boolean>
>readonlyArrayOfStringsNumbersAndBooleans : readonly (string | number | boolean)[]
>arrayOfStringsNumbersAndBooleans as ReadonlyArray<string | number | boolean> : readonly (string | number | boolean)[]
>arrayOfStringsNumbersAndBooleans : (string | number | boolean)[]

const readonlyFoundNumber: number | undefined = readonlyArrayOfStringsNumbersAndBooleans.find(isNumber);
>readonlyFoundNumber : number
>readonlyArrayOfStringsNumbersAndBooleans.find(isNumber) : number
>readonlyArrayOfStringsNumbersAndBooleans.find : { <S extends string | number | boolean>(predicate: (this: void, value: string | number | boolean, index: number, obj: ReadonlyArray<string | number | boolean>) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: ReadonlyArray<string | number | boolean>) => boolean, thisArg?: any): string | number | boolean; }
>readonlyArrayOfStringsNumbersAndBooleans : ReadonlyArray<string | number | boolean>
>find : { <S extends string | number | boolean>(predicate: (this: void, value: string | number | boolean, index: number, obj: ReadonlyArray<string | number | boolean>) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: ReadonlyArray<string | number | boolean>) => boolean, thisArg?: any): string | number | boolean; }
>readonlyArrayOfStringsNumbersAndBooleans.find : { <S extends string | number | boolean>(predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; }
>readonlyArrayOfStringsNumbersAndBooleans : readonly (string | number | boolean)[]
>find : { <S extends string | number | boolean>(predicate: (this: void, value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => value is S, thisArg?: any): S; (predicate: (value: string | number | boolean, index: number, obj: readonly (string | number | boolean)[]) => boolean, thisArg?: any): string | number | boolean; }
>isNumber : (x: any) => x is number

16 changes: 8 additions & 8 deletions tests/baselines/reference/arrayFlatMap.types
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ const array: number[] = [];
>[] : undefined[]

const readonlyArray: ReadonlyArray<number> = [];
>readonlyArray : ReadonlyArray<number>
>readonlyArray : readonly number[]
>[] : undefined[]

array.flatMap((): ReadonlyArray<number> => []); // ok
>array.flatMap((): ReadonlyArray<number> => []) : number[]
>array.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
>array.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]
>array : number[]
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
>(): ReadonlyArray<number> => [] : () => ReadonlyArray<number>
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]
>(): ReadonlyArray<number> => [] : () => readonly number[]
>[] : undefined[]

readonlyArray.flatMap((): ReadonlyArray<number> => []); // ok
>readonlyArray.flatMap((): ReadonlyArray<number> => []) : number[]
>readonlyArray.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
>readonlyArray : ReadonlyArray<number>
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | ReadonlyArray<U>, thisArg?: This) => U[]
>(): ReadonlyArray<number> => [] : () => ReadonlyArray<number>
>readonlyArray.flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]
>readonlyArray : readonly number[]
>flatMap : <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This) => U[]
>(): ReadonlyArray<number> => [] : () => readonly number[]
>[] : undefined[]

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray<B>'.
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'readonly B[]'.
Property 'b' is missing in type 'A' but required in type 'B'.
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C<A>' is not assignable to type 'ReadonlyArray<B>'.
tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C<A>' is not assignable to type 'readonly B[]'.
Types of property 'concat' are incompatible.
Type '{ (...items: ConcatArray<A>[]): A[]; (...items: (A | ConcatArray<A>)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray<B>[]): B[]; (...items: (B | ConcatArray<B>)[]): B[]; }'.
Type 'A[]' is not assignable to type 'B[]'.
Expand All @@ -22,7 +22,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T
rra = arb;
rrb = ara; // error: 'A' is not assignable to 'B'
~~~
!!! error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray<B>'.
!!! error TS2322: Type 'A[]' is not assignable to type 'readonly B[]'.
!!! error TS2322: Property 'b' is missing in type 'A' but required in type 'B'.
!!! related TS2728 tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts:2:21: 'b' is declared here.

Expand All @@ -31,7 +31,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T
rrb = crb;
rrb = cra; // error: 'A' is not assignable to 'B'
~~~
!!! error TS2322: Type 'C<A>' is not assignable to type 'ReadonlyArray<B>'.
!!! error TS2322: Type 'C<A>' is not assignable to type 'readonly B[]'.
!!! error TS2322: Types of property 'concat' are incompatible.
!!! error TS2322: Type '{ (...items: ConcatArray<A>[]): A[]; (...items: (A | ConcatArray<A>)[]): A[]; }' is not assignable to type '{ (...items: ConcatArray<B>[]): B[]; (...items: (B | ConcatArray<B>)[]): B[]; }'.
!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,48 +26,48 @@ declare var crb: C<B>;
>crb : C<B>

declare var rra: ReadonlyArray<A>;
>rra : ReadonlyArray<A>
>rra : readonly A[]

declare var rrb: ReadonlyArray<B>;
>rrb : ReadonlyArray<B>
>rrb : readonly B[]

rra = ara;
>rra = ara : A[]
>rra : ReadonlyArray<A>
>rra : readonly A[]
>ara : A[]

rrb = arb; // OK, Array<B> is assignable to ReadonlyArray<A>
>rrb = arb : B[]
>rrb : ReadonlyArray<B>
>rrb : readonly B[]
>arb : B[]

rra = arb;
>rra = arb : B[]
>rra : ReadonlyArray<A>
>rra : readonly A[]
>arb : B[]

rrb = ara; // error: 'A' is not assignable to 'B'
>rrb = ara : A[]
>rrb : ReadonlyArray<B>
>rrb : readonly B[]
>ara : A[]

rra = cra;
>rra = cra : C<A>
>rra : ReadonlyArray<A>
>rra : readonly A[]
>cra : C<A>

rra = crb; // OK, C<B> is assignable to ReadonlyArray<A>
>rra = crb : C<B>
>rra : ReadonlyArray<A>
>rra : readonly A[]
>crb : C<B>

rrb = crb;
>rrb = crb : C<B>
>rrb : ReadonlyArray<B>
>rrb : readonly B[]
>crb : C<B>

rrb = cra; // error: 'A' is not assignable to 'B'
>rrb = cra : C<A>
>rrb : ReadonlyArray<B>
>rrb : readonly B[]
>cra : C<A>

10 changes: 5 additions & 5 deletions tests/baselines/reference/bivariantInferences.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

interface Array<T> {
equalsShallow<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>): boolean;
>equalsShallow : <T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean
>this : ReadonlyArray<T>
>other : ReadonlyArray<T>
>equalsShallow : <T>(this: readonly T[], other: readonly T[]) => boolean
>this : readonly T[]
>other : readonly T[]
}

declare const a: (string | number)[] | null[] | undefined[] | {}[];
Expand All @@ -19,8 +19,8 @@ declare const b: (string | number)[] | null[] | undefined[] | {}[];
let x = a.equalsShallow(b);
>x : boolean
>a.equalsShallow(b) : boolean
>a.equalsShallow : (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean)
>a.equalsShallow : (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean)
>a : (string | number)[] | null[] | undefined[] | {}[]
>equalsShallow : (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean) | (<T>(this: ReadonlyArray<T>, other: ReadonlyArray<T>) => boolean)
>equalsShallow : (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean) | (<T>(this: readonly T[], other: readonly T[]) => boolean)
>b : (string | number)[] | null[] | undefined[] | {}[]

8 changes: 4 additions & 4 deletions tests/baselines/reference/circularContextualReturnType.types
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@

Object.freeze({
>Object.freeze({ foo() { return Object.freeze('a'); },}) : Readonly<{ foo(): string; }>
>Object.freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>Object : ObjectConstructor
>freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>{ foo() { return Object.freeze('a'); },} : { foo(): string; }

foo() {
>foo : () => string

return Object.freeze('a');
>Object.freeze('a') : string
>Object.freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>Object : ObjectConstructor
>freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>'a' : "a"

},
Expand Down
6 changes: 3 additions & 3 deletions tests/baselines/reference/doNotInferUnrelatedTypes.types
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
=== tests/cases/compiler/doNotInferUnrelatedTypes.ts ===
// #16709
declare function dearray<T>(ara: ReadonlyArray<T>): T;
>dearray : <T>(ara: ReadonlyArray<T>) => T
>ara : ReadonlyArray<T>
>dearray : <T>(ara: readonly T[]) => T
>ara : readonly T[]

type LiteralType = "foo" | "bar";
>LiteralType : LiteralType
Expand All @@ -13,6 +13,6 @@ declare var alt: Array<LiteralType>;
let foo: LiteralType = dearray(alt);
>foo : LiteralType
>dearray(alt) : LiteralType
>dearray : <T>(ara: ReadonlyArray<T>) => T
>dearray : <T>(ara: readonly T[]) => T
>alt : LiteralType[]

2 changes: 1 addition & 1 deletion tests/baselines/reference/intersectionTypeInference3.types
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ declare function from<T>(): T[];
>from : <T>() => T[]

const c2: ReadonlyArray<A> = from();
>c2 : ReadonlyArray<Nominal<"A", string>>
>c2 : readonly Nominal<"A", string>[]
>from() : Nominal<"A", string>[]
>from : <T>() => T[]

4 changes: 2 additions & 2 deletions tests/baselines/reference/keyofAndIndexedAccess.types
Original file line number Diff line number Diff line change
Expand Up @@ -1873,9 +1873,9 @@ class SampleClass<P> {
>this : this
>props : Readonly<P>
>Object.freeze(props) : Readonly<P>
>Object.freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>Object.freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>Object : ObjectConstructor
>freeze : { <T>(a: T[]): ReadonlyArray<T>; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>freeze : { <T>(a: T[]): readonly T[]; <T extends Function>(f: T): T; <T>(o: T): Readonly<T>; }
>props : P
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/baselines/reference/mappedTypesArraysTuples.types
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ type T12 = Required<string[]>;
>T12 : string[]

type T13 = Boxified<ReadonlyArray<string>>;
>T13 : ReadonlyArray<Box<string>>
>T13 : readonly Box<string>[]

type T14 = Partial<ReadonlyArray<string>>;
>T14 : ReadonlyArray<string | undefined>
>T14 : readonly (string | undefined)[]

type T15 = Required<ReadonlyArray<string>>;
>T15 : ReadonlyArray<string>
>T15 : readonly string[]

type T20 = Boxified<(string | undefined)[]>;
>T20 : Box<string | undefined>[]
Expand All @@ -43,13 +43,13 @@ type T22 = Required<(string | undefined)[]>;
>T22 : string[]

type T23 = Boxified<ReadonlyArray<string | undefined>>;
>T23 : ReadonlyArray<Box<string | undefined>>
>T23 : readonly Box<string | undefined>[]

type T24 = Partial<ReadonlyArray<string | undefined>>;
>T24 : ReadonlyArray<string | undefined>
>T24 : readonly (string | undefined)[]

type T25 = Required<ReadonlyArray<string | undefined>>;
>T25 : ReadonlyArray<string>
>T25 : readonly string[]

type T30 = Boxified<Partial<string[]>>;
>T30 : Box<string | undefined>[]
Expand All @@ -66,7 +66,7 @@ type B = { b: string };
>b : string

type T40 = Boxified<A | A[] | ReadonlyArray<A> | [A, B] | string | string[]>;
>T40 : string | Box<string>[] | Boxified<A> | Box<A>[] | ReadonlyArray<Box<A>> | [Box<A>, Box<B>]
>T40 : string | Box<string>[] | Boxified<A> | Box<A>[] | readonly Box<A>[] | [Box<A>, Box<B>]

declare function unboxify<T>(x: Boxified<T>): T;
>unboxify : <T>(x: Boxified<T>) => T
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/noUnusedLocals_writeOnly.types
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ function f(x = 0, b = false) {
>1 : 1
}
function f2(_: ReadonlyArray<number>): void {}
>f2 : (_: ReadonlyArray<number>) => void
>_ : ReadonlyArray<number>
>f2 : (_: readonly number[]) => void
>_ : readonly number[]

4 changes: 2 additions & 2 deletions tests/baselines/reference/objectFreeze.errors.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests/cases/compiler/objectFreeze.ts(9,1): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/compiler/objectFreeze.ts(9,1): error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
tests/cases/compiler/objectFreeze.ts(9,1): error TS2542: Index signature in type 'readonly number[]' only permits reading.
tests/cases/compiler/objectFreeze.ts(12,3): error TS2540: Cannot assign to 'b' because it is a read-only property.


Expand All @@ -16,7 +16,7 @@ tests/cases/compiler/objectFreeze.ts(12,3): error TS2540: Cannot assign to 'b' b
~~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
~~~~
!!! error TS2542: Index signature in type 'ReadonlyArray<number>' only permits reading.
!!! error TS2542: Index signature in type 'readonly number[]' only permits reading.

const o = Object.freeze({ a: 1, b: "string" });
o.b = o.a.toString();
Expand Down
Loading
0