Skip to content

Commit ecef0e9

Browse files
authored
refactor: remove unnecessary assertion (google-gemini#2579)
1 parent 90dd6df commit ecef0e9

File tree

6 files changed

+10
-32
lines changed

6 files changed

+10
-32
lines changed

packages/cli/src/config/settings.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import stripJsonComments from 'strip-json-comments'; // Will be mocked separatel
4343

4444
// These imports will get the versions from the vi.mock('./settings.js', ...) factory.
4545
import {
46-
LoadedSettings,
4746
loadSettings,
4847
USER_SETTINGS_PATH, // This IS the mocked path.
4948
SETTINGS_DIRECTORY_NAME, // This is from the original module, but used by the mock.
@@ -595,7 +594,7 @@ describe('Settings Loading and Merging', () => {
595594
describe('LoadedSettings class', () => {
596595
it('setValue should update the correct scope and recompute merged settings', () => {
597596
(mockFsExistsSync as Mock).mockReturnValue(false);
598-
const loadedSettings = loadSettings(MOCK_WORKSPACE_DIR) as LoadedSettings;
597+
const loadedSettings = loadSettings(MOCK_WORKSPACE_DIR);
599598

600599
vi.mocked(fs.writeFileSync).mockImplementation(() => {});
601600
// mkdirSync is mocked in beforeEach to return undefined, which is fine for void usage

packages/cli/src/ui/hooks/slashCommandProcessor.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,7 @@ export const useSlashCommandProcessor = (
127127
};
128128
} else {
129129
historyItemContent = {
130-
type: message.type as
131-
| MessageType.INFO
132-
| MessageType.ERROR
133-
| MessageType.USER,
130+
type: message.type,
134131
text: message.content,
135132
};
136133
}

packages/core/src/core/coreToolScheduler.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,9 @@ export class CoreToolScheduler {
282282

283283
// currentCall is a non-terminal state here and should have startTime and tool.
284284
const existingStartTime = currentCall.startTime;
285-
const toolInstance = (
286-
currentCall as
287-
| ValidatingToolCall
288-
| ScheduledToolCall
289-
| ExecutingToolCall
290-
| WaitingToolCall
291-
).tool;
292-
293-
const outcome = (
294-
currentCall as
295-
| ValidatingToolCall
296-
| ScheduledToolCall
297-
| ExecutingToolCall
298-
| WaitingToolCall
299-
).outcome;
285+
const toolInstance = currentCall.tool;
286+
287+
const outcome = currentCall.outcome;
300288

301289
switch (newStatus) {
302290
case 'success': {
@@ -579,7 +567,7 @@ export class CoreToolScheduler {
579567
callsToExecute.forEach((toolCall) => {
580568
if (toolCall.status !== 'scheduled') return;
581569

582-
const scheduledCall = toolCall as ScheduledToolCall;
570+
const scheduledCall = toolCall;
583571
const { callId, name: toolName } = scheduledCall.request;
584572
this.setStatusInternal(callId, 'executing');
585573

@@ -591,7 +579,7 @@ export class CoreToolScheduler {
591579
}
592580
this.toolCalls = this.toolCalls.map((tc) =>
593581
tc.request.callId === callId && tc.status === 'executing'
594-
? { ...(tc as ExecutingToolCall), liveOutput: outputChunk }
582+
? { ...tc, liveOutput: outputChunk }
595583
: tc,
596584
);
597585
this.notifyToolCallsUpdate();

packages/core/src/core/geminiChat.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ export class GeminiChat {
542542
automaticFunctionCallingHistory.length > 0
543543
) {
544544
this.history.push(
545-
...extractCuratedHistory(automaticFunctionCallingHistory!),
545+
...extractCuratedHistory(automaticFunctionCallingHistory),
546546
);
547547
} else {
548548
this.history.push(userInput);

packages/core/src/tools/web-fetch.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import { GroundingMetadata } from '@google/genai';
87
import { SchemaValidator } from '../utils/schemaValidator.js';
98
import {
109
BaseTool,
@@ -255,9 +254,7 @@ ${textContent}
255254

256255
let responseText = getResponseText(response) || '';
257256
const urlContextMeta = response.candidates?.[0]?.urlContextMetadata;
258-
const groundingMetadata = response.candidates?.[0]?.groundingMetadata as
259-
| GroundingMetadata
260-
| undefined;
257+
const groundingMetadata = response.candidates?.[0]?.groundingMetadata;
261258
const sources = groundingMetadata?.groundingChunks as
262259
| GroundingChunkItem[]
263260
| undefined;

packages/core/src/utils/editor.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ export function allowEditorTypeInSandbox(editor: EditorType): boolean {
7575
*/
7676
export function isEditorAvailable(editor: string | undefined): boolean {
7777
if (editor && isValidEditorType(editor)) {
78-
return (
79-
checkHasEditorType(editor as EditorType) &&
80-
allowEditorTypeInSandbox(editor as EditorType)
81-
);
78+
return checkHasEditorType(editor) && allowEditorTypeInSandbox(editor);
8279
}
8380
return false;
8481
}

0 commit comments

Comments
 (0)