mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Undo accidental style changes from Map/Set PR (#51529)
This commit is contained in:
+433
-435
File diff suppressed because it is too large
Load Diff
+12
-12
@@ -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) {
|
||||
@@ -1363,7 +1363,7 @@ 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) {
|
||||
@@ -1371,17 +1371,17 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
}
|
||||
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:
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
@@ -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,
|
||||
@@ -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) {
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
@@ -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;
|
||||
@@ -307,7 +307,7 @@ function computeModuleSpecifiers(
|
||||
|
||||
return pathsSpecifiers?.length ? pathsSpecifiers :
|
||||
nodeModulesSpecifiers?.length ? nodeModulesSpecifiers :
|
||||
Debug.checkDefined(relativeSpecifiers);
|
||||
Debug.checkDefined(relativeSpecifiers);
|
||||
}
|
||||
|
||||
interface Info {
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
),
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
])
|
||||
);
|
||||
@@ -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!,
|
||||
|
||||
Reference in New Issue
Block a user