-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Write non-missing undefined on mapped type results into output #59208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
weswigham
merged 8 commits into
microsoft:main
from
weswigham:exacter-optional-property-type-node-reuse
Jul 10, 2024
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
52a36f0
Write non-missing undefined missing from reused node into output
weswigham f1b8be9
Massively limit scope
weswigham 84919f0
Renames
weswigham dad3188
Merge branch 'main' into exacter-optional-property-type-node-reuse
weswigham 2df438e
Suggestion
weswigham de2b455
containsNonMissingUndefinedType
weswigham 9a228e1
Merge branch 'main' into exacter-optional-property-type-node-reuse
weswigham 151faae
Format
weswigham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
39 changes: 39 additions & 0 deletions
39
...clarationEmitExactOptionalPropertyTypesNodeNotReused(exactoptionalpropertytypes=false).js
This file contains hidden or 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,39 @@ | ||
//// [tests/cases/compiler/declarationEmitExactOptionalPropertyTypesNodeNotReused.ts] //// | ||
|
||
//// [declarationEmitExactOptionalPropertyTypesNodeNotReused.ts] | ||
type InexactOptionals<A> = { | ||
[K in keyof A as undefined extends A[K] ? K : never]?: undefined extends A[K] | ||
? A[K] | undefined | ||
: A[K]; | ||
} & { | ||
[K in keyof A as undefined extends A[K] ? never : K]: A[K]; | ||
}; | ||
|
||
type In = { | ||
foo?: string; | ||
bar: number; | ||
baz: undefined; | ||
} | ||
|
||
type Out = InexactOptionals<In> | ||
|
||
const foo = <A = {}>() => (x: Out & A) => null | ||
|
||
export const baddts = foo() | ||
|
||
|
||
//// [declarationEmitExactOptionalPropertyTypesNodeNotReused.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.baddts = void 0; | ||
var foo = function () { return function (x) { return null; }; }; | ||
exports.baddts = foo(); | ||
|
||
|
||
//// [declarationEmitExactOptionalPropertyTypesNodeNotReused.d.ts] | ||
export declare const baddts: (x: { | ||
foo?: string | undefined; | ||
baz?: undefined; | ||
} & { | ||
bar: number; | ||
}) => null; |
65 changes: 65 additions & 0 deletions
65
...tionEmitExactOptionalPropertyTypesNodeNotReused(exactoptionalpropertytypes=false).symbols
This file contains hidden or 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,65 @@ | ||
//// [tests/cases/compiler/declarationEmitExactOptionalPropertyTypesNodeNotReused.ts] //// | ||
|
||
=== declarationEmitExactOptionalPropertyTypesNodeNotReused.ts === | ||
type InexactOptionals<A> = { | ||
>InexactOptionals : Symbol(InexactOptionals, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 0)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
|
||
[K in keyof A as undefined extends A[K] ? K : never]?: undefined extends A[K] | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
|
||
? A[K] | undefined | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
|
||
: A[K]; | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
|
||
} & { | ||
[K in keyof A as undefined extends A[K] ? never : K]: A[K]; | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 5, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 5, 5)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 5, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 5, 5)) | ||
|
||
}; | ||
|
||
type In = { | ||
>In : Symbol(In, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 6, 2)) | ||
|
||
foo?: string; | ||
>foo : Symbol(foo, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 8, 11)) | ||
|
||
bar: number; | ||
>bar : Symbol(bar, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 9, 17)) | ||
|
||
baz: undefined; | ||
>baz : Symbol(baz, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 10, 16)) | ||
} | ||
|
||
type Out = InexactOptionals<In> | ||
>Out : Symbol(Out, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 12, 1)) | ||
>InexactOptionals : Symbol(InexactOptionals, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 0)) | ||
>In : Symbol(In, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 6, 2)) | ||
|
||
const foo = <A = {}>() => (x: Out & A) => null | ||
>foo : Symbol(foo, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 13)) | ||
>x : Symbol(x, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 27)) | ||
>Out : Symbol(Out, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 12, 1)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 13)) | ||
|
||
export const baddts = foo() | ||
>baddts : Symbol(baddts, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 18, 12)) | ||
>foo : Symbol(foo, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 5)) | ||
|
53 changes: 53 additions & 0 deletions
53
...rationEmitExactOptionalPropertyTypesNodeNotReused(exactoptionalpropertytypes=false).types
This file contains hidden or 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,53 @@ | ||
//// [tests/cases/compiler/declarationEmitExactOptionalPropertyTypesNodeNotReused.ts] //// | ||
|
||
=== declarationEmitExactOptionalPropertyTypesNodeNotReused.ts === | ||
type InexactOptionals<A> = { | ||
>InexactOptionals : InexactOptionals<A> | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
|
||
[K in keyof A as undefined extends A[K] ? K : never]?: undefined extends A[K] | ||
? A[K] | undefined | ||
: A[K]; | ||
} & { | ||
[K in keyof A as undefined extends A[K] ? never : K]: A[K]; | ||
}; | ||
|
||
type In = { | ||
>In : In | ||
> : ^^ | ||
|
||
foo?: string; | ||
>foo : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
|
||
bar: number; | ||
>bar : number | ||
> : ^^^^^^ | ||
|
||
baz: undefined; | ||
>baz : undefined | ||
> : ^^^^^^^^^ | ||
} | ||
|
||
type Out = InexactOptionals<In> | ||
>Out : Out | ||
> : ^^^ | ||
|
||
const foo = <A = {}>() => (x: Out & A) => null | ||
>foo : <A = {}>() => (x: Out & A) => null | ||
> : ^ ^^^^^^^^^^^^^ ^^ ^^^^^^^^^ | ||
><A = {}>() => (x: Out & A) => null : <A = {}>() => (x: Out & A) => null | ||
> : ^ ^^^^^^^^^^^^^ ^^ ^^^^^^^^^ | ||
>(x: Out & A) => null : (x: Out & A) => null | ||
> : ^ ^^ ^^^^^^^^^ | ||
>x : { foo?: string | undefined; baz?: undefined; } & { bar: number; } & A | ||
> : ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^ | ||
|
||
export const baddts = foo() | ||
>baddts : (x: { foo?: string | undefined; baz?: undefined; } & { bar: number; }) => null | ||
> : ^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^ | ||
>foo() : (x: { foo?: string | undefined; baz?: undefined; } & { bar: number; }) => null | ||
> : ^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^ | ||
>foo : <A = {}>() => (x: Out & A) => null | ||
> : ^ ^^^^^^^^^^^^^ ^^ ^^^^^^^^^ | ||
|
39 changes: 39 additions & 0 deletions
39
...eclarationEmitExactOptionalPropertyTypesNodeNotReused(exactoptionalpropertytypes=true).js
This file contains hidden or 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,39 @@ | ||
//// [tests/cases/compiler/declarationEmitExactOptionalPropertyTypesNodeNotReused.ts] //// | ||
|
||
//// [declarationEmitExactOptionalPropertyTypesNodeNotReused.ts] | ||
type InexactOptionals<A> = { | ||
[K in keyof A as undefined extends A[K] ? K : never]?: undefined extends A[K] | ||
? A[K] | undefined | ||
: A[K]; | ||
} & { | ||
[K in keyof A as undefined extends A[K] ? never : K]: A[K]; | ||
}; | ||
|
||
type In = { | ||
foo?: string; | ||
bar: number; | ||
baz: undefined; | ||
} | ||
|
||
type Out = InexactOptionals<In> | ||
|
||
const foo = <A = {}>() => (x: Out & A) => null | ||
|
||
export const baddts = foo() | ||
|
||
|
||
//// [declarationEmitExactOptionalPropertyTypesNodeNotReused.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.baddts = void 0; | ||
var foo = function () { return function (x) { return null; }; }; | ||
exports.baddts = foo(); | ||
|
||
|
||
//// [declarationEmitExactOptionalPropertyTypesNodeNotReused.d.ts] | ||
export declare const baddts: (x: { | ||
foo?: string | undefined; | ||
baz?: undefined; | ||
} & { | ||
bar: number; | ||
}) => null; |
65 changes: 65 additions & 0 deletions
65
...ationEmitExactOptionalPropertyTypesNodeNotReused(exactoptionalpropertytypes=true).symbols
This file contains hidden or 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,65 @@ | ||
//// [tests/cases/compiler/declarationEmitExactOptionalPropertyTypesNodeNotReused.ts] //// | ||
|
||
=== declarationEmitExactOptionalPropertyTypesNodeNotReused.ts === | ||
type InexactOptionals<A> = { | ||
>InexactOptionals : Symbol(InexactOptionals, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 0)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
|
||
[K in keyof A as undefined extends A[K] ? K : never]?: undefined extends A[K] | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
|
||
? A[K] | undefined | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
|
||
: A[K]; | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 1, 5)) | ||
|
||
} & { | ||
[K in keyof A as undefined extends A[K] ? never : K]: A[K]; | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 5, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 5, 5)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 5, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 22)) | ||
>K : Symbol(K, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 5, 5)) | ||
|
||
}; | ||
|
||
type In = { | ||
>In : Symbol(In, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 6, 2)) | ||
|
||
foo?: string; | ||
>foo : Symbol(foo, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 8, 11)) | ||
|
||
bar: number; | ||
>bar : Symbol(bar, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 9, 17)) | ||
|
||
baz: undefined; | ||
>baz : Symbol(baz, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 10, 16)) | ||
} | ||
|
||
type Out = InexactOptionals<In> | ||
>Out : Symbol(Out, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 12, 1)) | ||
>InexactOptionals : Symbol(InexactOptionals, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 0, 0)) | ||
>In : Symbol(In, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 6, 2)) | ||
|
||
const foo = <A = {}>() => (x: Out & A) => null | ||
>foo : Symbol(foo, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 5)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 13)) | ||
>x : Symbol(x, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 27)) | ||
>Out : Symbol(Out, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 12, 1)) | ||
>A : Symbol(A, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 13)) | ||
|
||
export const baddts = foo() | ||
>baddts : Symbol(baddts, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 18, 12)) | ||
>foo : Symbol(foo, Decl(declarationEmitExactOptionalPropertyTypesNodeNotReused.ts, 16, 5)) | ||
|
53 changes: 53 additions & 0 deletions
53
...arationEmitExactOptionalPropertyTypesNodeNotReused(exactoptionalpropertytypes=true).types
This file contains hidden or 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,53 @@ | ||
//// [tests/cases/compiler/declarationEmitExactOptionalPropertyTypesNodeNotReused.ts] //// | ||
|
||
=== declarationEmitExactOptionalPropertyTypesNodeNotReused.ts === | ||
type InexactOptionals<A> = { | ||
>InexactOptionals : InexactOptionals<A> | ||
> : ^^^^^^^^^^^^^^^^^^^ | ||
|
||
[K in keyof A as undefined extends A[K] ? K : never]?: undefined extends A[K] | ||
? A[K] | undefined | ||
: A[K]; | ||
} & { | ||
[K in keyof A as undefined extends A[K] ? never : K]: A[K]; | ||
}; | ||
|
||
type In = { | ||
>In : In | ||
> : ^^ | ||
|
||
foo?: string; | ||
>foo : string | undefined | ||
> : ^^^^^^^^^^^^^^^^^^ | ||
|
||
bar: number; | ||
>bar : number | ||
> : ^^^^^^ | ||
|
||
baz: undefined; | ||
>baz : undefined | ||
> : ^^^^^^^^^ | ||
} | ||
|
||
type Out = InexactOptionals<In> | ||
>Out : Out | ||
> : ^^^ | ||
|
||
const foo = <A = {}>() => (x: Out & A) => null | ||
>foo : <A = {}>() => (x: Out & A) => null | ||
> : ^ ^^^^^^^^^^^^^ ^^ ^^^^^^^^^ | ||
><A = {}>() => (x: Out & A) => null : <A = {}>() => (x: Out & A) => null | ||
> : ^ ^^^^^^^^^^^^^ ^^ ^^^^^^^^^ | ||
>(x: Out & A) => null : (x: Out & A) => null | ||
> : ^ ^^ ^^^^^^^^^ | ||
>x : { foo?: string | undefined; baz?: undefined; } & { bar: number; } & A | ||
> : ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^ | ||
|
||
export const baddts = foo() | ||
>baddts : (x: { foo?: string | undefined; baz?: undefined; } & { bar: number; }) => null | ||
> : ^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^ | ||
>foo() : (x: { foo?: string | undefined; baz?: undefined; } & { bar: number; }) => null | ||
> : ^ ^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^ | ||
>foo : <A = {}>() => (x: Out & A) => null | ||
> : ^ ^^^^^^^^^^^^^ ^^ ^^^^^^^^^ | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.