samuelcolvin / edge-mock

Tools for testing and developing CloudFlare worker apps.
https://www.npmjs.com/package/edge-mock
MIT License
53 stars 5 forks source link

importing `makeEdgeEnv` interferes with `@cloudflare/workers-types` typings #12

Closed toinbis closed 3 years ago

toinbis commented 3 years ago

Starting using edge-mock in one of the projects. Enjoying it much.

I came across and odd situation, which might be totally expected, but I felt like reporting it as potential issue nonetheless.

I was successfully using ModuleWorker typings from https://github.com/cloudflare/workers-types/blob/feat/module-worker/index.d.ts#L734 (installed @cloudflare/workers-types from git branch).

The moment I starting writing my test, and did this by adding import { makeEdgeEnv } from 'edge-mock' as first line to my initial test, this TS error started popping out.

Screenshot 2021-08-22 at 22 46 08

I can silence the error by either of: a) Commenting out import { makeEdgeEnv } from 'edge-mock' (which I sure don't wan't to do); b) Commenting out "tests/*.ts" from tsconfig.json's include values (which I'm not sure I want to do);

Either a) or b) brings back expected typings: Screenshot 2021-08-22 at 22 59 52

Maybe it's just b) - I am supposed to exclude tests from "include" in tsconfig.json. Maybe it's edge-mock not (yet) supporting Modules syntax. Or maybe anything else that my limited knowledge/expertise does not allow me to identify, that causes this TS error.

Kindly please feel free to instantly close this issue if that's an expected behaviour. Thanks!

toinbis commented 3 years ago

Rewrote repo from scratch and the issue seems to be gone. Sorry for false alarm. Am closing the issue.

samuelcolvin commented 3 years ago

Pleased you sorted it.