typelite

TypeLite -> TypeScript Enum -> Runtime error: Uncaught ReferenceError: TSEnum is not defined

邮差的信 提交于 2020-01-05 07:51:06
问题 We are using TypeLite to generate Enums in TypeScript. C#: [TsEnum(Module = "CustomEnum")] public enum TSEnum { None, Test } http://type.litesolutions.net/ Generates this code in a file called Enums.ts: namespace CustomEnum { export enum TSEnum { None = 0, Test =1 } } As default TypeLite generates a const enum but in order to be able to get the names of the TypeScript enum entry const has been removed. This was done by editing TypeLite.Net4.tt and changing: <# var ts = TypeScript.Definitions(

Typelite: Why is Dictionary<string, object> mapped to KeyValuePair and not to any or [index:string]:any

时间秒杀一切 提交于 2020-01-01 04:41:07
问题 I have a class, public class Instance : IResource { public Dictionary<string, object> Value { get; set; } and it is mapped to interface Instance { Value: System.Collections.Generic.KeyValuePair[]; interface KeyValuePair { Key: any; Value: any; } I would have expected interface Instance { Value: any; or interface Instance { Value: {[index:string]:any}; How can I change the generation? Also, how can I skip the name space in the generation? 回答1: A quick and dirty workaround is to use a regex to

Typescript with TypeLite - Run time type checking

喜你入骨 提交于 2019-12-06 05:45:28
问题 Let's say I have some C# DTO's and I want to convert them to TypeScript interfaces using T4 templates and neat little library called TypeLite On the client side, I have some concrete TypeScript classes (that inherit from Backbone.Model but that's not important) that represent the same DTO defined on the server side. The intended goal of the interfaces is to act as data contracts and ensure client and server DTOs are kept in sync. However, this is problematic since TypeScript supports no run

T4 -> C# class to Knockout View Model in Typescript [closed]

99封情书 提交于 2019-12-05 07:46:13
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I'm looking for some sort of T4 or similar way to take C# classes and generate both the interfaces for the data that will come across the wire AND the view models in a strongly typed fashion. I found typelite which works well for interfaces, but I'm looking for something that will handle the viewmodels too (or

Typescript with TypeLite - Run time type checking

£可爱£侵袭症+ 提交于 2019-12-04 10:37:45
Let's say I have some C# DTO's and I want to convert them to TypeScript interfaces using T4 templates and neat little library called TypeLite On the client side, I have some concrete TypeScript classes (that inherit from Backbone.Model but that's not important) that represent the same DTO defined on the server side. The intended goal of the interfaces is to act as data contracts and ensure client and server DTOs are kept in sync. However, this is problematic since TypeScript supports no run-time type checking facilities other than instanceof . The problem with instance of is when I fetch my

Typelite: Why is Dictionary<string, object> mapped to KeyValuePair and not to any or [index:string]:any

爱⌒轻易说出口 提交于 2019-12-03 12:25:56
I have a class, public class Instance : IResource { public Dictionary<string, object> Value { get; set; } and it is mapped to interface Instance { Value: System.Collections.Generic.KeyValuePair[]; interface KeyValuePair { Key: any; Value: any; } I would have expected interface Instance { Value: any; or interface Instance { Value: {[index:string]:any}; How can I change the generation? Also, how can I skip the name space in the generation? A quick and dirty workaround is to use a regex to alter output: Using <#= Regex.Replace( ts.Generate(TsGeneratorOutput.Properties) , @":\s*System\.Collections