apazureck / openui5vscodeTypescriptTools

Tools for openui5 to enhance productivity using VS Code
MIT License
22 stars 5 forks source link

IntelliSense not working for UI5 #46

Closed AlexLIN1974 closed 6 years ago

AlexLIN1974 commented 6 years ago

Hi apazureck, First thanks for the great UI5 TS extension.

After install this extension, intelliSense still not work, example below: no intelliSense is showed for oModel, could you share any clue on this?

sap.ui.define([
    "sap/ui/model/json/JSONModel"
], function( JSONModel ) {
    return Controller.extend("Demo.controller.App", {
        Init : function(){
            var oModel = new JSONModel();
            oModel. **_(no intellisense)_**
        }
    });
});
apazureck commented 6 years ago

Hi,

  1. make sure your file is a typescript file (.ts) to get vscode to use the right language.
  2. You have to import your json model like this: import JSONModel = sap.ui.model.json.JSONModel; After that you should get intellisense. If you are using my declarations you will get a model with a generic parameter. There you can specify which type you want to use. For example:
    
    interface IMyInterface {
    propertyA: string,
    propertyB: string,
    }

let mymodel = new sap.ui.model.json.JSONModel(...);



Here is a short example: https://github.com/apazureck/openui5vscodeTypescriptTools/wiki

have a look at this template:
https://github.com/apazureck/UI5TypescriptDeclarations/tree/master/generator
which uses gulp to transpile the typescript files (ctrl+shift+b to start the watch task, after that all in out folder will be supervised and built on save.

Here are some examples from the ui5 walkthrough:
https://github.com/apazureck/openui5TypescriptGenerator/tree/master/Walkthrough

If you like the extension please rate it on the marketplace or contribute (For example extending the wiki with your experience). Happy coding!

Regards