Interoperability
Transpose interoperates with existing JavaScript. You can call JavaScript from C#, call C# from JavaScript, and pass data between the two.
- Calling JavaScript — raw
injection with
Script.Write, and typed[External]bindings. - Calling C# from JavaScript — the shape of the emitted API, and how to make it predictable.
- Type Casting —
is,as, explicit casts, and what is checked at runtime.
Two rules cover most of the boundary:
- Plain values cross cleanly.
string,bool, the 32-bit-and-smaller integers,float/double, arrays of those, and[ObjectLiteral]types are plain JavaScript values in both directions. - Everything else is a runtime object.
long,decimal,DateTime,Guid,Task,List<T>,Dictionary<K,V>and any ordinary class have a runtime representation that JavaScript should not reach into. Project them at the boundary — see Working with Data.