Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jsii): do not mark "any" or "unknown" as optional (unless "?") #295

Merged
merged 1 commit into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/jsii-calc-base/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
},
"name": "typeName",
"returns": {
"optional": true,
"primitive": "any"
}
}
Expand Down Expand Up @@ -103,5 +102,5 @@
}
},
"version": "0.7.8",
"fingerprint": "K1rAUs6WiQ5lF08T46B8v/5UL8T8Ot59e0Nc8rh2jiQ="
"fingerprint": "FbKHAP60R40tOOnvhCeDrZDrNlgzIypOfAdWPed+Jog="
}
9 changes: 9 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,3 +939,12 @@ export interface IInterfaceWithMethods {
export interface IInterfaceThatShouldNotBeADataType extends IInterfaceWithMethods {
readonly otherValue: string;
}

/**
* jsii#284: do not recognize "any" as an optional argument
*/
export class DoNotRecognizeAnyAsOptional {
public method(_requiredAny: any, _optionalAny?: any, _optionalString?: string) {

}
}
62 changes: 47 additions & 15 deletions packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@
"type": {
"collection": {
"elementtype": {
"optional": true,
"primitive": "any"
},
"kind": "array"
Expand All @@ -394,13 +393,18 @@
"type": {
"collection": {
"elementtype": {
"optional": true,
"primitive": "any"
},
"kind": "map"
}
}
},
{
"name": "anyProperty",
"type": {
"primitive": "any"
}
},
{
"name": "arrayProperty",
"type": {
Expand Down Expand Up @@ -528,7 +532,6 @@
"type": {
"collection": {
"elementtype": {
"optional": true,
"primitive": "any"
},
"kind": "array"
Expand All @@ -540,17 +543,15 @@
"type": {
"collection": {
"elementtype": {
"optional": true,
"primitive": "any"
},
"kind": "map"
}
}
},
{
"name": "anyProperty",
"name": "unknownProperty",
"type": {
"optional": true,
"primitive": "any"
}
},
Expand All @@ -560,13 +561,6 @@
"fqn": "jsii-calc.StringEnum",
"optional": true
}
},
{
"name": "unknownProperty",
"type": {
"optional": true,
"primitive": "any"
}
}
]
},
Expand Down Expand Up @@ -1301,6 +1295,45 @@
],
"name": "DoNotOverridePrivates"
},
"jsii-calc.DoNotRecognizeAnyAsOptional": {
"assembly": "jsii-calc",
"docs": {
"comment": "jsii#284: do not recognize \"any\" as an optional argument"
},
"fqn": "jsii-calc.DoNotRecognizeAnyAsOptional",
"initializer": {
"initializer": true
},
"kind": "class",
"methods": [
{
"name": "method",
"parameters": [
{
"name": "_requiredAny",
"type": {
"primitive": "any"
}
},
{
"name": "_optionalAny",
"type": {
"optional": true,
"primitive": "any"
}
},
{
"name": "_optionalString",
"type": {
"optional": true,
"primitive": "string"
}
}
]
}
],
"name": "DoNotRecognizeAnyAsOptional"
},
"jsii-calc.DoubleTrouble": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.DoubleTrouble",
Expand Down Expand Up @@ -3062,7 +3095,6 @@
{
"name": "value",
"returns": {
"optional": true,
"primitive": "any"
}
}
Expand Down Expand Up @@ -3412,5 +3444,5 @@
}
},
"version": "0.7.8",
"fingerprint": "Xn7Rk17rqR3AaMx3+ssxT0GR1sCWwz0OGC+C8QuLI3A="
"fingerprint": "2BaszImarh4WChl9DFUcygfTpEfXU17fHQT2wgEptfM="
}
2 changes: 2 additions & 0 deletions packages/jsii-java-runtime-test/project/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bin/

!index.js
.idea
pom.xml
Expand Down
2 changes: 2 additions & 0 deletions packages/jsii-java-runtime/project/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bin/

!index.js
.idea
pom.xml
Expand Down
2 changes: 2 additions & 0 deletions packages/jsii-pacmak/test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
**/java/bin/

!*.tgz

Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
},
"name": "typeName",
"returns": {
"optional": true,
"primitive": "any"
}
}
Expand Down Expand Up @@ -103,5 +102,5 @@
}
},
"version": "0.7.8",
"fingerprint": "K1rAUs6WiQ5lF08T46B8v/5UL8T8Ot59e0Nc8rh2jiQ="
"fingerprint": "FbKHAP60R40tOOnvhCeDrZDrNlgzIypOfAdWPed+Jog="
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected Base(DeputyProps props): base(props)
}

