Skip to content

Commit 2876f3a

Browse files
authored
Minor fixes (microsoft#49791)
* Fix operator precedence * Tidy up some conditions with statically knowable values
1 parent cdc1996 commit 2876f3a

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7091,7 +7091,7 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
70917091
}
70927092
}
70937093

7094-
function serializeSymbol(symbol: Symbol, isPrivate: boolean, propertyAsAlias: boolean) {
7094+
function serializeSymbol(symbol: Symbol, isPrivate: boolean, propertyAsAlias: boolean): void {
70957095
// cache visited list based on merged symbol, since we want to use the unmerged top-level symbol, but
70967096
// still skip reserializing it if we encounter the merged product later on
70977097
const visitedSym = getMergedSymbol(symbol);
@@ -7104,12 +7104,11 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
71047104
if (skipMembershipCheck || (!!length(symbol.declarations) && some(symbol.declarations, d => !!findAncestor(d, n => n === enclosingDeclaration)))) {
71057105
const oldContext = context;
71067106
context = cloneNodeBuilderContext(context);
7107-
const result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
7107+
serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
71087108
if (context.reportedDiagnostic) {
71097109
oldcontext.reportedDiagnostic = context.reportedDiagnostic; // hoist diagnostic result into outer context
71107110
}
71117111
context = oldContext;
7112-
return result;
71137112
}
71147113
}
71157114

@@ -7123,7 +7122,7 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
71237122
// If it's a property: emit `export default _default` with a `_default` prop
71247123
// If it's a class/interface/function: emit a class/interface/function with a `default` modifier
71257124
// These forms can merge, eg (`export default 12; export default interface A {}`)
7126-
function serializeSymbolWorker(symbol: Symbol, isPrivate: boolean, propertyAsAlias: boolean) {
7125+
function serializeSymbolWorker(symbol: Symbol, isPrivate: boolean, propertyAsAlias: boolean): void {
71277126
const symbolName = unescapeLeadingUnderscores(symbol.escapedName);
71287127
const isDefault = symbol.escapedName === InternalSymbolName.Default;
71297128
if (isPrivate && !(context.flags & NodeBuilderFlags.AllowAnonymousIdentifier) && isStringANonContextualKeyword(symbolName) && !isDefault) {
@@ -10499,7 +10498,7 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
1049910498
error(declaration.typeExpression.type, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
1050010499
}
1050110500
else {
10502-
error(isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
10501+
error(isNamedDeclaration(declaration) ? declaration.name || declaration : declaration, Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
1050310502
}
1050410503
}
1050510504
links.declaredType = type;
@@ -31004,7 +31003,7 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
3100431003
argCheckMode = checkMode & CheckMode.IsForStringLiteralArgumentCompletions;
3100531004
if (inferenceContext) {
3100631005
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
31007-
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
31006+
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
3100831007
// If the original signature has a generic rest type, instantiation may produce a
3100931008
// signature with different arity and we need to perform another arity check.
3101031009
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
@@ -45016,9 +45015,6 @@ m2: ${(this.mapper2 as unknown as DebugTypeMapper).__debugToString().split("\n")
4501645015
else {
4501745016
return grammarErrorOnNode(initializer, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
4501845017
}
45019-
if (!isConstOrReadonly || isInvalidInitializer) {
45020-
return grammarErrorOnNode(initializer, Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
45021-
}
4502245018
}
4502345019
}
4502445020

src/compiler/emitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ namespace ts {
379379
}
380380

381381
// Make sure not to write js file and source map file if any of them cannot be written
382-
if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
382+
if (host.isEmitBlocked(jsFilePath) || compilerOptions.noEmit) {
383383
emitSkipped = true;
384384
return;
385385
}

src/compiler/tsbuildPublic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ namespace ts {
13581358
config: ParsedCommandLine
13591359
) {
13601360
if (program) {
1361-
if (program && state.write) listFiles(program, state.write);
1361+
if (state.write) listFiles(program, state.write);
13621362
if (state.host.afterProgramEmitAndDiagnostics) {
13631363
state.host.afterProgramEmitAndDiagnostics(program);
13641364
}

src/compiler/watchPublic.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ namespace ts {
283283
let parsedConfigs: ESMap<Path, ParsedConfig> | undefined; // Parsed commandline and watching cached for referenced projects
284284
let sharedExtendedConfigFileWatchers: ESMap<Path, SharedExtendedConfigFileWatcher<Path>>; // Map of file watchers for extended files, shared between different referenced projects
285285
let extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
286-
let changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
287286
let reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
288287

289288
const sourceFilesCache = new Map<string, HostFileInfo>(); // Cache that stores the source file and version info
@@ -434,13 +433,13 @@ namespace ts {
434433
const program = getCurrentBuilderProgram();
435434
if (hasChangedCompilerOptions) {
436435
newLine = updateNewLine();
437-
if (program && (changesAffectResolution || changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions))) {
436+
if (program && changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
438437
resolutionCache.clear();
439438
}
440439
}
441440

442441
// All resolutions are invalid if user provided resolutions
443-
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
442+
const hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
444443
if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
445444
if (hasChangedConfigFileParsingErrors) {
446445
if (reportFileChangeDetectedOnCreateProgram) {
@@ -457,7 +456,6 @@ namespace ts {
457456
createNewProgram(hasInvalidatedResolution);
458457
}
459458

460-
changesAffectResolution = false; // reset for next sync
461459
reportFileChangeDetectedOnCreateProgram = false;
462460

463461
if (host.afterProgramCreate && program !== builderProgram) {

0 commit comments

Comments
 (0)