SAP / ui5-typescript

Tooling to enable TypeScript support in SAPUI5/OpenUI5 projects
https://sap.github.io/ui5-typescript
Apache License 2.0
201 stars 28 forks source link

Regression in @sapui5/types of 1.122.1 with tsconfig for wdi5 #434

Closed LukasHeimann closed 2 months ago

LukasHeimann commented 5 months ago

Describe the bug For wdi5-based testing, ui5's types can be used. As the runtime there is not the browser but node, different settings for typescript are used:

Up until version 1.122.0 of the types, this worked without problems -- you could import the ui5 types and use them in your wdi5 config, exactly as advertised. With version 1.122.1 of the types, this broke for some reason. Running tsc --noEmit on a more or less empty project with these settings gives lots of errors, mostly internal to the types, i.e.: node_modules/@sapui5/types/types/commons-1.122.0-esm-d.ts(3,16): error TS2664: Invalid module name in augmentation, module 'sap/ui/commons/library' cannot be found.

I'm not sure if this could be due to (new?) behavior of the types, where when only some parts of the ui5 distribution are updated to the .1 patch version and others stay at .0, the files are renamed and thus cause the problem with the stricter type resolution settings.

Expected behavior Projects using wdi5 with TypeScript and the ui5 types should pass a typecheck without problems.

Additional context For easier debugging, I've created a minimal repository that fails: https://github.com/LukasHeimann/ui5-types-wdi5-issue It includes steps to reproduce the issue and shows that previous versions are not affected.

I've also included the log output of tsc --noEmit: https://github.com/LukasHeimann/ui5-types-wdi5-issue/blob/main/out.log

codeworrior commented 5 months ago

This is most likely another symptom of the issue described in #433. Due to an unexpected version mismatch, some files have not been renamed to library.name.d.ts but kept their (build-time) name e.g. commons-1.122.0-esm-d.ts. As those files are NOT named *.d.ts, TypeScript no longer handles them as ambient files, which then causes the errors.

1.123 should fix the problem. Fixes for 1.121 and 1.122 are prepared, so in case a patch will be produced, the issue should be fixed there as well. But I can't say whether or when such patches will be created.

codeworrior commented 5 months ago

Oh, and - as suggested by @akudev in #433 - you can continue to use 1.122.0 to avoid the problem until fixes become available.

LukasHeimann commented 5 months ago

Thank you for the quick response! I hadn't seen the closed issue. The workaround works perfectly for us already, but thank you for mentioning that as well :)

akudev commented 5 months ago

(Edited the title to make it clear that the issue only occurs in the SAPUI5 types)

akudev commented 2 months ago

Verified fixed with the 1.123.0 types