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 typing for 'Lifted<T>' to work better across versions of TS #3658

Merged
merged 3 commits into from
Dec 13, 2019

Conversation

CyrusNajmabadi
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Dec 13, 2019

This should likely go out in a 1.7.1 release.

This addresses the issue that with some versions of TS, using @pulumi/pulumi sxs with previous versions could cause assignability errors between Output<any> and Output<any>.

// Output<T> = OutputInstance<T> & Lifted<T>
// so returning an empty object just means that we're adding nothing to Output<T>.
// This is needed for cases like `Output<any>`.
{};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this happened due to the removal of T extends Resource ? { } : ... that came in: ad4da29#diff-b7a9c3c1793336a377df01cb5e0e9f40

Previously, the any cases in Output<any> would be caught by this, effectively adding no members to Output<any>. i.e. Output<any> = OutputInstance<any> & {} TS seems to have refined things slightly so that this now becomes Output<any> = OutputInstance<any> & Lifted<{}> which it feels is no longer compatible because objects are indexable.

My theory is that this fell out of TS 3.7's recursive type aliases work (something which we could benefit from). Basically, instead of aggressively flattening the type, they lazily do it, but it means that they can see different types here which now triggers some subtle assignability issue.

Regardless, the above should be strictly better and works downlevel and on 3.7. It does really indicate what we want, namely that only 'objects/arrays' should have their properties lifted up, and anything else should not participate in lifting.

@@ -3,7 +3,7 @@
"version": "${VERSION}",
"license": "Apache-2.0",
"dependencies": {
"@pulumi/pulumi": "latest"
"@pulumi/pulumi": "=1.6.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: i need to lock against pulumi 1.6 because 1.7.1 is not compatible with 1.7.0 (because of this very issue we are fixing). Effectively 1.7.0 is hte screwup one that we need to overlook. Once 1.7.1 is in, we can unlock this and validate that future versions are compatible with 1.7.1

# will be renabled once that goes in.
# pushd tests/sxs && yarn && tsc && popd
pushd tests/sxs_ts_3.6 && yarn && tsc && popd
pushd tests/sxs_ts_latest && yarn && tsc && popd
Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to actually test different versions of ts. I don't like that this is done with copy/pasting the test. ideally we could truly have a matrix here where we test a whole bunch of combinations. But i think this approach is acceptable for now given the time and amount of work we have.

Copy link
Member

@lukehoban lukehoban left a comment

Choose a reason for hiding this comment

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

LGTM

@CyrusNajmabadi CyrusNajmabadi changed the title Fix typeing for 'Lifted<T>' to work better across versions of TS Fix typing for 'Lifted<T>' to work better across versions of TS Dec 13, 2019
@CyrusNajmabadi CyrusNajmabadi merged commit 9151d48 into master Dec 13, 2019
@pulumi-bot pulumi-bot deleted the liftedTypings branch December 13, 2019 19:18
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.

None yet

2 participants