Apply TS2713 to classes#20335
Merged
Merged
Conversation
Formerly, they were excluded as values, but the error is just as relevant for classes. Note that it is not applied to enums since switching to an indexed access expression will not help for an enum.
amcasey
commented
Nov 29, 2017
| function checkAndReportErrorForUsingTypeAsNamespace(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { | ||
| if (meaning === SymbolFlags.Namespace) { | ||
| const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); | ||
| const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Class | SymbolFlags.Interface | SymbolFlags.TypeAlias, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); |
Member
Author
There was a problem hiding this comment.
It seems like type aliases might already have been resolved by this point, so I'm not sure the flag makes any difference.
Member
There was a problem hiding this comment.
What about type parameters etc?
function foo<T extends { abc: number }>(x: T) {
let a: T.abc = x.abc;
// ~~~~~
}
Member
Author
There was a problem hiding this comment.
I was (incorrectly) thinking of a nominal type system in which it would be preferable to just use the name of the base type to get at the property.
Member
Author
There was a problem hiding this comment.
Can you please elaborate on "etc"? Are there other values that make sense?
Member
Author
There was a problem hiding this comment.
Offline, we settled on SymbolFlags.Type & ~SymbolFlags.Namespace.
mhegazy
approved these changes
Nov 30, 2017
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.
Formerly, they were excluded as values, but the error is just as
relevant for classes.
Note that it is not applied to enums since switching to an indexed
access expression will not help for an enum.