Skip to content

Commit 30cc659

Browse files
committed
fix build error by skipping resolving ts files from ext src
1 parent 0f979d5 commit 30cc659

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

typescript/src/codeActions/getCodeActions.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import objectSwapKeysAndValues from './custom/objectSwapKeysAndValues'
44
import changeStringReplaceToRegex from './custom/changeStringReplaceToRegex'
55
import splitDeclarationAndInitialization from './custom/splitDeclarationAndInitialization'
66
import addMissingProperties from './extended/addMissingProperties'
7+
import { ApplyExtendedCodeActionResult, IpcExtendedCodeAction } from '../ipcTypes'
8+
import { Except } from 'type-fest'
79

810
const codeActions: CodeAction[] = [objectSwapKeysAndValues, changeStringReplaceToRegex, splitDeclarationAndInitialization]
911
const extendedCodeActions: ExtendedCodeAction[] = [addMissingProperties]
@@ -27,11 +29,6 @@ export type ApplyCodeAction = (
2729
languageServiceHost: ts.LanguageServiceHost,
2830
) => ts.RefactorEditInfo | SimplifiedRefactorInfo[] | true | undefined
2931

30-
export type ApplyExtendedCodeActionResult = {
31-
edits: ts.TextChange[]
32-
snippetEdits: ts.TextChange[]
33-
}
34-
3532
export type CodeAction = {
3633
name: string
3734
id: string
@@ -60,6 +57,11 @@ export type ExtendedCodeAction = {
6057
codes?: number[]
6158
}
6259

60+
type Satisfies<T, U extends T> = any
61+
62+
// ensure props are in sync
63+
type CheckCodeAction = Satisfies<Except<ExtendedCodeAction, 'tryToApply'>, IpcExtendedCodeAction>
64+
6365
export const getExtendedCodeActions = <T extends string | undefined>(
6466
sourceFile: ts.SourceFile,
6567
positionOrRange: ts.TextRange | number,

typescript/src/ipcTypes.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApplyExtendedCodeActionResult, ExtendedCodeAction } from './codeActions/getCodeActions'
1+
// should-not contain other typescript/* imports that use globals as is imported in extension code (src/)
22

33
export const passthroughExposedApiCommands = ['getNodePath', 'getSpanOfEnclosingComment', 'getNodeAtPosition'] as const
44

@@ -35,6 +35,12 @@ export type GetSignatureInfoParameter = {
3535
isOptional: boolean
3636
}
3737

38+
export type IpcExtendedCodeAction = {
39+
title: string
40+
kind: string
41+
codes?: number[]
42+
}
43+
3844
// OUTPUT
3945
/**
4046
* @keysSuggestions TriggerCharacterCommand
@@ -59,7 +65,7 @@ export type RequestResponseTypes = {
5965
totalObjectCount: number
6066
}
6167
moveToExistingFile?: {}
62-
extendedCodeActions: ExtendedCodeAction[]
68+
extendedCodeActions: IpcExtendedCodeAction[]
6369
}
6470
twoStepCodeActionSecondStep:
6571
| {
@@ -119,9 +125,7 @@ export type EmmetResult = {
119125
emmetTextOffset: number
120126
}
121127

122-
export type PostfixCompletion = {
123-
label: string
124-
// replacement: [startOffset: number, endOffset?: number]
125-
insertText: string
126-
// sortText?: number,
128+
export type ApplyExtendedCodeActionResult = {
129+
edits: ts.TextChange[]
130+
snippetEdits: ts.TextChange[]
127131
}

0 commit comments

Comments
 (0)