-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Component commits: 99110e9 Consider inferences between mapped type templates lower priority Co-authored-by: Wesley Wigham <[email protected]>
- Loading branch information
Showing
5 changed files
with
191 additions
and
2 deletions.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
tests/baselines/reference/localTypeParameterInferencePriority.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,58 @@ | ||
//// [localTypeParameterInferencePriority.ts] | ||
export type UnrollOnHover<O extends object> = O extends object ? | ||
{ [K in keyof O]: O[K]; } : | ||
never; | ||
|
||
|
||
export type Schema = Record<string, unknown>; | ||
class Table<S extends Schema> { | ||
__schema!: S; | ||
|
||
// Removing this line, removes the error | ||
getRows<C extends keyof S>(): Array<UnrollOnHover<Pick<S, C>>> { | ||
return null! | ||
} | ||
} | ||
|
||
class ColumnSelectViewImp<S extends Schema> extends Table<S> { } | ||
|
||
|
||
const ColumnSelectView1: new <S extends Schema>() => Table<UnrollOnHover<S>> = ColumnSelectViewImp; | ||
const ColumnSelectView2: new <S extends Schema>() => Table<UnrollOnHover<S>> = Table; | ||
|
||
//// [localTypeParameterInferencePriority.js] | ||
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
exports.__esModule = true; | ||
var Table = /** @class */ (function () { | ||
function Table() { | ||
} | ||
// Removing this line, removes the error | ||
Table.prototype.getRows = function () { | ||
return null; | ||
}; | ||
return Table; | ||
}()); | ||
var ColumnSelectViewImp = /** @class */ (function (_super) { | ||
__extends(ColumnSelectViewImp, _super); | ||
function ColumnSelectViewImp() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return ColumnSelectViewImp; | ||
}(Table)); | ||
var ColumnSelectView1 = ColumnSelectViewImp; | ||
var ColumnSelectView2 = Table; |
69 changes: 69 additions & 0 deletions
69
tests/baselines/reference/localTypeParameterInferencePriority.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,69 @@ | ||
=== tests/cases/compiler/localTypeParameterInferencePriority.ts === | ||
export type UnrollOnHover<O extends object> = O extends object ? | ||
>UnrollOnHover : Symbol(UnrollOnHover, Decl(localTypeParameterInferencePriority.ts, 0, 0)) | ||
>O : Symbol(O, Decl(localTypeParameterInferencePriority.ts, 0, 26)) | ||
>O : Symbol(O, Decl(localTypeParameterInferencePriority.ts, 0, 26)) | ||
|
||
{ [K in keyof O]: O[K]; } : | ||
>K : Symbol(K, Decl(localTypeParameterInferencePriority.ts, 1, 7)) | ||
>O : Symbol(O, Decl(localTypeParameterInferencePriority.ts, 0, 26)) | ||
>O : Symbol(O, Decl(localTypeParameterInferencePriority.ts, 0, 26)) | ||
>K : Symbol(K, Decl(localTypeParameterInferencePriority.ts, 1, 7)) | ||
|
||
never; | ||
|
||
|
||
export type Schema = Record<string, unknown>; | ||
>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) | ||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) | ||
|
||
class Table<S extends Schema> { | ||
>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 6, 12)) | ||
>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) | ||
|
||
__schema!: S; | ||
>__schema : Symbol(Table.__schema, Decl(localTypeParameterInferencePriority.ts, 6, 32)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 6, 12)) | ||
|
||
// Removing this line, removes the error | ||
getRows<C extends keyof S>(): Array<UnrollOnHover<Pick<S, C>>> { | ||
>getRows : Symbol(Table.getRows, Decl(localTypeParameterInferencePriority.ts, 7, 17)) | ||
>C : Symbol(C, Decl(localTypeParameterInferencePriority.ts, 10, 12)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 6, 12)) | ||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>UnrollOnHover : Symbol(UnrollOnHover, Decl(localTypeParameterInferencePriority.ts, 0, 0)) | ||
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 6, 12)) | ||
>C : Symbol(C, Decl(localTypeParameterInferencePriority.ts, 10, 12)) | ||
|
||
return null! | ||
} | ||
} | ||
|
||
class ColumnSelectViewImp<S extends Schema> extends Table<S> { } | ||
>ColumnSelectViewImp : Symbol(ColumnSelectViewImp, Decl(localTypeParameterInferencePriority.ts, 13, 1)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 15, 26)) | ||
>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) | ||
>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 15, 26)) | ||
|
||
|
||
const ColumnSelectView1: new <S extends Schema>() => Table<UnrollOnHover<S>> = ColumnSelectViewImp; | ||
>ColumnSelectView1 : Symbol(ColumnSelectView1, Decl(localTypeParameterInferencePriority.ts, 18, 5)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 18, 30)) | ||
>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) | ||
>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) | ||
>UnrollOnHover : Symbol(UnrollOnHover, Decl(localTypeParameterInferencePriority.ts, 0, 0)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 18, 30)) | ||
>ColumnSelectViewImp : Symbol(ColumnSelectViewImp, Decl(localTypeParameterInferencePriority.ts, 13, 1)) | ||
|
||
const ColumnSelectView2: new <S extends Schema>() => Table<UnrollOnHover<S>> = Table; | ||
>ColumnSelectView2 : Symbol(ColumnSelectView2, Decl(localTypeParameterInferencePriority.ts, 19, 5)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 19, 30)) | ||
>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) | ||
>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) | ||
>UnrollOnHover : Symbol(UnrollOnHover, Decl(localTypeParameterInferencePriority.ts, 0, 0)) | ||
>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 19, 30)) | ||
>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) | ||
|
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/localTypeParameterInferencePriority.types
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,40 @@ | ||
=== tests/cases/compiler/localTypeParameterInferencePriority.ts === | ||
export type UnrollOnHover<O extends object> = O extends object ? | ||
>UnrollOnHover : UnrollOnHover<O> | ||
|
||
{ [K in keyof O]: O[K]; } : | ||
never; | ||
|
||
|
||
export type Schema = Record<string, unknown>; | ||
>Schema : Schema | ||
|
||
class Table<S extends Schema> { | ||
>Table : Table<S> | ||
|
||
__schema!: S; | ||
>__schema : S | ||
|
||
// Removing this line, removes the error | ||
getRows<C extends keyof S>(): Array<UnrollOnHover<Pick<S, C>>> { | ||
>getRows : <C extends keyof S>() => Array<UnrollOnHover<Pick<S, C>>> | ||
|
||
return null! | ||
>null! : null | ||
>null : null | ||
} | ||
} | ||
|
||
class ColumnSelectViewImp<S extends Schema> extends Table<S> { } | ||
>ColumnSelectViewImp : ColumnSelectViewImp<S> | ||
>Table : Table<S> | ||
|
||
|
||
const ColumnSelectView1: new <S extends Schema>() => Table<UnrollOnHover<S>> = ColumnSelectViewImp; | ||
>ColumnSelectView1 : new <S extends Schema>() => Table<UnrollOnHover<S>> | ||
>ColumnSelectViewImp : typeof ColumnSelectViewImp | ||
|
||
const ColumnSelectView2: new <S extends Schema>() => Table<UnrollOnHover<S>> = Table; | ||
>ColumnSelectView2 : new <S extends Schema>() => Table<UnrollOnHover<S>> | ||
>Table : typeof Table | ||
|
20 changes: 20 additions & 0 deletions
20
tests/cases/compiler/localTypeParameterInferencePriority.ts
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,20 @@ | ||
export type UnrollOnHover<O extends object> = O extends object ? | ||
{ [K in keyof O]: O[K]; } : | ||
never; | ||
|
||
|
||
export type Schema = Record<string, unknown>; | ||
class Table<S extends Schema> { | ||
__schema!: S; | ||
|
||
// Removing this line, removes the error | ||
getRows<C extends keyof S>(): Array<UnrollOnHover<Pick<S, C>>> { | ||
return null! | ||
} | ||
} | ||
|
||
class ColumnSelectViewImp<S extends Schema> extends Table<S> { } | ||
|
||
|
||
const ColumnSelectView1: new <S extends Schema>() => Table<UnrollOnHover<S>> = ColumnSelectViewImp; | ||
const ColumnSelectView2: new <S extends Schema>() => Table<UnrollOnHover<S>> = Table; |