Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix anonymous type instantiation#19091

Merged
ahejlsberg merged 6 commits into
mastermicrosoft/TypeScript:masterfrom
fixAnonymousTypeInstantiationmicrosoft/TypeScript:fixAnonymousTypeInstantiationCopy head branch name to clipboard
Oct 11, 2017
Merged

Fix anonymous type instantiation#19091
ahejlsberg merged 6 commits into
mastermicrosoft/TypeScript:masterfrom
fixAnonymousTypeInstantiationmicrosoft/TypeScript:fixAnonymousTypeInstantiationCopy head branch name to clipboard

Conversation

@ahejlsberg

@ahejlsberg ahejlsberg commented Oct 11, 2017

Copy link
Copy Markdown
Member

With #18231 we included an optimization to track which type parameters are referenced in anonymous types such that unnecessary instantiations can be avoided. This optimization did not properly account for locally declared types that might reference type parameters. With this PR we now optimize only when there are no intervening statement blocks between an anonymous type literal and a particular type parameter (and thus no opportunity to indirectly reference the type parameter), and no type queries (typeof in a type position) within the anonymous type literal.

Fixes #19043.

@ahejlsberg ahejlsberg requested a review from mhegazy October 11, 2017 00:54
@mhegazy

mhegazy commented Oct 11, 2017

Copy link
Copy Markdown
Contributor

here is another example using typeof that exhibits the same aliasing behavior like type aliases:

declare function f<T>(a: T, b: { a: typeof a });
f(2, { a: 2 });

@ahejlsberg ahejlsberg merged commit 728d2a9 into master Oct 11, 2017
@ahejlsberg ahejlsberg deleted the fixAnonymousTypeInstantiation branch October 11, 2017 23:54
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.