Skip to content

Commit fbdf00c

Browse files
authored
Undo accidental style changes from Map/Set PR (#51529)
1 parent b553aff commit fbdf00c

File tree

6 files changed

+503
-505
lines changed

6 files changed

+503
-505
lines changed

src/compiler/checker.ts

Lines changed: 434 additions & 436 deletions
Large diffs are not rendered by default.

src/compiler/emitter.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ function getSourceMapFilePath(jsFilePath: string, options: CompilerOptions) {
192192
/** @internal */
193193
export function getOutputExtension(fileName: string, options: CompilerOptions): Extension {
194194
return fileExtensionIs(fileName, Extension.Json) ? Extension.Json :
195-
options.jsx === JsxEmit.Preserve && fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx]) ? Extension.Jsx :
196-
fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs]) ? Extension.Mjs :
197-
fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs]) ? Extension.Cjs :
198-
Extension.Js;
195+
options.jsx === JsxEmit.Preserve && fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx]) ? Extension.Jsx :
196+
fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs]) ? Extension.Mjs :
197+
fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs]) ? Extension.Cjs :
198+
Extension.Js;
199199
}
200200

201201
function getOutputPathWithoutChangingExt(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean, outputDir: string | undefined, getCommonSourceDirectory?: () => string) {
@@ -1363,25 +1363,25 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
13631363
if (onEmitNode !== noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
13641364
return pipelineEmitWithNotification;
13651365
}
1366-
// falls through
1366+
// falls through
13671367
case PipelinePhase.Substitution:
13681368
if (substituteNode !== noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) {
13691369
if (currentParenthesizerRule) {
13701370
lastSubstitution = currentParenthesizerRule(lastSubstitution);
13711371
}
13721372
return pipelineEmitWithSubstitution;
13731373
}
1374-
// falls through
1374+
// falls through
13751375
case PipelinePhase.Comments:
13761376
if (shouldEmitComments(node)) {
13771377
return pipelineEmitWithComments;
13781378
}
1379-
// falls through
1379+
// falls through
13801380
case PipelinePhase.SourceMaps:
13811381
if (shouldEmitSourceMaps(node)) {
13821382
return pipelineEmitWithSourceMaps;
13831383
}
1384-
// falls through
1384+
// falls through
13851385
case PipelinePhase.Emit:
13861386
return pipelineEmitWithHint;
13871387
default:
@@ -5081,7 +5081,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
50815081
const text = isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode);
50825082
return jsxAttributeEscape ? `"${escapeJsxAttributeString(text)}"` :
50835083
neverAsciiEscape || (getEmitFlags(node) & EmitFlags.NoAsciiEscaping) ? `"${escapeString(text)}"` :
5084-
`"${escapeNonAsciiString(text)}"`;
5084+
`"${escapeNonAsciiString(text)}"`;
50855085
}
50865086
else {
50875087
return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
@@ -5509,7 +5509,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
55095509
*/
55105510
function makeName(name: GeneratedIdentifier | GeneratedPrivateIdentifier) {
55115511
const prefix = formatGeneratedNamePart(name.autoGeneratePrefix, generateName);
5512-
const suffix = formatGeneratedNamePart(name.autoGenerateSuffix);
5512+
const suffix = formatGeneratedNamePart (name.autoGenerateSuffix);
55135513
switch (name.autoGenerateFlags & GeneratedIdentifierFlags.KindMask) {
55145514
case GeneratedIdentifierFlags.Auto:
55155515
return makeTempVariableName(TempFlags.Auto, !!(name.autoGenerateFlags & GeneratedIdentifierFlags.ReservedInNestedScopes), isPrivateIdentifier(name), prefix, suffix);
@@ -5829,7 +5829,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
58295829
}
58305830

58315831
function emitTrailingCommentOfPosition(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean) {
5832-
if (!currentSourceFile) return;
5832+
if(!currentSourceFile) return;
58335833
// trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
58345834

58355835
emitPos(commentPos);
@@ -6134,5 +6134,5 @@ function emitListItemWithParenthesizerRule(node: Node, emit: (node: Node, parent
61346134
function getEmitListItem<T extends Node, R extends ParenthesizerRuleOrSelector<T> | undefined>(emit: (node: Node, parenthesizerRule?: ((node: Node) => Node) | undefined) => void, parenthesizerRule: R): (node: Node, emit: (node: Node, parenthesizerRule?: ((node: Node) => Node) | undefined) => void, parenthesizerRule: R, index: number) => void {
61356135
return emit.length === 1 ? emitListItemNoParenthesizer :
61366136
typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
6137-
emitListItemWithParenthesizerRule;
6137+
emitListItemWithParenthesizerRule;
61386138
}

src/compiler/moduleNameResolver.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,8 +1312,8 @@ export enum NodeResolutionFeatures {
13121312
}
13131313

13141314
function node16ModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions,
1315-
host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
1316-
resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations {
1315+
host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
1316+
resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations {
13171317
return nodeNextModuleNameResolverWorker(
13181318
NodeResolutionFeatures.Node16Default,
13191319
moduleName,
@@ -1327,8 +1327,8 @@ function node16ModuleNameResolver(moduleName: string, containingFile: string, co
13271327
}
13281328

13291329
function nodeNextModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions,
1330-
host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
1331-
resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations {
1330+
host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
1331+
resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations {
13321332
return nodeNextModuleNameResolverWorker(
13331333
NodeResolutionFeatures.NodeNextDefault,
13341334
moduleName,
@@ -1861,7 +1861,7 @@ export interface PackageJsonInfoContents {
18611861
*
18621862
* @internal
18631863
*/
1864-
export function getPackageScopeForPath(fileName: string, state: ModuleResolutionState): PackageJsonInfo | undefined {
1864+
export function getPackageScopeForPath(fileName: string, state: ModuleResolutionState): PackageJsonInfo | undefined {
18651865
const parts = getPathComponents(fileName);
18661866
parts.pop();
18671867
while (parts.length > 0) {
@@ -2294,7 +2294,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
22942294
function useCaseSensitiveFileNames() {
22952295
return !state.host.useCaseSensitiveFileNames ? true :
22962296
typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
2297-
state.host.useCaseSensitiveFileNames();
2297+
state.host.useCaseSensitiveFileNames();
22982298
}
22992299

23002300
function tryLoadInputFileForPath(finalPath: string, entry: string, packagePath: string, isImports: boolean) {

src/compiler/moduleSpecifiers.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ function getPreferences(host: ModuleSpecifierResolutionHost, { importModuleSpeci
3535
return {
3636
relativePreference:
3737
importModuleSpecifierPreference === "relative" ? RelativePreference.Relative :
38-
importModuleSpecifierPreference === "non-relative" ? RelativePreference.NonRelative :
39-
importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative :
40-
RelativePreference.Shortest,
38+
importModuleSpecifierPreference === "non-relative" ? RelativePreference.NonRelative :
39+
importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative :
40+
RelativePreference.Shortest,
4141
ending: getEnding(),
4242
};
4343
function getEnding(): Ending {
@@ -62,7 +62,7 @@ function getPreferencesForUpdate(compilerOptions: CompilerOptions, oldImportSpec
6262

6363
function isFormatRequiringExtensions(compilerOptions: CompilerOptions, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost) {
6464
if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16
65-
&& getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
65+
&& getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
6666
return false;
6767
}
6868
return getImpliedNodeFormatForFile(importingSourceFileName, host.getPackageJsonInfoCache?.(), getModuleResolutionHost(host), compilerOptions) !== ModuleKind.CommonJS;
@@ -307,7 +307,7 @@ function computeModuleSpecifiers(
307307

308308
return pathsSpecifiers?.length ? pathsSpecifiers :
309309
nodeModulesSpecifiers?.length ? nodeModulesSpecifiers :
310-
Debug.checkDefined(relativeSpecifiers);
310+
Debug.checkDefined(relativeSpecifiers);
311311
}
312312

313313
interface Info {
@@ -736,7 +736,7 @@ function tryGetModuleNameFromExports(options: CompilerOptions, targetFilePath: s
736736
const subPackageName = getNormalizedAbsolutePath(combinePaths(packageName, k), /*currentDirectory*/ undefined);
737737
const mode = endsWith(k, "/") ? MatchingMode.Directory
738738
: stringContains(k, "*") ? MatchingMode.Pattern
739-
: MatchingMode.Exact;
739+
: MatchingMode.Exact;
740740
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, (exports as MapLike<unknown>)[k], conditions, mode);
741741
});
742742
}

src/compiler/program.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ export function isProgramUptoDate(
885885

886886
function resolvedProjectReferenceUptoDate(oldResolvedRef: ResolvedProjectReference | undefined, oldRef: ProjectReference): boolean {
887887
if (oldResolvedRef) {
888-
// Assume true
888+
// Assume true
889889
if (contains(seenResolvedRefs, oldResolvedRef)) return true;
890890

891891
const refPath = resolveProjectReferencePath(oldRef);
@@ -948,8 +948,8 @@ export function getImpliedNodeFormatForFileWorker(
948948
case ModuleResolutionKind.NodeNext:
949949
return fileExtensionIsOneOf(fileName, [Extension.Dmts, Extension.Mts, Extension.Mjs]) ? ModuleKind.ESNext :
950950
fileExtensionIsOneOf(fileName, [Extension.Dcts, Extension.Cts, Extension.Cjs]) ? ModuleKind.CommonJS :
951-
fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
952-
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
951+
fileExtensionIsOneOf(fileName, [Extension.Dts, Extension.Ts, Extension.Tsx, Extension.Js, Extension.Jsx]) ? lookupFromPackageJson() :
952+
undefined; // other extensions, like `json` or `tsbuildinfo`, are set as `undefined` here but they should never be fed through the transformer pipeline
953953
default:
954954
return undefined;
955955
}
@@ -2309,7 +2309,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
23092309
}
23102310

23112311
function getCachedSemanticDiagnostics(sourceFile?: SourceFile): readonly Diagnostic[] | undefined {
2312-
return sourceFile
2312+
return sourceFile
23132313
? cachedBindAndCheckDiagnosticsForFile.perFile?.get(sourceFile.path)
23142314
: cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
23152315
}
@@ -2400,7 +2400,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
24002400
// - check JS: .js files with either // ts-check or checkJs: true
24012401
// - external: files that are added by plugins
24022402
const includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX
2403-
|| sourceFile.scriptKind === ScriptKind.External || isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
2403+
|| sourceFile.scriptKind === ScriptKind.External || isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
24042404
let bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
24052405
let checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
24062406
if (isPlainJs) {

src/compiler/transformers/es2018.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -751,21 +751,21 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
751751
setTextRange(
752752
factory.createForStatement(
753753
/*initializer*/ setEmitFlags(
754-
setTextRange(
755-
factory.createVariableDeclarationList([
756-
factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
757-
setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
758-
factory.createVariableDeclaration(result)
759-
]),
760-
node.expression
754+
setTextRange(
755+
factory.createVariableDeclarationList([
756+
factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
757+
setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
758+
factory.createVariableDeclaration(result)
759+
]),
760+
node.expression
761+
),
762+
EmitFlags.NoHoisting
761763
),
762-
EmitFlags.NoHoisting
763-
),
764764
/*condition*/ factory.inlineExpressions([
765-
factory.createAssignment(result, createDownlevelAwait(callNext)),
766-
factory.createAssignment(done, getDone),
767-
factory.createLogicalNot(done)
768-
]),
765+
factory.createAssignment(result, createDownlevelAwait(callNext)),
766+
factory.createAssignment(done, getDone),
767+
factory.createLogicalNot(done)
768+
]),
769769
/*incrementor*/ undefined,
770770
/*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)
771771
),
@@ -801,38 +801,38 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
801801
factory.createBlock([
802802
factory.createTryStatement(
803803
/*tryBlock*/ factory.createBlock([
804-
setEmitFlags(
805-
factory.createIfStatement(
806-
factory.createLogicalAnd(
807-
factory.createLogicalAnd(
808-
factory.createLogicalNot(nonUserCode),
809-
factory.createLogicalNot(done),
810-
),
811-
factory.createAssignment(
812-
returnMethod,
813-
factory.createPropertyAccessExpression(iterator, "return")
814-
)
815-
),
816-
factory.createExpressionStatement(createDownlevelAwait(callReturn))
817-
),
818-
EmitFlags.SingleLine
819-
)
820-
]),
821-
/*catchClause*/ undefined,
822-
/*finallyBlock*/ setEmitFlags(
823-
factory.createBlock([
824804
setEmitFlags(
825805
factory.createIfStatement(
826-
errorRecord,
827-
factory.createThrowStatement(
828-
factory.createPropertyAccessExpression(errorRecord, "error")
829-
)
806+
factory.createLogicalAnd(
807+
factory.createLogicalAnd(
808+
factory.createLogicalNot(nonUserCode),
809+
factory.createLogicalNot(done),
810+
),
811+
factory.createAssignment(
812+
returnMethod,
813+
factory.createPropertyAccessExpression(iterator, "return")
814+
)
815+
),
816+
factory.createExpressionStatement(createDownlevelAwait(callReturn))
830817
),
831818
EmitFlags.SingleLine
832819
)
833820
]),
834-
EmitFlags.SingleLine
835-
)
821+
/*catchClause*/ undefined,
822+
/*finallyBlock*/ setEmitFlags(
823+
factory.createBlock([
824+
setEmitFlags(
825+
factory.createIfStatement(
826+
errorRecord,
827+
factory.createThrowStatement(
828+
factory.createPropertyAccessExpression(errorRecord, "error")
829+
)
830+
),
831+
EmitFlags.SingleLine
832+
)
833+
]),
834+
EmitFlags.SingleLine
835+
)
836836
)
837837
])
838838
);
@@ -1051,7 +1051,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
10511051
factory.createToken(SyntaxKind.AsteriskToken),
10521052
node.name && factory.getGeneratedNameForNode(node.name),
10531053
/*typeParameters*/ undefined,
1054-
/*parameters*/[],
1054+
/*parameters*/ [],
10551055
/*type*/ undefined,
10561056
factory.updateBlock(
10571057
node.body!,

0 commit comments

Comments
 (0)