Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importing the lib? #565

Open
busticated opened this issue Feb 22, 2024 · 1 comment
Open

importing the lib? #565

busticated opened this issue Feb 22, 2024 · 1 comment

Comments

@busticated
Copy link

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?

@horiuchi
Copy link
Owner

@busticated Hi!

There simply is no need for a default there.
Just write await dtsgenerator({ ~~~ });.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants