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

feature request: tsconfig alias path resolution #283

Closed
3 tasks done
asnaeb opened this issue Aug 15, 2024 · 9 comments · Fixed by #284
Closed
3 tasks done

feature request: tsconfig alias path resolution #283

asnaeb opened this issue Aug 15, 2024 · 9 comments · Fixed by #284
Labels
enhancement New feature or request good first issue Good for newcomers vite

Comments

@asnaeb
Copy link

asnaeb commented Aug 15, 2024

unplugin-typia version

0.6.18

What platform is your computer?

Darwin 23.5.0 arm64 arm

Describe the bug

When importing types from non relative paths, such types are parsed as any. Example of non relative paths are paths relative to tsconfig.compilerOptions.baseUrl or paths mapped from tsconfig.compilerOptions.paths.

Adding resolve.alias to vite.config.ts to map the paths in vite doesn't help.

Reproduction

https://github.com/asnaeb/vite-unplugin-typia-repro

run with npm run dev and check the console.

Validations

@ryoppippi
Copy link
Owner

ryoppippi commented Aug 15, 2024

Thank you for reporting this.
Currently, I'm not implementing alias resolution.
Also, we don't implement for path resolution, so maybe typia compiler should implement it.

@ryoppippi ryoppippi added enhancement New feature or request good first issue Good for newcomers labels Aug 15, 2024
@ryoppippi
Copy link
Owner

I transfered this issue to typia's repo

@asnaeb
Copy link
Author

asnaeb commented Aug 15, 2024

Thank you for reporting this. Currently, I'm not implementing alias resolution. Also, we don't implement for path resolution, so maybe typia compiler should implement it.

I tested typia without the plugin and code transformed directly with typia generate works for both cases

@ryoppippi
Copy link
Owner

Oh, really. Could you give me an example?

@ryoppippi
Copy link
Owner

ryoppippi commented Aug 15, 2024

OK, so import {MyType} from "src/types/mytype"; is not appropriate for vite project. try use ./foo

@asnaeb
Copy link
Author

asnaeb commented Aug 15, 2024

Oh, really. Could you give me an example?

https://github.com/asnaeb/typia-test

  • clone
  • npm install
  • npm run build
  • inspect build directory

@ryoppippi
Copy link
Owner

ryoppippi commented Aug 15, 2024

I do not have time to do it, and actually I don't use alias so much, so your contribution are welcome
Maybe, you should contribute to mlly first.
unjs/mlly#271

@ryoppippi ryoppippi changed the title Non relative type imports are treated as any feature request: tsconfig alias path resolution Aug 15, 2024
@asnaeb
Copy link
Author

asnaeb commented Aug 16, 2024

I gave a quick look at it and seems like I've found a way to handle this without having to resolve anything from tsconfig but doing it the vite way: If non relative imports match something inside vite's resolve.alias, then imported types are resolved accordingly. I think this is the right way to handle this because it is exactly what one would expect. If you agree, I'm going to write some tests and submit a PR tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers vite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants