-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add assignability rule relaxing the assignability of partial mapped t…
…ypes (#30112) * Add assignability rule relaxing the assignability of partial mapped types * Update comment
- Loading branch information
Showing
5 changed files
with
85 additions
and
8 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
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/mappedTypePartialNonHomomorphicBaseConstraint.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,21 @@ | ||
//// [mappedTypePartialNonHomomorphicBaseConstraint.ts] | ||
export type Errors<D> = { readonly [K in keyof D | "base"]?: string[] }; | ||
|
||
class Model<D> { | ||
getErrors(): Errors<D> { | ||
return { base: ["some base error"] }; | ||
} | ||
} | ||
|
||
|
||
//// [mappedTypePartialNonHomomorphicBaseConstraint.js] | ||
"use strict"; | ||
exports.__esModule = true; | ||
var Model = /** @class */ (function () { | ||
function Model() { | ||
} | ||
Model.prototype.getErrors = function () { | ||
return { base: ["some base error"] }; | ||
}; | ||
return Model; | ||
}()); |
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/mappedTypePartialNonHomomorphicBaseConstraint.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,21 @@ | ||
=== tests/cases/compiler/mappedTypePartialNonHomomorphicBaseConstraint.ts === | ||
export type Errors<D> = { readonly [K in keyof D | "base"]?: string[] }; | ||
>Errors : Symbol(Errors, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 0, 0)) | ||
>D : Symbol(D, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 0, 19)) | ||
>K : Symbol(K, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 0, 36)) | ||
>D : Symbol(D, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 0, 19)) | ||
|
||
class Model<D> { | ||
>Model : Symbol(Model, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 0, 72)) | ||
>D : Symbol(D, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 2, 12)) | ||
|
||
getErrors(): Errors<D> { | ||
>getErrors : Symbol(Model.getErrors, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 2, 16)) | ||
>Errors : Symbol(Errors, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 0, 0)) | ||
>D : Symbol(D, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 2, 12)) | ||
|
||
return { base: ["some base error"] }; | ||
>base : Symbol(base, Decl(mappedTypePartialNonHomomorphicBaseConstraint.ts, 4, 12)) | ||
} | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
tests/baselines/reference/mappedTypePartialNonHomomorphicBaseConstraint.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,18 @@ | ||
=== tests/cases/compiler/mappedTypePartialNonHomomorphicBaseConstraint.ts === | ||
export type Errors<D> = { readonly [K in keyof D | "base"]?: string[] }; | ||
>Errors : Errors<D> | ||
|
||
class Model<D> { | ||
>Model : Model<D> | ||
|
||
getErrors(): Errors<D> { | ||
>getErrors : () => Errors<D> | ||
|
||
return { base: ["some base error"] }; | ||
>{ base: ["some base error"] } : { base: string[]; } | ||
>base : string[] | ||
>["some base error"] : string[] | ||
>"some base error" : "some base error" | ||
} | ||
} | ||
|
7 changes: 7 additions & 0 deletions
7
tests/cases/compiler/mappedTypePartialNonHomomorphicBaseConstraint.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,7 @@ | ||
export type Errors<D> = { readonly [K in keyof D | "base"]?: string[] }; | ||
|
||
class Model<D> { | ||
getErrors(): Errors<D> { | ||
return { base: ["some base error"] }; | ||
} | ||
} |