Skip to content

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

Closed
Titian Cernicova-Dragomir (dragomirtitian) wants to merge 9 commits into
microsoft:mainfrom
bloomberg:ts-verbatim-declrations-from-function-expressions
Closed

Titian Cernicova-Dragomir (dragomirtitian) wants to merge 9 commits into
microsoft:mainfrom
bloomberg:ts-verbatim-declrations-from-function-expressions

Conversation

@dragomirtitian

Copy link
Copy Markdown
Contributor

Fixes #57677

@typescript-bot TypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 7, 2024
@dragomirtitian
Titian Cernicova-Dragomir (dragomirtitian) force-pushed the ts-verbatim-declrations-from-function-expressions branch from c8462ed to cd7636d Compare March 7, 2024 15:00
Comment thread src/compiler/checker.ts
return { accessibility: SymbolAccessibility.Accessible };
}

// Parameters or binding elements from parameters are always visible in their enclosing function declarations

Copy link
Copy Markdown
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.

Comment thread src/compiler/checker.ts

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

Copy link
Copy Markdown
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 Titian Cernicova-Dragomir (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 Titian Cernicova-Dragomir (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
@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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