jackmoore / autosize

Autosize is a small, stand-alone script to automatically adjust textarea height to fit text.
http://www.jacklmoore.com/autosize/
MIT License
5.1k stars 702 forks source link

support typescript #369

Closed Mikkou closed 6 years ago

Mikkou commented 6 years ago

Hello When i include your package into vue component on ts i have this error

Error: Module build failed: SyntaxError: Unexpected token (1:1894)
    at Parser.pp$4.raise (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2610)
    at Parser.pp.unexpected (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:637)
    at Parser.pp$3.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2094)
    at Parser.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:4372)
    at Parser.pp$3.parseExprSubscripts (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1955)
    at Parser.pp$3.parseMaybeUnary (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1932)
    at Parser.pp$3.parseExprOps (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1874)
    at Parser.pp$3.parseMaybeConditional (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1857)
    at Parser.pp$3.parseMaybeAssign (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1832)
    at Parser.pp$3.parseExpression (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1803)
    at Parser.pp$1.parseStatement (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:797)
    at Parser.pp$1.parseBlock (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1076)
    at Parser.pp$3.parseFunctionBody (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2466)
    at Parser.pp$1.parseFunction (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1177)
    at Parser.pp$3.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2082)
    at Parser.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:4372)
    at Parser.pp$3.parseExprSubscripts (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1955)
    at Parser.pp$3.parseMaybeUnary (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1932)
    at Parser.pp$3.parseExprOps (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1874)
    at Parser.pp$3.parseMaybeConditional (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1857)
    at Parser.pp$3.parseMaybeAssign (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1832)
    at Parser.pp$3.parsePropertyValue (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2310)
    at Parser.parseObj (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:4472)
    at Parser.pp$3.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2077)
    at Parser.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:4372)
    at Parser.pp$3.parseExprSubscripts (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1955)
    at Parser.pp$3.parseMaybeUnary (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1932)
    at Parser.pp$3.parseExprOps (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1874)
    at Parser.pp$3.parseMaybeConditional (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1857)
    at Parser.pp$3.parseMaybeAssign (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1832)
    at Parser.pp$4.raise (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2610)
    at Parser.pp.unexpected (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:637)
    at Parser.pp$3.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2094)
    at Parser.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:4372)
    at Parser.pp$3.parseExprSubscripts (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1955)
    at Parser.pp$3.parseMaybeUnary (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1932)
    at Parser.pp$3.parseExprOps (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1874)
    at Parser.pp$3.parseMaybeConditional (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1857)
    at Parser.pp$3.parseMaybeAssign (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1832)
    at Parser.pp$3.parseExpression (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1803)
    at Parser.pp$1.parseStatement (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:797)
    at Parser.pp$1.parseBlock (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1076)
    at Parser.pp$3.parseFunctionBody (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2466)
    at Parser.pp$1.parseFunction (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1177)
    at Parser.pp$3.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2082)
    at Parser.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:4372)
    at Parser.pp$3.parseExprSubscripts (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1955)
    at Parser.pp$3.parseMaybeUnary (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1932)
    at Parser.pp$3.parseExprOps (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1874)
    at Parser.pp$3.parseMaybeConditional (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1857)
    at Parser.pp$3.parseMaybeAssign (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1832)
    at Parser.pp$3.parsePropertyValue (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2310)
    at Parser.parseObj (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:4472)
    at Parser.pp$3.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:2077)
    at Parser.parseExprAtom (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:4372)
    at Parser.pp$3.parseExprSubscripts (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1955)
    at Parser.pp$3.parseMaybeUnary (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1932)
    at Parser.pp$3.parseExprOps (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1874)
    at Parser.pp$3.parseMaybeConditional (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1857)
    at Parser.pp$3.parseMaybeAssign (home/bitrix/www/node_modules/vue-template-es2015-compiler/buble.js:1832)
    at Object../node_modules/vue-loader/lib/template-compiler/index.js?{"id":"data-v-9613ffb8","hasScoped":true,"optionsId":"0","buble":{"transforms":{}}}!./node_modules/vue-loader/lib/selector.js?type=template&index=0!./src/components/FormCard.vue (AddObject~EditObject.67fc2d823fcac74c439e.js:1086)
    at __webpack_require__ (bootstrap:74)
    at Object../src/components/FormCard.vue (FormCard.vue:1)
    at __webpack_require__ (bootstrap:74)
    at Object../node_modules/ts-loader/index.js?{"appendTsSuffixTo":[{}]}!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/pages/AddObject.vue (AddObject.vue?9965:8)
    at __webpack_require__ (bootstrap:74)
    at Object../src/pages/AddObject.vue (AddObject.vue:1)
    at __webpack_require__ (bootstrap:74)

My code

<template>
    <div class="form-card__row form-card__description">
        <label :for="name"><strong>{{title}}</strong></label>
        <br>
        <textarea :id="name" ref="textarea" class="form-card__field" :name="name" rows="3"></textarea>
    </div>
</template>

<script lang="ts">
  import BaseComponent from '../BaseComponent'
  import {Component, Prop} from 'vue-property-decorator'
  import autosize from 'autosize'

  @Component({
    name: 'AutosizeTextarea'
  })

  export default class extends BaseComponent {
    constructor() {
      super()
    }

    @Prop(String) title!: String
    @Prop(String) name!: String

    mounted() {
      autosize(this.$refs.textarea)
    }
  }
</script>

What can be wrong?

Mikkou commented 6 years ago

issue closed. I found code v-model="{}" on this component... in this was problem.