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

add symbol type to loadToApp function property argument #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

windmemory
Copy link

Checklist
  • npm test passes
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

loader

Description of change

Add symbol type to the property argument of loadToApp function.
The js implementation supports this type of argument, but the typescript declaration does not support this, currently we can not pass symbol variable to be the property argument of loadToApp. As we use typescript heavily, we want to enable this type of argument.

…rty argument

The js implementation of loadToApp function in loader support passing type `symbol`
But the typescript declaration file does not support this
Add symbol type to loadToApp functon property argument
@codecov
Copy link

codecov bot commented May 28, 2020

Codecov Report

Merging #220 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #220   +/-   ##
=======================================
  Coverage   99.80%   99.80%           
=======================================
  Files          19       19           
  Lines        1016     1016           
=======================================
  Hits         1014     1014           
  Misses          2        2           
Impacted Files Coverage Δ
lib/loader/egg_loader.js 100.00% <ø> (ø)

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 ca04a45...c2fe695. Read the comment docs.

@atian25 atian25 requested a review from whxaxes May 28, 2020 07:34
@atian25
Copy link
Member

atian25 commented Aug 14, 2020

when could we load to a symbol?

@windmemory
Copy link
Author

You can not do this in TS now, because the definition is not allowed, but you can do this in JS. This PR wants to fix the TS version problem.

@atian25
Copy link
Member

atian25 commented Aug 14, 2020

my question is why will we call loadToApp to a symbol property?

@windmemory
Copy link
Author

I would suggest you ask the person who write the code in JS.

If the type of argument is supported by JS, then we should add a TS declaration for it, does this make sense?

@atian25
Copy link
Member

atian25 commented Aug 14, 2020

sorry, could you show me the link for the js code that you just mentioned?

@windmemory
Copy link
Author

Please check:

const target = this.app[property] = {};

And here: https://eggjs.org/zh-cn/advanced/framework.html#%E8%87%AA%E5%AE%9A%E4%B9%89-loader

The property is a key in a js map, and can be string, or Symbol, and you can see the official docs shows using a Symbol to be the key of a property.

@atian25
Copy link
Member

atian25 commented Aug 14, 2020

Symbol.for('egg#loader') which is used for the framework, it's not the same thing with loadToApp.

this.app[property] doesn't mean it's suggested to use Symbol, it's just js, we don't have to modify the file to forbid Symbol.

and we don't find the scenario to loadToApp with some Symbol, so I think it should not add to typings.

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