Skip to content

Commit 355db23

Browse files
author
Arthur Ozga
committed
Merge branch 'master' into JSDocCommentScaffolding
2 parents fff2f7b + 3805500 commit 355db23

11 files changed

Lines changed: 629 additions & 58 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tests/baselines/reference/projectOutput/*
2525
tests/baselines/local/projectOutput/*
2626
tests/services/baselines/prototyping/local/*
2727
tests/services/browser/typescriptServices.js
28+
scripts/configureNightly.js
2829
scripts/processDiagnosticMessages.d.ts
2930
scripts/processDiagnosticMessages.js
3031
scripts/importDefinitelyTypedTests.js

Jakefile.js

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ var harnessSources = harnessCoreSources.concat([
138138
"services/documentRegistry.ts",
139139
"services/preProcessFile.ts",
140140
"services/patternMatcher.ts",
141+
"session.ts",
141142
"versionCache.ts",
142143
"convertToBase64.ts",
143144
"transpile.ts"
@@ -313,7 +314,7 @@ var processDiagnosticMessagesTs = path.join(scriptsDirectory, "processDiagnostic
313314
var diagnosticMessagesJson = path.join(compilerDirectory, "diagnosticMessages.json");
314315
var diagnosticInfoMapTs = path.join(compilerDirectory, "diagnosticInformationMap.generated.ts");
315316

316-
file(processDiagnosticMessagesTs)
317+
file(processDiagnosticMessagesTs);
317318

318319
// processDiagnosticMessages script
319320
compileFile(processDiagnosticMessagesJs,
@@ -338,11 +339,49 @@ file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson],
338339
complete();
339340
});
340341
ex.run();
341-
}, {async: true})
342+
}, {async: true});
342343

343344
desc("Generates a diagnostic file in TypeScript based on an input JSON file");
344-
task("generate-diagnostics", [diagnosticInfoMapTs])
345+
task("generate-diagnostics", [diagnosticInfoMapTs]);
346+
347+
348+
// Publish nightly
349+
var configureNightlyJs = path.join(scriptsDirectory, "configureNightly.js");
350+
var configureNightlyTs = path.join(scriptsDirectory, "configureNightly.ts");
351+
var packageJson = "package.json";
352+
var programTs = path.join(compilerDirectory, "program.ts");
345353

354+
file(configureNightlyTs);
355+
356+
compileFile(/*outfile*/configureNightlyJs,
357+
/*sources*/ [configureNightlyTs],
358+
/*prereqs*/ [configureNightlyTs],
359+
/*prefixes*/ [],
360+
/*useBuiltCompiler*/ false,
361+
/*noOutFile*/ false,
362+
/*generateDeclarations*/ false,
363+
/*outDir*/ undefined,
364+
/*preserveConstEnums*/ undefined,
365+
/*keepComments*/ false,
366+
/*noResolve*/ false,
367+
/*stripInternal*/ false);
368+
369+
task("setDebugMode", function() {
370+
useDebugMode = true;
371+
});
372+
373+
task("configure-nightly", [configureNightlyJs], function() {
374+
var cmd = "node " + configureNightlyJs + " " + packageJson + " " + programTs;
375+
console.log(cmd);
376+
exec(cmd);
377+
}, { async: true });
378+
379+
desc("Configure, build, test, and publish the nightly release.");
380+
task("publish-nightly", ["configure-nightly", "LKG", "clean", "setDebugMode", "runtests"], function () {
381+
var cmd = "npm publish --tag next";
382+
console.log(cmd);
383+
exec(cmd);
384+
});
346385

347386
// Local target to build the compiler and services
348387
var tscFile = path.join(builtLocalDirectory, compilerFilename);
@@ -440,11 +479,11 @@ file(specMd, [word2mdJs, specWord], function () {
440479
child_process.exec(cmd, function () {
441480
complete();
442481
});
443-
}, {async: true})
482+
}, {async: true});
444483

445484

446485
desc("Generates a Markdown version of the Language Specification");
447-
task("generate-spec", [specMd])
486+
task("generate-spec", [specMd]);
448487

449488

450489
// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory
@@ -576,7 +615,7 @@ task("runtests", ["tests", builtLocalDirectory], function() {
576615
exec(cmd, deleteTemporaryProjectOutput);
577616
}, {async: true});
578617

