ui5-typescript
ui5-typescript copied to clipboard
URLHelper missing in sap.m types
sap.m.URLHelper.redirect(sUrl)
When using the URLHelper
, which exists as a global on the sap.m
library, typescript shows an error message:
Property 'URLHelper' does not exist on type 'typeof m'.
Looks like it is being automatically converted to an interface and not treated as a namespace, this is probably done as URLHelper is used as a type name somewhere and a namespace in TypeScript cannot be used as a Type.
- https://github.com/SAP/ui5-typescript/blob/be34da9da8f3cc631d41cdd00d348e312abcbb43/packages/ts-types/scripts/directives/namespaces-to-interfaces.js#L4
Maybe this is should be solved similarly to #48 where multiple TypeScript artifacts should be generated from a single api.json entity.
Need to consult on this with UI5 Colleagues, basically is this API considered legacy or modern? Does it have a module alternative (instead of globals?)
This was fixed in #208 and will be released in the next version of the dts-generator.
However the directives
passed to the DTS-generator in the UI5 build will also have to be adjusted.
- https://github.com/SAP/ui5-typescript/pull/208/files#diff-03cedc85309eb37b05bfb3335f5a362c93766cd5629e09ce05cbef9b30891f5fR1-R6
@petermuessig @codeworrior @RandomByte FYI
This seems to be an issue again as of 1.115 as the previous way of
import { URLHelper } from "sap/m/library";
URLHelper.redirect(...);
does not work anymore, as URLHelper is not exported in sap/m/library
anymore and does not exist on type 'typeof m'
.
Missing line in the .d.ts:
export const URLHelper: URLHelper;
Thanks for reporting. Seems like fallout of the recent bigger changes. In 1.114 it was export interface URLHelper
, now just interface URLHelper
(also with no later export). @petermuessig ?
Seems that the URLHelper isn't exported anymore. I'll have to check...
@akudev: it is as @HappyHepo describes - just export interface
doesn't work, the following line needs to be added after the interface has been defined: export const URLHelper: URLHelper;
- otherwise is cannot be used as a type!
@petermuessig As value, you mean, but yes. Both are needed, as in 1.114 and before.
Issue has been found an will be addressed with the next release of the types. Not sure yet, whether we have it as part of 1.115.1 or 1.116.0
@akudev : export interface
is wrong as it produces an error!
the interface must not be exported but the const value!
@HappyHepo This is fixed with version 1.115.1 (@types/openui5 is already available, @openui5/types and @sapui5/types will follow next week).
Also with the ts-types ("globals"), the bug is fixed in the meantime. Closing.