Skip to content
This repository was archived by the owner on Jul 29, 2020. It is now read-only.
This repository was archived by the owner on Jul 29, 2020. It is now read-only.

Better Typings - questions and feedback #1

Open
@apazureck

Description

@apazureck

Hi @lmcarreiro,

I wrote a parser to get better typings from the UI5 Documentation to use with your decorator.

check it out here:
https://github.com/apazureck/UI5TypescriptDefinitionParser/tree/develop

I tried to use it with your repo. Thus, I forked it:
https://github.com/apazureck/ui5-typescript-example

The fork contains the typings.

  1. I used declare module "foo" to be file system independent.
  2. I also tried to distinguish modules and globals to urge the programmer to use import foo from "bar" and get more stable code without missing modules. So maybe some globals are missing. I started with sap/ui/Global and declared everything there as module AND namespace.
  3. There are not much generics so far, I just added generic sap.ui.base.Event class and Model class, but more will follow when everything is working

So I have some problems:

The transpiler seems to create a wrong import in mockserver.ts. It imports import MockServer from "sap/ui/core/util/MockServer"; as MockServer_1 in javascript, but the MockServer_1 has this structure:

{
  default: {
    default: function (e,t,n) { ... }
    }
  }
}

Which causes the error:

TypeError: MockServer_1.default is not a constructor
mockserver.ts:30
    at Object.init (c:\dev\ui5-typescript-example\src\localService\mockserver.ts:30:23)
    at http://localhost:3000/:31:24
    at c:\dev\ui5-typescript-example\out\resources\sap-ui-core.js:88:2587
TypeError: Cannot read property 'Binding' of undefined
extensions::runtime:7
    at extensions::runtime:7:46
Error: "Natives disabled"
extensions::app:7
    at (anonymous) (extensions::app:7:22)
Error: "Natives disabled"
extensions::webstore:7
    at (anonymous) (extensions::webstore:7:22)

I used my gulp to automate the build. The output is in the out folder. Sources are still in the src folder.
You should be able to use the example with vscode:

> npm install
> gulp

F5 will attach the debugger. Make sure the chrome debug extension is installed.

I do not understand properly what is happening in the factory and why there are two default exports, maybe you can help me understanding this problem and adjusting the typings accordingly?

Thanks & regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions