mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-29 00:06:17 -05:00
Add undefined to default-valued parameters
When --strictNullChecks is on
This commit is contained in:
@@ -3206,7 +3206,8 @@ namespace ts {
|
||||
// Use the type of the initializer expression if one is present
|
||||
if (declaration.initializer) {
|
||||
const type = checkDeclarationInitializer(declaration);
|
||||
return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality);
|
||||
const isOptional = declaration.questionToken || (declaration.initializer && declaration.kind === SyntaxKind.Parameter);
|
||||
return addOptionality(type, isOptional && includeOptionality);
|
||||
}
|
||||
|
||||
// If it is a short-hand property assignment, use the type of the identifier
|
||||
|
||||
Reference in New Issue
Block a user