- Hello {userName}! - -
- - - - - diff --git a/test/e2e/fixtures/typescript-vue/src/component/LoginForm.vue b/test/e2e/fixtures/typescript-vue/src/component/LoginForm.vue deleted file mode 100644 index fd227b7a..00000000 --- a/test/e2e/fixtures/typescript-vue/src/component/LoginForm.vue +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - diff --git a/test/e2e/fixtures/typescript-vue/src/model/Role.ts b/test/e2e/fixtures/typescript-vue/src/model/Role.ts deleted file mode 100644 index e5fff7bd..00000000 --- a/test/e2e/fixtures/typescript-vue/src/model/Role.ts +++ /dev/null @@ -1,3 +0,0 @@ -type Role = 'admin' | 'client' | 'provider'; - -export default Role; diff --git a/test/e2e/fixtures/typescript-vue/src/model/User.ts b/test/e2e/fixtures/typescript-vue/src/model/User.ts deleted file mode 100644 index 5a0a1a62..00000000 --- a/test/e2e/fixtures/typescript-vue/src/model/User.ts +++ /dev/null @@ -1,16 +0,0 @@ -import Role from './Role'; - -type User = { - id: string; - email: string; - role: Role; - firstName?: string; - lastName?: string; -}; - -function getUserName(user: User): string { - return [user.firstName, user.lastName].filter((name) => name !== undefined).join(' '); -} - -export default User; -export { getUserName }; diff --git a/test/e2e/fixtures/typescript-vue/tsconfig.json b/test/e2e/fixtures/typescript-vue/tsconfig.json deleted file mode 100644 index 6a8e9a4c..00000000 --- a/test/e2e/fixtures/typescript-vue/tsconfig.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compilerOptions": { - "experimentalDecorators": true, - "jsx": "preserve", - "target": "ES5", - "lib": ["ES6", "DOM"], - "baseUrl": ".", - "paths": { - "@/*": ["src/*"], - "~/*": ["src/*"] - }, - "sourceMap": true, - "importsNotUsedAsValues": "preserve" - }, - "include": [ - "src" - ], - "exclude": [ - "node_modules" - ] -} diff --git a/test/e2e/fixtures/typescript-vue/webpack.config.js b/test/e2e/fixtures/typescript-vue/webpack.config.js deleted file mode 100644 index 97355023..00000000 --- a/test/e2e/fixtures/typescript-vue/webpack.config.js +++ /dev/null @@ -1,64 +0,0 @@ -const path = require('path'); -const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); - -let VueLoaderPlugin; -try { - // vue-loader 15 - VueLoaderPlugin = require('vue-loader/lib/plugin'); -} catch (error) { - // vue-loader 16 - VueLoaderPlugin = require('vue-loader/dist/plugin').default; -} - -module.exports = { - entry: './src/App.vue', - output: { - filename: 'index.js', - path: path.resolve(__dirname, 'dist'), - }, - module: { - rules: [ - { - test: /\.vue$/, - loader: 'vue-loader', - }, - { - test: /\.ts$/, - loader: 'ts-loader', - exclude: /node_modules/, - options: { - appendTsSuffixTo: [/\.vue$/], - transpileOnly: true, - }, - }, - { - test: /\.css$/, - loader: 'css-loader', - }, - ], - }, - resolve: { - extensions: ['.ts', '.js', '.vue', '.json'], - alias: { - '@': path.resolve(__dirname, './src'), - '~': path.resolve(__dirname, './src'), - }, - }, - plugins: [ - new VueLoaderPlugin(), - new ForkTsCheckerWebpackPlugin({ - async: false, - typescript: { - extensions: { - vue: { - enabled: true, - compiler: 'vue-template-compiler', - }, - }, - }, - }), - ], - infrastructureLogging: { - level: 'log', - }, -}; diff --git a/test/e2e/type-script-vue-extension.spec.ts b/test/e2e/type-script-vue-extension.spec.ts deleted file mode 100644 index c088ab2e..00000000 --- a/test/e2e/type-script-vue-extension.spec.ts +++ /dev/null @@ -1,117 +0,0 @@ -import path from 'path'; - -import { createWebpackDevServerDriver } from './driver/webpack-dev-server-driver'; - -describe('TypeScript Vue Extension', () => { - it.each([ - { - async: false, - compiler: 'vue-template-compiler', - typescript: '^3.8.0', - 'ts-loader': '^7.0.0', - 'vue-loader': '^15.8.3', - vue: '^2.6.11', - 'vue-template-compiler': '^2.6.11', - }, - { - async: true, - compiler: '@vue/compiler-sfc', - typescript: '^3.8.0', - 'ts-loader': '^7.0.0', - 'vue-loader': 'v16.0.0-beta.3', - vue: '^3.0.0-beta.14', - '@vue/compiler-sfc': '^3.0.0-beta.14', - }, - ])('reports semantic error for %p', async ({ async, compiler, ...dependencies }) => { - await sandbox.load(path.join(__dirname, 'fixtures/typescript-vue')); - await sandbox.install('yarn', { ...dependencies }); - await sandbox.patch('webpack.config.js', 'async: false,', `async: ${JSON.stringify(async)},`); - await sandbox.patch( - 'webpack.config.js', - "compiler: 'vue-template-compiler',", - `compiler: ${JSON.stringify(compiler)},` - ); - - if (dependencies.vue === '^2.6.11') { - await sandbox.write( - 'src/vue-shim.d.ts', - ['declare module "*.vue" {', ' import Vue from "vue";', ' export default Vue;', '}'].join( - '\n' - ) - ); - } else { - await sandbox.write('src/vue-shim.d.ts', 'declare module "*.vue";'); - } - - const driver = createWebpackDevServerDriver( - sandbox.spawn('yarn webpack serve --mode=development'), - async - ); - let errors: string[] = []; - - // first compilation is successful - await driver.waitForNoErrors(); - - // modify user model file - await sandbox.patch( - 'src/component/LoggedIn.vue', - "import User, { getUserName } from '@/model/User';", - "import User from '@/model/User';" - ); - - // next compilation should have missing function error - errors = await driver.waitForErrors(); - expect(errors).toEqual([ - [ - 'ERROR in ./src/component/LoggedIn.vue:27:23', - "TS2304: Cannot find name 'getUserName'.", - ' 25 | const user: User = this.user;', - ' 26 |', - " > 27 | return user ? getUserName(user) : '';", - ' | ^^^^^^^^^^^', - ' 28 | }', - ' 29 | },', - ' 30 | async logout() {', - ].join('\n'), - ]); - - // fix it - await sandbox.patch( - 'src/component/LoggedIn.vue', - "return user ? getUserName(user) : '';", - "return user ? `${user.firstName} ${user.lastName}` : '';" - ); - - await driver.waitForNoErrors(); - - // modify user model file again - await sandbox.patch('src/model/User.ts', ' firstName?: string;\n', ''); - - // not we should have an error about missing firstName property - errors = await driver.waitForErrors(); - expect(errors).toEqual([ - [ - 'ERROR in ./src/component/LoggedIn.vue:27:31', - "TS2339: Property 'firstName' does not exist on type 'User'.", - ' 25 | const user: User = this.user;', - ' 26 |', - " > 27 | return user ? `${user.firstName} ${user.lastName}` : '';", - ' | ^^^^^^^^^', - ' 28 | }', - ' 29 | },', - ' 30 | async logout() {', - ].join('\n'), - [ - 'ERROR in ./src/model/User.ts:11:16', - "TS2339: Property 'firstName' does not exist on type 'User'.", - ' 9 |', - ' 10 | function getUserName(user: User): string {', - " > 11 | return [user.firstName, user.lastName].filter((name) => name !== undefined).join(' ');", - ' | ^^^^^^^^^', - ' 12 | }', - ' 13 |', - ' 14 | export default User;', - ].join('\n'), - ]); - }); -}); diff --git a/test/unit/typescript/type-script-support.spec.ts b/test/unit/typescript/type-script-support.spec.ts index 5ef2e2e6..1d4eae9e 100644 --- a/test/unit/typescript/type-script-support.spec.ts +++ b/test/unit/typescript/type-script-support.spec.ts @@ -21,12 +21,6 @@ describe('typescript/type-script-support', () => { syntactic: false, }, enabled: true, - extensions: { - vue: { - enabled: false, - compiler: 'vue-template-compiler', - }, - }, memoryLimit: 2048, profile: false, typescriptPath: require.resolve('typescript'), diff --git a/test/unit/typescript/type-script-worker-config.spec.ts b/test/unit/typescript/type-script-worker-config.spec.ts index feca0137..33a84c32 100644 --- a/test/unit/typescript/type-script-worker-config.spec.ts +++ b/test/unit/typescript/type-script-worker-config.spec.ts @@ -6,7 +6,6 @@ import type webpack from 'webpack'; describe('typescript/type-scripts-worker-config', () => { let compiler: webpack.Compiler; - let createTypeScriptVueExtensionConfig: jest.Mock; const context = '/webpack/context'; const configuration: TypeScriptWorkerConfig = { @@ -23,12 +22,6 @@ describe('typescript/type-scripts-worker-config', () => { declaration: false, global: false, }, - extensions: { - vue: { - enabled: false, - compiler: 'vue-template-compiler', - }, - }, profile: false, typescriptPath: require.resolve('typescript'), }; @@ -39,13 +32,6 @@ describe('typescript/type-scripts-worker-config', () => { context, }, } as webpack.Compiler; - createTypeScriptVueExtensionConfig = jest.fn(() => ({ - enabled: false, - compiler: 'vue-template-compiler', - })); - jest.setMock('src/typescript/extension/vue/type-script-vue-extension-config', { - createTypeScriptVueExtensionConfig, - }); }); afterEach(() => { jest.resetModules(); @@ -99,23 +85,4 @@ describe('typescript/type-scripts-worker-config', () => { expect(config).toEqual(expectedConfig); }); - - it('passes vue options to the vue extension', async () => { - createTypeScriptVueExtensionConfig.mockImplementation(() => 'returned from vue extension'); - const { createTypeScriptWorkerConfig } = await import( - 'src/typescript/type-script-worker-config' - ); - - const vueOptions = { - enabled: true, - compiler: 'test-compiler', - }; - - const config = createTypeScriptWorkerConfig(compiler, { - extensions: { vue: vueOptions }, - }); - - expect(createTypeScriptVueExtensionConfig).toHaveBeenCalledWith(vueOptions); - expect(config.extensions.vue).toEqual('returned from vue extension'); - }); });