Skip to content

Commit 52057ac

Browse files
committed
Merge branch 'master' of https://github.com/Microsoft/TypeScript into bug/24542-bad-error-message-for-import-ing-an-export
2 parents 945eed8 + 4a0bc59 commit 52057ac

File tree

273 files changed

+30502
-25466
lines changed

Some content is hidden

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

273 files changed

+30502
-25466
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ matrix:
1616
branches:
1717
only:
1818
- master
19-
- release-2.7
20-
- release-2.8
21-
- release-2.9
22-
- release-3.0
23-
- release-3.1
19+
- /^release-.*/
2420

2521
install:
2622
- npm uninstall typescript --no-save

scripts/build/project.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,11 +683,17 @@ function ensureCompileTask(projectGraph, options) {
683683
}
684684
});
685685
}
686-
const js = (projectGraphConfig.resolvedOptions.js ? projectGraphConfig.resolvedOptions.js(stream.js) : stream.js)
686+
687+
const additionalJsOutputs = projectGraphConfig.resolvedOptions.js ? projectGraphConfig.resolvedOptions.js(stream.js)
688+
.pipe(gulpif(sourceMap || inlineSourceMap, sourcemaps.write(sourceMapPath, sourceMapOptions))) : undefined;
689+
const additionalDtsOutputs = projectGraphConfig.resolvedOptions.dts ? projectGraphConfig.resolvedOptions.dts(stream.dts)
690+
.pipe(gulpif(declarationMap, sourcemaps.write(sourceMapPath, sourceMapOptions))) : undefined;
691+
692+
const js = stream.js
687693
.pipe(gulpif(sourceMap || inlineSourceMap, sourcemaps.write(sourceMapPath, sourceMapOptions)));
688-
const dts = (projectGraphConfig.resolvedOptions.dts ? projectGraphConfig.resolvedOptions.dts(stream.dts) : stream.dts)
694+
const dts = stream.dts
689695
.pipe(gulpif(declarationMap, sourcemaps.write(sourceMapPath, sourceMapOptions)));
690-
return merge2([js, dts])
696+
return merge2([js, dts, additionalJsOutputs, additionalDtsOutputs].filter(x => !!x))
691697
.pipe(gulp.dest(destPath));
692698
});
693699
}

scripts/tslint/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"module": "commonjs",
1313
"outDir": "../../built/local/tslint",
1414
"baseUrl": "../..",
15+
"types": ["node"],
1516
"paths": {
1617
"typescript": ["lib/typescript.d.ts"]
1718
}

src/compiler/binder.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ namespace ts {
143143

144144
let symbolCount = 0;
145145

146-
let Symbol: { new (flags: SymbolFlags, name: __String): Symbol }; // tslint:disable-line variable-name
146+
let Symbol: new (flags: SymbolFlags, name: __String) => Symbol; // tslint:disable-line variable-name
147147
let classifiableNames: UnderscoreEscapedMap<true>;
148148

149149
const unreachableFlow: FlowNode = { flags: FlowFlags.Unreachable };
@@ -233,6 +233,11 @@ namespace ts {
233233
symbol.members = createSymbolTable();
234234
}
235235

236+
// On merge of const enum module with class or function, reset const enum only flag (namespaces will already recalculate)
237+
if (symbol.constEnumOnlyModule && (symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum))) {
238+
symbol.constEnumOnlyModule = false;
239+
}
240+
236241
if (symbolFlags & SymbolFlags.Value) {
237242
setValueDeclaration(symbol, node);
238243
}

src/compiler/builder.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ namespace ts {
6464
const state = BuilderState.create(newProgram, getCanonicalFileName, oldState) as BuilderProgramState;
6565
state.program = newProgram;
6666
const compilerOptions = newProgram.getCompilerOptions();
67-
if (!compilerOptions.outFile && !compilerOptions.out) {
67+
// With --out or --outFile, any change affects all semantic diagnostics so no need to cache them
68+
// With --isolatedModules, emitting changed file doesnt emit dependent files so we cant know of dependent files to retrieve errors so dont cache the errors
69+
if (!compilerOptions.outFile && !compilerOptions.out && !compilerOptions.isolatedModules) {
6870
state.semanticDiagnosticsPerFile = createMap<ReadonlyArray<Diagnostic>>();
6971
}
7072
state.changedFilesSet = createMap<true>();
@@ -281,10 +283,19 @@ namespace ts {
281283
}
282284

283285
// If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
284-
return !!forEachEntry(state.exportedModulesMap!, (exportedModules, exportedFromPath) =>
286+
if (forEachEntry(state.exportedModulesMap!, (exportedModules, exportedFromPath) =>
285287
!state.currentAffectedFilesExportedModulesMap!.has(exportedFromPath) && // If we already iterated this through cache, ignore it
286288
exportedModules.has(filePath) &&
287289
removeSemanticDiagnosticsOfFileAndExportsOfFile(state, exportedFromPath as Path, seenFileAndExportsOfFile)
290+
)) {
291+
return true;
292+
}
293+
294+
// Remove diagnostics of files that import this file (without going to exports of referencing files)
295+
return !!forEachEntry(state.referencedMap!, (referencesInFile, referencingFilePath) =>
296+
referencesInFile.has(filePath) &&
297+
!seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
298+
removeSemanticDiagnosticsOf(state, referencingFilePath as Path) // Dont add to seen since this is not yet done with the export removal
288299
);
289300
}
290301

@@ -329,15 +340,19 @@ namespace ts {
329340
*/
330341
function getSemanticDiagnosticsOfFile(state: BuilderProgramState, sourceFile: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic> {
331342
const path = sourceFile.path;
332-
const cachedDiagnostics = state.semanticDiagnosticsPerFile!.get(path);
333-
// Report the semantic diagnostics from the cache if we already have those diagnostics present
334-
if (cachedDiagnostics) {
335-
return cachedDiagnostics;
343+
if (state.semanticDiagnosticsPerFile) {
344+
const cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
345+
// Report the semantic diagnostics from the cache if we already have those diagnostics present
346+
if (cachedDiagnostics) {
347+
return cachedDiagnostics;
348+
}
336349
}
337350

338351
// Diagnostics werent cached, get them from program, and cache the result
339352
const diagnostics = state.program.getSemanticDiagnostics(sourceFile, cancellationToken);
340-
state.semanticDiagnosticsPerFile!.set(path, diagnostics);
353+
if (state.semanticDiagnosticsPerFile) {
354+
state.semanticDiagnosticsPerFile.set(path, diagnostics);
355+
}
341356
return diagnostics;
342357
}
343358

0 commit comments

Comments
 (0)