0.0.31 • Published 3 years ago

ts2nim v0.0.31

Weekly downloads
34
License
MIT
Repository
github
Last release
3 years ago

ts2nim

Build Status Total alerts Language grade: JavaScript Npm Version npm: total downloads Types Dep license

Typescript to Nim transpiler

It also can translate js code with the Nim type auto as typescript-estree compatible with the js estree.

It identified the .d.ts file if the ast node is TSMethodSignature it will add importcpp pragma to translated proc, so it could be used as a wrapper generator.

Motivation

Transpile nodejs modules, write in Typescript and transpile it to Nim, expand the Nim-Javascript backend ecosystem and so on.

Current goal is translating Typescript syntax into valid and pretty looking nim code. you may manually modify nim sources after translation. it just translate source code exclude dependency,even modules in nodejs std.

demo transpiled project:
vscode-uri

It can be easy to translate library processes like string manipulation, images, bytes and all these things.

RoadMap

This project has two routes
1. Generate nim js bridge through typescript type difinition file.
2. Generate nim source code through typescript source file.

Todos

  • Inferring js type (object or others)
  • Inferring native type (eg. number is int or float)

Limitations

assemblyscript basics described well, share same theory.

Installation

npm i ts2nim or
yarn add ts2nim

Usage

ts2nim -i inputFileOrDir -o outFileOrDir

without param it will transpile current directory in place with extension .nim

Translation

origintodescription
numberfloat
booleanbool
interface,type,classtype
Example()newExample()constructor for a class
let,var,constvarconst no-object -> const,others var
thisself
null,undefindednil
optinal paramnone(T)options module
T|null,T|undefindedTref type
RestElement paramopenArrayT
switchcase of
Arrayseq
StringTemplatefmtstrformat module
do whiledoWhiledoWhile template
raise new T()raise newException(T)
.length.len
.push.add
fs.readFileSyncreadFileos module
path.join/os module
.some.anysequtils module
.sort.sortedalgorithm module
async{.async.}asyncdispatch or asyncjs module
=====
!==!=
&&and
||or
!not
+& or +depends on a literal string or number found
deleteassign to nil
extends A,Bref object of A,BMultiple Inheritance not supported in Nim

Related Projects

mcclure/dts2nim

Projects use ts2nim

Add by you

0.0.31

3 years ago

0.0.30

4 years ago

0.0.29

4 years ago

0.0.27

4 years ago

0.0.26

4 years ago

0.0.24

4 years ago

0.0.25

4 years ago

0.0.23

4 years ago

0.0.21

4 years ago

0.0.22

4 years ago

0.0.20

4 years ago

0.0.17

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.16

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.12

4 years ago

0.0.13

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.1

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.0

4 years ago