electricessence / TypeScript.NET

A JavaScript-Friendly .NET Based TypeScript Library (Moved)
https://github.com/electricessence/TypeScript.NET-Core
Other
251 stars 36 forks source link
dotnet javascript linq typescript typescript-dotnet

MOVED

https://github.com/electricessence/TypeScript.NET-Core

For numerous reasons, TypeScript.NET has been archived in favor of breaking it up into more managable pieces that can be improved upon independently. See the above link for details.

TypeScript.NET (Archive)

A JavaScript-Friendly .NET Based TypeScript Library

Patreon donate button Or support by taking this course: https://www.udemy.com/stepping-up-to-typescript-fundamentals/

The intention of this project to to allow for the evolution of a .NET based TypeScript (and resultant JavaScript) library. Contributions are welcomed as the .NET Library (meaning it's class structure and classes, not necessarily its content) has a substantial amount of usefulness. With the open sourcing of .NET, TypeScript seems the most logical means to take advantage of it. Typing, generics, classes, modules, inheritance, all are required to make a resultant JavaScript library that takes advantage of this elegance.

Much inspiration comes from TypeScript itself and from libraries like linq.js. There is of course some variance away from .NET's convention (camelCase methods in favor of TitleCase) and some things simply have to be done different. "Extensions" as a feature might be one of the greatest additions to .NET that JavaScript doesn't have a plan for, but it does have some tricky equivalents.

If you have a .NET Library class that you want to see represented in TypeScript, submit it (as an issue), or contribute it yourself! :)

Why should I use this, let alone TypeScript?

  1. It's 100% compatible with JavaScript. Currently TypeScript .NET's target is ES5, so legacy ES3 won't work. Mainly because of accessors. But going forward, TypeScript is nearly the same as ES6 and you don't have to change your source code to target newer versions. :)
  2. TypeScript is lead by Anders Hejlsberg, the founder of C#. You will feel quite at home in TypeScript if you are a fan of typed languages (like C#), but at the same time you'll get all the flexibility and compatibility of JavaScript. See www.typescriptlang.org for more information about the TypeScript language. Also some more good info on Wikipedia.
  3. The benefits of intellisense and using an IDE for programming should be obvious especially if you are coding for a larger project. Typed compilation is less forgiving in a good way. You simply make much less mistakes in the long run. TypeScript might be the best answer to JavaScript yet. It's still JavaScript, but with many bonuses including a growing community. :)
  4. Most major IDEs and text editors now support TypeScript either built in, or via a plug-in:
    • Visual Studio
    • VS Code
    • WebStorm (Strongly recommended! Makes NodeJS development a dream.)
    • Sublime Text
    • Atom

To name a few.

Release Notes:

Highlights

Usage

After some time and effort, I've decided that this library should be module based since there are too many files and dependencies that may or may not get used. This is simply the right decision and results in:

Why not take this a step further and break it up into separate NPM style modules/packages?

There is a point where fragmentation and over-granularity just make life harder. If one module depends on another and you want to implement improvements it's just easier if they live in the same place.

NPM:

Version 2.5 was the first NPM release. The goal is to get this as user friendly as possible.

All distributions contain source-maps.
https://www.npmjs.com/search?q=typescript-dotnet

Universal Module Definition (UMD)

npm install typescript-dotnet-umd

It's highly recommended to use the UMD (minified) version for most cases since it works for AMD and CommonJS.
Note: WebPack has trouble with UMD. Use CommonJS or AMD if you intend to use WebPack.

All Published NPM Module Types

Install on only the module type you need in order to avoid type collisions.

Currently it is possible/supported to use TypeScript .NET in a number of different ways:

Import Examples:

import Enumerable from "typescript-dotnet-es6/System.Linq/Linq"
Recommended for users who are deploying directly to web/browsers:

Note: WebPack has trouble with UMD. Use CommonJS or AMD if you intend to use WebPack.

import Enumerable from "typescript-dotnet-umd/System.Linq/Linq"
Pure (unminified ES5) CommonJS is available this way:
import Enumerable from "typescript-dotnet-commonjs/System.Linq/Linq"
Recommended for users who want pure minified AMD (RequireJS) with source-maps:
import Enumerable from "typescript-dotnet-amd/System.Linq/Linq"

Bower:

bower install typescript-dotnet

This should also include require.js in your bower components directory. If you need another module type other than AMD, the TypeScript files are included so you can rebuild however you need.

Nuget:

PM> Install-Package TypeScript.NET.Library

Unit Tests

Mocha tests are in place for core functionality and expanding all the time. Istanbul is used for code coverage. Current coverage is good if not reasonable.

Examples

Currently the unit test cover many example usages.

Documentation

Currently improving over time using JSDoc style comments and TypeDoc. View Documentation: electricessence.github.io/TypeScript.NET/documentation

Documentation has a tendency to lag behind and TypeDoc is also lagging on updates.

Contribution

This library has immense potential and quite often a class, or function that is missing will simply be added. If you log any issues here on GitHub they will likely be addressed swiftly. If you have a class or module you'd like to see integrated, just log an issue and start the discussion or feel free to make a pull request from your own design. :)

Discussion

Join the chat at https://gitter.im/electricessence/TypeScript.NET

Reddit

TypeScript.NET Library

.NET, TypeScript

Learn, Connect & Evolve

Stepping up to Typescript: Fundamentals

Code Evolution

www.youtube.com/channel/UCG2QyAgVUEKSMBaC0Fkp5GQ

Click an image below to watch.

Intro to TypeScript.NET Library (Part 1)

Intro to TypeScript.NET Library (Part 1)

TypeScript.NET v3 Release Info/Update

TypeScript.NET v3 Release Info/Update