feature/feat-migrate-to-typescript #1544

Merged
konrad merged 9 commits from dpschen/frontend:feature/feat-migrate-to-typescript into main 2022-04-02 15:36:32 +00:00
Member

This pull request:

  • renames js files to ts
  • adds lang="ts" to all <script> blocks in .vue files.
  • wraps the default export of non-<script setup> components with defineComponent().
    • for some components it was so easy to convert them to <script setup> that I did that instead.
    • some components didn't even need a <script> part, so I removed it (yes, it's optional).

Motivation:
By using ts files we immediately get better typing, without changing anything else.

This pull request: - renames js files to ts - adds `lang="ts"` to all `<script>` blocks in `.vue` files. - wraps the default export of non-`<script setup>` components with `defineComponent()`. - for some components it was so easy to convert them to `<script setup>` that I did that instead. - some components didn't even need a `<script>` part, so I removed it (yes, it's optional). Motivation: By using ts files we immediately get better typing, without changing anything else.
dpschen added 3 commits 2022-02-15 12:20:53 +00:00
dpschen changed title from WIP: feature/feat-migrate-to-typescript to feature/feat-migrate-to-typescript 2022-02-15 12:23:05 +00:00
Member

Hi dpschen!

Thank you for creating a PR!

I've deployed the changes of this PR on a preview environment under this URL: https://1544-feature-feat-migrate-to-typescri--vikunja-frontend-preview.netlify.app

You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/.

Have a nice day!

Beep boop, I'm a bot.

Hi dpschen! Thank you for creating a PR! I've deployed the changes of this PR on a preview environment under this URL: https://1544-feature-feat-migrate-to-typescri--vikunja-frontend-preview.netlify.app You can use this url to view the changes live and test them out. You will need to manually connect this to an api running somehwere. The easiest to use is https://try.vikunja.io/. Have a nice day! > Beep boop, I'm a bot.
dpschen force-pushed feature/feat-migrate-to-typescript from 008e990e75 to 6bec9e3299 2022-02-15 12:31:44 +00:00 Compare
dpschen force-pushed feature/feat-migrate-to-typescript from 6bec9e3299 to 5cfcc66346 2022-02-15 12:43:51 +00:00 Compare
dpschen requested review from konrad 2022-02-15 13:27:52 +00:00
konrad was assigned by dpschen 2022-02-15 13:27:58 +00:00
Contributor

Should we maybe also consider using type-based declaration for eg. props and emits?

https://vuejs.org/guide/typescript/composition-api.html#typing-component-props

I usually like them alot more :)

Should we maybe also consider using type-based declaration for eg. props and emits? https://vuejs.org/guide/typescript/composition-api.html#typing-component-props I usually like them alot more :)
Author
Member

Should we maybe also consider using type-based declaration for eg. props and emits?

https://vuejs.org/guide/typescript/composition-api.html#typing-component-props

I usually like them alot more :)

Absolutely! =)
This pull-request also shouldn't be understood as a full typescript conversion (the title is a bit misleading). Rather I tried to do as little as possible so that the request can be reviewed and merged fast.

We had too many large pull requests that stayed open for a long time and were hard to merge, so I try to split it into many smaller packages that are managable instead. If you look at other pull-requests you'll see that I usually implement typing for props and emits in converted and new components.

Sometimes there is a component where I know that there is another pull request that's beeing worked on. In this case I try to keep the diff as minimal as possible to prevent complex merge conflicts. In the medium to long term the goal is to convert everything to typescript and use the recommended linting settings (I think they also enforce some of the typing).

EDIT: I want to add that I merged multiple pull request in this one together so in the end this results in a mixture between converting some components to ts and just adding lang="ts" / defineComponent / renaming to ts files.

