Skip to content

Commit 21c23d4

Browse files
committed
Merge branch 'master' into gulpProjectRefs
2 parents 891b15f + 4fafe0b commit 21c23d4

820 files changed

Lines changed: 5822 additions & 3299 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.

Jakefile.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ const ts = require("./lib/typescript");
1010
const del = require("del");
1111
const getDirSize = require("./scripts/build/getDirSize");
1212

13+
// add node_modules to path so we don't need global modules, prefer the modules by adding them first
14+
var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter;
15+
if (process.env.path !== undefined) {
16+
process.env.path = nodeModulesPathPrefix + process.env.path;
17+
}
18+
else if (process.env.PATH !== undefined) {
19+
process.env.PATH = nodeModulesPathPrefix + process.env.PATH;
20+
}
21+
1322
const host = process.env.TYPESCRIPT_HOST || process.env.host || "node";
1423

1524
const locales = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"];
@@ -197,17 +206,17 @@ task(TaskNames.lint, [TaskNames.buildRules], () => {
197206
if (fold.isTravis()) console.log(fold.end("lint"));
198207
complete();
199208
}));
200-
});
209+
}, { async: true });
201210

202211
desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable");
203212
task('diff', function () {
204-
var cmd = `"${getDiffTool()} ${Paths.baselines.reference} ${Paths.baselines.local}`;
213+
var cmd = `"${getDiffTool()}" ${Paths.baselines.reference} ${Paths.baselines.local}`;
205214
exec(cmd);
206215
}, { async: true });
207216

208217
desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable");
209218
task('diff-rwc', function () {
210-
var cmd = `"${getDiffTool()} ${Paths.baselines.referenceRwc} ${Paths.baselines.localRwc}`;
219+
var cmd = `"${getDiffTool()}" ${Paths.baselines.referenceRwc} ${Paths.baselines.localRwc}`;
211220
exec(cmd);
212221
}, { async: true });
213222

scripts/build/getDirSize.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,19 @@ const { join } = require("path");
44

