Skip to content

Doesn't work when alias has a suffix #233

Description

@R1D3R175

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions