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

generation fails if sfc has additional type/interface/class declarations #11

Closed
lucastheisen opened this issue May 25, 2017 · 5 comments

Comments

@lucastheisen
Copy link
Contributor

lucastheisen commented May 25, 2017

As a simple example, this sfc:

<template>
  <div>{{ foo }}</div>
</template>

<script lang="ts">
import Vue = require('vue')
import Component from 'vue-class-component'

type Foo = string;

@Component
export default class TsClass extends Vue {
  foo: Foo = 'Hello'
}
</script>

<style>
div {
  color: red;
}
</style>

Will not generate a *.vue.d.ts file. A little digging shows that the following line in language-service.ts:

    const output = this.tsService.getEmitOutput(fileName, true)

Will emit

{
  "outputFiles": [],
  "emitSkipped": true
}

I have a unit test demonstrating this, and can provide as a pull request if you would like, but it would break the CI unless you fixed this issue...

lucastheisen pushed a commit to lucastheisen/vuetype that referenced this issue May 25, 2017
@ktsn
Copy link
Owner

ktsn commented May 26, 2017

I guess this is because Foo type is not exported while it is used in component type. As we generates declaration files, we cannot use private types in a part of exported types.

@lucastheisen
Copy link
Contributor Author

@ktsn , I modified the following change:

--- a/test/fixtures/ts-class-with-additional-type.vue
+++ b/test/fixtures/ts-class-with-additional-type.vue
@@ -6,7 +6,7 @@
 import Vue = require('vue')
 import Component from 'vue-class-component'

-type Foo = string;
+export type Foo = string;

 @Component
 export default class TsClass extends Vue {

It still fails in the same manner. If you would like, I could submit a pull request for this unit test... Or you can tinker with my fork (specifically the genfail branch)

@ktsn
Copy link
Owner

ktsn commented May 26, 2017

PR for unit test is welcome 🙂

@lucastheisen
Copy link
Contributor Author

Supplied: unit test for generation fails if sfc has additional type/interface/class declarations #12

@ktsn
Copy link
Owner

ktsn commented May 26, 2017

See #12 (comment)

@ktsn ktsn closed this as completed May 26, 2017
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

No branches or pull requests

2 participants