scottrippey / next-router-mock

Mock implementation of the Next.js Router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MemoryRouterProvider/index.d.ts' is not a module.

yusukegoto opened this issue · comments

I see the error since v0.7.0.

error TS2306: File '/Users/yusukegoto/src/myapp/node_modules/next-router-mock/dist/MemoryRouterProvider/index.d.ts' is not a module.

And as error mesage said, index.d.js is empty.

ls -l ./node_modules/next-router-mock/dist/MemoryRouterProvider/index.d.ts
-rw-r--r--  1 yusukegoto  staff  0 10 Jun 15:57 ./node_modules/next-router-mock/dist/MemoryRouterProvider/index.d.ts

I import it like below. This is the same one written in README.

import { MemoryRouterProvider } from 'next-router-mock/MemoryRouterProvider';

Am I missing some configuration?

You're right ... the types are broken in the build. I'll fix this soon.

As a workaround, you can try importing the "explicit version number" like one of these:

import { MemoryRouterProvider } from 'next-router-mock/MemoryRouterProvider/next-12';
import { MemoryRouterProvider } from 'next-router-mock/MemoryRouterProvider/next-11';
import { MemoryRouterProvider } from 'next-router-mock/MemoryRouterProvider/next-10';

Published a fix, try out 0.7.2 and let me know!

@scottrippey

Published a fix, try out 0.7.2 and let me know!

Hi, error has changed. I'm using MemoryRouterProvider with storyboard and <MemoryRouterProvider /> still fails.

error TS1362: 'MemoryRouterProvider' cannot be used as a value because it was exported using 'export type'.

Then import with type fails.

import type { MemoryRouterProvider } from "next-router-mock/MemoryRouterProvider";
error TS1361: 'MemoryRouterProvider' cannot be used as a value because it was imported using 'import type'.

Thanks!

I found and fixed the problem, and added a unit test for this scenario! Thanks for finding it. Please try version 0.7.3 and LMK!