From 995732fad27ed88d0b2d75333b72e53c0f8eb5e2 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 3 Nov 2016 15:35:10 -0700 Subject: [PATCH] Add undefined to default-valued parameters When --strictNullChecks is on --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 28b14502af9..a459db40e1b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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