> Should we maybe also consider using type-based declaration for eg. props and emits? > > https://vuejs.org/guide/typescript/composition-api.html#typing-component-props > > I usually like them alot more :) Absolutely! =) This pull-request also shouldn't be understood as a full typescript conversion (the title is a bit misleading). Rather I tried to do as little as possible so that the request can be reviewed and merged fast. We had too many large pull requests that stayed open for a long time and were hard to merge, so I try to split it into many smaller packages that are managable instead. If you look at other pull-requests you'll see that I usually implement typing for props and emits in converted and new components. Sometimes there is a component where I know that there is another pull request that's beeing worked on. In this case I try to keep the diff as minimal as possible to prevent complex merge conflicts. In the medium to long term the goal is to convert everything to typescript and [use the recommended linting settings](https://kolaente.dev/vikunja/frontend/pulls/930) (I think they also enforce some of the typing). **EDIT**: I want to add that I merged multiple pull request in this one together so in the end this results in a mixture between converting some components to ts and just adding `lang="ts"` / `defineComponent` / renaming to ts files.
Author
Member

I'm trying to incooporate the tsconfig files from https://github.com/vuejs/create-vue (or the compiled version under https://github.com/vuejs/create-vue-templates )

I'm trying to incooporate the tsconfig files from https://github.com/vuejs/create-vue (or the compiled version under https://github.com/vuejs/create-vue-templates )
konrad reviewed 2022-02-18 17:09:25 +00:00
@ -18,9 +18,11 @@
</template>
<script lang="ts">

Do we need this script tag here at all?

Do we need this script tag here at all?
Author
Member

Just because the name of the button is x-button (which we might want to change). But since this is not what this pull request is about I'd like not to change this here.

Just because the name of the button is `x-button` (which we might want to change). But since this is not what this pull request is about I'd like not to change this here.
dpschen marked this conversation as resolved
@ -0,0 +1,32 @@
import AbstractModel from './abstractModel'
import UserModel from './user'
export default class LinkShareModel extends AbstractModel {

nice catch!

nice catch!
Author
Member

I found it because there were weird bugs happening after I imported the wrond model :D

I found it because there were weird bugs happening after I imported the wrond model :D
dpschen marked this conversation as resolved
@ -0,0 +3,4 @@
import {register} from 'register-service-worker'
if (import.meta.env.PROD) {
register('/sw.ts', {

Did you test this? AFAIK this won't get compiled so the browser will try to load /sw.ts directly (and fail).

Did you test this? AFAIK this won't get compiled so the browser will try to load `/sw.ts` directly (and fail).
Author
Member

Will check.

Will check.

Looks like the sw.js file itself is transpiled but the path here not adjusted automatically. I've adjusted the path in fb2eb4c439, seems to work great.

Looks like the `sw.js` file itself is transpiled but the path here not adjusted automatically. I've adjusted the path in fb2eb4c439580a34533a0bf0ee0adfb8f2d3b02d, seems to work great.
Author
Member

I have found some other issues with the pwa setup.
Will push some WIP changes regarding that soon.

I have found some other issues with the pwa setup. Will push some WIP changes regarding that soon.
@ -0,0 +39,4 @@
})
// Set the interceptors to process every request
const self = this

I'm wondering if the self is even required since we're only using arrow functions here?

I'm wondering if the `self` is even required since we're only using arrow functions here?
Author
Member

Seems not necessary else this line wouldn't work aswell: a2261a6900/src/services/abstractService.ts (L46)

Seems not necessary else this line wouldn't work aswell: https://kolaente.dev/vikunja/frontend/src/commit/a2261a69006fbc5e44b9fc8949f0e817cdd8078e/src/services/abstractService.ts#L46
Author
Member

Done in 5fad6bc57f

Done in https://kolaente.dev/vikunja/frontend/commit/5fad6bc57f248641767954e09002ce3297603096
dpschen marked this conversation as resolved
Owner

Looking good apart from the conflicts!

Looking good apart from the conflicts!
konrad force-pushed feature/feat-migrate-to-typescript from 5fad6bc57f to 175b786ec6 2022-04-02 15:17:22 +00:00 Compare
konrad added 1 commit 2022-04-02 15:23:27 +00:00
continuous-integration/drone/pr Build is passing Details
continuous-integration/drone/push Build is passing Details
fb2eb4c439
fix: service worker path
konrad approved these changes 2022-04-02 15:36:16 +00:00
konrad left a comment
Owner

Thanks for the effort!

Thanks for the effort!
konrad merged commit fb2eb4c439 into main 2022-04-02 15:36:32 +00:00
konrad deleted branch feature/feat-migrate-to-typescript 2022-04-02 15:36:32 +00:00
This repo is archived. You cannot comment on pull requests.
No description provided.