typelite


TypeLite generate external modules?


I am trying to generate external modules rather than a type definition file. I believe I need to do the following:
Change the extension of the file to .ts instead of .d.ts.
Generate one file per module.
Add the key word "Export" in front of each interface and enum.
I was easily able to change the extension of the file by changing the "output extension" setting in the tt file.
I cannot figure out how to split the modules into separate files.
I cannot figure out how to add the Export key word to each interface.
TypeLITE doesn't support generating multiple files. This feature has been requested by several users, but I am not aware of a simple way to generate multiple files from the single tt file.
export keyword can't be added without changing source code of the library (TsGenerator.cs). This is very specific requirement, so I probably won't add it to the library.
TypeLite is a good project but lacking in Documentation and examples, it's open source so anyone can contribute and make it better.
As for creating a file per class i solved it using the code below.
private static void GenerateTypeScriptContracts(string assemblyFile, string outputPath)
{
// Clean TS Folder
System.IO.DirectoryInfo di = new DirectoryInfo(outputPath);
foreach (FileInfo file in di.GetFiles())
{
file.Delete();
}
// --
var assembly = Assembly.LoadFrom(assemblyFile);
// If you want a subset of classes from this assembly, filter them here
var models = assembly.GetTypes();
foreach (var model in models)
{
var generator = new TypeScriptFluent()
.WithConvertor<Guid>(c => "string")
.WithMemberFormatter((identifier) => Char.ToLower(identifier.Name[0]) + identifier.Name.Substring(1));
generator.ModelBuilder.Add(model);
// Generate TS interface definitions
var tsClassDefinitions = generator.Generate(TsGeneratorOutput.Properties | TsGeneratorOutput.Fields);
File.WriteAllText(Path.Combine(outputPath, "I" + model.FullName.Replace("ProjectName.DtoModels.", "") + ".ts"), tsClassDefinitions);
}
}

Related Links

Typelite “Cannot load file or assembly” Autofac
TypeLite fresh install doesn't work
How to change TypeLite Output Directory
How to setup TypeLite to build types in other projects
Variant type and non, with same name
Ignoring types with fluent configuration in Typelite
IMemberIdentifier missing from TypeLite.TsModels namespace
Typelite Converts All Classes
Fluent module name change
TypeLite generate external modules?
Typelite: Why is Dictionary<string, object> mapped to KeyValuePair and not to any or [index:string]:any

Categories

HOME
hpoo
jboss
list
bots
celery
malware
dji-sdk
capistrano
u-boot
sympy
msmq
swarm
log4j2
yahoo
spring-security-oauth2
fireloop
graphdb
smooks
grocery-crud
mpu6050
dhcp
heap-dump
scala-ide
renderscript
yii2-basic-app
activeadmin
hdl
el
multi-upload
ini
chronicle-queue
router
web-config-transform
webviewclient
multi-dimensional-scaling
background-color
basex
react-bootstrap-table
code-climate
microprocessors
source-insight
infopath2010
osx-lion
appcode
nest
orchardcms-1.8
pdfminer
ftp-server
runtimeexception
xll
text-decorations
export-to-pdf
newtons-method
system-on-chip
hdiv
opal-framework
word-cloud
access-denied
yoast
google-prediction
kitura
libreoffice-writer
sequence-diagram
mura
wikimapia
sesame
zend-server
cefpython
rational-performance-test
bigdecimal
openquery
dcount
bilinear-interpolation
ftp-client
msbuild-4.0
oci
declarative
xcopy
as3-api
flipclock
ora-04091
highest
sequence-sql
artisan
quercus
text-align
mxe
python-c-extension
html-escape-characters
tkx
microsoft-expression-web
wicket-1.5
qt5.4
oracle-adf-mobile
aho-corasick
lumia-imaging-sdk
two.js
jini
neo4jphp
thruway
oxygene
code39
proxy-server
autonumber
jmenubar
discovery
apache-shindig
disjoint-union
.net-remoting
pacman
flv
spiral
ui-design
android-authenticator
ip-geolocation
audiotoolbox
instance-variables
voice-recording
hardcode
prototypal-inheritance
gwt-celltable
simile
icicles
jquery-effects
xap
isapi-redirect
service-factory

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App