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

Configure TypeScript Paths #11

Merged
merged 1 commit into from
Jun 7, 2024
Merged

Conversation

Dawaic6
Copy link
Contributor

@Dawaic6 Dawaic6 commented Jun 5, 2024

What does this PR do?

This PR sets up a new React project path aliases for TypeScript in a React project using Vite, making imports cleaner and more manageable for efficient development.

Description of Task to be Completed?

  • Set up path aliases in the TypeScript configuration file (tsconfig.json).
  • [x]Define aliases for commonly used directories or modules to simplify import statements.

@Dawaic6 Dawaic6 self-assigned this Jun 5, 2024
@Dawaic6 Dawaic6 force-pushed the ch-Configure-TypeScript-Paths-#8 branch from 72ed96a to e26c6a0 Compare June 5, 2024 16:04
Copy link

vercel bot commented Jun 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dynamites-ecomm-fe ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 8:18am

@codecov-commenter
Copy link

codecov-commenter commented Jun 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 17.24%. Comparing base (e6e16f6) to head (4b9e2b4).

Files Patch % Lines
src/main.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop      #11   +/-   ##
========================================
  Coverage    17.24%   17.24%           
========================================
  Files            4        4           
  Lines           29       29           
  Branches         4        4           
========================================
  Hits             5        5           
  Misses          21       21           
  Partials         3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Dawaic6 Dawaic6 requested a review from niyobern June 7, 2024 06:49
@Dawaic6 Dawaic6 added ready for review The PR is ready for review to be mergrd and removed WIP labels Jun 7, 2024
Copy link
Contributor

@wayneleon1 wayneleon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Job

@wayneleon1 wayneleon1 linked an issue Jun 7, 2024 that may be closed by this pull request
2 tasks
package.json Outdated
@@ -46,6 +46,7 @@
"tailwindcss": "^3.4.3",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vite-tsconfig-paths": "^4.3.2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where did you use this package?

src/main.tsx Outdated
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import App from 'src/App.tsx';
import './index.css';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you use the absolute import here?

src/main.tsx Outdated
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import App from 'src/App.tsx';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to import like import App from @/App.tsx

tsconfig.json Outdated

"baseUrl": ".",
"paths": {
"@src/*": ["src/*"],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "@/*": ["./src/*" ]

vite.config.ts Outdated
@@ -17,4 +18,14 @@ export default defineConfig({
environment: 'jsdom',
setupFiles: ['./src/__test__/setupTests.ts'],
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use like "@": path.resolve(__dirname, "./src"),

Copy link
Collaborator

@ambroisegithub ambroisegithub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!!!

- update vite config
- set up docker

[Finishes #10]
@dushimeemma dushimeemma merged commit 1d4ea43 into develop Jun 7, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Front-End ready for review The PR is ready for review to be mergrd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure TypeScript Paths
6 participants