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

Automatically resolve custom path aliases in build #32479

Closed
5 tasks done
lffg opened this issue Jul 19, 2019 · 1 comment
Closed
5 tasks done

Automatically resolve custom path aliases in build #32479

lffg opened this issue Jul 19, 2019 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@lffg
Copy link

lffg commented Jul 19, 2019

Search Terms

automatically resolve custom path aliases in build generated code

Suggestion

I personally can't find the reason why TypeScript does not automatically resolve custom path aliases in the build.

TypeScript is a compiler, so I think that it should take care of that.

To avoid any breaking changes, I think that introducing a new option such as resolveCustomPaths is a good solution.

Use Cases

When I have the paths option set in the tsconfig.json, TypeScript will automatically resolve the import paths in the generated code.

Examples

If I have the following tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "@core/*": ["app/core/*"]
      "@services/*": ["app/services/*"]
    }
  }
}

And I have the following /src/app/http/controllers/UserController.ts file:

import { ... } from '@services/my-service.ts';

Would be nice if the UserController.ts could be compiled into something like:

// UserController.js (Compiled)

// BaseURL (tsconfig.json `src`) + CustomPath (tsconfig.json `app/services`) + RequiredFile (`my-service.ts`)
const { ... } = require('src/app/services/my-service.js');

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.
@fatcerberus
Copy link

See #31643 (comment).

@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants