Skip to content
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

[ID-Prep] PR5 - Preserve type nodes from function like expression in declaration emit #57678

Conversation

dragomirtitian
Copy link
Contributor

Fixes #57677

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 7, 2024
@dragomirtitian dragomirtitian force-pushed the ts-verbatim-declrations-from-function-expressions branch from c8462ed to cd7636d Compare March 7, 2024 15:00
return { accessibility: SymbolAccessibility.Accessible };
}

// Parameters or binding elements from parameters are always visible in their enclosing function declarations
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checker complained about the parameter name not being accessible (since arrow functions are not themselves marked as visible by determineIfDeclarationIsVisible.

@@ -48160,13 +48177,25 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
hasSyntacticModifier(parameter, ModifierFlags.ParameterPropertyModifier);
}

function isExpandoFunctionDeclaration(node: Declaration): boolean {
const declaration = getParseTreeNode(node, isFunctionDeclaration);
function isExpandoFunctionDeclaration(node: FunctionDeclaration | VariableDeclaration): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both function and variable declarations will now be tested. We can't reliably determine the type for an expando functions variable from just it's declaration so we fall back on the type checker.

@dragomirtitian dragomirtitian changed the title Preserve type nodes from type assertions in declarations Preserve type nodes from function like expression in declaration emit Mar 7, 2024
@dragomirtitian dragomirtitian changed the title Preserve type nodes from function like expression in declaration emit [ID-Prep] PR5 - Preserve type nodes from function like expression in declaration emit Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ID-Prep] Preserve type nodes from function expressions in initialisers
2 participants