Closed johhansantana closed 6 years ago
+1
Cannot find module './routes'
and on the client when using : [ts] Module '"/Users/chriscampbell/Desktop/ef prototype/routes"' has no exported member 'Link'.
I just opened #153 to get typings included in this project :)
You will need to rewrite your code like so:
import routes from '../routes';
const { Link, Route } = routes;
Since routes
is an instance of class Routes (see here), its members don't get exported as module exports. It's possible to destructure in vanilla JS but TypeScript is stricter about modules.
Thanks, it's merged now.
I'm using 1.4.2
and still getting the has no exported member 'Link'
error from TypeScript when trying to import Link
.
import { Link } from '../../server/routes';
Was this actually fixed of do I need to use @disintegrator's workaround still?
I'm using
1.4.2
and still getting thehas no exported member 'Link'
error from TypeScript when trying to importLink
.import { Link } from '../../server/routes';
Was this actually fixed of do I need to use @disintegrator's workaround still?
I'm trying to do this with version 1.4.2
, and i confirm is still needed the solution of @disintegrator.
I'm using
1.4.2
and still getting thehas no exported member 'Link'
error from TypeScript when trying to importLink
.import { Link } from '../../server/routes';
I was getting the same error, but was able to fix it by providing additional JSDoc annotations in routes.js
. This helps TS to figure out the exported types, based on the type-definitions provided by next-routes
.
// routes.js
/**
* @typedef { import("next-routes").Registry } Registry}
*/
const routes = require('next-routes');
/**
* @type {Registry}
*/
module.exports = routes()
.add('/:slug', 'page');
The import-syntax is specific to TypeScript and described here in detail: https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript#import-types
I'm using typescript with nextjs but this error shows up. The library works though.