Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate unmeasurable from unreliable to reduce the impact of this ch…
…ange, for now
- Loading branch information
Showing
8 changed files
with
442 additions
and
61 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
tests/baselines/reference/consistentAliasVsNonAliasRecordBehavior.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
tests/cases/compiler/consistentAliasVsNonAliasRecordBehavior.ts(17,5): error TS2741: Property 'a' is missing in type 'Record<string, string>' but required in type 'Record2<"a", string>'. | ||
tests/cases/compiler/consistentAliasVsNonAliasRecordBehavior.ts(21,5): error TS2741: Property 'a' is missing in type 'Record2<string, string>' but required in type 'Record<"a", string>'. | ||
tests/cases/compiler/consistentAliasVsNonAliasRecordBehavior.ts(33,5): error TS2741: Property 'a' is missing in type 'Record<string, T>' but required in type 'Record2<"a", T>'. | ||
tests/cases/compiler/consistentAliasVsNonAliasRecordBehavior.ts(37,5): error TS2741: Property 'a' is missing in type 'Record2<string, T>' but required in type 'Record<"a", T>'. | ||
|
||
|
||
==== tests/cases/compiler/consistentAliasVsNonAliasRecordBehavior.ts (4 errors) ==== | ||
// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being | ||
// by incorrect variance-based relationships | ||
|
||
type Record2<K extends keyof any, T> = { | ||
[P in K]: T; | ||
}; | ||
|
||
function defaultRecord(x: Record<'a', string>, y: Record<string, string>) { | ||
x = y; // no error, but error expected. | ||
} | ||
|
||
function customRecord(x: Record2<'a', string>, y: Record2<string, string>) { | ||
x = y; // no error, but error expected. | ||
} | ||
|
||
function mixed1(x: Record2<'a', string>, y: Record<string, string>) { | ||
x = y; // error | ||
~ | ||
!!! error TS2741: Property 'a' is missing in type 'Record<string, string>' but required in type 'Record2<"a", string>'. | ||
} | ||
|
||
function mixed2(x: Record<'a', string>, y: Record2<string, string>) { | ||
x = y; // error | ||
~ | ||
!!! error TS2741: Property 'a' is missing in type 'Record2<string, string>' but required in type 'Record<"a", string>'. | ||
} | ||
|
||
function defaultRecord2<T>(x: Record<'a', T>, y: Record<string, T>) { | ||
x = y; // no error, but error expected. | ||
} | ||
|
||
function customRecord2<T>(x: Record2<'a', T>, y: Record2<string, T>) { | ||
x = y; // no error, but error expected. | ||
} | ||
|
||
function mixed3<T>(x: Record2<'a', T>, y: Record<string, T>) { | ||
x = y; // error | ||
~ | ||
!!! error TS2741: Property 'a' is missing in type 'Record<string, T>' but required in type 'Record2<"a", T>'. | ||
} | ||
|
||
function mixed4<T>(x: Record<'a', T>, y: Record2<string, T>) { | ||
x = y; // error | ||
~ | ||
!!! error TS2741: Property 'a' is missing in type 'Record2<string, T>' but required in type 'Record<"a", T>'. | ||
} | ||
|
68 changes: 68 additions & 0 deletions
68
tests/baselines/reference/consistentAliasVsNonAliasRecordBehavior.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//// [consistentAliasVsNonAliasRecordBehavior.ts] | ||
// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being | ||
// by incorrect variance-based relationships | ||
|
||
type Record2<K extends keyof any, T> = { | ||
[P in K]: T; | ||
}; | ||
|
||
function defaultRecord(x: Record<'a', string>, y: Record<string, string>) { | ||
x = y; // no error, but error expected. | ||
} | ||
|
||
function customRecord(x: Record2<'a', string>, y: Record2<string, string>) { | ||
x = y; // no error, but error expected. | ||
} | ||
|
||
function mixed1(x: Record2<'a', string>, y: Record<string, string>) { | ||
x = y; // error | ||
} | ||
|
||
function mixed2(x: Record<'a', string>, y: Record2<string, string>) { | ||
x = y; // error | ||
} | ||
|
||
function defaultRecord2<T>(x: Record<'a', T>, y: Record<string, T>) { | ||
x = y; // no error, but error expected. | ||
} | ||
|
||
function customRecord2<T>(x: Record2<'a', T>, y: Record2<string, T>) { | ||
x = y; // no error, but error expected. | ||
} | ||
|
||
function mixed3<T>(x: Record2<'a', T>, y: Record<string, T>) { | ||
x = y; // error | ||
} | ||
|
||
function mixed4<T>(x: Record<'a', T>, y: Record2<string, T>) { | ||
x = y; // error | ||
} | ||
|
||
|
||
//// [consistentAliasVsNonAliasRecordBehavior.js] | ||
// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being | ||
// by incorrect variance-based relationships | ||
function defaultRecord(x, y) { | ||
x = y; // no error, but error expected. | ||
} | ||
function customRecord(x, y) { | ||
x = y; // no error, but error expected. | ||
} | ||
function mixed1(x, y) { | ||
x = y; // error | ||
} | ||
function mixed2(x, y) { | ||
x = y; // error | ||
} | ||
function defaultRecord2(x, y) { | ||
x = y; // no error, but error expected. | ||
} | ||
function customRecord2(x, y) { | ||
x = y; // no error, but error expected. | ||
} | ||
function mixed3(x, y) { | ||
x = y; // error | ||
} | ||
function mixed4(x, y) { | ||
x = y; // error | ||
} |
124 changes: 124 additions & 0 deletions
124
tests/baselines/reference/consistentAliasVsNonAliasRecordBehavior.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
=== tests/cases/compiler/consistentAliasVsNonAliasRecordBehavior.ts === | ||
// TODO: FIXME: All the below cases labeled `no error` _should be an error_, and are only prevented from so being | ||
// by incorrect variance-based relationships | ||
|
||
type Record2<K extends keyof any, T> = { | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
>K : Symbol(K, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 3, 13)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 3, 33)) | ||
|
||
[P in K]: T; | ||
>P : Symbol(P, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 4, 5)) | ||
>K : Symbol(K, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 3, 13)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 3, 33)) | ||
|
||
}; | ||
|
||
function defaultRecord(x: Record<'a', string>, y: Record<string, string>) { | ||
>defaultRecord : Symbol(defaultRecord, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 5, 2)) | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 7, 23)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 7, 46)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
|
||
x = y; // no error, but error expected. | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 7, 23)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 7, 46)) | ||
} | ||
|
||
function customRecord(x: Record2<'a', string>, y: Record2<string, string>) { | ||
>customRecord : Symbol(customRecord, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 9, 1)) | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 11, 22)) | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 11, 46)) | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
|
||
x = y; // no error, but error expected. | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 11, 22)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 11, 46)) | ||
} | ||
|
||
function mixed1(x: Record2<'a', string>, y: Record<string, string>) { | ||
>mixed1 : Symbol(mixed1, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 13, 1)) | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 15, 16)) | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 15, 40)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
|
||
x = y; // error | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 15, 16)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 15, 40)) | ||
} | ||
|
||
function mixed2(x: Record<'a', string>, y: Record2<string, string>) { | ||
>mixed2 : Symbol(mixed2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 17, 1)) | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 19, 16)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 19, 39)) | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
|
||
x = y; // error | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 19, 16)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 19, 39)) | ||
} | ||
|
||
function defaultRecord2<T>(x: Record<'a', T>, y: Record<string, T>) { | ||
>defaultRecord2 : Symbol(defaultRecord2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 21, 1)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 23, 24)) | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 23, 27)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 23, 24)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 23, 45)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 23, 24)) | ||
|
||
x = y; // no error, but error expected. | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 23, 27)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 23, 45)) | ||
} | ||
|
||
function customRecord2<T>(x: Record2<'a', T>, y: Record2<string, T>) { | ||
>customRecord2 : Symbol(customRecord2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 25, 1)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 27, 23)) | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 27, 26)) | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 27, 23)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 27, 45)) | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 27, 23)) | ||
|
||
x = y; // no error, but error expected. | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 27, 26)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 27, 45)) | ||
} | ||
|
||
function mixed3<T>(x: Record2<'a', T>, y: Record<string, T>) { | ||
>mixed3 : Symbol(mixed3, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 29, 1)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 31, 16)) | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 31, 19)) | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 31, 16)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 31, 38)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 31, 16)) | ||
|
||
x = y; // error | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 31, 19)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 31, 38)) | ||
} | ||
|
||
function mixed4<T>(x: Record<'a', T>, y: Record2<string, T>) { | ||
>mixed4 : Symbol(mixed4, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 33, 1)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 35, 16)) | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 35, 19)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 35, 16)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 35, 37)) | ||
>Record2 : Symbol(Record2, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 0, 0)) | ||
>T : Symbol(T, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 35, 16)) | ||
|
||
x = y; // error | ||
>x : Symbol(x, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 35, 19)) | ||
>y : Symbol(y, Decl(consistentAliasVsNonAliasRecordBehavior.ts, 35, 37)) | ||
} | ||
|
Oops, something went wrong.