dtsgenerator icon indicating copy to clipboard operation
dtsgenerator copied to clipboard

importing the lib?

Open busticated opened this issue 4 months ago • 1 comments

hey there :wave:

i'm running into weirdness trying to import the lib in order to use the programmatic API (docs). using:

import dtsgenerator, { parseSchema } from 'dtsgenerator';
// same result using: import { default as dtsgenerator, parseSchema } from 'dtsgenerator';

// ...

async function generateWithDTSGen(destination: string, schema) {
	const output = await dtsgenerator.default({
		contents: [
			parseSchema(schema),
		],
		config: {
			plugins: {
				'@dtsgenerator/single-quote': true,
				'@dtsgenerator/replace-namespace': {
					map: [
						{
							from: ['Components', 'Schemas'],
							to: ['API', 'Entities'],
						},
					],
				},
			},
		},
	});

	await fs.outputFile(destination, output);
}

my script runs and produces expected output but i get a typescript error:

bin/generate-api-types.ts:30:36 - error TS2339: Property 'default' does not exist on type '(options: Options) => Promise<string>'.

30  const output = await dtsgenerator.default({
                                      ~~~~~~~


Found 1 error in bin/generate-api-types.ts:30

how should i be importing things?

busticated avatar Feb 22 '24 22:02 busticated