Skip to content
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 18, 2019
commit ef89d26dc8c163e30e1c98b742754f1d8ed875e7
40 changes: 40 additions & 0 deletions tests/baselines/reference/readonlyRestParameters.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(8,5): error TS2556: Expected 2 arguments, but got 0 or more.
tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(20,5): error TS2554: Expected 2 arguments, but got 3.
tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts(25,5): error TS2542: Index signature in type 'readonly string[]' only permits reading.


==== tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts (3 errors) ====
function f0(a: string, b: string) {
f0(a, b);
f1(a, b);
f2(a, b);
}

function f1(...args: readonly string[]) {
f0(...args); // Error
~~~~~~~~~~~
!!! error TS2556: Expected 2 arguments, but got 0 or more.
!!! related TS6210 tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts:1:13: An argument for 'a' was not provided.
f1('abc', 'def');
f1('abc', ...args);
f1(...args);
}

function f2(...args: readonly [string, string]) {
f0(...args);
f1('abc', 'def');
f1('abc', ...args);
f1(...args);
f2('abc', 'def');
f2('abc', ...args); // Error
~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 2 arguments, but got 3.
f2(...args);
}

function f4(...args: readonly string[]) {
args[0] = 'abc'; // Error
~~~~~~~
!!! error TS2542: Index signature in type 'readonly string[]' only permits reading.
}

73 changes: 73 additions & 0 deletions tests/baselines/reference/readonlyRestParameters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//// [readonlyRestParameters.ts]
function f0(a: string, b: string) {
f0(a, b);
f1(a, b);
f2(a, b);
}

function f1(...args: readonly string[]) {
f0(...args); // Error
f1('abc', 'def');
f1('abc', ...args);
f1(...args);
}

function f2(...args: readonly [string, string]) {
f0(...args);
f1('abc', 'def');
f1('abc', ...args);
f1(...args);
f2('abc', 'def');
f2('abc', ...args); // Error
f2(...args);
}

function f4(...args: readonly string[]) {
args[0] = 'abc'; // Error
}


//// [readonlyRestParameters.js]
"use strict";
function f0(a, b) {
f0(a, b);
f1(a, b);
f2(a, b);
}
function f1() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
f0.apply(void 0, args); // Error
f1('abc', 'def');
f1.apply(void 0, ['abc'].concat(args));
f1.apply(void 0, args);
}
function f2() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
f0.apply(void 0, args);
f1('abc', 'def');
f1.apply(void 0, ['abc'].concat(args));
f1.apply(void 0, args);
f2('abc', 'def');
f2.apply(void 0, ['abc'].concat(args)); // Error
f2.apply(void 0, args);
}
function f4() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
args[0] = 'abc'; // Error
}


//// [readonlyRestParameters.d.ts]
declare function f0(a: string, b: string): void;
declare function f1(...args: readonly string[]): void;
declare function f2(...args: readonly [string, string]): void;
declare function f4(...args: readonly string[]): void;
81 changes: 81 additions & 0 deletions tests/baselines/reference/readonlyRestParameters.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
=== tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts ===
function f0(a: string, b: string) {
>f0 : Symbol(f0, Decl(readonlyRestParameters.ts, 0, 0))
>a : Symbol(a, Decl(readonlyRestParameters.ts, 0, 12))
>b : Symbol(b, Decl(readonlyRestParameters.ts, 0, 22))

f0(a, b);
>f0 : Symbol(f0, Decl(readonlyRestParameters.ts, 0, 0))
>a : Symbol(a, Decl(readonlyRestParameters.ts, 0, 12))
>b : Symbol(b, Decl(readonlyRestParameters.ts, 0, 22))

f1(a, b);
>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1))
>a : Symbol(a, Decl(readonlyRestParameters.ts, 0, 12))
>b : Symbol(b, Decl(readonlyRestParameters.ts, 0, 22))

f2(a, b);
>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1))
>a : Symbol(a, Decl(readonlyRestParameters.ts, 0, 12))
>b : Symbol(b, Decl(readonlyRestParameters.ts, 0, 22))
}

function f1(...args: readonly string[]) {
>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 6, 12))

