Code Monkey home page Code Monkey logo

wisdom-typescript's Introduction

Wisdom-TypeScript

TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Any browser. Any host. Any OS. Open Source.

Wisdom-TypeScript integrates TypeScript compilation into Wisdom. So, TypeScript files (.ts files) automatically compiled to JavaScript at build time.

It supports the Wisdom Watch Mode, so any change to a .ts file immediately triggers the compilation and updates the output file.

Usage

Add the following plugin to you pom.xml file:

<plugin>
    <groupId>org.wisdom-framework</groupId>
    <artifactId>wisdom-typescript-maven-plugin</artifactId>
    <version>0.6</version> <!-- set the version here -->
    <executions>
        <execution>
            <id>compile-typescript-files</id>
            <phase>compile</phase>
            <goals>
                <goal>compile-typescript</goal>
            </goals>
        </execution>
    </executions>
</plugin>

By default, TypeScript 1.0.1 is used, but you can set the version to use as follows:

<plugin>
    <groupId>org.wisdom-framework</groupId>
    <artifactId>wisdom-typescript-maven-plugin</artifactId>
    <version>${project.version}</version>
    <executions>
            <execution>
                <id>compile-typescript-files</id>
                <phase>compile</phase>
                <goals>
                    <goal>compile-typescript</goal>
                </goals>
            </execution>
        </executions>
    <configuration>
        <version>1.0.1</version>
    </configuration>
</plugin>

Examples

The TypeScript files can be either in src/main/resources/assets (internal resources, packaged within the application), or in src/main/assets (external resources, only packaged within the distribution).

For example, the file src/main/resources/assets/Animal.ts with the following content:

class Animal {
    constructor(public name: string) { }
    move(meters: number) {
        alert(this.name + " moved " + meters + "m.");
    }
}

class Snake extends Animal {
    constructor(name: string) { super(name); }
    move() {
        alert("Slithering...");
        super.move(5);
    }
}

class Horse extends Animal {
    constructor(name: string) { super(name); }
    move() {
        alert("Galloping...");
        super.move(45);
    }
}

var sam = new Snake("Sammy the Python");
var tom: Animal = new Horse("Tommy the Palomino");

sam.move();
tom.move(34);

generates the target/classes/assets/Animal.js, as well as the associated source map and declaration.

Parameters

In addition to the version parameter seen above, the plugin supports:

  • removeComments : When enabled, removes the comments from the generated JavaScript files. (Default: false)
  • declaration : When enabled, generates corresponding +.d.ts+ files. (Default: false)
  • module : Set the type of module generated among "commonjs" and "amd". (Default: commonsjs)
  • noImplicitAny : When enabled, fail the compilation on expressions and declaration with an implied 'any' type. (Default: false)
  • sourcemap : When enabled, generates the source map files (Default: true)

wisdom-typescript's People

Contributors

cescoffier avatar jenf11 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wisdom-typescript's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.