The Wayback Machine - http://web.archive.org/web/20200914124159/https://github.com/angular/tsickle/pull/1165
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

Migrate tsickle to TypeScript 4.0. #1165

Open
wants to merge 2 commits into
base: master
from
Open

Migrate tsickle to TypeScript 4.0. #1165

wants to merge 2 commits into from

Conversation

@mprobst
Copy link
Collaborator

mprobst commented Jul 22, 2020

This mostly involves adjusting a number of callsites to the new
ts.factory API instead of the previous ts.getMutableClone.

Additionally it required several test changes:

  • an unspecified global this no longer is any
  • properties may no longer override getters
  • stricter checks of property initialization
@mprobst mprobst requested a review from rrdelaney Jul 22, 2020
@googlebot googlebot added the cla: yes label Jul 22, 2020
@mprobst mprobst force-pushed the ts4 branch 2 times, most recently from 27b1525 to 95e07c9 Jul 22, 2020
@@ -11,7 +11,7 @@
"src/*"
],
"peerDependencies": {
"typescript": "~3.9.5"
"typescript": "^4.0.0-dev"

This comment has been minimized.

@evmar

evmar Jul 22, 2020

Collaborator

We should use patterns like ~4.0 so that we don't implicitly pull in e.g. 4.1.

This comment has been minimized.

@mprobst

mprobst Jul 22, 2020

Author Collaborator

I went with ~4.0.0-dev so that we get the dev packages and patch levels in 4.0, but not 4.1

// as otherwise TS fails when resolving types for decorators.
sf = ts.getMutableClone(sf);
sf.statements = statements;
sf = ts.factory.updateSourceFile(

This comment has been minimized.

@evmar

evmar Jul 22, 2020

Collaborator

Man, I just copied the old pattern into my current project too...

const s = await 3;
return s + this.field;
return s + (this as any).field;

This comment has been minimized.

@evmar

evmar Jul 22, 2020

Collaborator

I think this isn't right, and might break dis/ambguation.

I can't tell from this change if it's meant to be a workaround, or if we expect user code to change in the same way?

This comment has been minimized.

@mprobst

mprobst Jul 22, 2020

Author Collaborator

Good catch. I was playing around with this and didn't remove the as any cast again. This ultimately didn't need a change I think.

This comment has been minimized.

@mprobst

mprobst Jul 22, 2020

Author Collaborator

The tricky bit is that TS compiler now disallows having a function without the this type specified here, so I needed to add an explicit this param type. That means a code path in tsickle is now under-exercised (never have a nested fn that needs a this * added), but I think that's OK.

@mprobst mprobst force-pushed the ts4 branch 2 times, most recently from e4a43ce to 4628180 Jul 22, 2020
Copy link
Collaborator

rrdelaney left a comment

LGTM. Should we get this working internally first, then sync it out from there? I think if this is merged and intermediate changes to tsickle will overwrite these changes.

@mprobst
Copy link
Collaborator Author

mprobst commented Jul 23, 2020

@rrdelaney we can keep it in this branch for the time being. I'll create an internal CL that we can patch to test the new version.

mprobst added 2 commits Jul 22, 2020
This mostly involves adjusting a number of callsites to the new
`ts.factory` API instead of the previous `ts.getMutableClone`.

Additionally it required several test changes:
- an unspecified global this no longer is any
- properties may no longer override getters
- stricter checks of property initialization
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.