-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Ambient types of wdi5
not working (wdi5 v2, esm, typescript)
#573
Comments
Hi @LukasHeimann, in your |
Did that for the MVP linked above, but that gives an error:
|
I think the ambient types are available in principle ( |
This adapted {
"compilerOptions": {
"moduleResolution": "node",
"strict": true,
"types": [
"node",
"@sapui5/types",
"@wdio/globals/types",
"expect-webdriverio",
"@wdio/mocha-framework",
"wdio-ui5-service/esm"
],
"skipLibCheck": true
}
} need to check why your config throws errors. |
Of course typescript will not complain about esm issues if you disable esm 😉 https://www.typescriptlang.org/tsconfig#module Small addendum: https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext explains it quite nicely:
Not using |
I guess this problem isn't too big, as most imports were already adjusted to use the I've drafted up main...LukasHeimann:wdi5:pathModuleConfiguration, let me know if I should open a PR. I haven't executed any tests besides making sure that the |
PR please, heck yeah! |
That probably was a bit too fast -- while that patch was reasonable, it wasn't complete... I was currently trying to get |
the pitfalls of relying on extensive CI ... 😐 |
So, I had a couple of minutes to look into it. 2.0.5 has fixed the issue with the ambient types, so this issue being closed is totally fine indeed. In my actual project, there was another problem revolving around importing the type |
I've created #576 -- this time fully tested against my local project with |
Describe the bug
In my project, we just migrated to wdi5 v2. We are using TypeScript, and we also migrated to ES Modules as target (instead of CommonJS scripts). For this setup (which is supported by wdi5), the ambient types that
wdi5
provides are broken. Whilebrowser.asControl()
is available as global type as expected, neither its parameter nor its return value is typed. It seems like in an actual project, the types referenced there can't be resolved and thus default toany
, which causes problems.To Reproduce
https://github.com/LukasHeimann/wdi5-types-sample
Expected behavior
browser.asControl()
is typed correctlyRuntime Env (please complete the following information):
wdi5/wdio-ui5-service
-version: 2.0.4UI5
version: 1.120.4wdio
-version (output ofwdio --version
): 8.27.1node
-version (output ofnode --version
): 20.9.0Additional context
I guess this may be due to improper bundling for esm. When you have esm, your imports must end with the file ending
.js
. This is even true in TypeScript projects as wdi5 is one: microsoft/TypeScript#16577. However it seems like this was not migrated, and so imports are failing if esm is used. Compare also built-in wdio plugins that do this correctly: https://github.com/webdriverio/webdriverio/blob/main/packages/wdio-reporter/src/index.tsFor bundling commonjs, I guess you'd need to then strip the
.js
extension anymore, though I am not sure about that.The text was updated successfully, but these errors were encountered: