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

fix: Add typescript definitions #146

Merged
merged 2 commits into from
Sep 20, 2022
Merged

fix: Add typescript definitions #146

merged 2 commits into from
Sep 20, 2022

Conversation

JoaoTMDias
Copy link
Contributor

Because:

  • There was an issue opened asking for Typescript definitions for this package.

This commit:

  • Adds an index.d.ts file to the src folder, as well as jsdoc documentation.
  • Adds a typings entry on the package.json file

@seiry-apt
Copy link

👍

@edufarre
Copy link

Any updates or intentions to move this forward? Can we iterate this PR or create a new one?

@JoaoTMDias
Copy link
Contributor Author

Any updates or intentions to move this forward? Can we iterate this PR or create a new one?

I've just pushed a commit with a fix on the types definition file.

@illright
Copy link

@bahmutov Is there anything else needed here to merge this?

@bahmutov
Copy link
Owner

Looks good, merging it, thank you

@bahmutov bahmutov merged commit 247a420 into bahmutov:main Sep 20, 2022
@github-actions
Copy link

🎉 This PR is included in version 2.1.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ahnpnl
Copy link
Contributor

ahnpnl commented Sep 21, 2022

Hi, I got an error with this change

TypeError: (0 , cypress_esbuild_preprocessor_1.createBundler) is not a function

when I do

import { addCucumberPreprocessorPlugin } from '@badeball/cypress-cucumber-preprocessor';
import createEsbuildPlugin from '@badeball/cypress-cucumber-preprocessor/esbuild';
import { createBundler } from '@bahmutov/cypress-esbuild-preprocessor';

export const cucumberProcessorPlugin: Cypress.PluginConfig = async (on, config) => {
    await addCucumberPreprocessorPlugin(on, config);

    on(
        'file:preprocessor',
        createBundler({
            plugins: [createEsbuildPlugin(config)],
        }),
    );

    // Make sure to return the config object as it might have been modified by the plugin.
    return config;
};

Before this change, I used to use this import

// @ts-expect-error
import createBundler from '@bahmutov/cypress-esbuild-preprocessor';

which always work.

@bahmutov
Copy link
Owner

Why did you switch from the default import to named one?

@ahnpnl
Copy link
Contributor

ahnpnl commented Sep 21, 2022

It is because type definition is misleading. In the type definition there is a declare export const which shouldn’t be. The 2 const shouldn’t be exported. If using default export, TypeScript will still complain
image

@bahmutov
Copy link
Owner

Ok, I will be open to a pull request to fix this

@ahnpnl
Copy link
Contributor

ahnpnl commented Sep 23, 2022

Ok, I will be open to a pull request to fix this

Please check my open PR:)

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

Successfully merging this pull request may close these issues.

7 participants