ZINC-FYP-2022-23 / console

ZINC UI for teaching assistants
1 stars 0 forks source link

refactor: start import path alias with `@/` #40

Closed AnsonH closed 1 year ago

AnsonH commented 1 year ago

Description

We should update the import path alias from @xxx to @/xxx in tsconfig.json:

"paths": {
-  "@components/*": ["components/*"],
+  "@/components/*": ["components/*"],
/* ... */

So importing stuff would become:

- import { Checkbox } from "@components/Input";
+ import { Checkbox } from "@/components/Input";

Reason

The main reason is to avoid clashing with the names of node modules.

For example, the following code will cause an error when trying to import from types/GuiBuilder/ folder

image

This is because our node_modules/ folder also has a folder called @types/ that stores the types of JavaScript libraries (e.g. @types/d3). Hence, using a custom import path alias of @types will clash with the node modules. (See this Stack Overflow thread)