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

feat: improve typings for lighthouse and shared #186

Merged
merged 1 commit into from
Oct 28, 2022

Conversation

ahnpnl
Copy link
Contributor

@ahnpnl ahnpnl commented Oct 25, 2022

Summary

When trying to use this package in a Cypress project with TypeScript, I ran into several errors with typings. For example:

// TypeScript said the functions `prepareAudit` and `lighthouse`  are not defined
import { prepareAudit, lighthouse } from '@cypress-audit/lighthouse';

export const lighthousePlugin: Cypress.PluginConfig = (on, config) => {
    on('before:browser:launch', (_browser, launchOptions) => {
        prepareAudit(launchOptions);
    });

    on('task', {
        lighthouse: lighthouse(),
    });

    return config;
};
  • Add cypress to root package.json. This will allow IDE to recognize /// <reference types="cypress" />
  • Update index.d.ts in packages/lighthouse
  • Add index.d.ts in packages/shared
  • Add types to package.json for both packages/lighthouse and packages/shared
  • Add .eslintignore to ignore .d.ts

cc @mfrachet

- Add `cypress` to root `package.json`. This will allow IDE to recognize `/// <reference types="cypress" />`
- Update `index.d.ts` in `packages/lighthouse`
- Add `index.d.ts` in `packages/shared`
- Add `types` to `package.json` for both `packages/lighthouse` and `packages/shared`
- Add `.eslintignore` to ignore `.d.ts`
@mfrachet mfrachet merged commit 091317b into mfrachet:master Oct 28, 2022
@mfrachet
Copy link
Owner

Thanks for the contribution 🙏🏻

@ahnpnl ahnpnl deleted the feature/improve-typings branch October 28, 2022 07:10
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

Successfully merging this pull request may close these issues.

2 participants