Problem with using typescript in server code
See original GitHub issuewhen I want to use type script as server code I get Error
my .ts code
` import * as express from ‘express’;
class PostController { public router; public path = ‘/Post’;
constructor() {
this.router = express.Router();
this.initRoutes();
}
public initRoutes() {
this.router.get(this.path, this.getPosts);
}
getPosts(request: express.Request, response: express.Response) {
response.send('Posts list')
}
}
export default PostController; `
and when I wun " npm run ssr" I get this error can you please help me
` ERROR in ./ServerCode/post.controller.ts 4:11 Module parse failed: Unexpected token (4:11) You may need an appropriate loader to handle this file type, currently no loader s are configured to process this file. See https://webpack.js.org/concepts#loade rs | | class PostController {
public router;
| public path = ‘/Post’; | @ ./server.ts 73:0-57 74:21-35 `
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
TypeScript Server Error (4.7.3) - Quick Fix... not working #50162
I have started VS Code by using the command: "Developer: Reload With Extensions Disabled". It's a newly generated project for which I have...
Read more >Common TypeScript module problems and how to solve them
Enabling the compiler module resolution tracing in TypeScript can provide insight in diagnosing and solving problems.
Read more >The common misconception about TypeScript
First, you have to understand why we need TypeScript when coding with JavaScript is enough for most of the use-cases. People use TypeScript...
Read more >A Complete Guide to Using TypeScript in Node.js - Better Stack
TypeScript is a superset of JavaScript that brings static typing capabilities to the language. Since its introduction in 2011, it has steadily gained ......
Read more >TypeScript tutorial with Visual Studio Code
The TypeScript language service has a powerful set of diagnostics to find common coding issues. For example, it can analyze your source code...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
and I am using it in the server.ts like this
`import PostController from ‘./ServerCode/post.controller’
app.use(‘/postUser’, PostController); `
I recommendation separate scripts for universal and backend