profile
viewpoint

Ask questionsExample from readme with typescript

I tried the example and it does not seem to compile

import Conf from 'conf'

const schema = {
	bar: {
		type: 'string'
	}
};

const config = new Conf({schema});

https://repl.it/repls/AliveLumberingTechnicians#index.ts

/usr/local/lib/node_modules/ts-node-fm/src/index.ts:226
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
index.ts:9:25 - error TS2345: Argument of type '{ schema: { bar: { type: string; }; }; }' is not assignable to parameter of type 'Readonly<Partial<Options<{ bar: {}; }>>>'.
  Types of property 'schema' are incompatible.
    Type '{ bar: { type: string; }; }' is not assignable to type 'Schema<{ bar: {}; }>'.
      Types of property 'bar' are incompatible.
        Type '{ type: string; }' is not assignable to type 'JSONSchema'.
          Types of property 'type' are incompatible.
            Type 'string' is not assignable to type '"string" | "number" | "boolean" | "object" | JSONSchemaType | "array" | "integer" | "null" | ("string" | "number" | "boolean" | "object" | JSONSchemaType | "array" | "integer" | "null")[] | undefined'.

9 const config = new Conf({schema});
                          ~~~~~~~~

    at createTSError (/usr/local/lib/node_modules/ts-node-fm/src/index.ts:226:12)
    at getOutput (/usr/local/lib/node_modules/ts-node-fm/src/index.ts:335:40)
    at Object.compile (/usr/local/lib/node_modules/ts-node-fm/src/index.ts:368:11)
    at startRepl (/usr/local/lib/node_modules/ts-node-fm/src/bin.ts:147:28)
    at Object.<anonymous> (/usr/local/lib/node_modules/ts-node-fm/src/bin.ts:66:1)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
sindresorhus/conf

Answer questions kevinsimper

Some good solutions has come up 👍

useful!

Related questions

No questions were found.
source:https://uonfu.com/
answerer
Kevin Simper kevinsimper Blackbeard Copenhagen, Denmark https://www.kevinsimper.dk Working on electric car sharing at @greenmobility
Github User Rank List