Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Gaëtan Redin
Gaëtan Redin

Posted on • Originally published atMedium on

     

Simplify Typescript import

Simplify TypeScript import

How to save your time using imports?

Hey, I’m sure you have already done something like:

import { MyService } from '../../../../../core/services/my-service.service';
Enter fullscreen modeExit fullscreen mode

Um, not sexy right?

But there is an easy solution to solve this.

Just open your tsconfig.app.json, and add paths option like this in the compilerOptions:

{    ...    "compilerOptions": {        ...        "paths": {            "@core/*": ["src/app/core/*"],            "@environments/*": ["src/environments/*"],            "@feature1/*": ["src/app/feature1/*"],            "@feature2/*": ["src/app/feature2/*"],            ...        }    }}
Enter fullscreen modeExit fullscreen mode

You can write as many as you want and the result will be:

import { MyService } from '@core/services/my-service.service';
Enter fullscreen modeExit fullscreen mode

No matter where you import it now, you will have this to write.

Thanks for reading.

Learn More.

Angular for everyone: All about it

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
kevindoran23 profile image
KevinDoran23
I have been working as a relay technician at Pup 'N' Taco for the last many years . A relay technician performs maintenance and repairs to relays in electrical power stations.
  • Location
    4558 Walnut Avenue Hackensack
  • Work
    Pup 'N' Taco ,Relay technician
  • Joined

you have posted really informative and valuable article . that will more beneficial for me i appreciate your work .पति पत्नी को अलग करने का टोटका

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Angular developer who love to share. Still seeking quality code and tips
  • Location
    Nantes, France
  • Work
    Lead dev on Angular project
  • Joined

More fromGaëtan Redin

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp