Skip to content

fix(typings): were not implemented correctly #289

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

Merged
merged 2 commits into from
Aug 1, 2018

Conversation

Tronix117
Copy link
Contributor

@Tronix117 Tronix117 commented Jul 26, 2018

Typings should not declare a module wereas they are already in the concerned module
Also, reusing Vue way of doing typings, and separating constructor from body to have better overriding capabilities


$refs generic types

import Vue from 'nativescript-vue'
import { RadSideDrawer } from 'nativescript-ui-sidedrawer'
import { Component } from 'components/decorator'

@Component({})
class TestComponent extends Vue {
    $refs: {
      drawer: Vue<RadSideDrawer>
      mainContent: Vue<StackLayout>
      drawerContent: Vue<StackLayout>,
    }

    mounted() {
        // `drawerView` will be of type RadSideDrawer
        const drawerView = this.$refs.drawer.nativeView
    }
}

Vue augmentation

You can augment the same way you are augmenting with Vue:

import Vue from 'vue'
import { Bus } from 'store/bus'
import * as moment from 'moment'
import { VueConstructor } from 'vue/types/vue'
import { Size } from 'tns-core-modules/ui/frame/frame'

import Components from 'components'
import * as http from 'http'

export interface VueDevice {
  screen: Size
  content: Size
  actionBar: Size
  navBar: Size
  statusBar: Size
  keyboard: Size
}

declare module 'vue/types/vue' {
  interface Vue {
    $http: typeof http,
    $bus: Bus
    $moment: typeof moment
    $device: VueDevice
  }

  interface VueConstructor {
    bus: Bus
    device: VueDevice
    moment: typeof moment
  }
}

Tronix117 and others added 2 commits July 26, 2018 18:18
Typings should not declare a module wereas they are already in the concerned module
Reusing Vue way of doing typings, and separating constructor from body to have better overriding capabilities
@rigor789 rigor789 merged commit bb265bd into nativescript-vue:master Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants