typescript
Advanced tools
Comparing version 1.5.3 to 1.6.0-beta
@@ -34,42 +34,73 @@ ## Contributing bug fixes | ||
`jake runtests` | ||
```Shell | ||
jake runtests | ||
``` | ||
This run will all tests; to run only a specific subset of tests, use: | ||
`jake runtests tests=<regex>` | ||
```Shell | ||
jake runtests tests=<regex> | ||
``` | ||
e.g. to run all compiler baseline tests: | ||
`jake runtests tests=compiler` | ||
```Shell | ||
jake runtests tests=compiler | ||
``` | ||
or to run specifc test:tests\cases\compiler\2dArrays.ts | ||
or to run specifc test: `tests\cases\compiler\2dArrays.ts` | ||
`jake runtests tests=2dArrays` | ||
```Shell | ||
jake runtests tests=2dArrays | ||
``` | ||
## Adding a Test | ||
To add a new testcase, simply place a .ts file in tests\cases\compiler containing code that exemplifies the bugfix or change you are making. | ||
To add a new testcase, simply place a `.ts` file in `tests\cases\compiler` containing code that exemplifies the bugfix or change you are making. | ||
These files support metadata tags in the format // @name: value . The supported names and values are: | ||
These files support metadata tags in the format `// @metaDataName: value`. The supported names and values are: | ||
* comments, sourcemap, noimplicitany, declaration: true or false (corresponds to the compiler command-line options of the same name) | ||
* target: ES3 or ES5 (same as compiler) | ||
* out, outDir: path (same as compiler) | ||
* module: local, commonjs, or amd (local corresponds to not passing any compiler --module flag) | ||
* `comments`, `sourcemap`, `noimplicitany`, `declaration`: true or false (corresponds to the compiler command-line options of the same name) | ||
* `target`: ES3 or ES5 (same as compiler) | ||
* `out`, outDir: path (same as compiler) | ||
* `module`: local, commonjs, or amd (local corresponds to not passing any compiler --module flag) | ||
* `fileName`: path | ||
* These tags delimit sections of a file to be used as separate compilation units. They are useful for tests relating to modules. See below for examples. | ||
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in tests\cases\conformance in an appropriately-named subfolder. | ||
**Note** that if you have a test corresponding to a specific spec compliance item, you can place it in `tests\cases\conformance` in an appropriately-named subfolder. | ||
**Note** that filenames here must be distinct from all other compiler testcase names, so you may have to work a bit to find a unique name if it's something common. | ||
### Tests for multiple files | ||
When one needs to test for scenarios which require multiple files, it is useful to use the `fileName` metadata tag as such: | ||
```TypeScript | ||
// @fileName: file1.ts | ||
export function f() { | ||
} | ||
// @fileName: file2.ts | ||
import { f as g } from "file1"; | ||
var x = g(); | ||
``` | ||
One can also write a project test, but it is slightly more involved. | ||
## Managing the Baselines | ||
Compiler testcases generate baselines that track the emitted .js, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output. | ||
Compiler testcases generate baselines that track the emitted `.js`, the errors produced by the compiler, and the type of each expression in the file. Additionally, some testcases opt in to baselining the source map output. | ||
When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use | ||
`jake diff` | ||
```Shell | ||
jake diff | ||
``` | ||
After verifying that the changes in the baselines are correct, run | ||
`jake baseline-accept` | ||
```Shell | ||
jake baseline-accept | ||
``` | ||
to establish the new baselines as the desired behavior. This will change the files in tests\baselines\reference, which should be included as part of your commit. It's important to carefully validate changes in the baselines. | ||
to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines. | ||
**Note** that baseline-accept should only be run after a full test run! Accepting baselines after running a subset of tests will delete baseline files for the tests that didn't run. |
156
Jakefile.js
@@ -20,3 +20,3 @@ // This file contains the build logic for the public repo | ||
var builtLocalDirectory = "built/local/"; | ||
var LKGDirectory = "bin/"; | ||
var LKGDirectory = "lib/"; | ||
@@ -107,5 +107,13 @@ var copyright = "CopyrightNotice.txt"; | ||
return path.join(serverDirectory, f); | ||
}); | ||
}).concat(servicesSources); | ||
var harnessSources = [ | ||
var languageServiceLibrarySources = [ | ||
"editorServices.ts", | ||
"protocol.d.ts", | ||
"session.ts" | ||
].map(function (f) { | ||
return path.join(serverDirectory, f); | ||
}).concat(servicesSources); | ||
var harnessCoreSources = [ | ||
"harness.ts", | ||
@@ -126,4 +134,7 @@ "sourceMapRecorder.ts", | ||
return path.join(harnessDirectory, f); | ||
}).concat([ | ||
}); | ||
var harnessSources = harnessCoreSources.concat([ | ||
"incrementalParser.ts", | ||
"jsDocParsing.ts", | ||
"services/colorization.ts", | ||
@@ -133,5 +144,9 @@ "services/documentRegistry.ts", | ||
"services/patternMatcher.ts", | ||
"session.ts", | ||
"versionCache.ts", | ||
"convertToBase64.ts", | ||
"transpile.ts" | ||
"transpile.ts", | ||
"reuseProgramStructure.ts", | ||
"cachingInServerLSHost.ts", | ||
"moduleResolution.ts" | ||
].map(function (f) { | ||
@@ -150,8 +165,8 @@ return path.join(unittestsDirectory, f); | ||
{ target: "lib.core.d.ts", sources: ["core.d.ts"] }, | ||
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, | ||
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "extensions.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, | ||
{ target: "lib.dom.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "dom.generated.d.ts"], }, | ||
{ target: "lib.webworker.d.ts", sources: ["importcore.d.ts", "intl.d.ts", "webworker.generated.d.ts"], }, | ||
{ target: "lib.scriptHost.d.ts", sources: ["importcore.d.ts", "scriptHost.d.ts"], }, | ||
{ target: "lib.d.ts", sources: ["core.d.ts", "extensions.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, | ||
{ target: "lib.d.ts", sources: ["core.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"], }, | ||
{ target: "lib.core.es6.d.ts", sources: ["core.d.ts", "es6.d.ts"]}, | ||
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"]}, | ||
{ target: "lib.es6.d.ts", sources: ["core.d.ts", "es6.d.ts", "intl.d.ts", "dom.generated.d.ts", "dom.es6.d.ts", "webworker.importscripts.d.ts", "scriptHost.d.ts"] }, | ||
]; | ||
@@ -214,3 +229,3 @@ | ||
var dir = useBuiltCompiler ? builtLocalDirectory : LKGDirectory; | ||
var options = "--module commonjs -noImplicitAny"; | ||
var options = "--module commonjs --noImplicitAny --noEmitOnError"; | ||
@@ -311,3 +326,3 @@ // Keep comments when specifically requested | ||
file(processDiagnosticMessagesTs) | ||
file(processDiagnosticMessagesTs); | ||
@@ -337,8 +352,46 @@ // processDiagnosticMessages script | ||
ex.run(); | ||
}, {async: true}) | ||
}, {async: true}); | ||
desc("Generates a diagnostic file in TypeScript based on an input JSON file"); | ||
task("generate-diagnostics", [diagnosticInfoMapTs]) | ||
task("generate-diagnostics", [diagnosticInfoMapTs]); | ||
// Publish nightly | ||
var configureNightlyJs = path.join(scriptsDirectory, "configureNightly.js"); | ||
var configureNightlyTs = path.join(scriptsDirectory, "configureNightly.ts"); | ||
var packageJson = "package.json"; | ||
var programTs = path.join(compilerDirectory, "program.ts"); | ||
file(configureNightlyTs); | ||
compileFile(/*outfile*/configureNightlyJs, | ||
/*sources*/ [configureNightlyTs], | ||
/*prereqs*/ [configureNightlyTs], | ||
/*prefixes*/ [], | ||
/*useBuiltCompiler*/ false, | ||
/*noOutFile*/ false, | ||
/*generateDeclarations*/ false, | ||
/*outDir*/ undefined, | ||
/*preserveConstEnums*/ undefined, | ||
/*keepComments*/ false, | ||
/*noResolve*/ false, | ||
/*stripInternal*/ false); | ||
task("setDebugMode", function() { | ||
useDebugMode = true; | ||
}); | ||
task("configure-nightly", [configureNightlyJs], function() { | ||
var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs; | ||
console.log(cmd); | ||
exec(cmd); | ||
}, { async: true }); | ||
desc("Configure, build, test, and publish the nightly release."); | ||
task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests"], function () { | ||
var cmd = "npm publish --tag next"; | ||
console.log(cmd); | ||
exec(cmd); | ||
}); | ||
// Local target to build the compiler and services | ||
@@ -363,3 +416,3 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename); | ||
/*stripInternal*/ true, | ||
/*callback*/ function () { | ||
/*callback*/ function () { | ||
jake.cpR(servicesFile, nodePackageFile, {silent: true}); | ||
@@ -372,3 +425,3 @@ | ||
var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); | ||
definitionFileContents = definitionFileContents.replace(/declare module ts/g, 'declare module "typescript"'); | ||
definitionFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); | ||
fs.writeFileSync(nodeDefinitionsFile, definitionFileContents); | ||
@@ -381,2 +434,16 @@ }); | ||
var lsslFile = path.join(builtLocalDirectory, "tslssl.js"); | ||
compileFile( | ||
lsslFile, | ||
languageServiceLibrarySources, | ||
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources), | ||
/*prefixes*/ [copyright], | ||
/*useBuiltCompiler*/ true, | ||
/*noOutFile*/ false, | ||
/*generateDeclarations*/ true); | ||
// Local target to build the language service server library | ||
desc("Builds language service server library"); | ||
task("lssl", [lsslFile]); | ||
// Local target to build the compiler and services | ||
@@ -429,7 +496,7 @@ desc("Builds the full compiler and services"); | ||
}); | ||
}, {async: true}) | ||
}, {async: true}); | ||
desc("Generates a Markdown version of the Language Specification"); | ||
task("generate-spec", [specMd]) | ||
task("generate-spec", [specMd]); | ||
@@ -480,3 +547,3 @@ | ||
function exec(cmd, completeHandler) { | ||
function exec(cmd, completeHandler, errorHandler) { | ||
var ex = jake.createExec([cmd], {windowsVerbatimArguments: true}); | ||
@@ -497,4 +564,8 @@ // Add listeners for output and error | ||
ex.addListener("error", function(e, status) { | ||
fail("Process exited with code " + status); | ||
}) | ||
if(errorHandler) { | ||
errorHandler(e, status); | ||
} else { | ||
fail("Process exited with code " + status); | ||
} | ||
}); | ||
@@ -521,5 +592,5 @@ ex.run(); | ||
// used to pass data from jake command line directly to run.js | ||
function writeTestConfigFile(tests, testConfigFile) { | ||
function writeTestConfigFile(tests, light, testConfigFile) { | ||
console.log('Running test(s): ' + tests); | ||
var testConfigContents = '{\n' + '\ttest: [\'' + tests + '\']\n}'; | ||
var testConfigContents = JSON.stringify({ test: [tests], light: light }); | ||
fs.writeFileSync('test.config', testConfigContents); | ||
@@ -540,2 +611,3 @@ } | ||
tests = process.env.test || process.env.tests || process.env.t; | ||
var light = process.env.light || false; | ||
var testConfigFile = 'test.config'; | ||
@@ -546,4 +618,4 @@ if(fs.existsSync(testConfigFile)) { | ||
if(tests) { | ||
writeTestConfigFile(tests, testConfigFile); | ||
if(tests || light) { | ||
writeTestConfigFile(tests, light, testConfigFile); | ||
} | ||
@@ -558,3 +630,3 @@ | ||
tests = tests ? ' -g ' + tests : ''; | ||
reporter = process.env.reporter || process.env.r || 'dot'; | ||
reporter = process.env.reporter || process.env.r || 'mocha-fivemat-progress-reporter'; | ||
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally | ||
@@ -567,3 +639,3 @@ // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer | ||
desc("Generates code coverage data via instanbul") | ||
desc("Generates code coverage data via instanbul"); | ||
task("generate-code-coverage", ["tests", builtLocalDirectory], function () { | ||
@@ -593,2 +665,3 @@ var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run; | ||
tests = process.env.test || process.env.tests || process.env.t; | ||
var light = process.env.light || false; | ||
var testConfigFile = 'test.config'; | ||
@@ -598,4 +671,4 @@ if(fs.existsSync(testConfigFile)) { | ||
} | ||
if(tests) { | ||
writeTestConfigFile(tests, testConfigFile); | ||
if(tests || light) { | ||
writeTestConfigFile(tests, light, testConfigFile); | ||
} | ||
@@ -612,3 +685,3 @@ | ||
if (!program) { | ||
fail("Add the 'DIFF' environment variable to the path of the program you want to use.") | ||
fail("Add the 'DIFF' environment variable to the path of the program you want to use."); | ||
} | ||
@@ -622,3 +695,3 @@ return program; | ||
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline; | ||
console.log(cmd) | ||
console.log(cmd); | ||
exec(cmd); | ||
@@ -630,3 +703,3 @@ }, {async: true}); | ||
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline; | ||
console.log(cmd) | ||
console.log(cmd); | ||
exec(cmd); | ||
@@ -717,1 +790,22 @@ }, {async: true}); | ||
}, { async: true }); | ||
desc("Updates the sublime plugin's tsserver"); | ||
task("update-sublime", ["local", serverFile], function() { | ||
jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/"); | ||
jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); | ||
}); | ||
// if the codebase were free of linter errors we could make jake runtests | ||
// run this task automatically | ||
desc("Runs tslint on the compiler sources"); | ||
task("lint", [], function() { | ||
function success(f) { return function() { console.log('SUCCESS: No linter errors in ' + f + '\n'); }}; | ||
function failure(f) { return function() { console.log('FAILURE: Please fix linting errors in ' + f + '\n') }}; | ||
var lintTargets = compilerSources.concat(harnessCoreSources); | ||
for (var i in lintTargets) { | ||
var f = lintTargets[i]; | ||
var cmd = 'tslint -c tslint.json ' + f; | ||
exec(cmd, success(f), failure(f)); | ||
} | ||
}, { async: true }); |
@@ -5,9 +5,4 @@ { | ||
"homepage": "http://typescriptlang.org/", | ||
"version": "1.5.3", | ||
"licenses": [ | ||
{ | ||
"type": "Apache License 2.0", | ||
"url": "https://github.com/Microsoft/TypeScript/blob/master/LICENSE.txt" | ||
} | ||
], | ||
"version": "1.6.0-beta", | ||
"license": "Apache-2.0", | ||
"description": "TypeScript is a language for application scale JavaScript development", | ||
@@ -28,4 +23,4 @@ "keywords": [ | ||
}, | ||
"preferGlobal": true, | ||
"main": "./bin/typescript.js", | ||
"main": "./lib/typescript.js", | ||
"typings": "./lib/typescript.d.ts", | ||
"bin": { | ||
@@ -43,7 +38,20 @@ "tsc": "./bin/tsc", | ||
"browserify": "latest", | ||
"istanbul": "latest" | ||
"istanbul": "latest", | ||
"mocha-fivemat-progress-reporter": "latest", | ||
"tslint": "latest" | ||
}, | ||
"scripts": { | ||
"test": "jake runtests" | ||
"pretest": "jake tests", | ||
"test": "jake runtests", | ||
"build": "npm run build:compiler && npm run build:tests", | ||
"build:compiler": "jake local", | ||
"build:tests": "jake tests", | ||
"clean": "jake clean" | ||
}, | ||
"browser": { | ||
"buffer": false, | ||
"fs": false, | ||
"os": false, | ||
"path": false | ||
} | ||
} |
[![Build Status](https://travis-ci.org/Microsoft/TypeScript.svg?branch=master)](https://travis-ci.org/Microsoft/TypeScript) | ||
[![Issue Stats](http://issuestats.com/github/Microsoft/TypeScript/badge/pr)](http://issuestats.com/github/microsoft/typescript) | ||
[![Issue Stats](http://issuestats.com/github/Microsoft/TypeScript/badge/issue)](http://issuestats.com/github/microsoft/typescript) | ||
[![npm version](https://badge.fury.io/js/typescript.svg)](http://badge.fury.io/js/typescript) | ||
@@ -9,5 +7,20 @@ [![Downloads](http://img.shields.io/npm/dm/TypeScript.svg)](https://npmjs.org/package/typescript) | ||
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [twitter account](https://twitter.com/typescriptlang). | ||
[![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). | ||
## Installing | ||
For the latest stable version: | ||
``` | ||
npm install -g typescript | ||
``` | ||
For our nightly builds: | ||
``` | ||
npm install -g typescript@next | ||
``` | ||
## Contribute | ||
@@ -67,3 +80,4 @@ | ||
parameters 'host=', 'tests=[regex], reporter=[list|spec|json|<more>]'. | ||
jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests. | ||
jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests. | ||
jake lint # Runs tslint on the TypeScript source. | ||
jake -T # List the above commands. | ||
@@ -70,0 +84,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12094973
28
233282
95
7
1
26
2