Skip to content

Commit

Permalink
chore: infer MongoClientOptions type instead of importing it (#403)
Browse files Browse the repository at this point in the history
Rather than importing it, define it in a slightly more reliable way
by referring to the second argument of `CliServiceProvider.connect()`.

For example, this also enables usage of `tlsUseSystemCA`, which is
included in `DevtoolsConnectOptions` (which is now the actual type
accepted by `CliServiceProvider.connect()`) but not in the driver's
`MongoClientOptions`.
  • Loading branch information
addaleax authored Mar 23, 2022
1 parent 87484f8 commit 5d3ba50
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/language/worker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CliServiceProvider } from '@mongosh/service-provider-server';
import type { MongoClientOptions } from '@mongosh/service-provider-server';
import { CompletionItemKind } from 'vscode-languageserver/node';
import { EJSON, Document } from 'bson';
import { ElectronRuntime } from '@mongosh/browser-runtime-electron';
Expand All @@ -8,6 +7,9 @@ import { parentPort, workerData } from 'worker_threads';
import { PlaygroundResult, PlaygroundDebug, ShellExecuteAllResult } from '../types/playgroundType';
import { ServerCommands } from './serverCommands';

// MongoClientOptions is the second argument of CliServiceProvider.connect(connectionStr, options)
type MongoClientOptions = NonNullable<Parameters<(typeof CliServiceProvider)['connect']>[1]>;

interface EvaluationResult {
printable: any;
type: string | null;
Expand Down

0 comments on commit 5d3ba50

Please sign in to comment.