Well, there are two ways:
Terminal
When talking about system directories, when using the ./
, it points to the current directory, and when using the ~/
, he points to the directory home/username
.
Programming
But when we talk about programming, for example in React, you can define relative paths (e. g: React-app-rewired)
So when you give one import
in a file using ../../../../shared/etc
, you need to be careful every time, thus decreasing productivity.
Then you define relative paths using a special character of your choice (the most common ones are ~
and @
)
So you point to the same location using ~/shared/etc
or ~/app/shared/etc
(is at the choice of its configuration)
It is good practice to use relative paths with ~/
, as it makes development easier and more productive.
In the file system the
~
points tohome
. On a web server~
points to the website root.– Augusto Vasques
The first is an absolute path, the second is relative to the current directory. So they will not always point to the same file. But it lacks context, this is there in statements of
import
typescript? If not, what is the context? Anyway, the "best" depends on each case...– hkotsubo
Exact, Typescript import statements in an Angular application.
– GILBERTO OLIVEIRA
Then please click [Edit] and add this information to the question. Also put related tags
– hkotsubo