question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Any plans for DefinitelyTyped support?

See original GitHub issue

Is your feature request related to a problem? Please describe. I was following the Cypress Full Stack Code Coverage guide and wanted to instrument my express back end by doing the following in my index.ts file:

import express from "express";
import cypressCodeCoverage from "@cypress/code-coverage/middleware/express";

const app = express();
cypressCodeCoverage(app);

I get the “Try npm install @types/cypress__code-coverage if it exists or add a new declaration (.d.ts) file containing declare module '@cypress/code-coverage/middleware/express';” error. When I tried to install the DefinitelyTyped module, I realized one does not exist for @types/cypress__code-coverage.

Describe the solution you’d like Either a new package in the DefinitelyTyped repo for @types/cypress_code-coverage, or for the package itself to natively support typescript for back end instrumentation.

Describe alternatives you’ve considered I’m happy to workaround this in the mean time by adding a global type declaration file for my package. I just wanted to see if you had any plans to support this or if you’d be okay with me putting up a PR for it (and see which approach you preferred)!

Additional context Let me know if you need anything else!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dvargas92495commented, Sep 5, 2020

@nicholaschiang this was deprioritized on my end as I moved away from the project that was using cypress code coverage. Doesn’t mean we can’t add to the DefinitelyTyped Repo! I’d be down to combine what I had from that project and what you have here as sort of a v1 that other people could use and grow from there

1reaction
nicholaschiangcommented, Sep 5, 2020

@dvargas92495 here are my current global.d.ts definitions (if you haven’t made some already):

// cypress/plugins/global.d.ts
declare module '@cypress/code-coverage/task' {
  export default function codecov(
    on: Cypress.PluginEvents, 
    config: Cypress.PluginConfigOptions
  ): void;
}

You can then use it in your cypress/plugins/index.ts like so:

// cypress/plugins/index.ts
import codecov from '@cypress/code-coverage/task';

export default function plugins(
  on: Cypress.PluginEvents, 
  config: Cypress.PluginConfigOptions
): Cypress.ConfigOptions {
  codecov(on, config);
  return config;
}

Note: You must first add the global cypress type definitions in your tsconfig.json to be able to reference them like that:

// cypress/tsconfig.json
{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "isolatedModules": false,
    "lib": ["es5", "dom"],
    "types": ["cypress", "node"]
  },
  "include": ["**/*.ts"]
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript and Google Maps | Maps JavaScript API
The DefinitelyTyped project is an open source projects that maintains type declaration files for many packages including Google Maps. The Google Maps JavaScript ......
Read more >
How to include Definitely Typed library to my deno project?
In the upcoming releases we plan to add support for a types field in package.json , to automatically lookup types and use them...
Read more >
Announcing the Official TypeScript Types Public Preview
Migrating from DefinitelyTyped · Fixes to problems in the existing definitions. · Removal of our (poor!) support for Ember Classic class features ...
Read more >
Using a JavaScript library (without type declarations ... - Medium
Don't give up yet, though — you can still use the library in your TypeScript project. Here's how. Plan B: Check Definitely Typed....
Read more >
TypeScript - Wikipedia
The default TypeScript Compiler can be used, or the Babel compiler can be invoked to convert TypeScript to JavaScript. TypeScript supports definition files...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found