Skip to content

Commit 334ca65

Browse files
committed
Merge branch 'main' into fix-exact-optional-unassignable-properties
2 parents d058191 + 9d957c6 commit 334ca65

File tree

169 files changed

+6026
-503
lines changed

Some content is hidden

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

169 files changed

+6026
-503
lines changed

package-lock.json

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/compiler/binder.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -916,10 +916,6 @@ namespace ts {
916916
return isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && isStringLiteralLike(expr2);
917917
}
918918

919-
function isNarrowableInOperands(left: Expression, right: Expression) {
920-
return isStringLiteralLike(left) && isNarrowingExpression(right);
921-
}
922-
923919
function isNarrowingBinaryExpression(expr: BinaryExpression) {
924920
switch (expr.operatorToken.kind) {
925921
case SyntaxKind.EqualsToken:
@@ -936,7 +932,7 @@ namespace ts {
936932
case SyntaxKind.InstanceOfKeyword:
937933
return isNarrowableOperand(expr.left);
938934
case SyntaxKind.InKeyword:
939-
return isNarrowableInOperands(expr.left, expr.right);
935+
return isNarrowingExpression(expr.right);
940936
case SyntaxKind.CommaToken:
941937
return isNarrowingExpression(expr.right);
942938
}

src/compiler/builderState.ts

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,16 @@ namespace ts {
178178
*/
179179
export type ComputeHash = ((data: string) => string) | undefined;
180180

181-
/**
182-
* Get the referencedFile from the imported module symbol
183-
*/
184-
function getReferencedFileFromImportedModuleSymbol(symbol: Symbol) {
185-
if (symbol.declarations && symbol.declarations[0]) {
186-
const declarationSourceFile = getSourceFileOfNode(symbol.declarations[0]);
187-
return declarationSourceFile && declarationSourceFile.resolvedPath;
188-
}
181+
function getReferencedFilesFromImportedModuleSymbol(symbol: Symbol): Path[] {
182+
return mapDefined(symbol.declarations, declaration => getSourceFileOfNode(declaration)?.resolvedPath);
189183
}
190184

191185
/**
192-
* Get the referencedFile from the import name node from file
186+
* Get the module source file and all augmenting files from the import name node from file
193187
*/
194-
function getReferencedFileFromImportLiteral(checker: TypeChecker, importName: StringLiteralLike) {
188+
function getReferencedFilesFromImportLiteral(checker: TypeChecker, importName: StringLiteralLike): Path[] | undefined {
195189
const symbol = checker.getSymbolAtLocation(importName);
196-
return symbol && getReferencedFileFromImportedModuleSymbol(symbol);
190+
return symbol && getReferencedFilesFromImportedModuleSymbol(symbol);
197191
}
198192

199193
/**
@@ -215,10 +209,8 @@ namespace ts {
215209
if (sourceFile.imports && sourceFile.imports.length > 0) {
216210
const checker: TypeChecker = program.getTypeChecker();
217211
for (const importName of sourceFile.imports) {
218-
const declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName);
219-
if (declarationSourceFilePath) {
220-
addReferencedFile(declarationSourceFilePath);
221-
}
212+
const declarationSourceFilePaths = getReferencedFilesFromImportLiteral(checker, importName);
213+
declarationSourceFilePaths?.forEach(addReferencedFile);
222214
}
223215
}
224216

@@ -458,20 +450,20 @@ namespace ts {
458450
}
459451

460452
let exportedModules: Set<Path> | undefined;
461-
exportedModulesFromDeclarationEmit.forEach(symbol => addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)));
453+
exportedModulesFromDeclarationEmit.forEach(symbol => addExportedModule(getReferencedFilesFromImportedModuleSymbol(symbol)));
462454
if (exportedModules) {
463455
exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules);
464456
}
465457
else {
466458
exportedModulesMapCache.deleteKey(sourceFile.resolvedPath);
467459
}
468460

469-
function addExportedModule(exportedModulePath: Path | undefined) {
470-
if (exportedModulePath) {
461+
function addExportedModule(exportedModulePaths: Path[] | undefined) {
462+
if (exportedModulePaths?.length) {
471463
if (!exportedModules) {
472464
exportedModules = new Set();
473465
}
474-
exportedModules.add(exportedModulePath);
466+
exportedModulePaths.forEach(path => exportedModules!.add(path));
475467
}
476468
}
477469
}

0 commit comments

Comments
 (0)