Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Javascript to Typescript code

jeanne.limApr 9 2019 — edited Apr 11 2019

Hi,

I am trying to use Typescript in Jet but I am a beginner in Typescript. I have some code in javascript that is working and I'm trying to adapt the code to Typescript. So from my javascript code I inserted this to my Typescript code:

viewModelParams['data'] = self.playersArray;

let viewPath = 'views/players/list.html';

let modelPath = 'viewModels/players/list';

let masterPromise = Promise.all([

    moduleUtils.createView({'viewPath':viewPath}),

    moduleUtils.createViewModel({'viewModelPath':modelPath})

]);

masterPromise.then(

    function(values){

        var viewModel = new values[1](viewModelParams);

        self.moduleConfig({'view':values[0],'viewModel':viewModel});

    }

);

I use this for navigating to a different view model and passing parameters to the view model. It builds my javascript but at runtime I get this error:

Uncaught (in promise) TypeError: values[1] is not a constructor

because of this line: var viewModel = new values[1](viewModelParams);

I'm wondering how do I translate this to Typescript or if there's another way to fix it and still pass parameters to the view model?

Thanks!

Comments
Post Details
Added on Apr 9 2019
7 comments
657 views