-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Fix: Windows tsconfig.json
resolution. aka: Typescript
Project detection
#14088
Conversation
finding tsconfig.json failed due to different path separators.
I encountered the same problem. In 4.3.2 everything worked in both Win and Linux environments, in 4.3.3 - 4.3.4 the same error. When creating db.connection it comes {}. |
It's because your configs (which are in ts) aren't transpiled and loaded cuz the project isn't detected as a TS project. |
It's also can be fixes by replace node's native const path = require('path'); to const path = require('pathe'); |
tsconfig.json
find fix.tsconfig.json
resolution. aka: Typescript Project detection
tsconfig.json
resolution. aka: Typescript Project detectiontsconfig.json
resolution. aka: Typescript
Project detection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question
Can somebody please review this? Currently new projects with typescript won't run. This fix worked for me. |
Fiiix pls |
Hi can we finally have this merged? So we can update ts projects without patch-package |
Hello. Any merge updates? Replacing |
Hey @psyirius, could you update your branch with main so that we can move forward with this, please? |
Wait ... I just looked at the date on this PR. You're telling me new Windows + TypeScript projects have been broken for over a month now with a fix proposed and no one on the Strapi team has moved to merge or fix this themselves yet? |
Coming here to bump this as it should definitely be a priority, it is essentially blocking every new user on Windows who uses Typescript Confirming the proposed fix works as well, with a quick little patch-package |
Thank you a lot for your contribution to this Pr, |
Oopsie, I stopped checking this pr after checking it for may days for update and no progress. |
Finding
tsconfig.json
is failed due to different path separators.What does it do?
Normalizes the found
tsconfig.json
with the platform's own path separator which helps to succeed the later condition.Why is it needed?
Throws
Unknown dialect
error when using TS on windows.it's because due to the following bug it is not detected as a TS project and the ts config files are not loaded.
thus it recieves
undefined
as dialect.On windows, the path separator is
\
whereas on other platforms it is/
.In the below function:
strapi/packages/utils/typescript/lib/utils/get-config-path.js
Lines 18 to 27 in 288dc33
When getting
dirAbsolutePath
fromdir
, thepath.resolve
function normalizes the path with the platform path separator.But typescript's function
ts.findConfigFile
normalizes the path with Posix-style path separator.Unless we normalize both paths
dirAbsolutePath
andconfigFilePath
to the same style it is never assured to match on all platforms even-though the tsconfig is found by typescript.How to test it?
Init a project with typescript support and run
strapi develop
orstrapi build && strapi start
.You'll be greeted with the below message...
My
package.json
for reference:Related issue(s)/PR(s)
Possible Issue: #13237