Skip to content

Filter out classes with private members from the contextual types for object literal nodes #56183

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Andarist
Copy link
Contributor

fixes #56177

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Oct 23, 2023
@@ -5384,7 +5385,7 @@ function getApparentProperties(type: Type, node: ObjectLiteralExpression | JsxAt
}

function containsNonPublicProperties(props: Symbol[]) {
return some(props, p => !!(getDeclarationModifierFlagsFromSymbol(p) & ModifierFlags.NonPublicAccessibilityModifier));
return some(props, p => !!(getDeclarationModifierFlagsFromSymbol(p) & ModifierFlags.NonPublicAccessibilityModifier) || !!p.valueDeclaration && isNamedDeclaration(p.valueDeclaration) && isPrivateIdentifier(p.valueDeclaration.name));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

likely this alone (or something close to it) would fix the completion problem (private foo is already filtered out from completions, only #foo is not) but that wouldn't fix the contextuallyTypedParametersPositionIncludesClassWithPrivateMember test cases

@sandersn sandersn requested a review from jakebailey November 2, 2023 22:08
@typescript-bot typescript-bot removed the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 2, 2023
@sandersn sandersn requested a review from iisaduan November 2, 2023 22:08
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Nov 2, 2023
@jakebailey
Copy link
Member

@typescript-bot test top200
@typescript-bot user test this
@typescript-bot run dt

@typescript-bot perf test this
@typescript-bot pack this

@typescript-bot user test tsserver
@typescript-bot test tsserver top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2023

Heya @jakebailey, I've started to run the tarball bundle task on this PR at dcff0c7. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite on this PR at dcff0c7. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2023

Heya @jakebailey, I've started to run the diff-based user code test suite (tsserver) on this PR at dcff0c7. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at dcff0c7. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite (tsserver) on this PR at dcff0c7. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2023

Heya @jakebailey, I've started to run the regular perf test suite on this PR at dcff0c7. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2023

Heya @jakebailey, I've started to run the parallelized Definitely Typed test suite on this PR at dcff0c7. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Nov 3, 2023

Hey @jakebailey, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/158467/artifacts?artifactName=tgz&fileId=9F3DEB1EDB34D1ED76C56540B3D135C7C7CFAE635A51B5D1FB3D2872C3DD6A4002&fileName=/typescript-5.4.0-insiders.20231103.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;

@typescript-bot
Copy link
Collaborator

@jakebailey
The results of the perf run you requested are in!

Here they are:

Compiler

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,152k (± 0.01%) 295,119k (± 0.01%) ~ 295,081k 295,137k p=0.230 n=6
Parse Time 2.63s (± 0.71%) 2.62s (± 0.45%) ~ 2.60s 2.63s p=0.223 n=6
Bind Time 0.84s (± 0.90%) 0.83s (± 0.62%) ~ 0.83s 0.84s p=0.247 n=6
Check Time 8.05s (± 0.40%) 8.05s (± 0.18%) ~ 8.03s 8.07s p=0.870 n=6
Emit Time 7.10s (± 0.30%) 7.08s (± 0.24%) ~ 7.05s 7.10s p=0.329 n=6
Total Time 18.62s (± 0.17%) 18.59s (± 0.10%) ~ 18.57s 18.62s p=0.061 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 193,649k (± 1.65%) 195,580k (± 1.23%) ~ 190,685k 196,656k p=0.471 n=6
Parse Time 1.36s (± 0.76%) 1.36s (± 0.60%) ~ 1.35s 1.37s p=0.932 n=6
Bind Time 0.73s (± 0.00%) 0.73s (± 0.00%) ~ 0.73s 0.73s p=1.000 n=6
Check Time 9.18s (± 0.19%) 9.17s (± 0.35%) ~ 9.12s 9.22s p=0.548 n=6
Emit Time 2.63s (± 0.56%) 2.63s (± 0.52%) ~ 2.61s 2.65s p=0.934 n=6
Total Time 13.89s (± 0.21%) 13.89s (± 0.19%) ~ 13.84s 13.91s p=0.747 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,373k (± 0.01%) 347,408k (± 0.01%) ~ 347,374k 347,430k p=0.066 n=6
Parse Time 2.45s (± 0.67%) 2.46s (± 0.31%) ~ 2.45s 2.47s p=0.216 n=6
Bind Time 0.95s (± 1.44%) 0.94s (± 0.67%) ~ 0.93s 0.95s p=0.388 n=6
Check Time 6.93s (± 0.32%) 6.93s (± 0.38%) ~ 6.89s 6.96s p=0.935 n=6
Emit Time 4.05s (± 0.35%) 4.06s (± 0.74%) ~ 4.03s 4.10s p=0.935 n=6
Total Time 14.38s (± 0.23%) 14.38s (± 0.32%) ~ 14.34s 14.45s p=0.872 n=6
TFS - node (v18.15.0, x64)
Memory used 302,595k (± 0.01%) 302,576k (± 0.01%) ~ 302,546k 302,640k p=0.298 n=6
Parse Time 1.99s (± 0.49%) 1.99s (± 0.94%) ~ 1.96s 2.01s p=0.404 n=6
Bind Time 1.00s (± 0.81%) 1.00s (± 0.54%) ~ 1.00s 1.01s p=0.859 n=6
Check Time 6.25s (± 0.31%) 6.25s (± 0.28%) ~ 6.23s 6.27s p=0.463 n=6
Emit Time 3.59s (± 0.46%) 3.57s (± 0.72%) ~ 3.55s 3.62s p=0.288 n=6
Total Time 12.83s (± 0.23%) 12.83s (± 0.19%) ~ 12.80s 12.87s p=0.684 n=6
material-ui - node (v18.15.0, x64)
Memory used 470,547k (± 0.00%) 470,578k (± 0.01%) ~ 470,530k 470,677k p=0.378 n=6
Parse Time 2.56s (± 0.84%) 2.56s (± 0.43%) ~ 2.54s 2.57s p=0.743 n=6
Bind Time 1.00s (± 1.23%) 0.99s (± 1.48%) ~ 0.97s 1.01s p=0.805 n=6
Check Time 16.64s (± 0.53%) 16.68s (± 0.26%) ~ 16.63s 16.74s p=0.574 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.20s (± 0.43%) 20.24s (± 0.23%) ~ 20.19s 20.30s p=0.520 n=6
xstate - node (v18.15.0, x64)
Memory used 512,817k (± 0.01%) 512,782k (± 0.01%) ~ 512,719k 512,830k p=0.298 n=6
Parse Time 3.27s (± 0.33%) 3.27s (± 0.16%) ~ 3.27s 3.28s p=0.324 n=6
Bind Time 1.54s (± 0.49%) 1.54s (± 0.68%) ~ 1.53s 1.56s p=0.273 n=6
Check Time 2.84s (± 0.57%) 2.82s (± 0.50%) ~ 2.80s 2.84s p=0.053 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 7.73s (± 0.30%) 7.71s (± 0.22%) ~ 7.68s 7.73s p=0.108 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Angular - node (v18.15.0, x64)
  • Compiler-Unions - node (v18.15.0, x64)
  • Monaco - node (v18.15.0, x64)
  • TFS - node (v18.15.0, x64)
  • material-ui - node (v18.15.0, x64)
  • xstate - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,381ms (± 0.49%) 2,382ms (± 0.48%) ~ 2,369ms 2,396ms p=1.000 n=6
Req 2 - geterr 5,347ms (± 1.38%) 5,373ms (± 1.55%) ~ 5,288ms 5,451ms p=0.521 n=6
Req 3 - references 326ms (± 0.50%) 329ms (± 1.40%) ~ 322ms 334ms p=0.293 n=6
Req 4 - navto 277ms (± 1.21%) 277ms (± 1.27%) ~ 273ms 280ms p=1.000 n=6
Req 5 - completionInfo count 1,356 (± 0.00%) 1,356 (± 0.00%) ~ 1,356 1,356 p=1.000 n=6
Req 5 - completionInfo 82ms (± 8.41%) 84ms (± 8.91%) ~ 75ms 90ms p=1.000 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,512ms (± 1.18%) 2,500ms (± 1.16%) ~ 2,451ms 2,530ms p=0.575 n=6
Req 2 - geterr 4,118ms (± 2.08%) 4,100ms (± 1.81%) ~ 4,037ms 4,206ms p=0.936 n=6
Req 3 - references 339ms (± 1.58%) 340ms (± 1.59%) ~ 333ms 345ms p=0.570 n=6
Req 4 - navto 282ms (± 0.58%) 282ms (± 0.27%) ~ 281ms 283ms p=0.564 n=6
Req 5 - completionInfo count 1,518 (± 0.00%) 1,518 (± 0.00%) ~ 1,518 1,518 p=1.000 n=6
Req 5 - completionInfo 83ms (± 7.69%) 86ms (± 7.27%) ~ 77ms 90ms p=0.314 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,598ms (± 0.32%) 2,596ms (± 0.19%) ~ 2,590ms 2,603ms p=0.625 n=6
Req 2 - geterr 1,697ms (± 2.62%) 1,717ms (± 1.94%) ~ 1,673ms 1,767ms p=0.296 n=6
Req 3 - references 117ms (± 7.57%) 108ms (± 5.85%) ~ 105ms 121ms p=0.062 n=6
Req 4 - navto 366ms (± 0.22%) 365ms (± 0.30%) ~ 363ms 366ms p=0.383 n=6
Req 5 - completionInfo count 2,073 (± 0.00%) 2,073 (± 0.00%) ~ 2,073 2,073 p=1.000 n=6
Req 5 - completionInfo 309ms (± 1.02%) 309ms (± 2.08%) ~ 299ms 316ms p=0.936 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstateTSServer - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 152.31ms (± 0.17%) 152.31ms (± 0.20%) ~ 151.26ms 157.39ms p=0.368 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 227.74ms (± 0.15%) 227.69ms (± 0.17%) -0.05ms (- 0.02%) 226.41ms 233.22ms p=0.002 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 229.33ms (± 0.17%) 229.37ms (± 0.19%) ~ 227.78ms 235.10ms p=0.625 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 229.26ms (± 0.19%) 229.22ms (± 0.18%) ~ 227.65ms 234.16ms p=0.609 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/56183/merge:

There were infrastructure failures potentially unrelated to your change:

  • 3 instances of "Package install failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the user test suite comparing main and refs/pull/56183/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @jakebailey, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/56183/merge:

Something interesting changed - please have a look.

Details

Server exited prematurely with code unknown and signal SIGABRT

Server exited prematurely with code unknown and signal SIGABRT

Affected repos

calcom/cal.com Raw error text: RepoResults7/calcom.cal.com.rawError.txt in the artifact folder

Last few requests

{"seq":808,"type":"request","command":"getOutliningSpans","arguments":{"file":"@PROJECT_ROOT@/apps/swagger/pages/_app.tsx"}}
{"seq":809,"type":"request","command":"updateOpen","arguments":{"changedFiles":[{"fileName":"@PROJECT_ROOT@/apps/swagger/pages/_app.tsx","textChanges":[{"newText":" //comment","start":{"line":1,"offset":42},"end":{"line":1,"offset":42}}]}],"closedFiles":[],"openFiles":[]}}
{"seq":810,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":["@PROJECT_ROOT@/apps/api/test/lib/middleware/withMiddleware.test.ts"],"openFiles":[]}}
{"seq":811,"type":"request","command":"updateOpen","arguments":{"changedFiles":[],"closedFiles":[],"openFiles":[{"file":"@PROJECT_ROOT@/apps/web/app/layout.tsx","projectRootPath":"@PROJECT_ROOT@"}]}}

Repro steps

  1. git clone https://github.com/calcom/cal.com --recurse-submodules
  2. In dir cal.com, run git reset --hard d1d50b0d9131e650eab2a88396e130dfb2067da4
  3. In dir cal.com, run yarn install --no-immutable --mode=skip-build
  4. Back in the initial folder, download RepoResults7/calcom.cal.com.replay.txt from the artifact folder
  5. npm install --no-save @typescript/server-replay
  6. npx tsreplay ./cal.com ./calcom.cal.com.replay.txt path/to/tsserver.js
  7. npx tsreplay --help to learn about helpful switches for debugging, logging, etc

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/56183/merge:

Everything looks good!

@jakebailey
Copy link
Member

There's a crash above, but not sure if it's due to this PR or not.

@Andarist
Copy link
Contributor Author

I really doubt that this crash is related to this PR - but who knows? Could you rerun the extended test suite here before I start investigating this?

@Andarist Andarist requested a review from jakebailey December 26, 2023 18:33
@jakebailey
Copy link
Member

@typescript-bot test top200

@typescript-bot
Copy link
Collaborator

typescript-bot commented Dec 26, 2023

Heya @jakebailey, I've started to run the diff-based top-repos suite on this PR at 34d43f0. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@jakebailey Here are the results of running the top-repos suite comparing main and refs/pull/56183/merge:

Everything looks good!

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

I'm a little bit suspicious of the fix itself from the PoV of just adding another layer of workers and then filtering, as compared to doing this more deeply in getContextualType, but I can't quite put my finger on what is better.

@Andarist
Copy link
Contributor Author

Andarist commented Jan 4, 2024

I'm a little bit suspicious of the fix itself from the PoV of just adding another layer of workers and then filtering, as compared to doing this more deeply in getContextualType, but I can't quite put my finger on what is better.

it has been a while since I was working on this. I vaguely remember similar concerns that I had. IIRC, I do this filtering here because I can't access the information about being within "literal expression object" context at a deeper level. At the end of the day, the same operation would have to be done deeper - we get a set of values and we need to reject some. So this level works as OK as any other (as long as it doesn't introduce problems, ofc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Waiting on reviewers
Development

Successfully merging this pull request may close these issues.

Don't suggest private fields in contexts where they are out of scope
4 participants