No announcement yet.

[CLOSED] How to use Retyped?

  • Filter
  • Time
  • Show
Clear All
new posts

    [CLOSED] How to use Retyped?

    I'm trying to use Retyped.knockout.
    Where can I find documentation or samples?

    João Miguel

    • Add Retyped.knockout package from nuget to your C# Bridge.Net project
    • Docs at
    • use it in c# code like
    knockout.ko.applyBindings(new MyViewModel());
    Last edited by geoffrey.mcgill; 2017-10-10 @ 11:39 PM.


      Hi joaommvsoares ,

      I've added a simple "Hello world" demo project for KnockoutJS:

      As Markus mentioned you can use the official Knockout documentation to discover its API:

      Also it's worth to keep on hand the declaration file used to generate Retyped.knockout package.
      using Bridge;
      using Bridge.Html5;
      using Newtonsoft.Json;
      using System;
      using static Retyped.knockout;
      using ObservableString = Retyped.knockout.KnockoutObservable<string>.Interface;
      using ComputedString = Retyped.knockout.KnockoutComputed<string>.Interface;
      namespace KnockoutDemo
          public class App
              public static void Main()
                  // Original "Hello wold" demo can be found here:
                  ko.applyBindings(new ViewModel("Planet", "Earth")); // This makes Knockout get to work
          // Here's my data model
          public class ViewModel
              public ObservableString firstName { get; set; }
              public ObservableString lastName { get; set; }
              public ComputedString fullName { get; set; }
              public ViewModel(string first, string last)
                  firstName = ko.observable.Self<string>(first);
                  lastName = ko.observable.Self<string>(last);
                  // Knockout tracks dependencies automatically. It knows that fullName depends on firstName and lastName, because these get called when evaluating fullName.
                  fullName = ko.pureComputed(() => firstName.Self() + " " + lastName.Self());
      Hope that helps.
      Last edited by geoffrey.mcgill; 2017-10-10 @ 11:40 PM.


        Hi Andrey ,

        Using the KnockoutDemo sample, but setting the "generateTypeScript": true, in the bridge.json:
        Generates the following error in d.ts file:

        TS2304 Cannot find name 'KnockoutComputed'.

        Missing definition?



          Hi joaommvsoares,

          Thanks, confirming the problem. I can see 2 issues here:
          1. The declaration files generated by Retyped are not referenced in the KnockoutDemo.d.ts generated by Bridge. You can get round that issue by manually adding the following line at the top:
            	/// <reference path="./knockout/index.d.ts" />
          2. For some reason Bridge didn't emit generic type arguments for types KnockoutObservable and KnockoutComputed. We'll investigate that.


            The following issues have been created in Bridge repository:
            1. [#3209] Reference declaration files originated from Retyped packages
            2. [#3213] Ignore [IgnoreGeneric] attribute when generating TypeScript declarations

            And one more was found:
            3. [#3210] External interface references in generated d.ts files


              All issues mentioned above are fixed. Now I'm able to get a valid TypeScript declaration file for KnockoutDemo sample.