Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work when alias has a suffix #233

Open
R1D3R175 opened this issue Oct 15, 2024 · 0 comments
Open

Doesn't work when alias has a suffix #233

R1D3R175 opened this issue Oct 15, 2024 · 0 comments

Comments

@R1D3R175
Copy link

R1D3R175 commented Oct 15, 2024

Environment

Express.JS application using express-file-routing for file-based routing.

Directory structure

├── index.ts
└── src/
    ├── services/
    ├── controllers/
    │   └── health.controller.ts
    ├── middlewares/
    ├── interfaces/
    └── routes/
        └── health.ts

tsconfig.json

"paths": {
  "@controllers/*": ["src/controllers/*.controller"],
  "@services/*": ["src/services/*.service"],
  "@middlewares/*": ["src/middlewares/*.middleware"],
  "@interfaces/*": ["src/interfaces/*.interface"]
},

What doesn't work?

Suppose I have the following file

import {checkHealth} from '@controllers/health';
import type {Handler} from 'express';

export const get: Handler = async (request, response) => {
  response.json({status: checkHealth()});
};

TypeScript will output the following

import { checkHealth } from '@controllers/health';
export const get = async (request, response) => {
    response.json({ status: checkHealth() });
};

Expected behaviour

tsc-alias should be able to resolve correctly

Results

tsc-alias doesn't resolve

Workaround

Remove any suffix from path aliases and it will work correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant