Skip to content

Commit b3da4ec

Browse files
committed
ignore ts errors for placeholder script of vue file
1 parent 83c9432 commit b3da4ec

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

src/VueProgram.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ class VueProgram {
216216
if (!script) {
217217
return {
218218
scriptKind: ts.ScriptKind.JS,
219-
content: '// tslint:disable\nexport default {};\n'
219+
content: '/* tslint:disable */\nexport default {};\n'
220220
};
221221
}
222222

@@ -228,8 +228,14 @@ class VueProgram {
228228
const src = script.attrs.src.replace(/\.tsx?$/i, '');
229229
return {
230230
scriptKind,
231-
content: '// tslint:disable\n'
231+
232+
// For now, ignore the error when the src file is not found
233+
// since it will produce incorrect code location.
234+
// It's not a large problem since it's handled on webpack side.
235+
content: '/* tslint:disable */\n'
236+
+ '// @ts-ignore\n'
232237
+ `export { default } from '${src}';\n`
238+
+ '// @ts-ignore\n'
233239
+ `export * from '${src}';\n`
234240
};
235241
}

test/integration/vue.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ describe('[INTEGRATION] vue', function () {
154154
});
155155
});
156156

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

160160
compiler.run(function(error, stats) {
161-
expect(stats.compilation.errors.length).to.be.equal(1);
161+
const errors = stats.compilation.errors;
162+
expect(errors.length).to.be.equal(1);
163+
expect(errors[0].file).to.match(/test\/integration\/vue\/src\/attrs\/test.ts$/);
162164
callback();
163165
});
164166
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<template>
2+
<div>Hello</div>
3+
</template>
4+
5+
<script lang="ts" src="./notfound.ts"></script>

test/integration/vue/tsconfig-attrs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"compilerOptions": {},
33
"include": [
4-
"src/attrs/Test.vue"
4+
"src/attrs/Test.vue",
5+
"src/attrs/NotFound.vue"
56
],
67
"exclude": [
78
"node_modules"

0 commit comments

Comments
 (0)