Skip to content

Commit ca2ea02

Browse files
fix missing type (#329)
1 parent 365bbfc commit ca2ea02

4 files changed

Lines changed: 19 additions & 18 deletions

File tree

src/appConfigurationImpl.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,18 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
9898
#sentinels: Map<WatchedSetting, SettingWatcher> = new Map();
9999
#watchAll: boolean = false;
100100
#kvRefreshInterval: number = DEFAULT_REFRESH_INTERVAL_IN_MS;
101-
#kvRefreshTimer: RefreshTimer;
101+
#kvRefreshTimer: RefreshTimer | undefined = undefined;
102102

103103
// Feature flags
104104
#featureFlagEnabled: boolean = false;
105105
#featureFlagRefreshEnabled: boolean = false;
106106
#ffRefreshInterval: number = DEFAULT_REFRESH_INTERVAL_IN_MS;
107-
#ffRefreshTimer: RefreshTimer;
107+
#ffRefreshTimer: RefreshTimer | undefined = undefined;
108108

109109
// Key Vault references
110110
#secretRefreshEnabled: boolean = false;
111111
#secretReferences: ConfigurationSetting[] = []; // cached key vault references
112-
#secretRefreshTimer: RefreshTimer;
112+
#secretRefreshTimer: RefreshTimer | undefined = undefined;
113113
#resolveSecretsInParallel: boolean = false;
114114

115115
/**
@@ -126,7 +126,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
126126

127127
constructor(
128128
clientManager: ConfigurationClientManager,
129-
options: AzureAppConfigurationOptions | undefined,
129+
options?: AzureAppConfigurationOptions,
130130
) {
131131
this.#options = options;
132132
this.#clientManager = clientManager;
@@ -415,7 +415,8 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
415415
postAttempts += 1;
416416
backoffDuration = getExponentialBackoffDuration(postAttempts);
417417
}
418-
console.warn(`Failed to load. Error message: ${error.message}. Retrying in ${backoffDuration} ms.`);
418+
const errorMessage = error instanceof Error ? error.message : String(error);
419+
console.warn(`Failed to load. Error message: ${errorMessage}. Retrying in ${backoffDuration} ms.`);
419420
await new Promise(resolve => setTimeout(resolve, backoffDuration));
420421
}
421422
} while (!abortSignal.aborted);
@@ -690,7 +691,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
690691
*/
691692
async #refreshFeatureFlags(): Promise<boolean> {
692693
// if still within refresh interval/backoff, return
693-
if (this.#ffRefreshInterval === undefined || !this.#ffRefreshTimer.canRefresh()) {
694+
if (this.#ffRefreshInterval === undefined || !this.#ffRefreshTimer!.canRefresh()) {
694695
return Promise.resolve(false);
695696
}
696697

@@ -699,7 +700,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
699700
await this.#loadFeatureFlags();
700701
}
701702

702-
this.#ffRefreshTimer.reset();
703+
this.#ffRefreshTimer!.reset();
703704
return Promise.resolve(needRefresh);
704705
}
705706

@@ -728,7 +729,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
728729
* @returns true if key-value collection has changed, false otherwise.
729730
*/
730731
async #checkConfigurationSettingsChange(selectors: PagedSettingsWatcher[]): Promise<boolean> {
731-
const funcToExecute = async (client) => {
732+
const funcToExecute = async (client: AppConfigurationClient) => {
732733
for (const selector of selectors) {
733734
if (selector.snapshotName) { // skip snapshot selector
734735
continue;
@@ -765,7 +766,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
765766
* Gets a configuration setting by key and label.If the setting is not found, return undefine instead of throwing an error.
766767
*/
767768
async #getConfigurationSetting(configurationSettingId: ConfigurationSettingId, getOptions?: GetConfigurationSettingOptions): Promise<GetConfigurationSettingResponse | undefined> {
768-
const funcToExecute = async (client) => {
769+
const funcToExecute = async (client: AppConfigurationClient) => {
769770
return getConfigurationSettingWithTrace(
770771
this.#requestTraceOptions,
771772
client,
@@ -788,7 +789,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
788789
}
789790

790791
async #listConfigurationSettings(listOptions: ListConfigurationSettingsOptions): Promise<{ items: ConfigurationSetting[]; pageWatchers: SettingWatcher[] }> {
791-
const funcToExecute = async (client) => {
792+
const funcToExecute = async (client: AppConfigurationClient) => {
792793
const pageWatchers: SettingWatcher[] = [];
793794
const pageIterator = listConfigurationSettingsWithTrace(
794795
this.#requestTraceOptions,
@@ -808,7 +809,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
808809
}
809810

810811
async #getSnapshot(snapshotName: string, getOptions?: GetSnapshotOptions): Promise<GetSnapshotResponse | undefined> {
811-
const funcToExecute = async (client) => {
812+
const funcToExecute = async (client: AppConfigurationClient) => {
812813
return getSnapshotWithTrace(
813814
this.#requestTraceOptions,
814815
client,
@@ -831,7 +832,7 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
831832
}
832833

833834
async #listConfigurationSettingsForSnapshot(snapshotName: string, listOptions?: ListConfigurationSettingsForSnapshotOptions): Promise<ConfigurationSetting[]> {
834-
const funcToExecute = async (client) => {
835+
const funcToExecute = async (client: AppConfigurationClient) => {
835836
const pageIterator = listConfigurationSettingsForSnapshotWithTrace(
836837
this.#requestTraceOptions,
837838
client,

src/common/contentType.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type ContentType = {
88
parameters: Record<string, string>;
99
}
1010

11-
export function parseContentType(contentTypeValue: string | undefined): ContentType | undefined {
11+
export function parseContentType(contentTypeValue?: string): ContentType | undefined {
1212
if (!contentTypeValue) {
1313
return undefined;
1414
}
@@ -27,7 +27,7 @@ export function parseContentType(contentTypeValue: string | undefined): ContentT
2727

2828
// Determine whether a content type string is a valid JSON content type.
2929
// https://docs.microsoft.com/en-us/azure/azure-app-configuration/howto-leverage-json-content-type
30-
export function isJsonContentType(contentType: ContentType | undefined): boolean {
30+
export function isJsonContentType(contentType?: ContentType): boolean {
3131
const mediaType = contentType?.mediaType;
3232
if (!mediaType) {
3333
return false;
@@ -45,15 +45,15 @@ export function isJsonContentType(contentType: ContentType | undefined): boolean
4545
return typeParts[1].split("+").includes("json");
4646
}
4747

48-
export function isFeatureFlagContentType(contentType: ContentType | undefined): boolean {
48+
export function isFeatureFlagContentType(contentType?: ContentType): boolean {
4949
const mediaType = contentType?.mediaType;
5050
if (!mediaType) {
5151
return false;
5252
}
5353
return mediaType === featureFlagContentType;
5454
}
5555

56-
export function isSecretReferenceContentType(contentType: ContentType | undefined): boolean {
56+
export function isSecretReferenceContentType(contentType?: ContentType): boolean {
5757
const mediaType = contentType?.mediaType;
5858
if (!mediaType) {
5959
return false;

src/keyvault/keyVaultKeyValueAdapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class AzureKeyVaultKeyValueAdapter implements IKeyValueAdapter {
1616
#keyVaultOptions: KeyVaultOptions | undefined;
1717
#keyVaultSecretProvider: AzureKeyVaultSecretProvider;
1818

19-
constructor(keyVaultOptions: KeyVaultOptions | undefined, refreshTimer?: RefreshTimer) {
19+
constructor(keyVaultOptions?: KeyVaultOptions, refreshTimer?: RefreshTimer) {
2020
this.#keyVaultOptions = keyVaultOptions;
2121
this.#keyVaultSecretProvider = new AzureKeyVaultSecretProvider(keyVaultOptions, refreshTimer);
2222
}

src/keyvault/keyVaultSecretProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export class AzureKeyVaultSecretProvider {
1414
#secretClients: Map<string, SecretClient>; // map key vault hostname to corresponding secret client
1515
#cachedSecretValues: Map<string, any> = new Map<string, any>(); // map secret identifier to secret value
1616

17-
constructor(keyVaultOptions: KeyVaultOptions | undefined, refreshTimer?: RefreshTimer) {
17+
constructor(keyVaultOptions?: KeyVaultOptions, refreshTimer?: RefreshTimer) {
1818
if (keyVaultOptions?.secretRefreshIntervalInMs !== undefined) {
1919
if (refreshTimer === undefined) {
2020
throw new ArgumentError("Refresh timer must be specified when Key Vault secret refresh is enabled.");

0 commit comments

Comments
 (0)