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

Emit declarations using alternative containing modules for types exported using separate export statements #56857

Conversation

Andarist
Copy link
Contributor

fixes #56856

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Dec 23, 2023
return undefined;
}
const containers = mapDefined(candidates, candidate => getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined);
return containers.length === 1 ? getWithAlternativeContainers(containers[0]) : containers;
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 line is ad-hoc, perhaps I should just flatMap this. From what I've seen the consumers of this return value assume some ordering - or well, operate on first items with priority or smth. So I'm not sure how it would behave in more complex scenarios with smth like: [...withAlternativeContainersA, ...withAlternativeContainersB, ...withAlternativeContainersC]

Choose a reason for hiding this comment

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

Wait I’m confused; why would there only being a single element in the array affect whether you need to repackage it or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to explain this in the comment above. This is the only case I know how to reason about and about which i’m somewhat confident here. This is not the final solution - i’m seeking guidance what should be done here when there are more items in this array

Copy link
Member

Choose a reason for hiding this comment

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

From what I've seen the consumers of this return value assume some ordering - or well, operate on first items with priority or smth

Indeed, the results returned here are intended to be in priority order for "what is best to serialize", which is, admittedly, a bit subjective. IMO, the ordering here would probably be the direct symbols for each available container symbol, followed by all their alternative symbols, in order - so not quite a flat map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implemented the suggested solution. Could you take another look?

return undefined;
}
const containers = mapDefined(candidates, candidate => getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined);
return containers.length === 1 ? getWithAlternativeContainers(containers[0]) : containers;
Copy link
Member

Choose a reason for hiding this comment

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

From what I've seen the consumers of this return value assume some ordering - or well, operate on first items with priority or smth

Indeed, the results returned here are intended to be in priority order for "what is best to serialize", which is, admittedly, a bit subjective. IMO, the ordering here would probably be the direct symbols for each available container symbol, followed by all their alternative symbols, in order - so not quite a flat map.

@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Jan 4, 2024
@Andarist Andarist force-pushed the fix/dts-emit-through-separate-export-statements branch from 4b7ce35 to 23553bb Compare January 6, 2024 08:58
@weswigham
Copy link
Member

@typescript-bot test this
@typescript-bot run dt
@typescript-bot test top100
@typescript-bot perf test public

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 9, 2024

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 9, 2024

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

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jan 9, 2024

Heya @weswigham, I've started to run the public perf test suite on this PR at 23553bb. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

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

@typescript-bot
Copy link
Collaborator

@weswigham
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
self-build-src - node (v20.5.1, x64)
Memory used 2,739,265k (± 5.68%) 2,656,870k (± 5.35%) ~ 2,574,037k 2,921,340k p=0.230 n=6
Parse Time 5.01s (± 0.85%) 5.01s (± 0.43%) ~ 4.99s 5.04s p=0.748 n=6
Bind Time 1.97s (± 1.09%) 1.99s (± 1.04%) ~ 1.96s 2.02s p=0.517 n=6
Check Time 32.02s (± 0.31%) 32.02s (± 0.55%) ~ 31.72s 32.26s p=0.936 n=6
Emit Time 2.80s (± 2.69%) 2.82s (± 3.69%) ~ 2.68s 2.99s p=0.936 n=6
Total Time 41.83s (± 0.21%) 41.86s (± 0.16%) ~ 41.76s 41.94s p=0.471 n=6
self-compiler - node (v20.5.1, x64)
Memory used 418,813k (± 0.02%) 418,829k (± 0.02%) ~ 418,755k 418,981k p=0.377 n=6
Parse Time 2.89s (± 0.75%) 2.90s (± 0.68%) ~ 2.87s 2.92s p=0.871 n=6
Bind Time 1.13s (± 0.48%) 1.13s (± 0.48%) ~ 1.13s 1.14s p=1.000 n=6
Check Time 14.09s (± 0.22%) 14.04s (± 0.40%) ~ 13.96s 14.11s p=0.077 n=6
Emit Time 1.04s (± 0.78%) 1.04s (± 0.52%) ~ 1.04s 1.05s p=0.441 n=6
Total Time 19.17s (± 0.26%) 19.12s (± 0.24%) ~ 19.04s 19.16s p=0.171 n=6
vscode - node (v20.5.1, x64)
Memory used 2,827,995k (± 0.00%) 2,828,008k (± 0.00%) ~ 2,827,977k 2,828,096k p=0.689 n=6
Parse Time 10.73s (± 0.41%) 10.73s (± 0.17%) ~ 10.71s 10.76s p=0.936 n=6
Bind Time 3.42s (± 0.47%) 3.43s (± 0.40%) ~ 3.41s 3.44s p=0.514 n=6
Check Time 56.17s (± 0.15%) 56.16s (± 0.24%) ~ 55.97s 56.36s p=0.872 n=6
Emit Time 16.20s (± 0.96%) 16.27s (± 0.46%) ~ 16.17s 16.36s p=0.261 n=6
Total Time 86.53s (± 0.19%) 86.59s (± 0.18%) ~ 86.34s 86.77s p=0.470 n=6
System info unknown
Hosts
  • node (v20.5.1, x64)
Scenarios
  • self-build-src - node (v20.5.1, x64)
  • self-compiler - node (v20.5.1, x64)
  • vscode - node (v20.5.1, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

chakra-ui/chakra-ui

4 of 28 projects failed to build with the old tsc and were ignored

packages/components/tsconfig.build.json

  • error TS5056: Cannot write file '/mnt/ts_downloads/chakra-ui/packages/components/dist/types/menu/menu.stories.d.ts' because it would be overwritten by multiple input files.
    • Project Scope

@weswigham weswigham merged commit 4557e34 into microsoft:main Jan 9, 2024
19 checks passed
@acutmore
Copy link
Contributor

Just a note to say that this change seems to have regressed our (Bloomberg's) workaround for #38111.

I'll put a playground together and raise a concrete issue tomorrow 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Declarations can't be emitted when types from inner modules are exported through separate export declarations
5 participants