mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-14 16:56:06 -05:00
Address code review feedback - revert declarations.ts changes and clean up test
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
This commit is contained in:
@@ -103,8 +103,7 @@ import {
|
||||
isExpandoPropertyDeclaration,
|
||||
isExportAssignment,
|
||||
isExportDeclaration,
|
||||
isExpressionWithTypeArguments,
|
||||
isExpression,
|
||||
isExpressionWithTypeArguments,
|
||||
isExternalModule,
|
||||
isExternalModuleAugmentation,
|
||||
isExternalModuleIndicator,
|
||||
@@ -129,9 +128,8 @@ import {
|
||||
isObjectLiteralExpression,
|
||||
isOmittedExpression,
|
||||
isParameter,
|
||||
isPrimitiveLiteralValue,
|
||||
isPrivateIdentifier,
|
||||
isPropertyAccessExpression,
|
||||
isPrimitiveLiteralValue,
|
||||
isPrivateIdentifier,
|
||||
isSemicolonClassElement,
|
||||
isSetAccessorDeclaration,
|
||||
isSourceFile,
|
||||
@@ -202,8 +200,8 @@ import {
|
||||
TransformationContext,
|
||||
Transformer,
|
||||
transformNodes,
|
||||
tryCast,
|
||||
TypeAliasDeclaration,
|
||||
tryCast,
|
||||
TypeAliasDeclaration,
|
||||
TypeNode,
|
||||
TypeParameterDeclaration,
|
||||
TypeReferenceNode,
|
||||
@@ -656,21 +654,21 @@ export function transformDeclarations(context: TransformationContext): Transform
|
||||
return newParam;
|
||||
}
|
||||
|
||||
function shouldPrintWithInitializer(node: Node): node is CanHaveLiteralInitializer & { initializer: Expression; } {
|
||||
return canHaveLiteralInitializer(node)
|
||||
&& !!node.initializer
|
||||
&& resolver.isLiteralConstDeclaration(getParseTreeNode(node) as CanHaveLiteralInitializer); // TODO: Make safea
|
||||
function shouldPrintWithInitializer(node: Node): node is CanHaveLiteralInitializer & { initializer: Expression; } {
|
||||
return canHaveLiteralInitializer(node)
|
||||
&& !!node.initializer
|
||||
&& resolver.isLiteralConstDeclaration(getParseTreeNode(node) as CanHaveLiteralInitializer); // TODO: Make safea
|
||||
}
|
||||
|
||||
function ensureNoInitializer(node: CanHaveLiteralInitializer) {
|
||||
if (shouldPrintWithInitializer(node)) {
|
||||
const unwrappedInitializer = unwrapParenthesizedExpression(node.initializer);
|
||||
if (!isPrimitiveLiteralValue(unwrappedInitializer)) {
|
||||
reportInferenceFallback(node);
|
||||
}
|
||||
return resolver.createLiteralConstValue(getParseTreeNode(node, canHaveLiteralInitializer)!, symbolTracker);
|
||||
}
|
||||
return undefined;
|
||||
function ensureNoInitializer(node: CanHaveLiteralInitializer) {
|
||||
if (shouldPrintWithInitializer(node)) {
|
||||
const unwrappedInitializer = unwrapParenthesizedExpression(node.initializer);
|
||||
if (!isPrimitiveLiteralValue(unwrappedInitializer)) {
|
||||
reportInferenceFallback(node);
|
||||
}
|
||||
return resolver.createLiteralConstValue(getParseTreeNode(node, canHaveLiteralInitializer)!, symbolTracker);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
function ensureType(node: VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertySignature | ExportAssignment | SignatureDeclaration, ignorePrivate?: boolean): TypeNode | undefined {
|
||||
if (!ignorePrivate && hasEffectiveModifier(node, ModifierFlags.Private)) {
|
||||
@@ -1051,12 +1049,12 @@ export function transformDeclarations(context: TransformationContext): Transform
|
||||
const oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
|
||||
let shouldEnterSuppressNewDiagnosticsContextContext = (input.kind === SyntaxKind.TypeLiteral || input.kind === SyntaxKind.MappedType) && input.parent.kind !== SyntaxKind.TypeAliasDeclaration;
|
||||
|
||||
// Emit methods which are private as properties with no type information
|
||||
if (isMethodDeclaration(input) || isMethodSignature(input)) {
|
||||
if (hasEffectiveModifier(input, ModifierFlags.Private)) {
|
||||
if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload
|
||||
return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
|
||||
}
|
||||
// Emit methods which are private as properties with no type information
|
||||
if (isMethodDeclaration(input) || isMethodSignature(input)) {
|
||||
if (hasEffectiveModifier(input, ModifierFlags.Private)) {
|
||||
if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload
|
||||
return cleanup(factory.createPropertyDeclaration(ensureModifiers(input), input.name, /*questionOrExclamationToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined));
|
||||
}
|
||||
}
|
||||
|
||||
if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
|
||||
|
||||
Reference in New Issue
Block a user