You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Relative module import paths in .gen.d.ts files are not rewritten to absolute paths. (in contrast to other .d.ts files)
This seems to be an older regression that could easily be fixed, although I do not know if other things might break. (see additional info)
The current behaviour breaks types of 2nd level custom controls in our lib package because the 1st level custom control's relative import path cannot be resolved from 2nd level custom control's transpiled .gen.d.ts file.
That results in 1st level custom control's settings properties not being known.
generate interfaces via @ui5/ts-interface-generator
// mylib/src/mylib/MyNamedListCard.gen.d.tsimport{PropertyBindingInfo}from"sap/ui/base/ManagedObject";import{$MyListCardSettings}from"./MyListCard";// <- relative import, as expecteddeclare module "./MyNamedListCard"{// <- relative declaration, as expected
build via @ui5/cli and ui5-tooling-transpile-task
// mylib/dist/resources/mylib/MyNamedListCard.gen.d.tsdeclare module "mylib/MyNamedListCard"{// <- absolute declaration, as expectedimport{PropertyBindingInfo}from"sap/ui/base/ManagedObject";import{$MyListCardSettings}from"./MyListCard";// <- relative import => breaks types in library !!!
release types package with d.ts, gen.d.ts files, e.g. as mylibtypes
app package myapp depending on mylibtypes package for making types known (real world lib also releases js files of course)
⚠ When instantiating the 2nd level custom control, neither 1st level custom control's settings, nor ui5 base control's settings are known.
importMyNamedListCardfrom"mylib/MyNamedListCard";// Only settings properties of MyNamedListCard are known here according to generated types.// That is because mylibtypes/dist/resources/mylib/MyNamedListCard.gen.d.ts uses relative import "./MyListCard" which cannot be resolved.// If I change that import to "mylib/MyListCard", then everything works fine.newMyNamedListCard({manifest: "{}",// <- This property should be known from sap/ui/integration/widgets/Card.dataPath: "...",// <- This property should be known from mylib/MyListCard.name: "",});
No overload matches this call.
Overload 1 of 2, '(idOrSettings?: string | $MyNamedListCardSettings): MyNamedListCard', gave the following error.
Object literal may only specify known properties, and 'manifest' does not exist in type '$MyNamedListCardSettings'.
Overload 2 of 2, '(id?: string, settings?: $MyNamedListCardSettings): MyNamedListCard', gave the following error.
Argument of type '{ manifest: string; dataPath: string; name: string; }' is not assignable to parameter of type 'string'.ts(2769)
Expected behavior
I'd expect the import to be transpiled to the absolute path.
// mylib/dist/resources/mylib/MyNamedListCard.gen.d.tsdeclare module "mylib/MyNamedListCard"{import{PropertyBindingInfo}from"sap/ui/base/ManagedObject";import{$MyListCardSettings}from"mylib/MyListCard";// <- absolute import here would fix this issue
Additional context
The import rewrite in packages/ui5-tooling-transpile/lib/task.js was initially applied to all .d.ts files. (see 6ec501c / #743)
Only later, in some dependencies update fix commit, were .gen.d.ts files excluded.
But I cannot see why. Neither the PR, nor the code document why that change was done.
(see PR diff / #754)
Reverting that change to packages/ui5-tooling-transpile/lib/task.js to apply import rewrite to all .d.ts files again, fixes the issue for me.
@stabpd there was a good reason to use the relative paths - something with the module augmentation didn't work except of using the relative path. I need to verify this again.
Describe the bug
Relative module import paths in
.gen.d.ts
files are not rewritten to absolute paths. (in contrast to other.d.ts
files)This seems to be an older regression that could easily be fixed, although I do not know if other things might break. (see additional info)
The current behaviour breaks types of 2nd level custom controls in our lib package because the 1st level custom control's relative import path cannot be resolved from 2nd level custom control's transpiled
.gen.d.ts
file.That results in 1st level custom control's settings properties not being known.
To Reproduce
mylib
two custom controls, inheriting from each other
generate interfaces via
@ui5/ts-interface-generator
build via
@ui5/cli
andui5-tooling-transpile-task
release types package with
d.ts
,gen.d.ts
files, e.g. asmylibtypes
myapp
depending onmylibtypes
package for making types known (real world lib also releases js files of course)⚠ When instantiating the 2nd level custom control, neither 1st level custom control's settings, nor ui5 base control's settings are known.
Expected behavior
I'd expect the import to be transpiled to the absolute path.
Additional context
The import rewrite in
packages/ui5-tooling-transpile/lib/task.js
was initially applied to all.d.ts
files. (see 6ec501c / #743)Only later, in some dependencies update fix commit, were
.gen.d.ts
files excluded.But I cannot see why. Neither the PR, nor the code document why that change was done.
(see PR diff / #754)
Reverting that change to
packages/ui5-tooling-transpile/lib/task.js
to apply import rewrite to all.d.ts
files again, fixes the issue for me.It might also fix another issue. (see SAP/ui5-typescript#431)
But I do not know if the change was intentional and if other stuff might break.
Please let me know if you need additional info or an mvp repo.
The text was updated successfully, but these errors were encountered: