Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Add types #67

Closed
OliverJAsh opened this issue Mar 3, 2020 · 11 comments 路 Fixed by #72
Closed

Add types #67

OliverJAsh opened this issue Mar 3, 2020 · 11 comments 路 Fixed by #72

Comments

@OliverJAsh
Copy link

Hey! Could we add these types to the repository so TS users don't have to define them manually? 馃槃

declare module '@cypress/webpack-preprocessor' {
  import * as webpack from 'webpack';

  type FilePreprocessor = (file: Cypress.FileObject) => string | Promise<string>;

  namespace _default {
    export type Options = { webpackOptions: webpack.Configuration };
  }

  const _default: (options: _default.Options) => FilePreprocessor;

  export = _default;
}
@jennifer-shehane
Copy link
Member

This is very low priority for us, but we would be open to a PR.

@NickBolles
Copy link
Contributor

@OliverJAsh are you using typescript in plugin files? if so how? Regardless, VSCode uses typescript types for intellisense for javascript too. I'll take a crack at this today.

@OliverJAsh
Copy link
Author

Yes, via the checkJs compiler option.

@chrisbreiding
Copy link
Collaborator

The main cypress package now includes types for the plugins file. See this example for how to utilize them.

@OliverJAsh
Copy link
Author

Does it include types for module @cypress/webpack-preprocessor?

@OliverJAsh
Copy link
Author

E.g. if I do this in my plugins file:

const webpack = require('@cypress/webpack-preprocessor');

I want webpack to have types.

@chrisbreiding
Copy link
Collaborator

馃帀 This issue has been resolved in version 5.1.0 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

@OliverJAsh
Copy link
Author

Unfortunately this is not quite fixed: https://github.com/cypress-io/cypress-webpack-preprocessor/pull/72/files#r404905879

Can we re-open? @chrisbreiding

@chrisbreiding chrisbreiding reopened this Apr 7, 2020
@chrisbreiding
Copy link
Collaborator

Properly fixed in 5.1.1

@OliverJAsh
Copy link
Author

How do I import the Options type? I would like to use that type to annotate my options.

@OliverJAsh
Copy link
Author

const webpack = require('@cypress/webpack-preprocessor');
// Namespace '_default' has no exported member 'Options'
/** @type {webpack.Options} */
const options = {
  webpackOptions: {}
}

This was referenced Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants