Skip to content

Conversation

@andrewbranch
Copy link
Member

Fixes #56648

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jan 25, 2024
import * as intermediate from './intermediate'
const ghost: intermediate.Ghost = new intermediate.Ghost()
~~~~~
!!! error TS2339: Property 'Ghost' does not exist on type 'typeof import("intermediate")'.
Copy link
Member Author

@andrewbranch andrewbranch Jan 25, 2024

Choose a reason for hiding this comment

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

It would be nice to be able to give a better type-only-specific error message here, but this is consistent with existing error messages you can get with other ways of doing property access on a module with type-only exports. (see exportNamespace3.ts, for example.)

@andrewbranch andrewbranch requested a review from sandersn January 25, 2024 21:19
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

This code is likely right, but I realised I'm missing background knowledge on how type-only imports work in the first place, so I asked a couple of questions.

if (type.flags & TypeFlags.Object) {
const resolved = resolveStructuredTypeMembers(type as ObjectType);
const symbol = resolved.members.get(name);
if (symbol && !includeTypeOnlyMembers && type.symbol?.flags & SymbolFlags.ValueModule && getSymbolLinks(type.symbol).typeOnlyExportStarMap?.has(name)) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand the check for !includeTypeOnlyMembers. If this is from a import * as intermediate from './x.js', the type doesn't indicate that type-only members should be skipped. Where does this come from?

Actually, the overall intent is to skip values that show up in the type-only exports map, right? How does this code distinguish a value (which shouldn't be included) from a type (which should (I think?))? Maybe that waits until the check just below the new one.

Copy link
Member Author

@andrewbranch andrewbranch Jan 30, 2024

Choose a reason for hiding this comment

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

This function gets properties which need to be values by definition. The question is whether the value has to exist in the emitted JavaScript or not. The only callers that pass includeTypeOnlyMembers: true are type queries and import type nodes:

type T = typeof x.y.z; // 'y' may be a namespace made by `export type * from "y"`
type U = typeof import("x").y.z;

These are constructs that query values, but don’t rely on those values actually existing, so they can safely return value symbols that are only accessible via type-only imports/exports.

How does this code distinguish a value (which shouldn't be included) from a type (which should (I think?))? Maybe that waits until the check just below the new one.

Your parentheticals are incorrect, but the top level sentence is correct—that’s handled by symbolIsValue below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Remember, “type-only” is not the same as “is a type” or “is not a value.” A type-only import/export is like a like a lens that can be applied to any symbol. Applying it doesn’t change the kind/meaning of the symbol; it just means that path to the symbol doesn’t exist in JS, so you have to be careful with how you reference it in any code that emits to JS.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, that example helped a lot. So the namespace 'y' can be, almost, a synthetic property that should only be visible from type space?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn’t show where x/y/z were declared, but the way I intended the example was that y itself is real (it’s the module namespace object of a file that does export type * but maybe has no real exports—so it would be an empty object), while z is the thing that acts like a “synthetic property” on y. But I think you understood the idea.

@andrewbranch
Copy link
Member Author

@typescript-bot perf test
@typescript-bot test top200
@typescript-bot run dt

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2024

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2024

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 30, 2024

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Angular - node (v18.15.0, x64)
Memory used 295,668k (± 0.01%) 295,658k (± 0.00%) ~ 295,637k 295,677k p=0.471 n=6
Parse Time 2.66s (± 0.15%) 2.67s (± 0.31%) ~ 2.66s 2.68s p=0.527 n=6
Bind Time 0.83s (± 1.41%) 0.83s (± 1.65%) ~ 0.82s 0.85s p=0.448 n=6
Check Time 8.20s (± 0.37%) 8.23s (± 0.43%) ~ 8.18s 8.28s p=0.257 n=6
Emit Time 7.11s (± 0.23%) 7.13s (± 0.60%) ~ 7.09s 7.21s p=0.676 n=6
Total Time 18.80s (± 0.20%) 18.85s (± 0.35%) ~ 18.80s 18.98s p=0.123 n=6
Compiler-Unions - node (v18.15.0, x64)
Memory used 193,468k (± 1.55%) 192,542k (± 1.26%) ~ 191,522k 197,506k p=0.936 n=6
Parse Time 1.36s (± 0.86%) 1.35s (± 0.38%) ~ 1.35s 1.36s p=0.523 n=6
Bind Time 0.72s (± 0.00%) 0.72s (± 0.00%) ~ 0.72s 0.72s p=1.000 n=6
Check Time 9.34s (± 0.28%) 9.39s (± 0.30%) +0.05s (+ 0.50%) 9.35s 9.43s p=0.030 n=6
Emit Time 2.61s (± 0.45%) 2.62s (± 0.62%) ~ 2.60s 2.64s p=0.142 n=6
Total Time 14.03s (± 0.25%) 14.08s (± 0.33%) ~ 14.03s 14.15s p=0.053 n=6
Monaco - node (v18.15.0, x64)
Memory used 347,443k (± 0.00%) 347,456k (± 0.01%) ~ 347,426k 347,490k p=0.521 n=6
Parse Time 2.47s (± 0.40%) 2.47s (± 0.74%) ~ 2.44s 2.49s p=0.730 n=6
Bind Time 0.92s (± 0.59%) 0.92s (± 0.56%) ~ 0.92s 0.93s p=0.640 n=6
Check Time 6.93s (± 0.26%) 6.95s (± 0.51%) ~ 6.91s 7.00s p=0.412 n=6
Emit Time 4.06s (± 0.29%) 4.05s (± 0.46%) ~ 4.03s 4.08s p=0.625 n=6
Total Time 14.39s (± 0.20%) 14.40s (± 0.27%) ~ 14.34s 14.46s p=0.421 n=6
TFS - node (v18.15.0, x64)
Memory used 302,840k (± 0.00%) 302,841k (± 0.00%) ~ 302,815k 302,857k p=0.872 n=6
Parse Time 2.02s (± 0.99%) 2.01s (± 1.16%) ~ 1.98s 2.04s p=0.512 n=6
Bind Time 1.01s (± 1.37%) 1.00s (± 0.41%) ~ 0.99s 1.00s p=0.390 n=6
Check Time 6.33s (± 0.39%) 6.33s (± 0.41%) ~ 6.31s 6.37s p=1.000 n=6
Emit Time 3.59s (± 0.39%) 3.59s (± 0.18%) ~ 3.58s 3.60s p=1.000 n=6
Total Time 12.95s (± 0.31%) 12.94s (± 0.28%) ~ 12.89s 12.97s p=0.683 n=6
material-ui - node (v18.15.0, x64)
Memory used 511,310k (± 0.00%) 511,320k (± 0.00%) ~ 511,294k 511,359k p=0.688 n=6
Parse Time 2.64s (± 0.92%) 2.63s (± 0.52%) ~ 2.62s 2.65s p=0.563 n=6
Bind Time 0.99s (± 1.34%) 1.00s (± 0.75%) ~ 0.99s 1.01s p=0.230 n=6
Check Time 17.17s (± 0.44%) 17.31s (± 0.13%) +0.14s (+ 0.80%) 17.29s 17.34s p=0.005 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 20.81s (± 0.38%) 20.95s (± 0.15%) +0.14s (+ 0.66%) 20.90s 20.98s p=0.016 n=6
mui-docs - node (v18.15.0, x64)
Memory used 1,695,141k (± 0.00%) 1,695,140k (± 0.00%) ~ 1,695,054k 1,695,185k p=0.936 n=6
Parse Time 6.53s (± 0.40%) 6.53s (± 0.73%) ~ 6.49s 6.62s p=0.936 n=6
Bind Time 2.36s (± 0.35%) 2.35s (± 0.51%) ~ 2.34s 2.37s p=0.157 n=6
Check Time 55.20s (± 0.54%) 55.46s (± 0.65%) ~ 55.27s 56.19s p=0.470 n=6
Emit Time 0.16s (± 0.00%) 0.16s (± 0.00%) ~ 0.16s 0.16s p=1.000 n=6
Total Time 64.25s (± 0.44%) 64.52s (± 0.53%) ~ 64.29s 65.20s p=0.298 n=6
self-build-src - node (v18.15.0, x64)
Memory used 2,410,688k (± 0.03%) 2,411,081k (± 0.01%) ~ 2,410,796k 2,411,743k p=0.066 n=6
Parse Time 4.97s (± 0.76%) 4.93s (± 0.96%) ~ 4.86s 4.98s p=0.520 n=6
Bind Time 1.89s (± 0.72%) 1.88s (± 0.52%) ~ 1.87s 1.89s p=0.673 n=6
Check Time 33.32s (± 0.27%) 33.38s (± 0.18%) ~ 33.28s 33.44s p=0.230 n=6
Emit Time 2.70s (± 1.18%) 2.68s (± 0.72%) ~ 2.65s 2.70s p=0.468 n=6
Total Time 42.89s (± 0.31%) 42.89s (± 0.12%) ~ 42.85s 42.96s p=0.810 n=6
self-compiler - node (v18.15.0, x64)
Memory used 418,589k (± 0.01%) 418,629k (± 0.02%) ~ 418,565k 418,767k p=0.199 n=6
Parse Time 2.80s (± 2.67%) 2.81s (± 2.67%) ~ 2.67s 2.87s p=0.809 n=6
Bind Time 1.10s (± 5.55%) 1.10s (± 5.36%) ~ 1.07s 1.22s p=0.611 n=6
Check Time 15.06s (± 0.22%) 15.12s (± 0.53%) ~ 15.03s 15.27s p=0.077 n=6
Emit Time 1.15s (± 1.10%) 1.14s (± 1.57%) ~ 1.12s 1.17s p=0.289 n=6
Total Time 20.11s (± 0.33%) 20.17s (± 0.41%) ~ 20.10s 20.30s p=0.172 n=6
vscode - node (v18.15.0, x64)
Memory used 2,810,811k (± 0.00%) 2,810,836k (± 0.00%) ~ 2,810,769k 2,810,909k p=0.423 n=6
Parse Time 10.62s (± 0.41%) 10.63s (± 0.45%) ~ 10.58s 10.70s p=0.469 n=6
Bind Time 3.40s (± 0.36%) 3.39s (± 0.24%) ~ 3.39s 3.41s p=0.142 n=6
Check Time 60.04s (± 0.57%) 59.86s (± 0.54%) ~ 59.43s 60.18s p=0.575 n=6
Emit Time 16.16s (± 0.70%) 16.19s (± 0.45%) ~ 16.09s 16.26s p=0.470 n=6
Total Time 90.22s (± 0.47%) 90.07s (± 0.36%) ~ 89.60s 90.51s p=0.689 n=6
webpack - node (v18.15.0, x64)
Memory used 393,459k (± 0.01%) 393,523k (± 0.02%) ~ 393,381k 393,578k p=0.066 n=6
Parse Time 3.09s (± 1.11%) 3.08s (± 1.10%) ~ 3.04s 3.13s p=1.000 n=6
Bind Time 1.40s (± 0.78%) 1.38s (± 1.26%) ~ 1.37s 1.41s p=0.115 n=6
Check Time 13.96s (± 0.32%) 13.96s (± 0.33%) ~ 13.90s 14.01s p=0.870 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 18.45s (± 0.30%) 18.44s (± 0.32%) ~ 18.34s 18.52s p=0.630 n=6
xstate - node (v18.15.0, x64)
Memory used 513,444k (± 0.03%) 513,373k (± 0.01%) ~ 513,351k 513,426k p=0.109 n=6
Parse Time 3.28s (± 0.25%) 3.27s (± 0.16%) ~ 3.27s 3.28s p=0.523 n=6
Bind Time 1.54s (± 0.26%) 1.54s (± 0.49%) ~ 1.53s 1.55s p=1.000 n=6
Check Time 2.85s (± 0.36%) 2.84s (± 0.65%) ~ 2.81s 2.86s p=0.800 n=6
Emit Time 0.08s (± 0.00%) 0.08s (± 0.00%) ~ 0.08s 0.08s p=1.000 n=6
Total Time 7.74s (± 0.21%) 7.75s (± 0.19%) ~ 7.72s 7.76s p=0.685 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)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - 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,353ms (± 0.84%) 2,341ms (± 0.45%) ~ 2,328ms 2,358ms p=0.228 n=6
Req 2 - geterr 5,460ms (± 1.28%) 5,564ms (± 1.25%) +104ms (+ 1.90%) 5,468ms 5,627ms p=0.031 n=6
Req 3 - references 325ms (± 1.55%) 324ms (± 1.22%) ~ 321ms 332ms p=0.746 n=6
Req 4 - navto 278ms (± 0.99%) 275ms (± 1.55%) ~ 271ms 281ms p=0.413 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 84ms (± 5.95%) 90ms (± 7.29%) ~ 79ms 96ms p=0.101 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,487ms (± 1.13%) 2,490ms (± 1.37%) ~ 2,444ms 2,545ms p=0.810 n=6
Req 2 - geterr 4,143ms (± 1.48%) 4,152ms (± 1.42%) ~ 4,113ms 4,270ms p=0.336 n=6
Req 3 - references 336ms (± 1.58%) 340ms (± 1.23%) ~ 332ms 343ms p=0.089 n=6
Req 4 - navto 285ms (± 0.44%) 285ms (± 0.36%) ~ 283ms 286ms p=0.868 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 81ms (± 9.68%) 88ms (± 5.66%) 🔻+7ms (+ 8.85%) 78ms 91ms p=0.037 n=6
xstateTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,612ms (± 0.24%) 2,603ms (± 0.50%) ~ 2,578ms 2,614ms p=0.128 n=6
Req 2 - geterr 1,749ms (± 1.15%) 1,728ms (± 2.57%) ~ 1,678ms 1,770ms p=0.575 n=6
Req 3 - references 113ms (± 8.57%) 123ms (± 7.26%) ~ 105ms 128ms p=0.100 n=6
Req 4 - navto 368ms (± 1.13%) 369ms (± 0.58%) ~ 365ms 371ms p=1.000 n=6
Req 5 - completionInfo count 2,078 (± 0.00%) 2,078 (± 0.00%) ~ 2,078 2,078 p=1.000 n=6
Req 5 - completionInfo 312ms (± 1.53%) 310ms (± 1.08%) ~ 307ms 315ms p=0.373 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 153.30ms (± 0.20%) 153.11ms (± 0.17%) -0.19ms (- 0.12%) 152.04ms 156.42ms p=0.000 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 228.92ms (± 0.83%) 228.10ms (± 0.15%) -0.81ms (- 0.35%) 226.79ms 232.26ms p=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 230.72ms (± 0.20%) 230.66ms (± 0.19%) ~ 228.91ms 236.92ms p=0.187 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 230.09ms (± 0.19%) 230.06ms (± 0.16%) ~ 228.59ms 234.13ms p=0.735 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

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

@typescript-bot
Copy link
Collaborator

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

Everything looks good!

@andrewbranch andrewbranch merged commit d2d3b24 into microsoft:main Jan 31, 2024
@andrewbranch andrewbranch deleted the bug/56648 branch January 31, 2024 01:04
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No error when referencing a value that was re-exported with export type *

3 participants