[web] fix TypeScript typing and add a test case (#24354)
### Description
Resolves https://github.com/microsoft/onnxruntime/issues/24343. Also
added a test case to avoid breaking the module resolution of TypeScript
in the future.
### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->