-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: type errors caused by upstream updates
- Loading branch information
Showing
6 changed files
with
199 additions
and
319 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
import type { UnwrapNestedRefs } from '@reactive-vscode/reactivity' | ||
import { reactive } from '@reactive-vscode/reactivity' | ||
import type { ConfigurationScope, ConfigurationTarget } from 'vscode' | ||
import type { ConfigTypeOptions, ParseConfigTypeOptions } from './defineConfigs' | ||
import { defineConfigs } from './defineConfigs' | ||
import type { Nullable } from './types' | ||
|
||
export type ConfigObject<C extends object> = UnwrapNestedRefs<C> & { | ||
/** | ||
* Write the configuration value to the workspace. | ||
* | ||
* @see https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration.update | ||
*/ | ||
$update: (key: keyof C, value: C[keyof C], configurationTarget?: Nullable<ConfigurationTarget>, overrideInLanguage?: boolean) => Promise<void> | ||
|
||
/** | ||
* Set the value without updating the workspace. | ||
*/ | ||
$set: (key: keyof C, value: C[keyof C]) => void | ||
} | ||
|
||
/** | ||
* Define configurations of an extension. See `vscode::workspace.getConfiguration`. | ||
* | ||
* You can use this function with [vscode-ext-gen](https://github.com/antfu/vscode-ext-gen). | ||
* | ||
* @category lifecycle | ||
*/ | ||
export function defineConfigObject<const C extends ConfigTypeOptions>(section: Nullable<string>, configs: C, scope?: Nullable<ConfigurationScope>): ConfigObject<ParseConfigTypeOptions<C>> | ||
export function defineConfigObject<C extends object>(section: Nullable<string>, configs: C, scope?: Nullable<ConfigurationScope>): ConfigObject<C> | ||
export function defineConfigObject(section: Nullable<string>, configs: Record<string, unknown>, scope?: Nullable<ConfigurationScope>) { | ||
const configRefs = defineConfigs(section, configs, scope) | ||
|
||
return reactive({ | ||
...configRefs, | ||
$update(key, value, configurationTarget, overrideInLanguage) { | ||
return configRefs[key].update(value, configurationTarget, overrideInLanguage) | ||
}, | ||
$set(key, value) { | ||
return configRefs[key].set(value) | ||
}, | ||
}) satisfies ConfigObject<typeof configs> | ||
} | ||
import type { UnwrapNestedRefs } from '@reactive-vscode/reactivity' | ||
import { reactive } from '@reactive-vscode/reactivity' | ||
import type { ConfigurationScope, ConfigurationTarget } from 'vscode' | ||
import type { ConfigTypeOptions, ParseConfigTypeOptions } from './defineConfigs' | ||
import { defineConfigs } from './defineConfigs' | ||
import type { Nullable } from './types' | ||
|
||
export type ConfigObject<C extends object> = UnwrapNestedRefs<C> & { | ||
/** | ||
* Write the configuration value to the workspace. | ||
* | ||
* @see https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration.update | ||
*/ | ||
$update: (key: keyof C, value: C[keyof C], configurationTarget?: Nullable<ConfigurationTarget>, overrideInLanguage?: boolean) => Promise<void> | ||
|
||
/** | ||
* Set the value without updating the workspace. | ||
*/ | ||
$set: (key: keyof C, value: C[keyof C]) => void | ||
} | ||
|
||
/** | ||
* Define configurations of an extension. See `vscode::workspace.getConfiguration`. | ||
* | ||
* You can use this function with [vscode-ext-gen](https://github.com/antfu/vscode-ext-gen). | ||
* | ||
* @category lifecycle | ||
*/ | ||
export function defineConfigObject<const C extends ConfigTypeOptions>(section: Nullable<string>, configs: C, scope?: Nullable<ConfigurationScope>): ConfigObject<ParseConfigTypeOptions<C>> | ||
export function defineConfigObject<C extends object>(section: Nullable<string>, configs: C, scope?: Nullable<ConfigurationScope>): ConfigObject<C> | ||
export function defineConfigObject(section: Nullable<string>, configs: Record<string, unknown>, scope?: Nullable<ConfigurationScope>) { | ||
const configRefs = defineConfigs(section, configs, scope) | ||
|
||
return reactive({ | ||
...configRefs, | ||
$update(key: string, value: any, configurationTarget: any, overrideInLanguage: any) { | ||
return configRefs[key].update(value, configurationTarget, overrideInLanguage) | ||
}, | ||
$set(key: string, value: any) { | ||
return configRefs[key].set(value) | ||
}, | ||
}) satisfies ConfigObject<typeof configs> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.