Skip to content

Commit

Permalink
feat(jsii-spec): Model parameter optionality
Browse files Browse the repository at this point in the history
Method `Parameters` now carry an `optional` flag that indicates whether
they are optional or required, and the `TypeReference#optional` field
was renamed to `TypeReference#nullable` to better reflect its semantics.

This also brings more flexibility in that it is now possible to model a
method with a nullable or defaulted argument that is followed by some
non-optional argument, and still obtain a reasonable type specification,
where previously this was an error.

Finally, in order to better reflect the type model of TypeScript and
Javascript, all `any` type references are now denoted `nullable`.

BREAKING CHANGE: JSII assemblies generated by older versions of the tool
will fail loading with this new version, and vice-versa. Re-compile your
projects in order to fix this.

Fixes #296
Fixes #414
  • Loading branch information
RomainMuller committed Apr 4, 2019
1 parent afbabff commit a772323
Show file tree
Hide file tree
Showing 123 changed files with 2,159 additions and 2,182 deletions.
2,794 changes: 1,401 additions & 1,393 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"lerna": "^3.13.1",
"nodeunit": "^0.11.3",
"nyc": "^13.3.0",
"tslint": "^5.13.0",
"typescript": "^3.3.3333"
"tslint": "^5.15.0",
"typescript": "^3.4.1"
}
}
8 changes: 4 additions & 4 deletions packages/codemaker/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/codemaker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@types/node": "^8.10.43",
"@types/nodeunit": "^0.0.30",
"nodeunit": "^0.11.3",
"typescript": "^3.3.3333"
"typescript": "^3.4.1"
},
"dependencies": {
"camelcase": "^5.2.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/jsii-calc-base/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
},
"name": "typeName",
"returns": {
"nullable": true,
"primitive": "any"
}
}
Expand Down Expand Up @@ -112,5 +113,5 @@
}
},
"version": "0.8.2",
"fingerprint": "lIcHicx5rBBxyy5vOvOqvbBGjk//8lFLX6oVx2xh5Fc="
"fingerprint": "f/Vo5ezvqYp8jwokKJftL6t8IIXU2GGM17L/jKRF2oQ="
}
10 changes: 5 additions & 5 deletions packages/jsii-calc-lib/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
},
"kind": "array"
},
"optional": true
"nullable": true
}
}
]
Expand Down Expand Up @@ -307,7 +307,7 @@
"immutable": true,
"name": "optional1",
"type": {
"optional": true,
"nullable": true,
"primitive": "string"
}
},
Expand All @@ -316,7 +316,7 @@
"immutable": true,
"name": "optional2",
"type": {
"optional": true,
"nullable": true,
"primitive": "number"
}
},
Expand All @@ -325,7 +325,7 @@
"immutable": true,
"name": "optional3",
"type": {
"optional": true,
"nullable": true,
"primitive": "boolean"
}
}
Expand Down Expand Up @@ -373,5 +373,5 @@
}
},
"version": "0.8.2",
"fingerprint": "SDQQzBvYRO3SXfWWgpKwLDSy3EgMqP/e6rd75kblKA0="
"fingerprint": "Y9xi2LtDOP8ebtxdHcYvi9Bo9Gj/JbjNJ5GP22d3dJk="
}
Loading

0 comments on commit a772323

Please sign in to comment.