-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Completion for default export should be '.default' #16742
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
Changes from all commits
f2359e4
5a6e240
126a46c
95613fb
d2686c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -949,6 +949,22 @@ namespace FourSlash { | |
this.verifySymbol(symbol, declarationRanges); | ||
} | ||
|
||
public symbolsInScope(range: Range): ts.Symbol[] { | ||
const node = this.goToAndGetNode(range); | ||
return this.getChecker().getSymbolsInScope(node, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: doesn't SymbolFlags have an alias defined like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not currently; |
||
} | ||
|
||
public verifyTypeOfSymbolAtLocation(range: Range, symbol: ts.Symbol, expected: string): void { | ||
const node = this.goToAndGetNode(range); | ||
const checker = this.getChecker(); | ||
const type = checker.getTypeOfSymbolAtLocation(symbol, node); | ||
|
||
const actual = checker.typeToString(type); | ||
if (actual !== expected) { | ||
this.raiseError(`Expected: '${expected}', actual: '${actual}'`); | ||
} | ||
} | ||
|
||
private verifyReferencesAre(expectedReferences: Range[]) { | ||
const actualReferences = this.getReferencesAtCaret() || []; | ||
|
||
|
@@ -3426,6 +3442,10 @@ namespace FourSlashInterface { | |
public markerByName(s: string): FourSlash.Marker { | ||
return this.state.getMarkerByName(s); | ||
} | ||
|
||
public symbolsInScope(range: FourSlash.Range): ts.Symbol[] { | ||
return this.state.symbolsInScope(range); | ||
} | ||
} | ||
|
||
export class GoTo { | ||
|
@@ -3694,6 +3714,10 @@ namespace FourSlashInterface { | |
this.state.verifySymbolAtLocation(startRange, declarationRanges); | ||
} | ||
|
||
public typeOfSymbolAtLocation(range: FourSlash.Range, symbol: ts.Symbol, expected: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't we get this from the quick info? I don't know whether we need a separate method for comparing the stringified type of a symbol. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, quick info gets us the type of the symbol under the cursor -- this lets us call |
||
this.state.verifyTypeOfSymbolAtLocation(range, symbol, expected); | ||
} | ||
|
||
public referencesOf(start: FourSlash.Range, references: FourSlash.Range[]) { | ||
this.state.verifyReferencesOf(start, references); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why combine flags in the true case instead of just returning
symbol.exportSymbol.flags
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
findAllRefsForDefaultExport08
(andfindAllRefsForDefaultExport02
), we have an exported class and a non-exported namespace merged with it. So the local symbol will have flags that the exported symbol is lacking; it hasNamespaceModule|ExportValue|ExportType
while the exported symbol just hasClass
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense