11import test from 'ava'
2- import { SettingsDefinitionMap , SettingDefinition , Settings } from '../src/config'
2+ import { AdapterConfig , SettingDefinition , Settings } from '../src/config'
33
44// This file has type declarations that test the types of the config system at
55// compile time.
@@ -158,7 +158,7 @@ const _settingsType: ExpectEqual<
158158void _settingsType
159159
160160// Reproduces the bug from `packages/sources/liveart/src/config/index.ts`.
161- // Annotating the variable with the default `SettingsDefinitionMap ` (no
161+ // Annotating the variable with the default `AdapterConfig ` (no
162162// inferred generic) widens the settings map to `Record<string,
163163// SettingDefinition>`. Any custom setting then resolves via an index
164164// signature whose value type is the full `SettingType<SettingDefinition>`
@@ -168,20 +168,19 @@ void _settingsType
168168// distributive over `SettingDefinition`), which silently allowed values
169169// like `adapterSettings.API_BASE_URL` to be passed into stricter types
170170// such as Axios's `baseURL: string | undefined`.
171- const wideConfig : SettingsDefinitionMap = {
171+ const wideConfig : AdapterConfig = new AdapterConfig ( {
172172 API_BASE_URL : {
173173 type : 'string' ,
174174 description : 'API base URL' ,
175175 required : true ,
176176 default : 'https://example.com' ,
177177 } ,
178- }
179- void wideConfig
178+ } )
180179
181- const _wideConfigAccess : ExpectEqual <
182- Settings < typeof wideConfig > [ 'API_BASE_URL' ] ,
183- string | number | boolean | undefined
184- > = true
180+ wideConfig . initialize ( )
181+
182+ // @ts -expect-error TS2339: Property 'API_BASE_URL' does not exist on type 'AdapterConfig<SettingsDefinitionMap>'.
183+ const _wideConfigAccess = wideConfig . settings . API_BASE_URL
185184void _wideConfigAccess
186185
187186// The tests below are not directly a test of the config types, but it
0 commit comments