55
/**
66
* Find the size of a directory recursively.
7-
* Symbolic links are counted once (same inode).
7+
* Symbolic links can cause a loop.
88
* @param {string} root
9-
* @param {Set} seen
109
* @returns {number} bytes
1110
*/
12-
function getDirSize(root, seen = new Set()) {
11+
function getDirSize(root) {
1312
const stats = lstatSync(root);
1413

15-
if (seen.has(stats.ino)) {
16-
return 0;
17-
}
18-
19-
seen.add(stats.ino);
20-
2114
if (!stats.isDirectory()) {
2215
return stats.size;
2316
}
2417

2518
return readdirSync(root)
26-
.map(file => getDirSize(join(root, file), seen))
19+
.map(file => getDirSize(join(root, file)))
2720
.reduce((acc, num) => acc + num, 0);
2821
}
2922

scripts/produceLKG.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async function writeGitAttributes() {
7777

7878
async function copyWithCopyright(fileName: string) {
7979
const content = await fs.readFile(path.join(source, fileName), "utf-8");
80-
await fs.writeFile(path.join(dest, fileName), copyright + "\r\n" + content);
80+
await fs.writeFile(path.join(dest, fileName), copyright + "\n" + content);
8181
}
8282

8383
async function copyFromBuiltLocal(fileName: string) {

src/compiler/sourcemap.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,19 +390,24 @@ namespace ts {
390390
const firstLineColumnOffset = writer.getColumn();
391391
// First, decode the old component sourcemap
392392
const originalMap = parsed;
393+
394+
const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir;
395+
const resolvedPathCache = createMap<string>();
393396
sourcemaps.calculateDecodedMappings(originalMap, (raw): void => {
394397
// Apply offsets to each position and fixup source entries
395398
const rawPath = originalMap.sources[raw.sourceIndex];
396399
const relativePath = originalMap.sourceRoot ? combinePaths(originalMap.sourceRoot, rawPath) : rawPath;
397400
const combinedPath = combinePaths(getDirectoryPath(node.sourceMapPath!), relativePath);
398-
const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir;
399-
const resolvedPath = getRelativePathToDirectoryOrUrl(
400-
sourcesDirectoryPath,
401-
combinedPath,
402-
host.getCurrentDirectory(),
403-
host.getCanonicalFileName,
404-
/*isAbsolutePathAnUrl*/ true
405-
);
401+
if (!resolvedPathCache.has(combinedPath)) {
402+
resolvedPathCache.set(combinedPath, getRelativePathToDirectoryOrUrl(
403+
sourcesDirectoryPath,
404+
combinedPath,
405+
host.getCurrentDirectory(),
406+
host.getCanonicalFileName,
407+
/*isAbsolutePathAnUrl*/ true
408+
));
409+
}
410+
const resolvedPath = resolvedPathCache.get(combinedPath)!;
406411
const absolutePath = getNormalizedAbsolutePath(resolvedPath, sourcesDirectoryPath);
407412
// tslint:disable-next-line:no-null-keyword
408413
setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining?

src/compiler/transformers/es2015.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,9 +4067,13 @@ namespace ts {
40674067
priority: 0,
40684068
text: `
40694069
var __extends = (this && this.__extends) || (function () {
4070-
var extendStatics = Object.setPrototypeOf ||
4071-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4072-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4070+
var extendStatics = function (d, b) {
4071+
extendStatics = Object.setPrototypeOf ||
4072+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4073+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4074+
return extendStatics(d, b);
4075+
}
4076+
40734077
return function (d, b) {
40744078
extendStatics(d, b);
40754079
function __() { this.constructor = d; }

src/compiler/transformers/esnext.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -890,13 +890,16 @@ namespace ts {
890890
scoped: false,
891891
priority: 1,
892892
text: `
893-
var __assign = (this && this.__assign) || Object.assign || function(t) {
894-
for (var s, i = 1, n = arguments.length; i < n; i++) {
895-
s = arguments[i];
896-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
897-
t[p] = s[p];
898-
}
899-
return t;
893+
var __assign = (this && this.__assign) || function () {
894+
__assign = Object.assign || function(t) {
895+
for (var s, i = 1, n = arguments.length; i < n; i++) {
896+
s = arguments[i];
897+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
898+
t[p] = s[p];
899+
}
900+
return t;
901+
};
902+
return __assign.apply(this, arguments);
900903
};`
901904
};
902905

src/compiler/tsbuild.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,7 @@ namespace ts {
11181118

11191119
let pseudoUpToDate = false;
11201120
let usesPrepend = false;
1121+
let upstreamChangedProject: string | undefined;
11211122
if (project.projectReferences && host.parseConfigFile) {
11221123
for (const ref of project.projectReferences) {
11231124
usesPrepend = usesPrepend || !!(ref.prepend);
@@ -1150,6 +1151,7 @@ namespace ts {
11501151
// *after* those files, then we're "psuedo up to date" and eligible for a fast rebuild
11511152
if (refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
11521153
pseudoUpToDate = true;
1154+
upstreamChangedProject = ref.path;
11531155
continue;
11541156
}
11551157

@@ -1178,8 +1180,12 @@ namespace ts {
11781180
};
11791181
}
11801182

1181-
if (usesPrepend) {
1182-
pseudoUpToDate = false;
1183+
if (usesPrepend && pseudoUpToDate) {
1184+
return {
1185+
type: UpToDateStatusType.OutOfDateWithUpstream,
1186+
outOfDateOutputFileName: oldestOutputFileName,
1187+
newerProjectName: upstreamChangedProject!
1188+
};
11831189
}
11841190

11851191
// Up to date

src/server/protocol.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ namespace ts.server.protocol {
617617
}
618618

619619
export interface OrganizeImportsResponse extends Response {
620-
edits: ReadonlyArray<FileCodeEdits>;
620+
body: ReadonlyArray<FileCodeEdits>;
621621
}
622622

623623
export interface GetEditsForFileRenameRequest extends Request {
@@ -633,7 +633,7 @@ namespace ts.server.protocol {
633633
}
634634

635635
export interface GetEditsForFileRenameResponse extends Response {
636-
edits: ReadonlyArray<FileCodeEdits>;
636+
body: ReadonlyArray<FileCodeEdits>;
637637
}
638638

639639
/**

src/testRunner/unittests/tsbuild.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,23 @@ namespace ts {
259259
});
260260
});
261261
});
262+
263+
describe("tsbuild - downstream prepend projects always get rebuilt", () => {
264+
const fs = outFileFs.shadow();
265+
const host = new fakes.CompilerHost(fs);
266+
const builder = createSolutionBuilder(host, buildHost, ["/src/third"], { dry: false, force: false, verbose: false });
267+
clearDiagnostics();
268+
builder.buildAllProjects();
269+
assertDiagnosticMessages(/*none*/);
270+
assert.equal(fs.statSync("src/third/thirdjs/output/third-output.js").mtimeMs, time(), "First build timestamp is correct");
271+
tick();
272+
replaceText(fs, "src/first/first_PART1.ts", "Hello", "Hola");
273+
tick();
274+
builder.resetBuildContext();
275+
builder.buildAllProjects();
276+
assertDiagnosticMessages(/*none*/);
277+
assert.equal(fs.statSync("src/third/thirdjs/output/third-output.js").mtimeMs, time(), "Second build timestamp is correct");
278+
});
262279
}
263280

264281
describe("tsbuild - graph-ordering", () => {

tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ module A {
2222

2323
//// [ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js]
2424
var __extends = (this && this.__extends) || (function () {
25-
var extendStatics = Object.setPrototypeOf ||
26-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
25+
var extendStatics = function (d, b) {
26+
extendStatics = Object.setPrototypeOf ||
27+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
29+
return extendStatics(d, b);
30+
}
2831
return function (d, b) {
2932
extendStatics(d, b);
3033
function __() { this.constructor = d; }

0 commit comments

Comments
 (0)