Title: LanguageServerHost fileExists / readFile no longer optional? · Issue #18753 · microsoft/TypeScript · GitHub
Open Graph Title: LanguageServerHost fileExists / readFile no longer optional? · Issue #18753 · microsoft/TypeScript
X Title: LanguageServerHost fileExists / readFile no longer optional? · Issue #18753 · microsoft/TypeScript
Description: TypeScript Version: 2.4.2, also in master This issue was encountered when upgrading javascript-typescript-langserver from typescript 2.3.4 (see sourcegraph/javascript-typescript-langserver#356) Code When implementing a LanguageServiceHos...
Open Graph Description: TypeScript Version: 2.4.2, also in master This issue was encountered when upgrading javascript-typescript-langserver from typescript 2.3.4 (see sourcegraph/javascript-typescript-langserver#356) Cod...
X Description: TypeScript Version: 2.4.2, also in master This issue was encountered when upgrading javascript-typescript-langserver from typescript 2.3.4 (see sourcegraph/javascript-typescript-langserver#356) Cod...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/18753
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"LanguageServerHost fileExists / readFile no longer optional?","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n**TypeScript Version:** 2.4.2, also in master\r\n\r\nThis issue was encountered when upgrading javascript-typescript-langserver from typescript 2.3.4 (see https://github.com/sourcegraph/javascript-typescript-langserver/pull/356)\r\n\r\n**Code**\r\n\r\nWhen implementing a LanguageServiceHost without implementing optional `fileExists` or `readFile`, the compilerHost instance silently skips `import` statements:\r\n```ts\r\nexport class InMemoryLanguageServiceHost implements ts.LanguageServiceHost {\r\n // only required members implemented here..\r\n}\r\n```\r\n\r\nThe above implementation compiled without errors against 2.4.2, but all `import` statements in source files added to the language server failed to resolve, resulting in diagnostics, missing definitions, completions, etc.\r\n\r\n**Expected behavior:**\r\n\r\nEither:\r\n* Compilation failure indicating that LanguageServiceHost is now incomplete\r\n* Module resolver falls back to ModuleResolutionHost to access `fileExists` / `readFile`\r\n\r\n**Actual behavior:**\r\n\r\nImports fail to resolve where they do exist, in `nodeModuleResolverWorker`, following the path:\r\n\r\n```\r\nnodeLoadModuleByRelativeName -> loadModuleFromFile\r\nloadModuleFromFile -> tryExtension -> tryFile -> state.host.fileExists\r\n```\r\n\r\nDebugger screenshot showing the issue at runtime at https://github.com/Microsoft/TypeScript/blob/21bbdd33c51f07a46663e9b50fff62e9c007c806/src/services/services.ts#L1166\r\n\r\n\u003cimg width=\"983\" alt=\"screen shot 2017-09-25 at 19 37 12\" src=\"https://user-images.githubusercontent.com/4395832/30823982-65bae216-a22e-11e7-9a91-399150e11949.png\">\r\n\r\nThe typings published at https://github.com/Microsoft/TypeScript/blob/master/lib/typescript.d.ts#L3764-L3765 show that the two members are still optional.\r\n\r\nThis dependency appears to have been introduced at: https://github.com/Microsoft/TypeScript/commit/2ec92b9c02ba6ac6b97d3fb5af830d0ece6dcd92","author":{"url":"https://github.com/tomv564","@type":"Person","name":"tomv564"},"datePublished":"2017-09-25T18:41:16Z","url":"https://github.com/microsoft/TypeScript/issues/18753"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d2be1f96-2b6a-d0d2-48f5-3d298659a5e9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 887A:317608:CCEAD3:104F3E5:6B00FF09 |
| html-safe-nonce | 676c61a852129ca2d5440e2d311f6b0d52da0d8d362d554cab093f446599898f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODdBOjMxNzYwODpDQ0VBRDM6MTA0RjNFNTo2QjAwRkYwOSIsInZpc2l0b3JfaWQiOiIyMDQyMjkxNjI3NTg2MzUyNzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 186f4a44f57fc507040579109c0c7db97236bb5c79c63ccd82ca663f2b69d271 |
| hovercard-subject-tag | issue:260375457 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/18753/issue_layout |
| twitter:image | https://opengraph.githubassets.com/80a3e4f3113231a3b2dd3862918f791951210ec877a2cc2b5b4b690d4493fa74/microsoft/TypeScript/issues/18753 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/80a3e4f3113231a3b2dd3862918f791951210ec877a2cc2b5b4b690d4493fa74/microsoft/TypeScript/issues/18753 |
| og:image:alt | TypeScript Version: 2.4.2, also in master This issue was encountered when upgrading javascript-typescript-langserver from typescript 2.3.4 (see sourcegraph/javascript-typescript-langserver#356) Cod... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tomv564 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width