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

docs: proposal for two new immutable methods for Vue's list rendering #2709

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

Conversation

dev-itsheng
Copy link
Contributor

Description of Problem

Proposed Solution

Additional Information

JavaScript provides two new immutable methods on arrays to solve the problem of legacy functions with side effects. These two methods also apply to Vue's list rendering optimizations as well, so I've modified the documentation to add suggestions for them.

Copy link

netlify bot commented Feb 23, 2024

Deploy Preview for vuejs ready!

Name Link
🔨 Latest commit deada93
🔍 Latest deploy log https://app.netlify.com/sites/vuejs/deploys/65d840d99c6706000851dfcc
😎 Deploy Preview https://deploy-preview-2709--vuejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brc-dd
Copy link
Member

brc-dd commented Feb 23, 2024

Note that these are ES2023 features not available in over 10% browsers and require manually configuring tsconfig.

@dev-itsheng
Copy link
Contributor Author

dev-itsheng commented Feb 23, 2024

Note that these are ES2023 features not available in over 10% browsers and require manually configuring tsconfig.

I have three considerations.

  1. most users will be using the latest version of Chrome and they will get the expected results when learning the code in the documentation.

  2. if the user is using TypeScript in their project, they will have already learned to configure tsconfig, and babel will be similar.

  3. give the user the necessary hints that these two new APIs can solve the problem of array side effects, not only in this scenario in Vue, but in other scenarios as well.

@AloisSeckar
Copy link
Contributor

Note that these are ES2023 features not available in over 10% browsers and require manually configuring tsconfig.

Although I agree that it should at least come with a comment and warning about potential issues, I am not sure you're right in the part about requiring manual configuration.

I just scaffolded fresh Vue project starter by npm create vue@latest and I can use Array.toReversed without any further config. Target is set to ESNext in default Vue's tsconfig that is being extended.

@brc-dd
Copy link
Member

brc-dd commented Feb 23, 2024

Target is set to ESNext in default Vue's tsconfig that is being extended

Not in tsconfig.dom.json. You probably are trying inside some ts file. It should show error in sfc.

But yeah, I agree, it's there for about a year now. We can just add a note like "if you're targeting newer browsers, you can directly use toReversed/toSorted instead"

@AloisSeckar
Copy link
Contributor

Not in tsconfig.dom.json.

This file is extending general tsconfig.json and not changing the target setting... 🤷

@brc-dd
Copy link
Member

brc-dd commented Feb 23, 2024

target doesn't matter compilerOptions.lib does.

In newly created vue app:

image

@AloisSeckar
Copy link
Contributor

You're right. I was checking whether the app can run without complaining during build time, not the actual appearance in VSCode.

@AloisSeckar
Copy link
Contributor

@dev-itsheng

  1. if the user is using TypeScript in their project, they will have already learned to configure tsconfig, and babel will be similar.

This is a terribly wrong consideration, imo. Nowadays tools allow people using them without deeper understanding of the principles behind. I think it is generally a good thing, because it allows awesome content being created by almost everyone, but you should keep that in mind and not assuming others know what you do.

@brc-dd
Copy link
Member

brc-dd commented Feb 23, 2024

without complaining during build time

Yeah, the type-check command (vue-tsc) will throw error, build won't because vite doesn't check types.

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

3 participants