ui5-typescript icon indicating copy to clipboard operation
ui5-typescript copied to clipboard

URLHelper missing in sap.m types

Open BenReim opened this issue 4 years ago • 4 comments

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'.

BenReim avatar Nov 27 '19 09:11 BenReim

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.

bd82 avatar Nov 27 '19 09:11 bd82

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?)

bd82 avatar May 12 '20 16:05 bd82

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

bd82 avatar Dec 20 '20 15:12 bd82

@petermuessig @codeworrior @RandomByte FYI

bd82 avatar Dec 20 '20 15:12 bd82

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;

HappyHepo avatar Jun 18 '23 13:06 HappyHepo

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 ?

akudev avatar Jun 19 '23 14:06 akudev

Seems that the URLHelper isn't exported anymore. I'll have to check...

petermuessig avatar Jun 19 '23 14:06 petermuessig

@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 avatar Jun 19 '23 14:06 petermuessig

@petermuessig As value, you mean, but yes. Both are needed, as in 1.114 and before.

akudev avatar Jun 19 '23 16:06 akudev

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

petermuessig avatar Jun 19 '23 16:06 petermuessig

@akudev : export interface is wrong as it produces an error!

image

the interface must not be exported but the const value!

petermuessig avatar Jun 19 '23 16:06 petermuessig

@HappyHepo This is fixed with version 1.115.1 (@types/openui5 is already available, @openui5/types and @sapui5/types will follow next week).

akudev avatar Jun 23 '23 08:06 akudev

Also with the ts-types ("globals"), the bug is fixed in the meantime. Closing.

image

akudev avatar Jun 23 '23 08:06 akudev