jesseditson / fs-router

Use the FS as your micro router
BSD 3-Clause "New" or "Revised" License
165 stars 19 forks source link

Fixed exports in type declaration file #11

Closed michaelmosher closed 6 years ago

michaelmosher commented 6 years ago

I ran into issue when I tried to use the new type declarations. Example code:

import { router } from 'fs-router'
let intents = router(__dirname + '/intents')

Typescript was able to compile this, but running the code caused this error:

TypeError: fs_router_1.router is not a function

I realized this was because the library uses this syntax:

module.exports = function router() {

Instead of this syntax:

module.exports.router = function router() {

I made these changes to support that fact.

Incidentally, with this change, my code no longer compiled. Typescript returned an error like

Module '${my app path}/node_modules/fs-router/index"' resolves to a non-module entity and cannot be imported using this construct.

I modified my usage to this:

import Router = require('fs-router')
let intents = Router(__dirname + '/intents')

And now everything seems happy.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 7e48b3fad1ec6b66f0a40c5e2c6283891e37bbe9 on michaelmosher:master into 5e1638ddb2f58027ce4243ac38602a361b1f631e on jesseditson:master.

coveralls commented 6 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 7e48b3fad1ec6b66f0a40c5e2c6283891e37bbe9 on michaelmosher:master into 5e1638ddb2f58027ce4243ac38602a361b1f631e on jesseditson:master.