node-convict icon indicating copy to clipboard operation
node-convict copied to clipboard

_cvtProperties undefined

Open HighWolf opened this issue 3 years ago • 1 comments

_cvtProperties do not exist on final path of schema

The default value for FOO.BAR.BAZ is stored in _schema._cvtProperties at: FOO._cvtProperties.BAR._cvtProperties.BAZ.default

TypeError: Cannot read properties of undefined (reading <k>)
    at node_modules\convict\src\main.js:371:52
    at Array.forEach (<anonymous>)
    at overlay (node_modules\convict\src\main.js:363:21)
    at node_modules\convict\src\main.js:371:7
    at Array.forEach (<anonymous>)
    at overlay (node_modules\convict\src\main.js:363:21)
    at node_modules\convict\src\main.js:371:7
    at Array.forEach (<anonymous>)
    at overlay (node_modules\convict\src\main.js:363:21)
    at node_modules\convict\src\main.js:609:11

HighWolf avatar Jan 05 '23 00:01 HighWolf

The problem occurs when creating a schema from a dynamic type:

type TInitialSetup<T> = {
    [key: string]: T;
}
<SchemaObj<TInitialSetup<TValueUnit>>>{
    nullable: false,
    format: initialSetupValidator,
    default: {
        high: {
            value: 1
        },
        width: {
            value: 1,
            unit: 'cm'
        }
    }
}

HighWolf avatar Jan 20 '23 01:01 HighWolf