Skip to content

Commit

Permalink
feat: vue-tsc extends Checker
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Jul 17, 2021
1 parent 0736c0d commit 95fddec
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/vite-plugin-checker/bin/vls
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env node
require('../lib/checkers/vls2/cli.js')
require('../lib/checkers/vls/cli.js')
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os from 'os'
import invariant from 'tiny-invariant'
import ts from 'typescript'
import { isMainThread, parentPort } from 'worker_threads'
import { parentPort } from 'worker_threads'

import { Checker, CheckerAbility } from '../../Checker'
import { diagnosticToTerminalLog, diagnosticToViteError, normalizeDiagnostic } from '../../logger'
Expand Down
38 changes: 38 additions & 0 deletions packages/vite-plugin-checker/src/checkers/vueTsc/main2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Checker, CheckerAbility } from '../../Checker'

import type { CreateDiagnostic } from '../../types'

// TODO: watch mode is not supported for now
const createDiagnostic: CreateDiagnostic<'vueTsc'> = (pluginConfig) => {
return {
config: (config) => {
//
},
configureServer(server) {
//
},
}
}

export class VueTscChecker extends Checker<'vueTsc'> implements CheckerAbility {
public constructor() {
super({
name: 'typescript',
absFilePath: __filename,
build: { buildBin: ['vue-tsc', ['--noEmit']] },
createDiagnostic,
})
}

public sealConclusion() {}

public init() {
const createServeAndBuild = super.initMainThread()
module.exports.createServeAndBuild = createServeAndBuild
super.initWorkerThread()
}
}

const vueTscChecker = new VueTscChecker()
vueTscChecker.prepare()
vueTscChecker.init()
2 changes: 1 addition & 1 deletion playground/vue3-vue-tsc/__tests__/test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('vue3-vue-tsc', () => {

it('enableBuild: false', async () => {
editFile('vite.config.ts', (code) =>
code.replace('vueTsc: true', 'typescript: true, enableBuild: false')
code.replace('vueTsc: true', 'vueTsc: true, enableBuild: false')
)
await viteBuild({ unexpectedErrorMsg: 'error TS2322', cwd: testDir })
})
Expand Down

0 comments on commit 95fddec

Please sign in to comment.