Skip to content

Commit

Permalink
Fixed optional constructor properties.
Browse files Browse the repository at this point in the history
Signed-off-by: Titian Cernicova-Dragomir <tcernicovad1@bloomberg.net>
  • Loading branch information
dragomirtitian committed Nov 27, 2023
1 parent 867e100 commit 3199057
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 5 deletions.
26 changes: 23 additions & 3 deletions src/compiler/transformers/declarations/localInferenceResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
LiteralExpression,
MethodDeclaration,
MethodSignature,
ModifierFlags,
Node,
NodeArray,
NodeFlags,
Expand All @@ -83,7 +84,9 @@ import {
} from "../../types";
import {
createDiagnosticForNode,
hasSyntacticModifier,
isEntityNameExpression,
isOptionalDeclaration,
} from "../../utilities";
import {
isConstTypeReference,
Expand Down Expand Up @@ -745,8 +748,22 @@ export function createLocalInferenceResolver({
localType = invalid(node);
}

if (node.initializer && !(localType.flags & LocalTypeInfoFlags.Invalid) && strictNullChecks && !resolver.isOptionalParameter(node)) {
localType.typeNode = addUndefinedInUnion(localType.typeNode);
if (strictNullChecks && !(localType.flags & LocalTypeInfoFlags.Invalid)) {
const isOptional = resolver.isOptionalParameter(node);
/**
* If a parameter with a default value is not optional we need to add undefined
* function x(o = "", v: string)
*/
if (node.initializer && !isOptional) {
localType.typeNode = addUndefinedInUnion(localType.typeNode);
}
/**
* Constructor properties that are optional must have | undefined included to work well with exactOptionalPropertyTypes
* constructor(public x?: number) -> x?: number | undefined
*/
if (isOptional && !node.initializer && hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier)) {
localType.typeNode = addUndefinedInUnion(localType.typeNode);
}
}
}
else if (type) {
Expand All @@ -764,14 +781,17 @@ export function createLocalInferenceResolver({
localType = invalid(node);
}
else if (isClassExpression(node.initializer)) {
localType = invalid(node.initializer, Diagnostics.Declaration_emit_for_class_expressions_are_not_supported_with_isolatedDeclarations)
localType = invalid(node.initializer, Diagnostics.Declaration_emit_for_class_expressions_are_not_supported_with_isolatedDeclarations);
}
else {
localType = localInference(node.initializer, node.parent.flags & NodeFlags.Const ? NarrowBehavior.KeepLiterals : NarrowBehavior.None);
}
}
else if (isPropertyDeclaration(node) && node.initializer) {
localType = localInference(node.initializer);
if (isOptionalDeclaration(node)) {
localType.typeNode = addUndefinedInUnion(localType.typeNode);
}
}
else if (isInterfaceDeclaration(node.parent) || isTypeLiteralNode(node.parent)) {
return factory.createKeywordTypeNode(SyntaxKind.AnyKeyword);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// [[Reason: Sourcemap is more detailed]] ////

//// [tests/cases/compiler/declarationEmitParameterProperty.ts] ////

===================================================================
--- TSC declarations
+++ DTE declarations
@@ -1,6 +1,6 @@

//// [declarationEmitParameterProperty.d.ts.map]
-{"version":3,"file":"declarationEmitParameterProperty.d.ts","sourceRoot":"","sources":["declarationEmitParameterProperty.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACK,GAAG,CAAC;gBAAJ,GAAG,CAAC,oBAAQ;CAEhC"}
+{"version":3,"file":"declarationEmitParameterProperty.d.ts","sourceRoot":"","sources":["declarationEmitParameterProperty.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACK,GAAG,CAAC,EAAE,MAAM;gBAAZ,GAAG,CAAC,EAAE,MAAM,YAAA;CAEhC"}

-//// https://sokra.github.io/source-map-visualization#base64,ZXhwb3J0IGRlY2xhcmUgY2xhc3MgRm9vIHsNCiAgICBiYXI/OiBzdHJpbmcgfCB1bmRlZmluZWQ7DQogICAgY29uc3RydWN0b3IoYmFyPzogc3RyaW5nIHwgdW5kZWZpbmVkKTsNCn0NCi8vIyBzb3VyY2VNYXBwaW5nVVJMPWRlY2xhcmF0aW9uRW1pdFBhcmFtZXRlclByb3BlcnR5LmQudHMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjbGFyYXRpb25FbWl0UGFyYW1ldGVyUHJvcGVydHkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImRlY2xhcmF0aW9uRW1pdFBhcmFtZXRlclByb3BlcnR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHFCQUFhLEdBQUc7SUFDSyxHQUFHLENBQUM7Z0JBQUosR0FBRyxDQUFDLG9CQUFRO0NBRWhDIn0=,ZXhwb3J0IGNsYXNzIEZvbyB7CiAgY29uc3RydWN0b3IocHVibGljIGJhcj86IHN0cmluZykgewogIH0KfQo=
+//// https://sokra.github.io/source-map-visualization#base64,ZXhwb3J0IGRlY2xhcmUgY2xhc3MgRm9vIHsNCiAgICBiYXI/OiBzdHJpbmcgfCB1bmRlZmluZWQ7DQogICAgY29uc3RydWN0b3IoYmFyPzogc3RyaW5nIHwgdW5kZWZpbmVkKTsNCn0NCi8vIyBzb3VyY2VNYXBwaW5nVVJMPWRlY2xhcmF0aW9uRW1pdFBhcmFtZXRlclByb3BlcnR5LmQudHMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjbGFyYXRpb25FbWl0UGFyYW1ldGVyUHJvcGVydHkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImRlY2xhcmF0aW9uRW1pdFBhcmFtZXRlclByb3BlcnR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHFCQUFhLEdBQUc7SUFDSyxHQUFHLENBQUMsRUFBRSxNQUFNO2dCQUFaLEdBQUcsQ0FBQyxFQUFFLE1BQU0sWUFBQTtDQUVoQyJ9,ZXhwb3J0IGNsYXNzIEZvbyB7CiAgY29uc3RydWN0b3IocHVibGljIGJhcj86IHN0cmluZykgewogIH0KfQo=

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// [[Reason: Sourcemap is more detailed]] ////

//// [tests/cases/conformance/types/namedTypes/optionalMethods.ts] ////

===================================================================
--- TSC declarations
+++ DTE declarations
@@ -1,6 +1,6 @@

//// [optionalMethods.d.ts.map]
-{"version":3,"file":"optionalMethods.d.ts","sourceRoot":"","sources":["optionalMethods.ts"],"names":[],"mappings":"AAAA,UAAU,GAAG;IACT,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,IAAI,MAAM,CAAC;IACZ,CAAC,CAAC,IAAI,MAAM,CAAC;CAChB;AAED,iBAAS,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAQ3B;AAED,cAAM,GAAG;IAIc,CAAC,CAAC;IAAiB,CAAC;IAHvC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,qBAAK;gBACY,CAAC,CAAC,oBAAQ,EAAS,CAAC,SAAK;IAC5C,CAAC,IAAI,MAAM;IAGX,CAAC,CAAC,IAAI,MAAM;IACZ,CAAC,CAAC,IAAI,MAAM;CAGf;AAED,iBAAS,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAa3B;AAED,cAAM,IAAI;IACN,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,IAAI,MAAM;CACf;AAED,cAAM,OAAQ,SAAQ,IAAI;IACtB,CAAC,SAAK;IACN,CAAC,IAAI,MAAM;CACd"}
+{"version":3,"file":"optionalMethods.d.ts","sourceRoot":"","sources":["optionalMethods.ts"],"names":[],"mappings":"AAAA,UAAU,GAAG;IACT,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,IAAI,MAAM,CAAC;IACZ,CAAC,CAAC,IAAI,MAAM,CAAC;CAChB;AAED,iBAAS,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAQ3B;AAED,cAAM,GAAG;IAIc,CAAC,CAAC,EAAE,MAAM;IAAS,CAAC;IAHvC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,qBAAK;gBACY,CAAC,CAAC,EAAE,MAAM,YAAA,EAAS,CAAC,SAAK;IAC5C,CAAC,IAAI,MAAM;IAGX,CAAC,CAAC,IAAI,MAAM;IACZ,CAAC,CAAC,IAAI,MAAM;CAGf;AAED,iBAAS,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAa3B;AAED,cAAM,IAAI;IACN,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,IAAI,MAAM;CACf;AAED,cAAM,OAAQ,SAAQ,IAAI;IACtB,CAAC,SAAK;IACN,CAAC,IAAI,MAAM;CACd"}

-//// https://sokra.github.io/source-map-visualization#base64,aW50ZXJmYWNlIEZvbyB7DQogICAgYTogbnVtYmVyOw0KICAgIGI/OiBudW1iZXI7DQogICAgZigpOiBudW1iZXI7DQogICAgZz8oKTogbnVtYmVyOw0KfQ0KZGVjbGFyZSBmdW5jdGlvbiB0ZXN0MSh4OiBGb28pOiB2b2lkOw0KZGVjbGFyZSBjbGFzcyBCYXIgew0KICAgIGQ/OiBudW1iZXIgfCB1bmRlZmluZWQ7DQogICAgZTogbnVtYmVyOw0KICAgIGE6IG51bWJlcjsNCiAgICBiPzogbnVtYmVyOw0KICAgIGM/OiBudW1iZXIgfCB1bmRlZmluZWQ7DQogICAgY29uc3RydWN0b3IoZD86IG51bWJlciB8IHVuZGVmaW5lZCwgZT86IG51bWJlcik7DQogICAgZigpOiBudW1iZXI7DQogICAgZz8oKTogbnVtYmVyOw0KICAgIGg/KCk6IG51bWJlcjsNCn0NCmRlY2xhcmUgZnVuY3Rpb24gdGVzdDIoeDogQmFyKTogdm9pZDsNCmRlY2xhcmUgY2xhc3MgQmFzZSB7DQogICAgYT86IG51bWJlcjsNCiAgICBmPygpOiBudW1iZXI7DQp9DQpkZWNsYXJlIGNsYXNzIERlcml2ZWQgZXh0ZW5kcyBCYXNlIHsNCiAgICBhOiBudW1iZXI7DQogICAgZigpOiBudW1iZXI7DQp9DQovLyMgc291cmNlTWFwcGluZ1VSTD1vcHRpb25hbE1ldGhvZHMuZC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BudW1iZXI7CiAgICBnPygpOiBudW1iZXI7Cn0KCmZ1bmN0aW9uIHRlc3QxKHg6IEZvbyk6IHZvaWQgewogICAgeC5hOwogICAgeC5iOwogICAgeC5mOwogICAgeC5nOwogICAgbGV0IGYxID0geC5mKCk7CiAgICBsZXQgZzEgPSB4LmcgJiYgeC5nKCk7CiAgICBsZXQgZzIgPSB4LmcgPyB4LmcoKSA6IDA7Cn0KCmNsYXNzIEJhciB7CiAgICBhOiBudW1iZXI7CiAgICBiPzogbnVtYmVyOwogICAgYz8gPSAyOwogICAgY29uc3RydWN0b3IocHVibGljIGQ/OiBudW1iZXIsIHB1YmxpYyBlID0gMTApIHt9CiAgICBmKCk6IG51bWJlciB7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICBnPygpOiBudW1iZXI7ICAvLyBCb2R5IG9mIG9wdGlvbmFsIG1ldGhvZCBjYW4gYmUgb21pdHRlZAogICAgaD8oKTogbnVtYmVyIHsKICAgICAgICByZXR1cm4gMjsKICAgIH0KfQoKZnVuY3Rpb24gdGVzdDIoeDogQmFyKTogdm9pZCB7CiAgICB4LmE7CiAgICB4LmI7CiAgICB4LmM7CiAgICB4LmQ7CiAgICB4LmU7CiAgICB4LmY7CiAgICB4Lmc7CiAgICBsZXQgZjEgPSB4LmYoKTsKICAgIGxldCBnMSA9IHguZyAmJiB4LmcoKTsKICAgIGxldCBnMiA9IHguZyA/IHguZygpIDogMDsKICAgIGxldCBoMSA9IHguaCAmJiB4LmgoKTsKICAgIGxldCBoMiA9IHguaCA/IHguaCgpIDogMDsKfQoKY2xhc3MgQmFzZSB7CiAgICBhPzogbnVtYmVyOwogICAgZj8oKTogbnVtYmVyOwp9CgpjbGFzcyBEZXJpdmVkIGV4dGVuZHMgQmFzZSB7CiAgICBhID0gMTsKICAgIGYoKTogbnVtYmVyIHsgcmV0dXJuIDE7IH0KfQo=
+//// https://sokra.github.io/source-map-visualization#base64,aW50ZXJmYWNlIEZvbyB7DQogICAgYTogbnVt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BudW1iZXIsIHB1YmxpYyBlID0gMTApIHt9CiAgICBmKCk6IG51bWJlciB7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CiAgICBnPygpOiBudW1iZXI7ICAvLyBCb2R5IG9mIG9wdGlvbmFsIG1ldGhvZCBjYW4gYmUgb21pdHRlZAogICAgaD8oKTogbnVtYmVyIHsKICAgICAgICByZXR1cm4gMjsKICAgIH0KfQoKZnVuY3Rpb24gdGVzdDIoeDogQmFyKTogdm9pZCB7CiAgICB4LmE7CiAgICB4LmI7CiAgICB4LmM7CiAgICB4LmQ7CiAgICB4LmU7CiAgICB4LmY7CiAgICB4Lmc7CiAgICBsZXQgZjEgPSB4LmYoKTsKICAgIGxldCBnMSA9IHguZyAmJiB4LmcoKTsKICAgIGxldCBnMiA9IHguZyA/IHguZygpIDogMDsKICAgIGxldCBoMSA9IHguaCAmJiB4LmgoKTsKICAgIGxldCBoMiA9IHguaCA/IHguaCgpIDogMDsKfQoKY2xhc3MgQmFzZSB7CiAgICBhPzogbnVtYmVyOwogICAgZj8oKTogbnVtYmVyOwp9CgpjbGFzcyBEZXJpdmVkIGV4dGVuZHMgQmFzZSB7CiAgICBhID0gMTsKICAgIGYoKTogbnVtYmVyIHsgcmV0dXJuIDE7IH0KfQo=

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//// [tests/cases/compiler/declarationEmitParameterProperty.ts] ////



/// [Declarations] ////



//// [declarationEmitParameterProperty.d.ts]
export declare class Foo {
bar?: string | undefined;
constructor(bar?: string | undefined);
}
//# sourceMappingURL=declarationEmitParameterProperty.d.ts.map

/// [Declarations Maps] ////


//// [declarationEmitParameterProperty.d.ts.map]
{"version":3,"file":"declarationEmitParameterProperty.d.ts","sourceRoot":"","sources":["declarationEmitParameterProperty.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACK,GAAG,CAAC,EAAE,MAAM;gBAAZ,GAAG,CAAC,EAAE,MAAM,YAAA;CAEhC"}

//// https://sokra.github.io/source-map-visualization#base64,ZXhwb3J0IGRlY2xhcmUgY2xhc3MgRm9vIHsNCiAgICBiYXI/OiBzdHJpbmcgfCB1bmRlZmluZWQ7DQogICAgY29uc3RydWN0b3IoYmFyPzogc3RyaW5nIHwgdW5kZWZpbmVkKTsNCn0NCi8vIyBzb3VyY2VNYXBwaW5nVVJMPWRlY2xhcmF0aW9uRW1pdFBhcmFtZXRlclByb3BlcnR5LmQudHMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjbGFyYXRpb25FbWl0UGFyYW1ldGVyUHJvcGVydHkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImRlY2xhcmF0aW9uRW1pdFBhcmFtZXRlclByb3BlcnR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHFCQUFhLEdBQUc7SUFDSyxHQUFHLENBQUMsRUFBRSxNQUFNO2dCQUFaLEdBQUcsQ0FBQyxFQUFFLE1BQU0sWUFBQTtDQUVoQyJ9,ZXhwb3J0IGNsYXNzIEZvbyB7CiAgY29uc3RydWN0b3IocHVibGljIGJhcj86IHN0cmluZykgewogIH0KfQo=

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//// [tests/cases/conformance/types/namedTypes/optionalMethods.ts] ////



/// [Declarations] ////



//// [optionalMethods.d.ts]
interface Foo {
a: number;
b?: number;
f(): number;
g?(): number;
}
declare function test1(x: Foo): void;
declare class Bar {
d?: number | undefined;
e: number;
a: number;
b?: number;
c?: number | undefined;
constructor(d?: number | undefined, e?: number);
f(): number;
g?(): number;
h?(): number;
}
declare function test2(x: Bar): void;
declare class Base {
a?: number;
f?(): number;
}
declare class Derived extends Base {
a: number;
f(): number;
}
//# sourceMappingURL=optionalMethods.d.ts.map

/// [Declarations Maps] ////


//// [optionalMethods.d.ts.map]
{"version":3,"file":"optionalMethods.d.ts","sourceRoot":"","sources":["optionalMethods.ts"],"names":[],"mappings":"AAAA,UAAU,GAAG;IACT,CAAC,EAAE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coKTsKICAgIGxldCBnMiA9IHguZyA/IHguZygpIDogMDsKICAgIGxldCBoMSA9IHguaCAmJiB4LmgoKTsKICAgIGxldCBoMiA9IHguaCA/IHguaCgpIDogMDsKfQoKY2xhc3MgQmFzZSB7CiAgICBhPzogbnVtYmVyOwogICAgZj8oKTogbnVtYmVyOwp9CgpjbGFzcyBEZXJpdmVkIGV4dGVuZHMgQmFzZSB7CiAgICBhID0gMTsKICAgIGYoKTogbnVtYmVyIHsgcmV0dXJuIDE7IH0KfQo=

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//// [tests/cases/compiler/declarationEmitParameterProperty.ts] ////



/// [Declarations] ////



//// [declarationEmitParameterProperty.d.ts]
export declare class Foo {
bar?: string | undefined;
constructor(bar?: string | undefined);
}
//# sourceMappingURL=declarationEmitParameterProperty.d.ts.map

/// [Declarations Maps] ////


//// [declarationEmitParameterProperty.d.ts.map]
{"version":3,"file":"declarationEmitParameterProperty.d.ts","sourceRoot":"","sources":["declarationEmitParameterProperty.ts"],"names":[],"mappings":"AAAA,qBAAa,GAAG;IACK,GAAG,CAAC;gBAAJ,GAAG,CAAC,oBAAQ;CAEhC"}

//// https://sokra.github.io/source-map-visualization#base64,ZXhwb3J0IGRlY2xhcmUgY2xhc3MgRm9vIHsNCiAgICBiYXI/OiBzdHJpbmcgfCB1bmRlZmluZWQ7DQogICAgY29uc3RydWN0b3IoYmFyPzogc3RyaW5nIHwgdW5kZWZpbmVkKTsNCn0NCi8vIyBzb3VyY2VNYXBwaW5nVVJMPWRlY2xhcmF0aW9uRW1pdFBhcmFtZXRlclByb3BlcnR5LmQudHMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVjbGFyYXRpb25FbWl0UGFyYW1ldGVyUHJvcGVydHkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImRlY2xhcmF0aW9uRW1pdFBhcmFtZXRlclByb3BlcnR5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLHFCQUFhLEdBQUc7SUFDSyxHQUFHLENBQUM7Z0JBQUosR0FBRyxDQUFDLG9CQUFRO0NBRWhDIn0=,ZXhwb3J0IGNsYXNzIEZvbyB7CiAgY29uc3RydWN0b3IocHVibGljIGJhcj86IHN0cmluZykgewogIH0KfQo=

Loading

0 comments on commit 3199057

Please sign in to comment.