mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Add only 'undefined' to optional parameter types
This commit is contained in:
1 parent
436e70ea8f
commit
a0790fba7d
1 file changed
+2
-2
@@ -2698,7 +2698,7 @@ namespace ts {
|
||||
// Use type from type annotation if one is present
|
||||
if (declaration.type) {
|
||||
const type = getTypeFromTypeNode(declaration.type);
|
||||
return declaration.questionToken ? getNullableType(type) : type;
|
||||
return strictNullChecks && declaration.questionToken ? addNullableKind(type, TypeFlags.Undefined) : type;
|
||||
}
|
||||
|
||||
if (declaration.kind === SyntaxKind.Parameter) {
|
||||
@@ -2713,7 +2713,7 @@ namespace ts {
|
||||
// Use contextual parameter type if one is available
|
||||
const type = getContextuallyTypedParameterType(<ParameterDeclaration>declaration);
|
||||
if (type) {
|
||||
return declaration.questionToken ? getNullableType(type) : type;
|
||||
return strictNullChecks && declaration.questionToken ? addNullableKind(type, TypeFlags.Undefined) : type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user