Giter VIP home page Giter VIP logo

Comments (10)

prograhammer avatar prograhammer commented on May 21, 2024 4

The new PR is up and waiting feedback/approval: #77

For a quick install into your current Vue project (to see it working):

 npm install git://github.com/prograhammer/fork-ts-checker-webpack-plugin.git#vue --save-dev

See this post further up this thread for instructions on Webpack config and more.

from fork-ts-checker-webpack-plugin.

prograhammer avatar prograhammer commented on May 21, 2024 2

This actually can be accomplished by overriding default host behavior with host.resolveModuleNames (just like it is already being done in host.getSourceFile in the source here). Since the .vue file is not going to be processed through vue-loader, I'm using a parser to get the AST and strip out the typescript. This might need to be optimized later, but my PR should get it working for everyone eagerly waiting vue support!

Stay tuned, I working on a PR now and should be done by tomorrow-ish!

from fork-ts-checker-webpack-plugin.

prograhammer avatar prograhammer commented on May 21, 2024 1

For anyone else following this thread, you can use this plugin right away with npm install git://github.com/prograhammer/fork-ts-checker-webpack-plugin.git#temp --save-dev. Check back in a week and we'll have the PR merged or I'll just put it on npm so we can all just get back to writing Vue apps!

from fork-ts-checker-webpack-plugin.

prograhammer avatar prograhammer commented on May 21, 2024 1

Alright! I found how to get it to work fully on .vue files (without need to go the route of .vue.ts).

It's working in my vscode extension fork: TSLint Vue. So now I can release a new working PR here. Stay tuned!

from fork-ts-checker-webpack-plugin.

Toilal avatar Toilal commented on May 21, 2024

Thanks. When PR is ready, I will will include it as soon as possible in my vue webpack template fork https://github.com/Toilal/vue-webpack-template to test this.

from fork-ts-checker-webpack-plugin.

prograhammer avatar prograhammer commented on May 21, 2024

Hi @Toilal

You can see the PR here: #77
For a quick test, I created a vue branch (out of the feature/vue branch) with the built lib folder included. So you can install like this:

npm install git://github.com/prograhammer/fork-ts-checker-webpack-plugin.git#vue --save-dev

  1. Turn on the vue option in the plugin in your webpack config:
    new ForkTsCheckerWebpackPlugin({
      tslint: true,
      vue: true
    })
  1. For linting to work in .vue files, you need to ensure your script tag's language attribute is set
    to ts or tsx (also make sure you include the .vue extension in all your import statements as shown below):
<script lang="ts">
import Hello from '@/components/hello.vue'

// ...

</script>
  1. If you are testing in Webpack, (in addition to this plugin) you'll need something like this in your rules:
{
  test: /\.ts$/,
  loader: 'ts-loader',
  include: [resolve('src'), resolve('test')],
  options: {
    appendTsSuffixTo: [/\.vue$/],
    transpileOnly: true
  }
},
{
  test: /\.vue$/,
  loader: 'vue-loader',
  options: vueLoaderConfig
},
  1. I also currently use tslint-config-standard so my tslint.json looks something like:
{
    "defaultSeverity": "error",
    "extends": [
      "tslint-config-standard"
    ]
}
  1. Ensure your tsconfig.json doesn't exclude .vue files:
// tsconfig.json
{
  "include": [
    "src/**/*.ts",
    "src/**/*.vue"
  ],
  "exclude": [
      "node_modules"
  ],
  "compilerOptions": {
    
    // ...

    "baseUrl": ".",
    "paths": {
      "@/*": [
        "src/*"
      ]
    }
  }
}

If you are working in VSCode, you'll need extensions Vetur and TSLint Vue (a forked extension which I also currently maintain) and the editor will match the output you get from this fork-ts-checker-webpack-plugin.

from fork-ts-checker-webpack-plugin.

prograhammer avatar prograhammer commented on May 21, 2024

I just found a critical problem that I'm working to fix. It looks like the .vue file has to be referenced somewhere in the import dependency chain that leads back to the entry point (ie. main.ts). It is also having problems with relative path imports of .vue files. I somehow missed this before PR. Working on it...

from fork-ts-checker-webpack-plugin.

johnnyreilly avatar johnnyreilly commented on May 21, 2024

Exciting!!

from fork-ts-checker-webpack-plugin.

RehanSaeed avatar RehanSaeed commented on May 21, 2024

I seem to be able to build and run my app with and without the vue: true option. What exactly does it do?

from fork-ts-checker-webpack-plugin.

Toilal avatar Toilal commented on May 21, 2024

this adds TypeScript type checking and TSLint to vue SFC.

from fork-ts-checker-webpack-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.