Fix isolatedDeclarations errors for arrow functions with default parameters#3521
Draft
Fix isolatedDeclarations errors for arrow functions with default parameters#3521
Conversation
Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/53d7fd07-d1fd-491c-9d95-c05007af347d Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
…meters Fix pseudochecker to correctly handle parameter optionality and type inference for parameters with default values in function-like expressions: 1. cloneParameters: A parameter with an initializer is now correctly marked as optional only when all subsequent parameters are also optional/initialized/rest, matching the checker's isOptionalParameter. 2. typeFromParameter: When a parameter has both a type annotation and an initializer, and there are required parameters after it, add | undefined to the pseudo type to match the checker's getTypeOfParameter. 3. typeNodeCouldReferToUndefined: Correctly recognize KindUndefinedKeyword as referring to undefined, fixing a known TODO. Agent-Logs-Url: https://github.com/microsoft/typescript-go/sessions/53d7fd07-d1fd-491c-9d95-c05007af347d Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix isolatedDeclarations error with arrow functions
Fix isolatedDeclarations errors for arrow functions with default parameters
Apr 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
isolatedDeclarationsincorrectly reported TS9025/TS9013 errors on arrow function parameters that have both type annotations and default values when followed by required parameters:Root cause: the pseudochecker's pseudo type for these parameters didn't match the checker's type during the equivalence check in
serializeTypeForDeclaration, causing spuriousReportInferenceFallbackcalls.Three fixes in
internal/pseudochecker/lookup.go:cloneParameters: Was unconditionally settingOptional=truefor parameters with initializers. Now matches the checker'sisOptionalParametersemantics — a parameter with an initializer is optional only when all subsequent parameters are also optional/initialized/rest.typeFromParameter: When a typed parameter has an initializer and is followed by required parameters, the pseudo type now includes| undefinedto matchgetTypeOfParameter.typeNodeCouldReferToUndefined:KindUndefinedKeywordwas falling through to the defaultreturn falsecase (flagged by an existing TODO comment), causingstring | undefinedannotations to not be recognized as already containing undefined.Also improves convergence with tsc on
isolatedDeclarationsAddUndefined(2 errors → 1, matching tsc's count).