openui5vscodeTypescriptTools icon indicating copy to clipboard operation
openui5vscodeTypescriptTools copied to clipboard

Command to generate sap.ui.define imports

Open apazureck opened this issue 8 years ago • 2 comments

Create a command to automatically add imports like:

import JSONModel = sap.ui.model.json.JSONModel;

to the sap.ui.define

Command can be called via autocomplete, too.

apazureck avatar Dec 23 '16 13:12 apazureck

is it like done here? https://marketplace.visualstudio.com/items?itemName=tapsiturbi-publisher.openui5-require

antonsn avatar Mar 28 '17 10:03 antonsn

Yes, but not for typescript. Or have you tried it out? Does it work with that extension?

This:

sap.ui.define([
    
], function() {
    Controller.extend("app.controller.pages.FirstPage");
});

namespace app.controller.pages {
    import Controller = sap.ui.core.mvc.Controller;
    export class FirstPage extends Controller {
        onInit() {
            console.log("Initializing FirstPage Controller");
            console.log("Testchange");
        }
    }
}

Should become this:

sap.ui.define([
    "sap/ui/core/mvc/Controller"
], function(Controller: sap.ui.core.mvc.Controller) {
    Controller.extend("app.controller.pages.FirstPage");
});

namespace app.controller.pages {
    import Controller = sap.ui.core.mvc.Controller;
    export class FirstPage extends Controller {
        onInit() {
            console.log("Initializing FirstPage Controller");
            console.log("Testchange");
        }
    }
}

Based on import bla = blub

I am not sure, if this extension does the trick for typescript.

apazureck avatar Mar 28 '17 10:03 apazureck