$ npm install ntypescript
The following is left as legacy docs.
Nicer TypeScript, making it easier to work with the compiler API 🌹
Kudos to the TypeScript team for maintaining all the code that this project depends on. This project is just a minor automation on top.
Niceness list:
n
prefix): require('ntypescript')
, ntsc
package.json
links you to typescript definitions (using typescript.definition
entry)/* internal */
)ts
variable. Just require('ntypescript')
once and start using ts
like you are in the actual compiler source code.const enum
in the compiler definition to enum
. This decreases the typescript compiler version dependence on your dev tools TS->JS emit.node_modules/ntypescript/src
folder in atom-typescript and press f6
to get a new local rebuild.Design incompatibilities:
tsserver
.Similar to typescript
you can install and use ntypescript
globally:
npm install ntypescript -g
or in your package.json
npm install ntypescript@latest --save --save-exact
Each release is named after the day it was built and the git commit hash in Microsoft/TypeScript/master that it was built from. We recommend adding save-exact
as there are no guarantees on when stuff might break and you want your users to get the same version you tested.
You can use ntsc
exactly like the tsc
command line tool.
Use require('ntypescript')
ts
In addition to returning what typescript
returns we also expose ts
as a global.
declare var require: any;
require('ntypescript');
console.log(ts.createScanner);
Which makes it easy to use the compiler API if you are using it heavily. Note you only need to require
once from any file.
For require('typescript')
you can do that quite simply using your package.json:
"dependencies": {
"typescript": "https://github.com/basarat/ntypescript/tarball/<release name>"
}
Release name example : 1.201506301047.1+e1c9d28cb0706f81c14ca95b92fa3e2a223cc60b
This project comes with a built in grunt
task called ntypescript
. Just has just one task level option:
project
: path to the project directory i.e. the directory that contains tsconfig.json
.Here is a sample Gruntfile.js
for usage:
module.exports = function(grunt) {
grunt.loadNpmTasks('ntypescript');
grunt.initConfig({
ntypescript: {
options: {
project: '.'
}
},
});
grunt.registerTask('default', ['ntypescript']);
};
Init and setup in package.json
npm init
npm install ntypescript@latest --save --save-exact
"scripts": {
"build": "ntsc -p ./src"
},
And then you just need to do the following to build your project:
npm run build
Note that this is a personal endeavor, not officially by Microsoft.
© 2010 - cnpmjs.org x YWFE | Home | YWFE