Diagnostic for expressions of Vue.js templates
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
data
src
test
types
.gitignore
.travis.yml
LICENSE
README.md
package.json
tsconfig.base.json
tslint.json
yarn.lock

README.md

vue-template-diagnostic

Example

import {
  createComponentHost,
  createTypeRepository,
  parseExpression,
  checkExpression
} from 'vue-template-diagnostic'

// Create TypeScript context
const checker = program.getTypeChecker()
const context = { ts, program, checker }

// Create a type repository
const repository = createTypeRepository(context)

// Get a TypeScript source file of a Vue.js component somehow
const source = program.getSourceFile('/path/to/component.ts')

// Create a component host
const host = createComponentHost(source, context)
if (host) {
  // Parse an expression in a Vue.js template
  const exp = parseExpression('"Hello, " + msg')

  if (!exp.failed) {
    // Check the parsed expression.
    // Must be provided a variables scope (you can use `host.members`)
    // and type repository
    const diagnostics = checkExpression(exp.value, host.members, repository)

    console.log(diagnostics)
  }
}

License

MIT