Skip to content

Commit cffd4bc

Browse files
committed
fix: better error message in devtools console when TS misbehaves (you will see no completions in this case)
1 parent e144fe6 commit cffd4bc

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

typescript/src/completionsAtPosition.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ export const getCompletionsAtPosition = (
7272
const sourceFile = program?.getSourceFile(fileName)
7373
if (!program || !sourceFile) return
7474
if (!scriptSnapshot || isInBannedPosition(position, scriptSnapshot, sourceFile)) return
75+
// just pick up random setting to check if we they are here
76+
if (c('correctSorting.enable') === undefined) {
77+
throw new Error(
78+
"Plugin didn't get required user settings (config). Most probably there is a problem with TypeScript. Either restart TS server, use stable TS version or disable typescript-essentials-plugin if you need to test this TS version",
79+
)
80+
}
7581
const exactNode = findChildContainingExactPosition(sourceFile, position)
7682
const isCheckedFile =
7783
!tsFull.isSourceFileJS(sourceFile as any) || !!tsFull.isCheckJsEnabledForFile(sourceFile as any, additionalData.compilerOptions as any)
@@ -226,11 +232,6 @@ export const getCompletionsAtPosition = (
226232
// if (c('completionHelpers') && node) prior.entries = objectLiteralHelpers(node, prior.entries) ?? prior.entries
227233

228234
if (c('patchToString.enable')) {
229-
// const indexToPatch = arrayMoveItemToFrom(
230-
// prior.entries,
231-
// ({ name }) => name === 'toExponential',
232-
// ({ name }) => name === 'toString',
233-
// )
234235
const indexToPatch = prior.entries.findIndex(({ name, kind }) => name === 'toString' && kind !== ts.ScriptElementKind.warning)
235236
if (indexToPatch !== -1) {
236237
const entryToPatch = prior.entries[indexToPatch]!

0 commit comments

Comments
 (0)