Skip to content

Print deferred mapped symbols 1 level deep#21311

Merged
sandersn merged 3 commits into
masterfrom
print-deferred-inferred-symbols-1-level-deep
Feb 8, 2018
Merged

Print deferred mapped symbols 1 level deep#21311
sandersn merged 3 commits into
masterfrom
print-deferred-inferred-symbols-1-level-deep

Conversation

@sandersn
Copy link
Copy Markdown
Member

Previously, deferred mapped symbols would not print their type at all; they would always print as any. This differed from the older behaviour that printed it forever if necessary. As a compromise, we now print deferred mapped symbosl 1 level deep before giving up and printing any. This should cover the most common uses of mapped types.

The baseline updates are the easiest-to-understand examples of this change.

Previously, deferred mapped symbols would not print their type at all;
it would always print as `any`. This differed from the older behaviour
that printed it forever if necessary. As a compromise, we now print
deferred mapped symbosl 1 level deep before giving up and printing
`any`. This should cover the most common uses of mapped types.
Copy link
Copy Markdown
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one comment, but definitely seems like an improvement. 👍 (Though I still wish these types were printed with less heuristics and more totally 🙁 )

Comment thread src/compiler/checker.ts Outdated
const globals = createSymbolTable();
const reverseMappedCache = createMap<Type | undefined>();
let ambientModulesCache: Symbol[] | undefined;
let alreadyCreatingReverseMappedType = false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a state flag in context, instead of a local flag so it can be tracked across calls, I think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@sandersn sandersn merged commit 37f15cc into master Feb 8, 2018
@sandersn sandersn deleted the print-deferred-inferred-symbols-1-level-deep branch February 8, 2018 21:35
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants