Repository navigation
Treat {} in T = {} as any in JS files - #19977
Merged
Wesley Wigham (weswigham) merged 1 commit intoNov 13, 2017
Merged
Wesley Wigham (weswigham) merged 1 commit into
Wesley Wigham (weswigham) merged 1 commit into
Conversation
Wesley Wigham (weswigham)
requested review from
Ryan Cavanaugh (RyanCavanaugh),
Mohamed Hegazy (mhegazy) and
Ron Buckton (rbuckton)
November 13, 2017 21:07
Ron Buckton (rbuckton)
approved these changes
Nov 13, 2017
Ryan Cavanaugh (RyanCavanaugh)
approved these changes
Nov 13, 2017
| const mapper = createTypeMapper(typeParameters, typeArguments); | ||
| const defaultType = getDefaultFromTypeParameter(typeParameters[i]); | ||
| let defaultType = getDefaultFromTypeParameter(typeParameters[i]); | ||
| if (defaultType && isTypeIdenticalTo(defaultType, emptyObjectType) && isJavaScriptImplicitAny) { |
Contributor
There was a problem hiding this comment.
would emptyTypeLiteralType equality check do the trick?
Member
Author
There was a problem hiding this comment.
Any {} which has an alias symbol (like in react) would defeat that. IE,
type InternalMembers = {}
export class ComponentBase<P = InternalMembers> {}
Mohamed Hegazy (mhegazy)
approved these changes
Nov 13, 2017
Wesley Wigham (weswigham)
deleted the
empty-curly-defaults-as-any-in-js
branch
November 13, 2017 23:39
Member
Author
|
Mohamed Hegazy (@mhegazy) I know I've already merged, but as an improvement, should this production of |
Contributor
|
i guess we should flag them all for consistency... that applies to |
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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This is mostly for cases like
react, where the component type is defined with restrictive default props of{}, which while great for TS consumers, makes things difficult for JS users, and makes consuming JS react components inside TS difficult.Fixes #19971