Skip to content

importing the lib? #565

Open
Open
@busticated

Description

@busticated

hey there 👋

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions