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

[Vue Rewrite] Enable Typescript Vue Components #1831

Merged
merged 16 commits into from
Jul 4, 2022

Conversation

devlinjunker
Copy link
Contributor

@devlinjunker devlinjunker commented Jun 17, 2022

Adding typescript to the build process

  • Follows [Vue Rewrite] Fix CI Jobs #1816
  • Re-engineered configuration from typescript+vue2 project generated by the @vue/cli-plugin v5.0.0
    • Update webpack config to handle typescript with decorators inside of vue templates
    • Added tsconfig + shim files (from generated projected)
  • Added more eslint configs
  • Converted Explore component to Typescript Vue Class with decorator as working example

see devlinjunker#28 for full work history

Jun-17-2022 09-43-42

TODO Before Merge:

  • Remove class decorator/babel-loader + class component

Up Next:

  • Remove unique linting rules (+ standardize indentation and clean up any other failures/warnings)
  • Move all Components to typescript (no classes/decorators though)
  • Add Unit Tests to run with npm run test
  • Add Vuex Store (see 58a196b for preview)
  • Add Proper Routing (see devlinjunker/news@vue-version...devlinjunker:vue-routes for preview)

Signed-off-by: Devlin Junker <[email protected]>
Signed-off-by: Devlin Junker <[email protected]>
Signed-off-by: Devlin Junker <[email protected]>
Signed-off-by: Devlin Junker <[email protected]>
Signed-off-by: Devlin Junker <[email protected]>
Signed-off-by: Devlin Junker <[email protected]>
Signed-off-by: Devlin Junker <[email protected]>
@tcitworld
Copy link
Member

Note: vue-class-components is kinda abandonned, using typescript with vue2 makes a better experience and future proof with @vue/composition-api.

@devlinjunker
Copy link
Contributor Author

devlinjunker commented Jun 17, 2022

@tcitworld oh dang! thanks for pointing that out!

I'm new to the Vue world and thought this was pretty cool to get working - but I'd rather follow future-proof conventions like you mention.

using typescript with vue2

Do you mean just adding typescript/type-checking to the original syntax of the Vue components (i.e. before I converted the Explore component to a class)?

e.g.

export default {
    components: {
        // Modal,
        Button,
        AddFeed,
    },
    props: {
        feed: '',
    },
    data() {
        return {
            explorableSites: [],
            showAddFeed: false,
        }
    },
    created() {
    ... 
    },
    methods: {
    ...
    }
}

@devlinjunker
Copy link
Contributor Author

devlinjunker commented Jun 17, 2022

or should I be using Vue.component and Vue.extends?

I found this guide: https://v2.vuejs.org/v2/guide/typescript.html but that's for Vue 2.... 🤔 still seems applicable though for typescript

@devlinjunker
Copy link
Contributor Author

devlinjunker commented Jun 17, 2022

Also found a migration guide from Vue 2 to Vue 3: https://v3-migration.vuejs.org/ that I will try to read and include details from:

  • Avoid Scoped slots
  • Can we use vue-router v4 (for transition and keepAlive directives in Vue 3)?
  • Also seems like vuex v4 will be important

@devlinjunker
Copy link
Contributor Author

Seems like we can't use the v4 versions of the libraries until we transition to vue v3... so I didn't update either of those.

I did remove the vue-property-decorator library and the class decorators then reverted the Class component to Vue.extends({ ... syntax

Please review/merge and I will move forward with the Up Next section in PR

Signed-off-by: Devlin Junker <[email protected]>
Signed-off-by: Devlin Junker <[email protected]>
@tcitworld
Copy link
Member

The standard experience with Typescript and Vue 2 isn't terrible, but it's being improved with Vue 2.7 (currently in beta) or with @vue/composition-api (if we would be using this API in the future) by using defineComponent instead of Vue.extend. Then when @nextcloud/vue is Vue 3 ready it will be easier to jump.

In any case, I would predict keeping the class components wouldn't help at all, glad you switched from it.

Copy link
Member

@Grotax Grotax left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, it is highly appreciated :)

@devlinjunker
Copy link
Contributor Author

devlinjunker commented Jul 1, 2022

currently put some time in on the next two tasks mentioned above

  • Remove unique linting rules (+ standardize indentation and clean up any other failures/warnings)
  • Move all Components to typescript (no classes/decorators though)

(see these two PRs):

once this PR is merged I can rebase these branches and create PRs against nextcloud:vue-rewrite branch in this repo

@Grotax
Copy link
Member

Grotax commented Jul 1, 2022

Is there anything left to do for this PR then?

@devlinjunker
Copy link
Contributor Author

@Grotax i don’t think there is anything left on this one

@devlinjunker
Copy link
Contributor Author

@SMillerDev @Grotax you guys ready to approve and merge this PR?

Copy link
Contributor

@anoymouserver anoymouserver left a comment

Choose a reason for hiding this comment

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

LGTM

@anoymouserver anoymouserver merged commit f1668df into nextcloud:vue-rewrite Jul 4, 2022
@devlinjunker devlinjunker mentioned this pull request Aug 5, 2022
8 tasks
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.

5 participants