-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
TypeError: hostOrText.readFile is not a function when extending @tsconfig/node18 #14223
Comments
I see you have a patch which fixes the issue. Would you like to open a PR? |
Same issue here as well, upgraded to TypeScript 4.9 and started failing. We're under a bit of pressure so didn't have time to look into it deeply, but it's the same situation (be it with Can confirm that patching NoteI first patched function readTsConfigOptions(tsConfigPath) {
// ...
} But that didn't seem to do anything for my use case. Just wanted to say that it's in the code base twice:
|
@AgentEnder: I've created a PR for it: #14380 |
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context. |
Current Behavior
Given the
devDependency
"@tsconfig/node18": "1.0.1"
and a
tsconfig.json
with"extends": "@tsconfig/node18"
every target (here: linting) results in
The reason is a call to
readFile
in typescript/typescript.js line 19519:var jsonText = ts.isString(hostOrText) ? hostOrText : hostOrText.readFile(path);
It can be interpreted as a breaking change in typescript where a surrounding try-block was removed:
microsoft/TypeScript#51644
However, IMHO at least judging from the referenced discussion, it also seems to be a bug in nx as it provides a
host
that is missing thereadFile
method in nx/utils/typescript.js line 23:Remark: I got the stack trace with linting. But there were also situations (I think just
tsc
) where I only got the error message. This made tracking down the problem unnecessarily difficult.Expected Behavior
no error
Github Repo
No response
Steps to Reproduce
See above
"extends": "@tsconfig/node18"
totsconfig.json
npx nx lint
Nx Report
Failure Logs
Additional Information
The attached patch fixes the problem. As a workaround, you may want to apply it with patch-package as postinstall.
nx+15.4.4.patch
The text was updated successfully, but these errors were encountered: