Skip to content

Commit e7aa7e4

Browse files
committed
Merge branch 'master' into this-function-types
2 parents a014edf + 3820dfa commit e7aa7e4

520 files changed

Lines changed: 8639 additions & 2448 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ build.json
2828
*.actual
2929
tests/webhost/*.d.ts
3030
tests/webhost/webtsc.js
31-
tests/*.js
32-
tests/*.js.map
33-
tests/*.d.ts
31+
tests/cases/**/*.js
32+
tests/cases/**/*.js.map
33+
tests/cases/**/*.d.ts
3434
*.config
3535
scripts/debug.bat
3636
scripts/run.bat

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Issues that ask questions answered in the FAQ will be closed without elaboration
1313
## 3. Do you have a question?
1414

1515
The issue tracker is for **issues**, in other words, bugs and suggestions.
16-
If you have a *question*, please use [http://stackoverflow.com/questions/tagged/typescript](Stack Overflow), [https://gitter.im/Microsoft/TypeScript](Gitter), your favorite search engine, or other resources.
16+
If you have a *question*, please use [Stack Overflow](http://stackoverflow.com/questions/tagged/typescript), [Gitter](https://gitter.im/Microsoft/TypeScript), your favorite search engine, or other resources.
1717
Due to increased traffic, we can no longer answer questions in the issue tracker.
1818

1919
## 4. Did you find a bug?

Jakefile.js

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -223,51 +223,59 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename);
223223
* @param prereqs: prerequisite tasks to compiling the file
224224
* @param prefixes: a list of files to prepend to the target file
225225
* @param useBuiltCompiler: true to use the built compiler, false to use the LKG
226-
* @param noOutFile: true to compile without using --out
227-
* @param generateDeclarations: true to compile using --declaration
228-
* @param outDir: true to compile using --outDir
229-
* @param keepComments: false to compile using --removeComments
226+
* @parap {Object} opts - property bag containing auxiliary options
227+
* @param {boolean} opts.noOutFile: true to compile without using --out
228+
* @param {boolean} opts.generateDeclarations: true to compile using --declaration
229+
* @param {string} opts.outDir: value for '--outDir' command line option
230+
* @param {boolean} opts.keepComments: false to compile using --removeComments
231+
* @param {boolean} opts.preserveConstEnums: true if compiler should keep const enums in code
232+
* @param {boolean} opts.noResolve: true if compiler should not include non-rooted files in compilation
233+
* @param {boolean} opts.stripInternal: true if compiler should remove declarations marked as @internal
234+
* @param {boolean} opts.noMapRoot: true if compiler omit mapRoot option
230235
* @param callback: a function to execute after the compilation process ends
231236
*/
232-
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOutFile, generateDeclarations, outDir, preserveConstEnums, keepComments, noResolve, stripInternal, callback) {
237+
function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) {
233238
file(outFile, prereqs, function() {
234239
var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler;
235240
var options = "--noImplicitAny --noEmitOnError --pretty";
236-
241+
opts = opts || {};
237242
// Keep comments when specifically requested
238243
// or when in debug mode.
239-
if (!(keepComments || useDebugMode)) {
244+
if (!(opts.keepComments || useDebugMode)) {
240245
options += " --removeComments";
241246
}
242247

243-
if (generateDeclarations) {
248+
if (opts.generateDeclarations) {
244249
options += " --declaration";
245250
}
246251

247-
if (preserveConstEnums || useDebugMode) {
252+
if (opts.preserveConstEnums || useDebugMode) {
248253
options += " --preserveConstEnums";
249254
}
250255

251-
if (outDir) {
252-
options += " --outDir " + outDir;
256+
if (opts.outDir) {
257+
options += " --outDir " + opts.outDir;
253258
}
254259

255-
if (!noOutFile) {
260+
if (!opts.noOutFile) {
256261
options += " --out " + outFile;
257262
}
258263
else {
259264
options += " --module commonjs"
260265
}
261266

262-
if(noResolve) {
267+
if(opts.noResolve) {
263268
options += " --noResolve";
264269
}
265270

266271
if (useDebugMode) {
267-
options += " -sourcemap -mapRoot file:///" + path.resolve(path.dirname(outFile));
272+
options += " -sourcemap";
273+
if (!opts.noMapRoot) {
274+
options += " -mapRoot file:///" + path.resolve(path.dirname(outFile));
275+
}
268276
}
269277

270-
if (stripInternal) {
278+
if (opts.stripInternal) {
271279
options += " --stripInternal"
272280
}
273281

@@ -382,13 +390,7 @@ compileFile(/*outfile*/configureNightlyJs,
382390
/*prereqs*/ [configureNightlyTs],
383391
/*prefixes*/ [],
384392
/*useBuiltCompiler*/ false,
385-
/*noOutFile*/ false,
386-
/*generateDeclarations*/ false,
387-
/*outDir*/ undefined,
388-
/*preserveConstEnums*/ undefined,
389-
/*keepComments*/ false,
390-
/*noResolve*/ false,
391-
/*stripInternal*/ false);
393+
{ noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false });
392394

393395
task("setDebugMode", function() {
394396
useDebugMode = true;
@@ -438,6 +440,7 @@ var tscFile = path.join(builtLocalDirectory, compilerFilename);
438440
compileFile(tscFile, compilerSources, [builtLocalDirectory, copyright].concat(compilerSources), [copyright], /*useBuiltCompiler:*/ false);
439441

440442
var servicesFile = path.join(builtLocalDirectory, "typescriptServices.js");
443+
var servicesFileInBrowserTest = path.join(builtLocalDirectory, "typescriptServicesInBrowserTest.js");
441444
var standaloneDefinitionsFile = path.join(builtLocalDirectory, "typescriptServices.d.ts");
442445
var nodePackageFile = path.join(builtLocalDirectory, "typescript.js");
443446
var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts");
@@ -446,13 +449,7 @@ var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_s
446449
compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
447450
/*prefixes*/ [copyright],
448451
/*useBuiltCompiler*/ true,
449-
/*noOutFile*/ false,
450-
/*generateDeclarations*/ true,
451-
/*outDir*/ undefined,
452-
/*preserveConstEnums*/ true,
453-
/*keepComments*/ true,
454-
/*noResolve*/ false,
455-
/*stripInternal*/ true,
452+
{ noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true },
456453
/*callback*/ function () {
457454
jake.cpR(servicesFile, nodePackageFile, {silent: true});
458455

@@ -475,6 +472,16 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca
475472
fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents);
476473
});
477474

475+
compileFile(servicesFileInBrowserTest, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources),
476+
/*prefixes*/ [copyright],
477+
/*useBuiltCompiler*/ true,
478+
{ noOutFile: false, generateDeclarations: true, preserveConstEnums: true, keepComments: true, noResolve: false, stripInternal: true, noMapRoot: true },
479+
/*callback*/ function () {
480+
var content = fs.readFileSync(servicesFileInBrowserTest).toString();
481+
var i = content.lastIndexOf("\n");
482+
fs.writeFileSync(servicesFileInBrowserTest, content.substring(0, i) + "\r\n//# sourceURL=../built/local/typeScriptServices.js" + content.substring(i));
483+
});
484+
478485

479486
var serverFile = path.join(builtLocalDirectory, "tsserver.js");
480487
compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true);
@@ -486,8 +493,7 @@ compileFile(
486493
[builtLocalDirectory, copyright].concat(languageServiceLibrarySources),
487494
/*prefixes*/ [copyright],
488495
/*useBuiltCompiler*/ true,
489-
/*noOutFile*/ false,
490-
/*generateDeclarations*/ true);
496+
{ noOutFile: false, generateDeclarations: true });
491497

492498
// Local target to build the language service server library
493499
desc("Builds language service server library");
@@ -720,7 +726,7 @@ task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
720726
// Browser tests
721727
var nodeServerOutFile = 'tests/webTestServer.js'
722728
var nodeServerInFile = 'tests/webTestServer.ts'
723-
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, /*noOutFile*/ true);
729+
compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true });
724730

725731
desc("Runs browserify on run.js to produce a file suitable for running tests in the browser");
726732
task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() {
@@ -729,7 +735,7 @@ task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function()
729735
}, {async: true});
730736

731737
desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], port=, browser=[chrome|IE]");
732-
task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function() {
738+
task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() {
733739
cleanTestDirs();
734740
host = "node"
735741
port = process.env.port || process.env.p || '8888';
@@ -881,7 +887,8 @@ var tslintRulesOutFiles = tslintRules.map(function(p) {
881887
desc("Compiles tslint rules to js");
882888
task("build-rules", tslintRulesOutFiles);
883889
tslintRulesFiles.forEach(function(ruleFile, i) {
884-
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, /*noOutFile*/ true, /*generateDeclarations*/ false, path.join(builtLocalDirectory, "tslint"));
890+
compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false,
891+
{ noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint")});
885892
});
886893

887894
function getLinterOptions() {

doc/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# Read This!
2+
13
This directory contains miscellaneous documentation such as the TypeScript language specification and logo.
24
If you are looking for more introductory material, you might want to take a look at the [TypeScript Handbook](https://github.com/Microsoft/TypeScript-Handbook).
35

46
# Spec Contributions
57

68
The specification is first authored as a Microsoft Word (docx) file and then generated into Markdown and PDF formats.
7-
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new) rather than sent as pull requests.
9+
Due to the binary format of docx files, and the merging difficulties that may come with it, it is preferred that **any suggestions or problems found in the spec should be [filed as issues](https://github.com/Microsoft/TypeScript/issues/new)** rather than sent as pull requests.

doc/handbook/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# The TypeScript Handbook
2+
3+
The contents of the TypeScript Handbook can be read from [its GitHub repository](https://github.com/Microsoft/TypeScript-Handbook).
4+
Issues and pull requests should be directed there.

doc/wiki/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# The TypeScript Wiki
2+
3+
To read the wiki, [visit the wiki on GitHub](https://github.com/Microsoft/TypeScript/wiki).
4+
5+
To contribute by filing an issue or sending a pull request, [visit the wiki repository](https://github.com/Microsoft/TypeScript-wiki).
6+

lib/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Read this!
1+
# Read This!
22

3-
These files are not meant to be edited by hand.
4-
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. Running `jake LKG` will then appropriately update the files in this directory.
3+
**These files are not meant to be edited by hand.**
4+
If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory.
5+
Running `jake LKG` will then appropriately update the files in this directory.

src/compiler/binder.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace ts {
1212
}
1313

1414
const enum Reachability {
15-
Unintialized = 1 << 0,
15+
Uninitialized = 1 << 0,
1616
Reachable = 1 << 1,
1717
Unreachable = 1 << 2,
1818
ReportedUnreachable = 1 << 3
@@ -393,7 +393,7 @@ namespace ts {
393393
// the getLocalNameOfContainer function in the type checker to validate that the local name
394394
// used for a container is unique.
395395
function bindChildren(node: Node) {
396-
// Before we recurse into a node's chilren, we first save the existing parent, container
396+
// Before we recurse into a node's children, we first save the existing parent, container
397397
// and block-container. Then after we pop out of processing the children, we restore
398398
// these saved values.
399399
const saveParent = parent;
@@ -418,7 +418,7 @@ namespace ts {
418418
// Finally, if this is a block-container, then we clear out any existing .locals object
419419
// it may contain within it. This happens in incremental scenarios. Because we can be
420420
// reusing a node from a previous compilation, that node may have had 'locals' created
421-
// for it. We must clear this so we don't accidently move any stale data forward from
421+
// for it. We must clear this so we don't accidentally move any stale data forward from
422422
// a previous compilation.
423423
const containerFlags = getContainerFlags(node);
424424
if (containerFlags & ContainerFlags.IsContainer) {
@@ -699,7 +699,7 @@ namespace ts {
699699

700700
const hasDefault = forEach(n.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
701701

702-
// post switch state is unreachable if switch is exaustive (has a default case ) and does not have fallthrough from the last case
702+
// post switch state is unreachable if switch is exhaustive (has a default case ) and does not have fallthrough from the last case
703703
const postSwitchState = hasDefault && currentReachabilityState !== Reachability.Reachable ? Reachability.Unreachable : preSwitchState;
704704

705705
popImplicitLabel(postSwitchLabel, postSwitchState);
@@ -766,7 +766,7 @@ namespace ts {
766766

767767
case SyntaxKind.Block:
768768
// do not treat blocks directly inside a function as a block-scoped-container.
769-
// Locals that reside in this block should go to the function locals. Othewise 'x'
769+
// Locals that reside in this block should go to the function locals. Otherwise 'x'
770770
// would not appear to be a redeclaration of a block scoped local in the following
771771
// example:
772772
//
@@ -956,7 +956,7 @@ namespace ts {
956956

957957
const identifier = <Identifier>prop.name;
958958

959-
// ECMA-262 11.1.5 Object Initialiser
959+
// ECMA-262 11.1.5 Object Initializer
960960
// If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true
961961
// a.This production is contained in strict code and IsDataDescriptor(previous) is true and
962962
// IsDataDescriptor(propId.descriptor) is true.
@@ -1632,14 +1632,14 @@ namespace ts {
16321632
if (hasProperty(labelIndexMap, name.text)) {
16331633
return false;
16341634
}
1635-
labelIndexMap[name.text] = labelStack.push(Reachability.Unintialized) - 1;
1635+
labelIndexMap[name.text] = labelStack.push(Reachability.Uninitialized) - 1;
16361636
return true;
16371637
}
16381638

16391639
function pushImplicitLabel(): number {
16401640
initializeReachabilityStateIfNecessary();
16411641

1642-
const index = labelStack.push(Reachability.Unintialized) - 1;
1642+
const index = labelStack.push(Reachability.Uninitialized) - 1;
16431643
implicitLabels.push(index);
16441644
return index;
16451645
}
@@ -1669,7 +1669,7 @@ namespace ts {
16691669
}
16701670

16711671
function setCurrentStateAtLabel(innerMergedState: Reachability, outerState: Reachability, label: Identifier): void {
1672-
if (innerMergedState === Reachability.Unintialized) {
1672+
if (innerMergedState === Reachability.Uninitialized) {
16731673
if (label && !options.allowUnusedLabels) {
16741674
file.bindDiagnostics.push(createDiagnosticForNode(label, Diagnostics.Unused_label));
16751675
}
@@ -1690,7 +1690,7 @@ namespace ts {
16901690
return false;
16911691
}
16921692
const stateAtLabel = labelStack[index];
1693-
labelStack[index] = stateAtLabel === Reachability.Unintialized ? outerState : or(stateAtLabel, outerState);
1693+
labelStack[index] = stateAtLabel === Reachability.Uninitialized ? outerState : or(stateAtLabel, outerState);
16941694
return true;
16951695
}
16961696

0 commit comments

Comments
 (0)