Next-routes: Default export from next-routes

Created on 24 May 2018  路  6Comments  路  Source: fridays/next-routes

Hi !

I'm trying to get next-routes working with TypeScript.

I have this code right now :

import Routes from 'next-routes';

const routes = new Routes();

routes
  .add('about')
  .add('post', '/p/:id')

export default routes;

But when I'm trying to compile I get this error :

const routes = new Routes();
^
TypeError: next_routes_1.default is not a constructor

I followed example here

Could you please help me ?

Most helpful comment

Same here. I "solved" it with:

import * as createRoutes from "next-routes"
import Routes from "next-routes"

// @ts-ignore Types are broken
const routes: Routes = createRoutes()

routes
  .add("about")

export default routes
export const Link = routes.Link
export const Router = routes.Router

All 6 comments

Same here. I "solved" it with:

import * as createRoutes from "next-routes"
import Routes from "next-routes"

// @ts-ignore Types are broken
const routes: Routes = createRoutes()

routes
  .add("about")

export default routes
export const Link = routes.Link
export const Router = routes.Router

@prevostc Oh wow, it works ! Thanks :)

It works but requires a @ts-ignore and has pretty a bad semantic. I would like to see this fixed too :) @fridays do you accept PR on this issue?

@prevostc I agree, that's not good and should be fixed but.. It works atleast :D

@fridays I believe there's a pending PR to fix this. Can we get it merged please?

Anything happening with this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nishtacular picture nishtacular  路  3Comments

adekbadek picture adekbadek  路  4Comments

davidnguyen179 picture davidnguyen179  路  6Comments

ccuilla picture ccuilla  路  6Comments

breeny picture breeny  路  5Comments