-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2405,7 +2405,7 @@ export function getCompletionEntriesFromSymbols( | |
} | ||
|
||
// When in a value location in a JS file, ignore symbols that definitely seem to be type-only | ||
if (!isTypeOnlyLocation && isInJSFile(sourceFile) && !(symbol.flags & SymbolFlags.Value) && !isInJSFile(symbol.declarations?.[0]?.getSourceFile())) { | ||
if (!isTypeOnlyLocation && isInJSFile(sourceFile) && symbolAppearsToBeTypeOnly(symbol)) { | ||
continue; | ||
} | ||
|
||
|
@@ -2503,6 +2503,10 @@ export function getCompletionEntriesFromSymbols( | |
// expressions are value space (which includes the value namespaces) | ||
return !!(allFlags & SymbolFlags.Value); | ||
} | ||
|
||
function symbolAppearsToBeTypeOnly(symbol: Symbol): boolean { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
JoshuaKGoldberg
Author
Contributor
|
||
return !(symbol.flags & SymbolFlags.Value) && (!isInJSFile(symbol.declarations?.[0]?.getSourceFile()) || !!(symbol.flags & SymbolFlags.Type)); | ||
This comment has been minimized.
Sorry, something went wrong.
Andarist
Contributor
|
||
} | ||
} | ||
|
||
function getLabelCompletionAtPosition(node: BreakOrContinueStatement): CompletionInfo | undefined { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/// <reference path='fourslash.ts'/> | ||
// @allowJs: true | ||
|
||
// @Filename: types.js | ||
//// /** | ||
//// * @typedef {Object} Pet | ||
//// * @prop {string} name | ||
//// */ | ||
//// module.exports = { a: 1 }; | ||
|
||
// @Filename: app.js | ||
//// import { /**/ } from "./types" | ||
|
||
verify.completions({ marker: "", excludes: "Pet" }); |
nit: is the "appearsToBe" bit intentional or are you just unsure if this already covers everything? :p If you are just unsure then I would still use a more "confident" function name - if this function can return some false positives intentionally then the name is fine.