/// <returns>the name of the class (to verify native type names are created for derived classes).</returns>
[JsiiMethod("typeName", "{\"primitive\":\"any\",\"optional\":true}", "[]")]
[JsiiMethod("typeName", "{\"primitive\":\"any\"}", "[]")]
public virtual object TypeName()
{
return InvokeInstanceMethod<object>(new object[]{});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ protected Base(final software.amazon.jsii.JsiiObject.InitializationMode mode) {
/**
* @return the name of the class (to verify native type names are created for derived classes).
*/
@javax.annotation.Nullable
public java.lang.Object typeName() {
return this.jsiiCall("typeName", java.lang.Object.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Base
.. py:method:: typeName() -> any

:return: the name of the class (to verify native type names are created for derived classes).
:rtype: any or ``undefined``
:rtype: any


BaseProps (interface)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ Number
*Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>`

:return: the name of the class (to verify native type names are created for derived classes).
:rtype: any or ``undefined``
:rtype: any


.. py:method:: toString() -> string
Expand Down Expand Up @@ -411,7 +411,7 @@ Operation
*Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>`

:return: the name of the class (to verify native type names are created for derived classes).
:rtype: any or ``undefined``
:rtype: any


.. py:attribute:: value
Expand Down Expand Up @@ -528,6 +528,6 @@ Value
*Inherited from* :py:meth:`@scope/jsii-calc-base.Base <@scope/jsii-calc-base.Base.typeName>`

:return: the name of the class (to verify native type names are created for derived classes).
:rtype: any or ``undefined``
:rtype: any


Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@
"type": {
"collection": {
"elementtype": {
"optional": true,
"primitive": "any"
},
"kind": "array"
Expand All @@ -394,13 +393,18 @@
"type": {
"collection": {
"elementtype": {
"optional": true,
"primitive": "any"
},
"kind": "map"
}
}
},
{
"name": "anyProperty",
"type": {
"primitive": "any"
}
},
{
"name": "arrayProperty",
"type": {
Expand Down Expand Up @@ -528,7 +532,6 @@
"type": {
"collection": {
"elementtype": {
"optional": true,
"primitive": "any"
},
"kind": "array"
Expand All @@ -540,17 +543,15 @@
"type": {
"collection": {
"elementtype": {
"optional": true,
"primitive": "any"
},
"kind": "map"
}
}
},
{
"name": "anyProperty",
"name": "unknownProperty",
"type": {
"optional": true,
"primitive": "any"
}
},
Expand All @@ -560,13 +561,6 @@
"fqn": "jsii-calc.StringEnum",
"optional": true
}
},
{
"name": "unknownProperty",
"type": {
"optional": true,
"primitive": "any"
}
}
]
},
Expand Down Expand Up @@ -1301,6 +1295,45 @@
],
"name": "DoNotOverridePrivates"
},
"jsii-calc.DoNotRecognizeAnyAsOptional": {
"assembly": "jsii-calc",
"docs": {
"comment": "jsii#284: do not recognize \"any\" as an optional argument"
},
"fqn": "jsii-calc.DoNotRecognizeAnyAsOptional",
"initializer": {
"initializer": true
},
"kind": "class",
"methods": [
{
"name": "method",
"parameters": [
{
"name": "_requiredAny",
"type": {
"primitive": "any"
}
},
{
"name": "_optionalAny",
"type": {
"optional": true,
"primitive": "any"
}
},
{
"name": "_optionalString",
"type": {
"optional": true,
"primitive": "string"
}
}
]
}
],
"name": "DoNotRecognizeAnyAsOptional"
},
"jsii-calc.DoubleTrouble": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.DoubleTrouble",
Expand Down Expand Up @@ -3062,7 +3095,6 @@
{
"name": "value",
"returns": {
"optional": true,
"primitive": "any"
}
}
Expand Down Expand Up @@ -3412,5 +3444,5 @@
}
},
"version": "0.7.8",
"fingerprint": "Xn7Rk17rqR3AaMx3+ssxT0GR1sCWwz0OGC+C8QuLI3A="
"fingerprint": "2BaszImarh4WChl9DFUcygfTpEfXU17fHQT2wgEptfM="
}