Skip to content

Undo accidental style changes from Map/Set PR #51529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
870 changes: 434 additions & 436 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ function getSourceMapFilePath(jsFilePath: string, options: CompilerOptions) {
/** @internal */
export function getOutputExtension(fileName: string, options: CompilerOptions): Extension {
return fileExtensionIs(fileName, Extension.Json) ? Extension.Json :
options.jsx === JsxEmit.Preserve && fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx]) ? Extension.Jsx :
fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs]) ? Extension.Mjs :
fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs]) ? Extension.Cjs :
Extension.Js;
options.jsx === JsxEmit.Preserve && fileExtensionIsOneOf(fileName, [Extension.Jsx, Extension.Tsx]) ? Extension.Jsx :
fileExtensionIsOneOf(fileName, [Extension.Mts, Extension.Mjs]) ? Extension.Mjs :
fileExtensionIsOneOf(fileName, [Extension.Cts, Extension.Cjs]) ? Extension.Cjs :
Extension.Js;
}

function getOutputPathWithoutChangingExt(inputFileName: string, configFile: ParsedCommandLine, ignoreCase: boolean, outputDir: string | undefined, getCommonSourceDirectory?: () => string) {
Expand Down Expand Up @@ -1363,25 +1363,25 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
if (onEmitNode !== noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
return pipelineEmitWithNotification;
}
// falls through
// falls through
case PipelinePhase.Substitution:
if (substituteNode !== noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node) || node) !== node) {
if (currentParenthesizerRule) {
lastSubstitution = currentParenthesizerRule(lastSubstitution);
}
return pipelineEmitWithSubstitution;
}
// falls through
// falls through
case PipelinePhase.Comments:
if (shouldEmitComments(node)) {
return pipelineEmitWithComments;
}
// falls through
// falls through
case PipelinePhase.SourceMaps:
if (shouldEmitSourceMaps(node)) {
return pipelineEmitWithSourceMaps;
}
// falls through
// falls through
case PipelinePhase.Emit:
return pipelineEmitWithHint;
default:
Expand Down Expand Up @@ -5081,7 +5081,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
const text = isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode);
return jsxAttributeEscape ? `"${escapeJsxAttributeString(text)}"` :
neverAsciiEscape || (getEmitFlags(node) & EmitFlags.NoAsciiEscaping) ? `"${escapeString(text)}"` :
`"${escapeNonAsciiString(text)}"`;
`"${escapeNonAsciiString(text)}"`;
}
else {
return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
Expand Down Expand Up @@ -5509,7 +5509,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
*/
function makeName(name: GeneratedIdentifier | GeneratedPrivateIdentifier) {
const prefix = formatGeneratedNamePart(name.autoGeneratePrefix, generateName);
const suffix = formatGeneratedNamePart(name.autoGenerateSuffix);
const suffix = formatGeneratedNamePart (name.autoGenerateSuffix);
switch (name.autoGenerateFlags & GeneratedIdentifierFlags.KindMask) {
case GeneratedIdentifierFlags.Auto:
return makeTempVariableName(TempFlags.Auto, !!(name.autoGenerateFlags & GeneratedIdentifierFlags.ReservedInNestedScopes), isPrivateIdentifier(name), prefix, suffix);
Expand Down Expand Up @@ -5829,7 +5829,7 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
}

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

emitPos(commentPos);
Expand Down Expand Up @@ -6134,5 +6134,5 @@ function emitListItemWithParenthesizerRule(node: Node, emit: (node: Node, parent
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 {
return emit.length === 1 ? emitListItemNoParenthesizer :
typeof parenthesizerRule === "object" ? emitListItemWithParenthesizerRuleSelector :
emitListItemWithParenthesizerRule;
emitListItemWithParenthesizerRule;
}
12 changes: 6 additions & 6 deletions src/compiler/moduleNameResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1312,8 +1312,8 @@ export enum NodeResolutionFeatures {
}

function node16ModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions,
host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations {
host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations {
return nodeNextModuleNameResolverWorker(
NodeResolutionFeatures.Node16Default,
moduleName,
Expand All @@ -1327,8 +1327,8 @@ function node16ModuleNameResolver(moduleName: string, containingFile: string, co
}

function nodeNextModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions,
host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations {
host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference,
resolutionMode?: ResolutionMode): ResolvedModuleWithFailedLookupLocations {
return nodeNextModuleNameResolverWorker(
NodeResolutionFeatures.NodeNextDefault,
moduleName,
Expand Down Expand Up @@ -1861,7 +1861,7 @@ export interface PackageJsonInfoContents {
*
* @internal
*/
export function getPackageScopeForPath(fileName: string, state: ModuleResolutionState): PackageJsonInfo | undefined {
export function getPackageScopeForPath(fileName: string, state: ModuleResolutionState): PackageJsonInfo | undefined {
const parts = getPathComponents(fileName);
parts.pop();
while (parts.length > 0) {
Expand Down Expand Up @@ -2294,7 +2294,7 @@ function getLoadModuleFromTargetImportOrExport(extensions: Extensions, state: Mo
function useCaseSensitiveFileNames() {
return !state.host.useCaseSensitiveFileNames ? true :
typeof state.host.useCaseSensitiveFileNames === "boolean" ? state.host.useCaseSensitiveFileNames :
state.host.useCaseSensitiveFileNames();
state.host.useCaseSensitiveFileNames();
}

function tryLoadInputFileForPath(finalPath: string, entry: string, packagePath: string, isImports: boolean) {
Expand Down
12 changes: 6 additions & 6 deletions src/compiler/moduleSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function getPreferences(host: ModuleSpecifierResolutionHost, { importModuleSpeci
return {
relativePreference:
importModuleSpecifierPreference === "relative" ? RelativePreference.Relative :
importModuleSpecifierPreference === "non-relative" ? RelativePreference.NonRelative :
importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative :
RelativePreference.Shortest,
importModuleSpecifierPreference === "non-relative" ? RelativePreference.NonRelative :
importModuleSpecifierPreference === "project-relative" ? RelativePreference.ExternalNonRelative :
RelativePreference.Shortest,
ending: getEnding(),
};
function getEnding(): Ending {
Expand All @@ -62,7 +62,7 @@ function getPreferencesForUpdate(compilerOptions: CompilerOptions, oldImportSpec

function isFormatRequiringExtensions(compilerOptions: CompilerOptions, importingSourceFileName: Path, host: ModuleSpecifierResolutionHost) {
if (getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.Node16
&& getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
&& getEmitModuleResolutionKind(compilerOptions) !== ModuleResolutionKind.NodeNext) {
return false;
}
return getImpliedNodeFormatForFile(importingSourceFileName, host.getPackageJsonInfoCache?.(), getModuleResolutionHost(host), compilerOptions) !== ModuleKind.CommonJS;
Expand Down Expand Up @@ -307,7 +307,7 @@ function computeModuleSpecifiers(

return pathsSpecifiers?.length ? pathsSpecifiers :
nodeModulesSpecifiers?.length ? nodeModulesSpecifiers :
Debug.checkDefined(relativeSpecifiers);
Debug.checkDefined(relativeSpecifiers);
}

interface Info {
Expand Down Expand Up @@ -736,7 +736,7 @@ function tryGetModuleNameFromExports(options: CompilerOptions, targetFilePath: s
const subPackageName = getNormalizedAbsolutePath(combinePaths(packageName, k), /*currentDirectory*/ undefined);
const mode = endsWith(k, "/") ? MatchingMode.Directory
: stringContains(k, "*") ? MatchingMode.Pattern
: MatchingMode.Exact;
: MatchingMode.Exact;
return tryGetModuleNameFromExports(options, targetFilePath, packageDirectory, subPackageName, (exports as MapLike<unknown>)[k], conditions, mode);
});
}
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ export function isProgramUptoDate(

function resolvedProjectReferenceUptoDate(oldResolvedRef: ResolvedProjectReference | undefined, oldRef: ProjectReference): boolean {
if (oldResolvedRef) {
// Assume true
// Assume true
if (contains(seenResolvedRefs, oldResolvedRef)) return true;

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

function getCachedSemanticDiagnostics(sourceFile?: SourceFile): readonly Diagnostic[] | undefined {
return sourceFile
return sourceFile
? cachedBindAndCheckDiagnosticsForFile.perFile?.get(sourceFile.path)
: cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
}
Expand Down Expand Up @@ -2400,7 +2400,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
// - check JS: .js files with either // ts-check or checkJs: true
// - external: files that are added by plugins
const includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === ScriptKind.TS || sourceFile.scriptKind === ScriptKind.TSX
|| sourceFile.scriptKind === ScriptKind.External || isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
|| sourceFile.scriptKind === ScriptKind.External || isPlainJs || isCheckJs || sourceFile.scriptKind === ScriptKind.Deferred);
let bindDiagnostics: readonly Diagnostic[] = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : emptyArray;
let checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : emptyArray;
if (isPlainJs) {
Expand Down
80 changes: 40 additions & 40 deletions src/compiler/transformers/es2018.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,21 +751,21 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
setTextRange(
factory.createForStatement(
/*initializer*/ setEmitFlags(
setTextRange(
factory.createVariableDeclarationList([
factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
factory.createVariableDeclaration(result)
]),
node.expression
setTextRange(
factory.createVariableDeclarationList([
factory.createVariableDeclaration(nonUserCode, /*exclamationToken*/ undefined, /*type*/ undefined, factory.createTrue()),
setTextRange(factory.createVariableDeclaration(iterator, /*exclamationToken*/ undefined, /*type*/ undefined, initializer), node.expression),
factory.createVariableDeclaration(result)
]),
node.expression
),
EmitFlags.NoHoisting
),
EmitFlags.NoHoisting
),
/*condition*/ factory.inlineExpressions([
factory.createAssignment(result, createDownlevelAwait(callNext)),
factory.createAssignment(done, getDone),
factory.createLogicalNot(done)
]),
factory.createAssignment(result, createDownlevelAwait(callNext)),
factory.createAssignment(done, getDone),
factory.createLogicalNot(done)
]),
/*incrementor*/ undefined,
/*statement*/ convertForOfStatementHead(node, getValue, nonUserCode)
),
Expand Down Expand Up @@ -801,38 +801,38 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
factory.createBlock([
factory.createTryStatement(
/*tryBlock*/ factory.createBlock([
setEmitFlags(
factory.createIfStatement(
factory.createLogicalAnd(
factory.createLogicalAnd(
factory.createLogicalNot(nonUserCode),
factory.createLogicalNot(done),
),
factory.createAssignment(
returnMethod,
factory.createPropertyAccessExpression(iterator, "return")
)
),
factory.createExpressionStatement(createDownlevelAwait(callReturn))
),
EmitFlags.SingleLine
)
]),
/*catchClause*/ undefined,
/*finallyBlock*/ setEmitFlags(
factory.createBlock([
setEmitFlags(
factory.createIfStatement(
errorRecord,
factory.createThrowStatement(
factory.createPropertyAccessExpression(errorRecord, "error")
)
factory.createLogicalAnd(
factory.createLogicalAnd(
factory.createLogicalNot(nonUserCode),
factory.createLogicalNot(done),
),
factory.createAssignment(
returnMethod,
factory.createPropertyAccessExpression(iterator, "return")
)
),
factory.createExpressionStatement(createDownlevelAwait(callReturn))
),
EmitFlags.SingleLine
)
]),
EmitFlags.SingleLine
)
/*catchClause*/ undefined,
/*finallyBlock*/ setEmitFlags(
factory.createBlock([
setEmitFlags(
factory.createIfStatement(
errorRecord,
factory.createThrowStatement(
factory.createPropertyAccessExpression(errorRecord, "error")
)
),
EmitFlags.SingleLine
)
]),
EmitFlags.SingleLine
)
)
])
);
Expand Down Expand Up @@ -1051,7 +1051,7 @@ export function transformES2018(context: TransformationContext): (x: SourceFile
factory.createToken(SyntaxKind.AsteriskToken),
node.name && factory.getGeneratedNameForNode(node.name),
/*typeParameters*/ undefined,
/*parameters*/[],
/*parameters*/ [],
/*type*/ undefined,
factory.updateBlock(
node.body!,
Expand Down