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

fix: more types #4361

Merged
merged 27 commits into from Jan 28, 2022
Merged

fix: more types #4361

merged 27 commits into from Jan 28, 2022

Conversation

dnalborczyk
Copy link
Contributor

@dnalborczyk dnalborczyk commented Jan 23, 2022

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

@dnalborczyk dnalborczyk changed the title chore: more type fixes fix: more types Jan 23, 2022
@codecov
Copy link

codecov bot commented Jan 23, 2022

Codecov Report

Merging #4361 (2c47163) into master (4e124d8) will increase coverage by 0.01%.
The diff coverage is 95.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4361      +/-   ##
==========================================
+ Coverage   98.68%   98.70%   +0.01%     
==========================================
  Files         205      205              
  Lines        7323     7320       -3     
  Branches     2083     2083              
==========================================
- Hits         7227     7225       -2     
+ Misses         36       35       -1     
  Partials       60       60              
Impacted Files Coverage Δ
cli/run/loadConfigFile.ts 96.15% <ø> (ø)
cli/run/loadConfigFromCommand.ts 100.00% <ø> (ø)
cli/run/resetScreen.ts 100.00% <ø> (ø)
cli/run/stdin.ts 100.00% <ø> (ø)
cli/run/watch-cli.ts 89.70% <ø> (ø)
src/Bundle.ts 100.00% <ø> (ø)
src/ExternalModule.ts 100.00% <ø> (ø)
src/Graph.ts 100.00% <ø> (ø)
src/ast/scopes/ChildScope.ts 100.00% <ø> (ø)
src/ast/scopes/ModuleScope.ts 100.00% <ø> (ø)
... and 44 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e124d8...2c47163. Read the comment docs.

@dnalborczyk dnalborczyk marked this pull request as ready for review January 24, 2022 02:29
src/Module.ts Outdated
node: ExportAllDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration
): void => this.addExport(node),
addImport: (node: ImportDeclaration): void => this.addImport(node),
addImportMeta: (node: MetaProperty): void => this.addImportMeta(node),
Copy link
Member

Choose a reason for hiding this comment

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

What is the advantage of doing this? Considering performance, my understanding is that .bind is now more efficient as it avoids the indirection of the additional function, and these functions are "hot" in that they are called very often during the tree-shaking phase. And TypeScript should be able to handle .bind correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, that has nothing to do with typescript. there were perf issues with bind (in the past), I think those have been fixed tho.

it's just consistency, e.g.: https://github.com/rollup/rollup/pull/4361/files/437e90bc8e8e784d8b3667280d4890dbcfff9945#diff-bdf37a1325be24e5865c89e911c2f1125a1d857ec429afb790bde572bbe12b0fR761-R765

but I'll revert.

const [resolveStaticDependencyPromises, resolveDynamicImportPromises] = await loadPromise;
return Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]);
await Promise.all([...resolveStaticDependencyPromises, ...resolveDynamicImportPromises]);
Copy link
Member

Choose a reason for hiding this comment

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

To avoid the unnecessary "await as last statement", one could also just type this as Promise<unknown>. My understanding is that this avoids one implicit layer of Promise unwrapping the compiler has to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably so (albeit probably microscopic in the grand schema of things). I believe I saw this pattern across the code base. I guess there is no "good" way to return undefined if the caller ignores the function result entirely. I think it makes the code easier to read and also interpret the intend. if the only caller of a function which returns a result ignores the result it feels more like an oversight than done on purpose. that's all.

I'll revert.

this.getFileName = this.fileEmitter.getFileName.bind(this.fileEmitter);
this.finaliseAssets = this.fileEmitter.assertAssetsFinalized.bind(this.fileEmitter);
this.setOutputBundle = this.fileEmitter.setOutputBundle.bind(this.fileEmitter);
this.emitFile = (emittedFile: EmittedFile) => this.fileEmitter.emitFile(emittedFile);
Copy link
Member

Choose a reason for hiding this comment

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

Again the same question as with the AstContext

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above, I'll revert.

Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

Great improvements 👍

@lukastaegert lukastaegert merged commit 7194b88 into rollup:master Jan 28, 2022
@dnalborczyk dnalborczyk deleted the more-type-fixes branch February 3, 2022 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants