New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

typescript.api

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript.api - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

18

index.js

@@ -84,2 +84,11 @@ var _vm = require("vm");

function reset() {
var api = load_typescript_api();
var logger = new api.Loggers.NullLogger();
exports.compiler = new api.Compile.Compiler(exports.languageVersion, exports.moduleTarget, logger);
}
exports.reset = reset;
function create(path, content) {

@@ -161,11 +170,2 @@ var api = load_typescript_api();

function reset() {
var api = load_typescript_api();
var logger = new api.Loggers.NullLogger();
exports.compiler = new api.Compile.Compiler(exports.languageVersion, exports.moduleTarget, logger);
}
exports.reset = reset;
function reflect(compiledUnits, callback) {

@@ -172,0 +172,0 @@ var api = load_typescript_api();

{
"name": "typescript.api",
"version": "0.4.0",
"version": "0.4.1",
"description": "A compiler as a service api enabling nodejs developers to resolve, compile, reflect and run typescript 0.9 source files.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -30,3 +30,19 @@ # typescript.api

```
### overview
* [manual compilation](#manual_compilation)
* [compiler options](#options)
### methods
* [create](#create)
* [resolve](#resolve)
* [compile](#compile)
* [check](#check)
* [build](#build)
* [run](#run)
* [reset](#reset)
* [sort](#sort)
<a name="manual_compilation" />
### manual compilation

@@ -37,3 +53,3 @@

The process will first resolve 'program.ts' and all its referenced sources files. The resolved
sources (units) then checked prior to being sent to the compiler for compilation. Once compiled,
sources array (resolved) are then checked prior to being sent to the compiler for compilation. Once compiled,
the compilation is checked again for problems prior to being run.

@@ -82,7 +98,27 @@

<a name="options" />
### compiler options
The following are options available on the typescript compiler.
```javascript
var typescript = require("typescript.api");
// enables remote resolution of source files over http. false by default.
typescript.allowRemote = false;
// the javascript language version to target. EcmaScript3 | EcmaScript5
typescript.languageVersion = "EcmaScript5";
// CommonJS or AMD module profiles, Synchronous | Asynchronous. Synchronous is the default.
typescript.moduleTarget = "Synchronous";
```
## reference
<a name="resolve" />
### typescript.resolve (sources, callback)
Will resolve source units by traversing each source files reference element.
Will resolve source units by traversing each source files reference element. The result will be an
ordered (in order of dependancy) array of source units.

@@ -92,3 +128,3 @@ __arguments__

* sources - A filename, or a array of filenames to resolve.
* callback(units) - A callback with the resolved units.
* callback(units) - A callback which passes the resolved source units.

@@ -106,10 +142,10 @@ __example__

for(var n in resolved) {
console.log( resolved[n].path );
console.log( resolved[n].path ); // the source files path
console.log( resolved[n].content );
console.log( resolved[n].content ); // the source files content (typescript)
for(var m in resolved[n].references) {
console.log( resolved[n].references[m] )
console.log( resolved[n].references[m] ) // paths to referenced source files.

@@ -120,10 +156,10 @@ }

```
<a name="check" />
### typescript.check (units)
Checks source units for diagnostic errors.
Utility method to check if a source or compiled unit has errors.
__arguments__
* units - units to be checked.
* units - units to be checked.
* returns - true if ok.

@@ -140,7 +176,7 @@

if(typescript.check (resolved)) {
if(typescript.check (resolved)) { // check here for reference errors.
typescript.compile(resolved, function(compiled) {
if( typescript.check (compiled) ) {
if( typescript.check (compiled) ) { // check here for syntax and type errors.

@@ -155,12 +191,16 @@ typescript.run(compiled, null, function(context) {

```
<a name="create" />
### typescript.create ( filename, code )
Will create a unit from the supplied filename and source code.
Creates a source unit from a string.
__arguments__
* filename - A filename that other units can reference.
* code - The source code for this unit.
* filename - A filename that other units may reference.
* code - The source code for this unit.
__returns__
* unit - A source unit.
__example__

@@ -185,3 +225,3 @@

```
<a name="compile" />
### typescript.compile ( units, callback )

@@ -193,4 +233,4 @@

* units - An array of source units.
* callback - A callback that passes the compiled output.
* units - An array of source units.
* callback - A callback that passed the compiled output.

@@ -215,35 +255,3 @@ __example__

```
### typescript.reflect ( compilation, callback )
Reflects compilation AST and produces meta data about the modules, classes,
methods and variables contained within the compilation.
__arguments__
* units - The compilation to be reflected.
* callback - A callback that passes the reflected metadata.
__example__
The following will resolve the source file 'program.ts', compile it, then reflect its
meta data to the console as a JSON string.
```javascript
var typescript = require("typescript.api");
typescript.resolve(['program.ts'], function(resolved){
typescript.compile(resolved, function(compiled) {
typescript.reflect(compiled, function(reflection) {
var json = JSON.stringify(reflection, null, ' ');
console.log(json);
});
});
});
```
<a name="build" />
### typescript.build ( sources, callback )

@@ -285,5 +293,5 @@

```
<a name="run" />
### typescript.run ( compiledUnits, sandbox, callback )
### typescript.run ( compilation, sandbox, callback )
Runs a compilation.

@@ -293,5 +301,5 @@

* compilation - The compilation to be run.
* sandbox - A sandbox. pass null to inherit the current sandbox.
* callback - A callback that passes a context containing any exported variables and function.
* compiledUnits - compiled source units.
* sandbox - A sandbox. pass null to inherit the current sandbox. code in executed in nodejs vm.
* callback - A callback that passes a context containing any exported variables and function.

@@ -312,3 +320,3 @@ __example__

console.log(context.value);
console.log(context.value); // outputs 123

@@ -318,3 +326,14 @@ });

```
<a name="reset" />
### typescript.reset ()
Resets the compiler.
```javascript
var typescript = require("typescript.api");
typescript.reset();
```
<a name="sort" />
### typescript.sort ( units )

@@ -321,0 +340,0 @@

@@ -159,41 +159,2 @@ declare module TypeScript.Api.IO {

}
declare module TypeScript.Api.Units {
class CompiledUnit extends Units.Unit {
public ast: TypeScript.AST;
public declaration: string;
constructor(path: string, content: string, diagnostics: Units.Diagnostic[], ast: TypeScript.AST, declaration: string);
public references(): string[];
}
}
declare module TypeScript.Api.Compile {
interface IEmitter {
directoryExists(path: string): boolean;
fileExists(path: string): boolean;
resolvePath(path: string): string;
writeFile(fileName: string, contents: string, writeByteOrderMark: boolean): void;
}
class Emitter implements IEmitter {
public files: string[];
constructor();
public writeFile(fileName: string, contents: string, writeByteOrderMark: boolean): void;
public directoryExists(path: string): boolean;
public fileExists(path: string): boolean;
public resolvePath(path: string): string;
}
}
declare module TypeScript.Api.Compile {
class Compiler {
public compiler: TypeScript.TypeScriptCompiler;
public logger: TypeScript.ILogger;
public sourceUnits: Api.Units.SourceUnit[];
constructor(languageVersion: TypeScript.LanguageVersion, moduleTarget: TypeScript.ModuleGenTarget, logger: TypeScript.ILogger);
private isSourceUnitInCache(sourceUnit);
private isSourceUnitUpdated(sourceUnit);
private addSourceUnit(sourceUnit);
private syntaxCheck(sourceUnit);
private typeCheck(sourceUnit);
private emitUnits(sourceUnits);
public compile(sourceUnits: Api.Units.SourceUnit[], callback: (compiledUnits: Api.Units.CompiledUnit[]) => void): void;
}
}
declare module TypeScript.Api.Reflect {

@@ -354,1 +315,42 @@ class Import {

}
declare module TypeScript.Api.Units {
class CompiledUnit extends Units.Unit {
public ast: TypeScript.AST;
public declaration: string;
public sourcemap: string;
public reflection: Api.Reflect.Script;
constructor(path: string, content: string, diagnostics: Units.Diagnostic[], ast: TypeScript.AST, declaration: string, sourcemap: string, reflection: Api.Reflect.Script);
public references(): string[];
}
}
declare module TypeScript.Api.Compile {
interface IEmitter {
directoryExists(path: string): boolean;
fileExists(path: string): boolean;
resolvePath(path: string): string;
writeFile(fileName: string, contents: string, writeByteOrderMark: boolean): void;
}
class Emitter implements IEmitter {
public files: string[];
constructor();
public writeFile(fileName: string, contents: string, writeByteOrderMark: boolean): void;
public directoryExists(path: string): boolean;
public fileExists(path: string): boolean;
public resolvePath(path: string): string;
}
}
declare module TypeScript.Api.Compile {
class Compiler {
public compiler: TypeScript.TypeScriptCompiler;
public logger: TypeScript.ILogger;
public sourceUnits: Api.Units.SourceUnit[];
constructor(languageVersion: TypeScript.LanguageVersion, moduleTarget: TypeScript.ModuleGenTarget, logger: TypeScript.ILogger);
private isSourceUnitInCache(sourceUnit);
private isSourceUnitUpdated(sourceUnit);
private addSourceUnit(sourceUnit);
private syntaxCheck(sourceUnit);
private typeCheck(sourceUnit);
private emitUnits(sourceUnits);
public compile(sourceUnits: Api.Units.SourceUnit[], callback: (compiledUnits: Api.Units.CompiledUnit[]) => void): void;
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc