-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
I have this bit of code:
import * as express from 'express';
import {RequestHandler} from 'express';
const router = express.Router();
export const register = (v: any) => {
router.get('/', makeGetFoo(v));
router.put('/', makePutFoo(v));
};
namespace ApiDoc {
export interface makeGetFoo { // <--- i want to share this interface with front-end codebase
success: boolean
}
export interface makePutFoo { // <--- i want to share this interface with front-end codebase
success: boolean
}
}
const makeGetFoo = (v: any): RequestHandler => {
return (req, res, next) => {
res.json(<ApiDoc[makeGetFoo.name]>{success: true});
};
};
const makePutFoo = (v: any): RequestHandler => {
return (req, res, next) => {
res.json(<ApiDoc[makePutFoo.name]>{success: true});
};
};my goal is to put the typings in a intermediary file, so that the types can be sourced by the front-end code. Hopefully you understand what I am trying to do.
The problem is I get this:
Cannot use namespace ApiDoc as a type
What I want to do is create a system where the interface name matches the function name so that I don't have to guess, etc.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