579-
desc("Generates code coverage data via instanbul")
618+
desc("Generates code coverage data via instanbul");
580619
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
581620
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
582621
console.log(cmd);
@@ -619,7 +658,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory], function(
619658
function getDiffTool() {
620659
var program = process.env['DIFF']
621660
if (!program) {
622-
fail("Add the 'DIFF' environment variable to the path of the program you want to use.")
661+
fail("Add the 'DIFF' environment variable to the path of the program you want to use.");
623662
}
624663
return program;
625664
}
@@ -628,14 +667,14 @@ function getDiffTool() {
628667
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
629668
task('diff', function () {
630669
var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline;
631-
console.log(cmd)
670+
console.log(cmd);
632671
exec(cmd);
633672
}, {async: true});
634673

635674
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
636675
task('diff-rwc', function () {
637676
var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline;
638-
console.log(cmd)
677+
console.log(cmd);
639678
exec(cmd);
640679
}, {async: true});
641680

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "typescript",
33
"author": "Microsoft Corp.",
44
"homepage": "http://typescriptlang.org/",
5-
"version": "1.5.3",
5+
"version": "1.6.0",
66
"license": "Apache-2.0",
77
"description": "TypeScript is a language for application scale JavaScript development",
88
"keywords": [

scripts/configureNightly.ts

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/// <reference path="../src/compiler/sys.ts" />
2+
3+
/**
4+
* A minimal description for a parsed package.json object.
5+
*/
6+
interface PackageJson {
7+
name: string;
8+
version: string;
9+
keywords: string[];
10+
}
11+
12+
function main(): void {
13+
const sys = ts.sys;
14+
if (sys.args.length < 2) {
15+
sys.write("Usage:" + sys.newLine)
16+
sys.write("\tnode configureNightly.js <package.json location> <file containing version>" + sys.newLine);
17+
return;
18+
}
19+
20+
// Acquire the version from the package.json file and modify it appropriately.
21+
const packageJsonFilePath = ts.normalizePath(sys.args[0]);
22+
const packageJsonContents = sys.readFile(packageJsonFilePath);
23+
const packageJsonValue: PackageJson = JSON.parse(packageJsonContents);
24+
25+
const nightlyVersion = getNightlyVersionString(packageJsonValue.version);
26+
27+
// Modify the package.json structure
28+
packageJsonValue.version = nightlyVersion;
29+
30+
// Acquire and modify the source file that exposes the version string.
31+
const tsFilePath = ts.normalizePath(sys.args[1]);
32+
const tsFileContents = sys.readFile(tsFilePath);
33+
const versionAssignmentRegExp = /export\s+const\s+version\s+=\s+".*";/;
34+
const modifiedTsFileContents = tsFileContents.replace(versionAssignmentRegExp, `export const version = "${nightlyVersion}";`);
35+
36+
// Ensure we are actually changing something - the user probably wants to know that the update failed.
37+
if (tsFileContents === modifiedTsFileContents) {
38+
let err = `\n '${tsFilePath}' was not updated while configuring for a nightly publish.\n `;
39+
40+
if (tsFileContents.match(versionAssignmentRegExp)) {
41+
err += `Ensure that you have not already run this script; otherwise, erase your changes using 'git checkout -- "${tsFilePath}"'.`;
42+
}
43+
else {
44+
err += `The file seems to no longer have a string matching '${versionAssignmentRegExp}'.`;
45+
}
46+
47+
throw err + "\n";
48+
}
49+
50+
// Finally write the changes to disk.
51+
sys.writeFile(packageJsonFilePath, JSON.stringify(packageJsonValue, /*replacer:*/ undefined, /*space:*/ 4))
52+
sys.writeFile(tsFilePath, modifiedTsFileContents);
53+
}
54+
55+
function getNightlyVersionString(versionString: string): string {
56+
// If the version string already contains "-nightly",
57+
// then get the base string and update based on that.
58+
const dashNightlyPos = versionString.indexOf("-dev");
59+
if (dashNightlyPos >= 0) {
60+
versionString = versionString.slice(0, dashNightlyPos);
61+
}
62+
63+
// We're going to append a representation of the current time at the end of the current version.
64+
// String.prototype.toISOString() returns a 24-character string formatted as 'YYYY-MM-DDTHH:mm:ss.sssZ',
65+
// but we'd prefer to just remove separators and limit ourselves to YYYYMMDD.
66+
// UTC time will always be implicit here.
67+
const now = new Date();
68+
const timeStr = now.toISOString().replace(/:|T|\.|-/g, "").slice(0, 8);
69+
70+
return `${versionString}-dev.${timeStr}`;
71+
}
72+
73+
main();

src/compiler/checker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ namespace ts {
6868
getPropertyOfType,
6969
getSignaturesOfType,
7070
getIndexTypeOfType,
71+
getBaseTypes,
7172
getReturnTypeOfSignature,
7273
getSymbolsInScope,
7374
getSymbolAtLocation,

src/compiler/program.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace ts {
88
/* @internal */ export let ioWriteTime = 0;
99

1010
/** The version of the TypeScript compiler release */
11-
export const version = "1.5.3";
11+
export const version = "1.6.0";
1212

1313
export function findConfigFile(searchPath: string): string {
1414
let fileName = "tsconfig.json";
@@ -341,7 +341,7 @@ namespace ts {
341341
});
342342
}
343343

344-
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
344+
function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
345345
return runWithCancellationToken(() => {
346346
if (!isDeclarationFile(sourceFile)) {
347347
let resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
@@ -350,7 +350,7 @@ namespace ts {
350350
return ts.getDeclarationDiagnostics(getEmitHost(writeFile), resolver, sourceFile);
351351
}
352352
});
353-
}
353+
}
354354

355355
function getOptionsDiagnostics(): Diagnostic[] {
356356
let allDiagnostics: Diagnostic[] = [];

src/compiler/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,7 @@ namespace ts {
14041404
getPropertyOfType(type: Type, propertyName: string): Symbol;
14051405
getSignaturesOfType(type: Type, kind: SignatureKind): Signature[];
14061406
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
1407+
getBaseTypes(type: InterfaceType): ObjectType[];
14071408
getReturnTypeOfSignature(signature: Signature): Type;
14081409

14091410
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
@@ -1808,7 +1809,9 @@ namespace ts {
18081809
typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic)
18091810
outerTypeParameters: TypeParameter[]; // Outer type parameters (undefined if none)
18101811
localTypeParameters: TypeParameter[]; // Local type parameters (undefined if none)
1812+
/* @internal */
18111813
resolvedBaseConstructorType?: Type; // Resolved base constructor type of class
1814+
/* @internal */
18121815
resolvedBaseTypes: ObjectType[]; // Resolved base types
18131816
}
18141817

src/harness/harness.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var Buffer: BufferConstructor = require('buffer').Buffer;
2929
// this will work in the browser via browserify
3030
var _chai: typeof chai = require('chai');
3131
var assert: typeof _chai.assert = _chai.assert;
32+
var expect: typeof _chai.expect = _chai.expect;
3233
declare var __dirname: string; // Node-specific
3334
var global = <any>Function("return this").call(null);
3435

0 commit comments

Comments
 (0)