Skip to content

fix(jsii): use base interfaces for 'datatype' property#265

Merged
rix0rrr merged 3 commits intomasterfrom
huijbers/inherited-datatypes
Oct 16, 2018
Merged

fix(jsii): use base interfaces for 'datatype' property#265
rix0rrr merged 3 commits intomasterfrom
huijbers/inherited-datatypes

Conversation

@rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Oct 16, 2018

If an interface inherits from a non-datatype interface, it should no
longer be classified as a datatype interface itself.

Making this change requires that information about the base classes
has already been determined, so I introduced an ordering mechanism
for 'deferred's.

Fixes #264.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

If an interface inherits from a non-datatype interface, it should no
longer be classified as a datatype interface itself.

Making this change requires that information about the base classes
has already been determined, so I introduced an ordering mechanism
for 'deferred's.

Fixes #264.
*/
private _defer(cb: () => void) {
this._deferred.push(cb.bind(this));
private _defer(fqn: string, depFqns: string[], cb: () => void) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just inline this method into _deferUntilTypeAvailable so people won't be tempted to use this sketchy mechanism

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree that it's sketchy--it's running some analysis in a guaranteed order. I was debating whether to rewrite the whole assembler into two phases, first collect all types and relationships between types, then do the regular processing in order.

Part of the processing doesn't require the base types though, so I ultimately decided it would be a lower-impact change to leave the standalone analysis in the first pass and only do the analysis that requires base types in the second pass--and the "deferred" mechanism could be extended easily enough to accomodate the ordering required for that second pass.

Now, whether or not it should be inlined is another case. In principle the ordered analysis method is more general than it's being used for right now. It doesn't NEED to work on NamedTypeReferences that are dereferenced... just so happens that all places where it's being used use that pattern, so I extracted that out again. I don't think it hurts to show there are two layers to it.


interface DeferredRecord {
fqn: string;
depFqns: string[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some doc comments would be welcome here... Is "dep" for "depended" or "depending" ?

* that case anyway.
*/
// tslint:disable-next-line:max-line-length
private _deferUntilTypeAvailable(fqn: string, baseTypes: NamedTypeReference[], referencingNode: ts.Node, cb: (...xs: spec.Type[]) => void) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it not be _deferUntilType+s+Available?
I would also like it if the doc had @params.

@rix0rrr rix0rrr merged commit 1c56902 into master Oct 16, 2018
@rix0rrr rix0rrr deleted the huijbers/inherited-datatypes branch October 16, 2018 13:03
rix0rrr pushed a commit that referenced this pull request Oct 23, 2018
* **jsii:** use base interfaces for 'datatype' property ([#265](#265)) ([1c56902](1c56902)), closes [#264](#264)
* **jsii:** use default jsx compiler options ([#261](#261)) ([bf1f586](bf1f586)), closes [aws/aws-cdk#830](aws/aws-cdk#830)
* match behavioral interface to 'I'-prefix ([#271](#271)) ([03103f3](03103f3))
* require distinct argument and property names ([#272](#272)) ([4d2f268](4d2f268)), closes [#268](#268)
@rix0rrr rix0rrr mentioned this pull request Oct 23, 2018
rix0rrr added a commit that referenced this pull request Oct 23, 2018
Bug Fixes
=======

* **jsii:** use base interfaces for 'datatype' property ([#265](#265)) ([1c56902](1c56902)), closes [#264](#264)
* **jsii:** use default jsx compiler options ([#261](#261)) ([bf1f586](bf1f586)), closes [aws/aws-cdk#830](aws/aws-cdk#830)
* match behavioral interface to 'I'-prefix ([#271](#271)) ([03103f3](03103f3))
* require distinct argument and property names ([#272](#272)) ([4d2f268](4d2f268)), closes [#268](#268)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants