typescript-services
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

typescript-services

NPM version Views

NPM

Open up TypeScript services for nodejs consumption

Usage

/// <reference path="./typescriptServices.d.ts"/>
import ts = require('typescript-services');
 
// formatter:
var snapshot = ts.SimpleText.fromString('var foo = 123;');
var formatter = new ts.Services.Formatting.TextSnapshot(snapshot);
console.log(formatter);
 

Contributing

Getting the language service

Opening up the TypeScript compiler : http://www.slideshare.net/nnzz2475/typescript-35845723

git glone https://git01.codeplex.com/typescript TypeScript
cd TypeScript
npm install 
node_modules/.bin/jake local
cd built/local
ls

Important:

typescriptServices.d.ts
typescriptServices.js

unwrap

.js

Add line at bottom of .js:

module.exports = TypeScript;

.d.ts

Add header needed to a valid DT definition:

// Type definitions for TypeScript-Services
// Project: https://www.npmjs.org/package/typescript-services
// Definitions by: Basarat Ali Syed <http://github.com/basarat>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

Cleanup the following lines from .d.ts as these should come from node.d.ts.

declare var require: any;
declare var module: any;
declare module process {
    var argv: string[];
    var platform: string;
    function on(event: string, handler: (arg: any) => void): void;
    module stdout {
        function write(str: string): any;
        function on(event: string, action: () => void): void;
    }
    module stderr {
        function write(str: string): any;
        function on(event: string, action: () => void): void;
    }
    module mainModule {
        var filename: string;
    }
    function exit(exitCode?: number): any;
}
declare var Buffer: new(str: string, encoding?: string) => any;
declare var global: any;

Add line at bottom on .d.ts:

declare module 'typescript-services' {
    export = TypeScript;
}

All set!

Package Sidebar

Install

npm i typescript-services

Weekly Downloads

9

Version

0.1.5

License

MIT

Last publish

Collaborators

  • basarat