Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Maintain modifiers on `Omit`
- Loading branch information
Showing
16 changed files
with
273 additions
and
51 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
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
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
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
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/omitTypeHelperModifiers01.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,27 @@ | ||
tests/cases/compiler/omitTypeHelperModifiers01.ts(16,7): error TS2540: Cannot assign to 'c' because it is a read-only property. | ||
|
||
|
||
==== tests/cases/compiler/omitTypeHelperModifiers01.ts (1 errors) ==== | ||
type A = { | ||
a: number; | ||
b?: string; | ||
readonly c: boolean; | ||
d: unknown; | ||
}; | ||
|
||
type B = Omit<A, 'a'>; | ||
|
||
function f(x: B) { | ||
const b = x.b; | ||
x.b = "hello"; | ||
x.b = undefined; | ||
|
||
const c = x.c; | ||
x.c = true; | ||
~ | ||
!!! error TS2540: Cannot assign to 'c' because it is a read-only property. | ||
|
||
const d = x.d; | ||
x.d = d; | ||
} | ||
|
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,34 @@ | ||
//// [omitTypeHelperModifiers01.ts] | ||
type A = { | ||
a: number; | ||
b?: string; | ||
readonly c: boolean; | ||
d: unknown; | ||
}; | ||
|
||
type B = Omit<A, 'a'>; | ||
|
||
function f(x: B) { | ||
const b = x.b; | ||
x.b = "hello"; | ||
x.b = undefined; | ||
|
||
const c = x.c; | ||
x.c = true; | ||
|
||
const d = x.d; | ||
x.d = d; | ||
} | ||
|
||
|
||
//// [omitTypeHelperModifiers01.js] | ||
"use strict"; | ||
function f(x) { | ||
var b = x.b; | ||
x.b = "hello"; | ||
x.b = undefined; | ||
var c = x.c; | ||
x.c = true; | ||
var d = x.d; | ||
x.d = d; | ||
} |
69 changes: 69 additions & 0 deletions
69
tests/baselines/reference/omitTypeHelperModifiers01.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/omitTypeHelperModifiers01.ts === | ||
type A = { | ||
>A : Symbol(A, Decl(omitTypeHelperModifiers01.ts, 0, 0)) | ||
|
||
a: number; | ||
>a : Symbol(a, Decl(omitTypeHelperModifiers01.ts, 0, 10)) | ||
|
||
b?: string; | ||
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14)) | ||
|
||
readonly c: boolean; | ||
>c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15)) | ||
|
||
d: unknown; | ||
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24)) | ||
|
||
}; | ||
|
||
type B = Omit<A, 'a'>; | ||
>B : Symbol(B, Decl(omitTypeHelperModifiers01.ts, 5, 2)) | ||
>Omit : Symbol(Omit, Decl(lib.es5.d.ts, --, --)) | ||
>A : Symbol(A, Decl(omitTypeHelperModifiers01.ts, 0, 0)) | ||
|
||
function f(x: B) { | ||
>f : Symbol(f, Decl(omitTypeHelperModifiers01.ts, 7, 22)) | ||
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11)) | ||
>B : Symbol(B, Decl(omitTypeHelperModifiers01.ts, 5, 2)) | ||
|
||
const b = x.b; | ||
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 10, 9)) | ||
>x.b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14)) | ||
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11)) | ||
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14)) | ||
|
||
x.b = "hello"; | ||
>x.b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14)) | ||
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11)) | ||
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14)) | ||
|
||
x.b = undefined; | ||
>x.b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14)) | ||
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11)) | ||
>b : Symbol(b, Decl(omitTypeHelperModifiers01.ts, 1, 14)) | ||
>undefined : Symbol(undefined) | ||
|
||
const c = x.c; | ||
>c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 14, 9)) | ||
>x.c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15)) | ||
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11)) | ||
>c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15)) | ||
|
||
x.c = true; | ||
>x.c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15)) | ||
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11)) | ||
>c : Symbol(c, Decl(omitTypeHelperModifiers01.ts, 2, 15)) | ||
|
||
const d = x.d; | ||
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 17, 9)) | ||
>x.d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24)) | ||
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11)) | ||
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24)) | ||
|
||
x.d = d; | ||
>x.d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24)) | ||
>x : Symbol(x, Decl(omitTypeHelperModifiers01.ts, 9, 11)) | ||
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 3, 24)) | ||
>d : Symbol(d, Decl(omitTypeHelperModifiers01.ts, 17, 9)) | ||
} | ||
|
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,72 @@ | ||
=== tests/cases/compiler/omitTypeHelperModifiers01.ts === | ||
type A = { | ||
>A : A | ||
|
||
a: number; | ||
>a : number | ||
|
||
b?: string; | ||
>b : string | undefined | ||
|
||
readonly c: boolean; | ||
>c : boolean | ||
|
||
d: unknown; | ||
>d : unknown | ||
|
||
}; | ||
|
||
type B = Omit<A, 'a'>; | ||
>B : Pick<A, "b" | "c" | "d"> | ||
|
||
function f(x: B) { | ||
>f : (x: Pick<A, "b" | "c" | "d">) => void | ||
>x : Pick<A, "b" | "c" | "d"> | ||
|
||
const b = x.b; | ||
>b : string | undefined | ||
>x.b : string | undefined | ||
>x : Pick<A, "b" | "c" | "d"> | ||
>b : string | undefined | ||
|
||
x.b = "hello"; | ||
>x.b = "hello" : "hello" | ||
>x.b : string | undefined | ||
>x : Pick<A, "b" | "c" | "d"> | ||
>b : string | undefined | ||
>"hello" : "hello" | ||
|
||
x.b = undefined; | ||
>x.b = undefined : undefined | ||
>x.b : string | undefined | ||
>x : Pick<A, "b" | "c" | "d"> | ||
>b : string | undefined | ||
>undefined : undefined | ||
|
||
const c = x.c; | ||
>c : boolean | ||
>x.c : boolean | ||
>x : Pick<A, "b" | "c" | "d"> | ||
>c : boolean | ||
|
||
x.c = true; | ||
>x.c = true : true | ||
>x.c : any | ||
>x : Pick<A, "b" | "c" | "d"> | ||
>c : any | ||
>true : true | ||
|
||
const d = x.d; | ||
>d : unknown | ||
>x.d : unknown | ||
>x : Pick<A, "b" | "c" | "d"> | ||
>d : unknown | ||
|
||
x.d = d; | ||
>x.d = d : unknown | ||
>x.d : unknown | ||
>x : Pick<A, "b" | "c" | "d"> | ||
>d : unknown | ||
>d : unknown | ||
} | ||
|
Oops, something went wrong.