Skip to content

Commit

Permalink
ignore ts errors for placeholder script of vue file
Browse files Browse the repository at this point in the history
  • Loading branch information
ktsn committed Jul 25, 2018
1 parent 83c9432 commit b3da4ec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/VueProgram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class VueProgram {
if (!script) {
return {
scriptKind: ts.ScriptKind.JS,
content: '// tslint:disable\nexport default {};\n'
content: '/* tslint:disable */\nexport default {};\n'
};
}

Expand All @@ -228,8 +228,14 @@ class VueProgram {
const src = script.attrs.src.replace(/\.tsx?$/i, '');
return {
scriptKind,
content: '// tslint:disable\n'

// For now, ignore the error when the src file is not found
// since it will produce incorrect code location.
// It's not a large problem since it's handled on webpack side.
content: '/* tslint:disable */\n'
+ '// @ts-ignore\n'
+ `export { default } from '${src}';\n`
+ '// @ts-ignore\n'
+ `export * from '${src}';\n`
};
}
Expand Down
6 changes: 4 additions & 2 deletions test/integration/vue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,13 @@ describe('[INTEGRATION] vue', function () {
});
});

it('should resolve src attribute and check referred source', function (callback) {
it('should resolve src attribute but not report not found error', function (callback) {
createCompiler({ vue: true, tsconfig: 'tsconfig-attrs.json' });

compiler.run(function(error, stats) {
expect(stats.compilation.errors.length).to.be.equal(1);
const errors = stats.compilation.errors;
expect(errors.length).to.be.equal(1);
expect(errors[0].file).to.match(/test\/integration\/vue\/src\/attrs\/test.ts$/);
callback();
});
});
Expand Down
5 changes: 5 additions & 0 deletions test/integration/vue/src/attrs/NotFound.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div>Hello</div>
</template>

<script lang="ts" src="./notfound.ts"></script>
3 changes: 2 additions & 1 deletion test/integration/vue/tsconfig-attrs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {},
"include": [
"src/attrs/Test.vue"
"src/attrs/Test.vue",
"src/attrs/NotFound.vue"
],
"exclude": [
"node_modules"
Expand Down

0 comments on commit b3da4ec

Please sign in to comment.