Strip literal freshness of contextually typed literals - #49884
Conversation
|
TypeScript Bot (@typescript-bot) user test this inline |
|
Heya Andrew Branch (@andrewbranch), I've started to run the parallelized Definitely Typed test suite on this PR at b9709fb. You can monitor the build here. |
|
Heya Andrew Branch (@andrewbranch), I've started to run the perf test suite on this PR at b9709fb. You can monitor the build here. Update: The results are in! |
|
Heya Andrew Branch (@andrewbranch), I've started to run the abridged perf test suite on this PR at b9709fb. You can monitor the build here. Update: The results are in! |
|
Heya Andrew Branch (@andrewbranch), I've started to run the diff-based user code test suite on this PR at b9709fb. You can monitor the build here. Update: The results are in! |
|
Andrew Branch (@andrewbranch) Here they are:Comparison Report - main..refs/pull/49884/merge puppeteer4 of 4 projects failed to build with the old tsc /mnt/ts_downloads/puppeteer/scripts/tsconfig.json
/mnt/ts_downloads/puppeteer/tsconfig.json
|
|
Andrew Branch (@andrewbranch) Here they are:
CompilerComparison Report - main..49884
System
Hosts
Scenarios
TSServerComparison Report - main..49884
System
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Andrew Branch (@andrewbranch) Here they are:Comparison Report - main..49884
System
Hosts
Scenarios
Developer Information: |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Anders Hejlsberg (ahejlsberg)
left a comment
There was a problem hiding this comment.
Looks good to me. Definitely seems wrong to infer fresh literal types for array literal elements and object literal properties.
|
The puppeteer failure shows that const PUPPETEER_REVISIONS = Object.freeze({
chromium: '1011831',
firefox: 'latest',
});
let preferredRevision = PUPPETEER_REVISIONS.chromium; // Previously string, now "1011931"
preferredRevision = PUPPETEER_REVISIONS.firefox; // Previously ok, now error |
|
Ah yes, I see there's some cleverness in the |
|
Would it be possible to get a test build with this? I'd like to test if I can get rid of basically a ton of |
|
TypeScript Bot (@typescript-bot) pack this |
|
Doesn't look like that worked Andrew Branch (@andrewbranch) |
|
TypeScript Bot (@typescript-bot) pack this |
|
Heya Ryan Cavanaugh (@RyanCavanaugh), I've started to run the tarball bundle task on this PR at d2ff6b8. You can monitor the build here. |
|
Hey Ryan Cavanaugh (@RyanCavanaugh), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build and an npm module you can use via |
|
Thanks! Doesn't seem to affect my use case though. |
|
Andrew Branch (@andrewbranch) I assume this is 4.9-bound, right? |
Is there a proposed workaround for this? I am having the same issue here. #52125 I think this new behaviour goes against JavaScript's syntax. In the example you gave above, I think it is fine to do the re-assignment but now we have TypeScript telling us that it is an error. In my use case, creating an array from an immutable object and running includes on that array should not throw a type error. With this breaking change, does this mean that to get around this, we need to do |
I thought this would be way too heavy-handed, but surprisingly the baselines don’t look that bad?
Fixes #49514