f0(...args); // Error
>f0 : Symbol(f0, Decl(readonlyRestParameters.ts, 0, 0))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 6, 12))

f1('abc', 'def');
>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1))

f1('abc', ...args);
>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 6, 12))

f1(...args);
>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 6, 12))
}

function f2(...args: readonly [string, string]) {
>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12))

f0(...args);
>f0 : Symbol(f0, Decl(readonlyRestParameters.ts, 0, 0))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12))

f1('abc', 'def');
>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1))

f1('abc', ...args);
>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12))

f1(...args);
>f1 : Symbol(f1, Decl(readonlyRestParameters.ts, 4, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12))

f2('abc', 'def');
>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1))

f2('abc', ...args); // Error
>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12))

f2(...args);
>f2 : Symbol(f2, Decl(readonlyRestParameters.ts, 11, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 13, 12))
}

function f4(...args: readonly string[]) {
>f4 : Symbol(f4, Decl(readonlyRestParameters.ts, 21, 1))
>args : Symbol(args, Decl(readonlyRestParameters.ts, 23, 12))

args[0] = 'abc'; // Error
>args : Symbol(args, Decl(readonlyRestParameters.ts, 23, 12))
}

116 changes: 116 additions & 0 deletions tests/baselines/reference/readonlyRestParameters.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
=== tests/cases/conformance/es6/restParameters/readonlyRestParameters.ts ===
function f0(a: string, b: string) {
>f0 : (a: string, b: string) => void
>a : string
>b : string

f0(a, b);
>f0(a, b) : void
>f0 : (a: string, b: string) => void
>a : string
>b : string

f1(a, b);
>f1(a, b) : void
>f1 : (...args: readonly string[]) => void
>a : string
>b : string

f2(a, b);
>f2(a, b) : void
>f2 : (args_0: string, args_1: string) => void
>a : string
>b : string
}

function f1(...args: readonly string[]) {
>f1 : (...args: readonly string[]) => void
>args : readonly string[]

f0(...args); // Error
>f0(...args) : void
>f0 : (a: string, b: string) => void
>...args : string
>args : readonly string[]

f1('abc', 'def');
>f1('abc', 'def') : void
>f1 : (...args: readonly string[]) => void
>'abc' : "abc"
>'def' : "def"

f1('abc', ...args);
>f1('abc', ...args) : void
>f1 : (...args: readonly string[]) => void
>'abc' : "abc"
>...args : string
>args : readonly string[]

f1(...args);
>f1(...args) : void
>f1 : (...args: readonly string[]) => void
>...args : string
>args : readonly string[]
}

function f2(...args: readonly [string, string]) {
>f2 : (args_0: string, args_1: string) => void
>args : readonly [string, string]

f0(...args);
>f0(...args) : void
>f0 : (a: string, b: string) => void
>...args : string
>args : readonly [string, string]

f1('abc', 'def');
>f1('abc', 'def') : void
>f1 : (...args: readonly string[]) => void
>'abc' : "abc"
>'def' : "def"

f1('abc', ...args);
>f1('abc', ...args) : void
>f1 : (...args: readonly string[]) => void
>'abc' : "abc"
>...args : string
>args : readonly [string, string]

f1(...args);
>f1(...args) : void
>f1 : (...args: readonly string[]) => void
>...args : string
>args : readonly [string, string]

f2('abc', 'def');
>f2('abc', 'def') : void
>f2 : (args_0: string, args_1: string) => void
>'abc' : "abc"
>'def' : "def"

f2('abc', ...args); // Error
>f2('abc', ...args) : void
>f2 : (args_0: string, args_1: string) => void
>'abc' : "abc"
>...args : string
>args : readonly [string, string]

f2(...args);
>f2(...args) : void
>f2 : (args_0: string, args_1: string) => void
>...args : string
>args : readonly [string, string]
}

function f4(...args: readonly string[]) {
>f4 : (...args: readonly string[]) => void
>args : readonly string[]

args[0] = 'abc'; // Error
>args[0] = 'abc' : "abc"
>args[0] : string
>args : readonly string[]
>0 : 0
>'abc' : "abc"
}