opensearch-project / opensearch-js

Node.js Client for OpenSearch
https://opensearch.org/docs/latest/clients/javascript/
Apache License 2.0
188 stars 122 forks source link

[BUG] VSCode is not resolving types when opensearch-js is imported via require #839

Closed dblock closed 2 months ago

dblock commented 2 months ago

What is the bug?

Coming from https://github.com/opensearch-project/opensearch-js/issues/803#issuecomment-2286662634. VSCode resolves types when import, but not require.

How can one reproduce the bug?

Check out https://github.com/dblock/opensearch-node-client-demo. Toggle between import and require in the demo.

What is the expected behavior?

VSCode should be resolving types all the time.

What is your host/environment?

Visual Studio Code w/ TypeScript.

Do you have any screenshots?

TODO

Do you have any additional context?

Seems to work with JetBrains.

dblock commented 2 months ago

@nhtruong What's the verdict on this one? Are we leaving it as is?

nhtruong commented 2 months ago

JetBrains can still infer the type using require in both ts and js files. Projects that use TS will most likely be using more modern JS syntax with import anyway. I think we can close it as it's a VS Code issue for a very niche use case.

image