Click here to Skip to main content
15,892,674 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Stupid Computer Pin
enhzflep27-Jun-15 9:30
enhzflep27-Jun-15 9:30 
GeneralRe: Stupid Computer Pin
DaveX8627-Jun-15 9:34
DaveX8627-Jun-15 9:34 
GeneralRe: Stupid Computer Pin
enhzflep27-Jun-15 9:41
enhzflep27-Jun-15 9:41 
GeneralRe: Stupid Computer Pin
DaveX8627-Jun-15 9:50
DaveX8627-Jun-15 9:50 
GeneralRe: Stupid Computer Pin
enhzflep27-Jun-15 22:34
enhzflep27-Jun-15 22:34 
GeneralTypescript - waow! Pin
JMK-NI26-Jun-15 9:20
professionalJMK-NI26-Jun-15 9:20 
GeneralRe: Typescript - waow! Pin
Gjeltema26-Jun-15 9:43
Gjeltema26-Jun-15 9:43 
GeneralRe: Typescript - waow! PinPopular
JMK-NI26-Jun-15 9:56
professionalJMK-NI26-Jun-15 9:56 
Sure.

Well, first of all I am working with a .net back-end, so doing all of my coding in Visual Studio (2015 RC). Visual Studio 2015 + ReSharper + Web Essentials which provides a really nice environment for working with Typescript.

For my API, server side, I am using ServiceStack. ServiceStack have created a Visual Studio plugin to generate a DTO in Typescript based on your API. You write your API, run this program, and you have an interface for every Request and Response object in your API.

There is a Typescript project called DefinitelyTyped. It provides type definitions for all of the frameworks I am using, which for this project are:
  • AngularJS
  • Angular UI Router
  • Angular UI Directives for Bootstrap
  • AngularJS Toastr
This means that you can write your client side code in Typescript, and everything is strongly typed. Here is an AngularJS service I wrote earlier today in Typescript:
C#
import CreateAdjustmentRequest = JobManager.Model.CreateAdjustmentRequest;
import AdjustmentResponse = JobManager.Model.AdjustmentResponse;
import HttpPromise = angular.IHttpPromise;
import GetAdjustmentRequest = JobManager.Model.GetAdjustmentRequest;
import GetAdjustmentsRequest = JobManager.Model.GetAdjustmentsRequest;
import UpdateAdjustmentRequest = JobManager.Model.UpdateAdjustmentRequest;
import DeleteAdjustmentRequest = JobManager.Model.DeleteAdjustmentRequest;

export class AdjustmentService {

    httpService: angular.IHttpService;
    constructor(httpService: angular.IHttpService) { this.httpService = httpService; }

    getAdjustment(request: GetAdjustmentRequest):HttpPromise<AdjustmentResponse> {
        return this.httpService.get('/adjustments/' + request.Id);
    }

    getAdjustments(request: GetAdjustmentsRequest): HttpPromise<AdjustmentResponse[]> {
        return this.httpService.get('/adjustments/all/' + request.JobId);
    }

    createAdjustment(request: CreateAdjustmentRequest): HttpPromise<AdjustmentResponse> {
        return this.httpService.post('/adjustments/create', request);
    }

    updateAdjustment(request: UpdateAdjustmentRequest): HttpPromise<AdjustmentResponse> {
        return this.httpService.post('/adjustments/' + request.Id, request);
    }

    deleteAdjustment(request: DeleteAdjustmentRequest): HttpPromise<boolean> {
        return this.httpService.delete('/adjustments/' + request.Id);
    }
}

(() => angular.module('JobManager').service('AdjustmentService', ['$http', (http: angular.IHttpService) => {
    return new AdjustmentService(http);
}]))();

How nice is that? You have all sorts of niceties from C# such as generics and lambda expressions, and everything you see is strongly typed. The colon syntax on method arguments is used to assign a type to an object. If you don't use this, then it's similar to a dynamic object in C#, and will compile no matter what you do. The colon syntax on a method itself is used to specify which type of object the method returns.

IHttpService comes from the AngularJS DefinitelyTyped library. The requests and responses have been generated by ServiceStack, based on the C# classes used. If you get anything wrong, then the project doesn't build and you can catch errors at compile time as opposed to run time.

Loving it all so far!

One of the core developers of Typescript is Anders Hejlsberg, who was also one of the core developers of C#. AngularJS 2 is build on TypeScript! This is a collaboration between Microsoft on Google, which is insanely cool! Asana is built with Typescript, as are a bunch of major SPA's.[^]

I'm not writing any more Javascript if I can avoid it.

modified 26-Jun-15 16:34pm.

GeneralRe: Typescript - waow! Pin
TheGreatAndPowerfulOz26-Jun-15 10:21
TheGreatAndPowerfulOz26-Jun-15 10:21 
GeneralRe: Typescript - waow! Pin
Gjeltema26-Jun-15 12:24
Gjeltema26-Jun-15 12:24 
GeneralRe: Typescript - waow! Pin
Jörgen Andersson26-Jun-15 20:59
professionalJörgen Andersson26-Jun-15 20:59 
GeneralRe: Typescript - waow! Pin
Brisingr Aerowing27-Jun-15 11:58
professionalBrisingr Aerowing27-Jun-15 11:58 
GeneralRe: Typescript - waow! Pin
Sander Rossel26-Jun-15 22:53
professionalSander Rossel26-Jun-15 22:53 
QuestionWindows update problems for some updates... Pin
Joan M26-Jun-15 8:23
professionalJoan M26-Jun-15 8:23 
AnswerRe: Windows update problems for some updates... Pin
phil.o26-Jun-15 8:36
professionalphil.o26-Jun-15 8:36 
GeneralRe: Windows update problems for some updates... Pin
Joan M26-Jun-15 8:49
professionalJoan M26-Jun-15 8:49 
GeneralRe: Windows update problems for some updates... Pin
phil.o26-Jun-15 9:29
professionalphil.o26-Jun-15 9:29 
GeneralRe: Windows update problems for some updates... Pin
Joan M27-Jun-15 22:34
professionalJoan M27-Jun-15 22:34 
GeneralRe: Windows update problems for some updates... Pin
phil.o27-Jun-15 22:57
professionalphil.o27-Jun-15 22:57 
GeneralRe: Windows update problems for some updates... Pin
Member 1179559026-Jun-15 10:44
Member 1179559026-Jun-15 10:44 
AnswerRe: Windows update problems for some updates... Pin
Ron Anders26-Jun-15 14:00
Ron Anders26-Jun-15 14:00 
GeneralXKCDOTD Pin
clientSurfer26-Jun-15 6:08
professionalclientSurfer26-Jun-15 6:08 
GeneralRe: XKCDOTD Pin
Richard Deeming26-Jun-15 6:11
mveRichard Deeming26-Jun-15 6:11 
GeneralRe: XKCDOTD PinPopular
clientSurfer26-Jun-15 7:13
professionalclientSurfer26-Jun-15 7:13 
GeneralRe: XKCDTIJRDTWEPTTCWIADITAOAECASHTIDTPITLT Pin
Richard Deeming26-Jun-15 7:20
mveRichard Deeming26-Jun-15 7:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.