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

Type definition of $loading causes conflict when using nuxt-ts #1268

Closed
lu40 opened this issue Mar 7, 2019 · 18 comments
Closed

Type definition of $loading causes conflict when using nuxt-ts #1268

lu40 opened this issue Mar 7, 2019 · 18 comments

Comments

@lu40
Copy link

lu40 commented Mar 7, 2019

Overview of the problem

Buefy version: 0.7.3
Vuejs version: 2.6.8
Nuxt version: 2.4.5
OS/Browser: -

Description

When using nuxt-ts and buefy together the following error occurs:

73:18 Interface 'NuxtApp' incorrectly extends interface 'Vue'.
  Types of property '$loading' are incompatible.
    Property 'open' is missing in type 'NuxtLoading' but required in type '{ open: (params: LoadingConfig) => { close: () => any; }; }'.
    71 | }
    72 | 
  > 73 | export interface NuxtApp extends Vue {
       |                  ^
    74 |   $loading: NuxtLoading;
    75 |   isOffline: boolean;
    76 |   isOnline: boolean;

See the corresponding issue at nuxt: https://github.com/nuxt/nuxt.js/issues/4877

The proposed solution is to have a namespaced applied, like vuetify does. So I guess to have something like this.$buefy.loading.

As I wasn't able to find any workaround until now, this really makes it impossible to use buefy together with the typescript version of Nuxt. As $loading is a very generic name, I guess it's likely that this will not only conflict with Nuxt.

Steps to reproduce

  1. Install nuxt-ts together with Buefy
  2. See the error come up
@DonNicoJs
Copy link
Contributor

DonNicoJs commented Mar 7, 2019

While I agree 100% that namespacing is a good idea I would add for now a 'noconflict' mode that install under the name space and document this.

To then remove the mode and go only with the name space in the future to give people time to transition

Edit: node to mode

@lu40
Copy link
Author

lu40 commented Mar 7, 2019

@DonNicoJs Yes I think that'd be great! How would you set up this "noconflict" node? As a branch in this repository? I could probably do a PR next week.

@DonNicoJs
Copy link
Contributor

@lu40 I meant mode :D but yeah what I suggest is to modify this: https://github.com/buefy/buefy/blob/dev/src/utils/plugins.js#L12
to take a config parameter from the install to use the namespace.

@lu40
Copy link
Author

lu40 commented Mar 7, 2019

@DonNicoJs Ahh, I see! :D

I'm not sure though if this can solve the type definition problem of having $loading added to the Vue instance: https://github.com/buefy/buefy/blob/dev/types/index.d.ts#L10

For now, I only see the way of setting up a branch or fork, where the type definitions are namespaced too..

@DonNicoJs
Copy link
Contributor

@lu40 true that as well mmh but since all the ts users would use the name space (I think) we could change the types no?

@lu40
Copy link
Author

lu40 commented Mar 7, 2019

@DonNicoJs This only applies for the ones who use Nuxt. Other users, using e.g. plain Vue with Typescript and Buefy won't have the namespace conflict.

@DonNicoJs
Copy link
Contributor

@lu40 True, even tho I am of the opinion that the namespace should be the default.
Instead of two branch / fork what about 2 different set of types ? ( possibly auto-generated during the build ? ) One for the namespaced version and one for legacy

@axelthat
Copy link

When will the namespaced version be out btw?

@service-paradis
Copy link
Collaborator

@jtommy
Is this something that could be made for the next version (0.8.0) since it will already include some breaking changes?

@jtommy
Copy link
Member

jtommy commented Jul 13, 2019

Yes, probably I'll work on it for next version

@jtommy jtommy closed this as completed in 5ba5094 Jul 30, 2019
@lu40
Copy link
Author

lu40 commented Jul 31, 2019

Awesome! Thanks :)

@afwn90cj93201nixr2e1re
Copy link
Contributor

@jtommy it's too much breakable change.
Write some articles on doc's page.

@service-paradis
Copy link
Collaborator

@afwn90cj93201nixr2e1re
There is an entire section dedicated to breaking changes in the release notes for 0.8.0:
https://github.com/buefy/buefy/releases

@afwn90cj93201nixr2e1re
Copy link
Contributor

It's on github. Not on doc's site.

doc's page

@service-paradis
Copy link
Collaborator

Nope, the docs is for the current release. There is a link to the changelog if needed:
image

@afwn90cj93201nixr2e1re
Copy link
Contributor

There should be additional page, inside docs, merging from -> to.
Plain users should check it on docs page.

@jkhmnk
Copy link

jkhmnk commented Nov 8, 2019

试试 tsconfig.json compilerOptions参数里

"compilerOptions": {
"skipLibCheck": true
}

@jtommy
Copy link
Member

jtommy commented Nov 8, 2019

@jkhmnk now you shouldn't need it

carlobeltrame added a commit to gloggi/tramopoly that referenced this issue Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants