From 4a052483ff38bf88a60a603f0181d69501c09c65 Mon Sep 17 00:00:00 2001 From: ChangJoo Park Date: Wed, 21 Aug 2019 09:34:11 +0900 Subject: [PATCH 01/54] typescript support using typescript-build --- saofile.js | 18 ++++++++++++++++-- template/_package.json | 8 ++++++++ template/nuxt/nuxt.config.js | 3 +++ template/tsconfig.json | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 template/tsconfig.json diff --git a/saofile.js b/saofile.js index ad4756c08..ea2c6df4d 100644 --- a/saofile.js +++ b/saofile.js @@ -25,6 +25,16 @@ module.exports = { default: '{gitUser.name}', store: true }, + { + name: 'language', + message: 'Choose programming language', + choices: [ + { name: 'JavaScript', value: 'js' }, + { name: 'TypeScript', value: 'ts' } + ], + type: 'list', + default: 'yarn' + }, { name: 'pm', message: 'Choose the package manager', @@ -121,12 +131,14 @@ module.exports = { message: 'Choose development tools', type: 'checkbox', choices: [ - { name: 'jsconfig.json (Recommended for VS Code)', value: 'jsconfig.json' } + { name: 'jsconfig.json (Recommended for VS Code)', value: 'jsconfig.json' }, + { name: 'tsconfig.json (Recommended for VS Code and TypeScript)', value: 'tsconfig.json' } ], default: [] } ], templateData () { + const typescript = this.answers.language.includes('ts') const pwa = this.answers.features.includes('pwa') const eslint = this.answers.linter.includes('eslint') const prettier = this.answers.linter.includes('prettier') @@ -139,6 +151,7 @@ module.exports = { const edge = cliOptions.edge ? '-edge' : '' return { + typescript, pwa, eslint, prettier, @@ -213,7 +226,8 @@ module.exports = { filters: { '_.eslintrc.js': 'linter.includes("eslint")', '.prettierrc': 'linter.includes("prettier")', - 'jsconfig.json': 'devTools.includes("jsconfig.json")' + 'jsconfig.json': 'devTools.includes("jsconfig.json")', + 'tsconfig.json': 'devTools.includes("tsconfig.json")', } }) diff --git a/template/_package.json b/template/_package.json index 4cd757578..8d5251a30 100644 --- a/template/_package.json +++ b/template/_package.json @@ -49,6 +49,9 @@ <%_ } else { _%> "nuxt": "^2.0.0", <%_ } _%> + <%_ if (typescript) { _%> + "ts-node": "^8.3.0", + <%_ } _%> <%_ if (server !== 'none') { _%> "cross-env": "^5.2.0", <%_ } _%> @@ -111,6 +114,11 @@ <%_ if (server !== 'none') { _%> "nodemon": "^1.18.9", <%_ } _%> + <%_ if (typescript) { _%> + "@nuxt/typescript-build": "^0.1.10", + "@types/node": "^10.14.16", + "@types/webpack-env": "^1.14.0", + <%_ } _%> <%_ if (ui === 'tailwind') { _%> "@nuxtjs/tailwindcss": "^1.0.0", <%_ } else if (ui === 'vuetify') { _%> diff --git a/template/nuxt/nuxt.config.js b/template/nuxt/nuxt.config.js index 1e727ac51..936ad491a 100644 --- a/template/nuxt/nuxt.config.js +++ b/template/nuxt/nuxt.config.js @@ -83,6 +83,9 @@ module.exports = { ** Nuxt.js dev-modules */ devModules: [ + <%_ if (typescript) {_%> + '@nuxt/typescript-build', + <%_ } _%> <%_ if (eslint) { _%> // Doc: https://github.com/nuxt-community/eslint-module '@nuxtjs/eslint-module', diff --git a/template/tsconfig.json b/template/tsconfig.json new file mode 100644 index 000000000..8f80709e7 --- /dev/null +++ b/template/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "target": "esnext", + "module": "esnext", + "moduleResolution": "node", + "lib": [ + "esnext", + "esnext.asynciterable", + "dom" + ], + "esModuleInterop": true, + "allowJs": true, + "sourceMap": true, + "strict": true, + "noEmit": true, + "experimentalDecorators": true, + "baseUrl": ".", + "paths": { + "~/*": [ + "./*" + ], + "@/*": [ + "./*" + ] + }, + "types": [ + "@types/node", + "@nuxt/types" + ] + }, + "exclude": [ + "node_modules" + ] +} From 4bd4f0876932832ddbc02385cc10823225c6cfa9 Mon Sep 17 00:00:00 2001 From: ChangJoo Park Date: Wed, 21 Aug 2019 09:41:54 +0900 Subject: [PATCH 02/54] Remove trailing comma --- saofile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/saofile.js b/saofile.js index ea2c6df4d..db6bc8684 100644 --- a/saofile.js +++ b/saofile.js @@ -227,7 +227,7 @@ module.exports = { '_.eslintrc.js': 'linter.includes("eslint")', '.prettierrc': 'linter.includes("prettier")', 'jsconfig.json': 'devTools.includes("jsconfig.json")', - 'tsconfig.json': 'devTools.includes("tsconfig.json")', + 'tsconfig.json': 'devTools.includes("tsconfig.json")' } }) From e244e81a31928597428acff3043400095fb2567e Mon Sep 17 00:00:00 2001 From: ChangJoo Park Date: Thu, 29 Aug 2019 21:31:18 +0900 Subject: [PATCH 03/54] remove @types/node --- template/_package.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/template/_package.json b/template/_package.json index 8d5251a30..19f11c678 100644 --- a/template/_package.json +++ b/template/_package.json @@ -116,8 +116,6 @@ <%_ } _%> <%_ if (typescript) { _%> "@nuxt/typescript-build": "^0.1.10", - "@types/node": "^10.14.16", - "@types/webpack-env": "^1.14.0", <%_ } _%> <%_ if (ui === 'tailwind') { _%> "@nuxtjs/tailwindcss": "^1.0.0", From bf7e77c541f7303479135381ff163b1a3a497011 Mon Sep 17 00:00:00 2001 From: ChangJoo Park Date: Thu, 29 Aug 2019 22:18:42 +0900 Subject: [PATCH 04/54] Add default / ts-runtime for none server + ts --- saofile.js | 12 ++++++++++++ template/_package.json | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/saofile.js b/saofile.js index db6bc8684..f9cd817ae 100644 --- a/saofile.js +++ b/saofile.js @@ -82,6 +82,16 @@ module.exports = { ], default: 'none' }, + { + name: 'runtime', + message: 'Choose the runtime for TypeScript', + type: 'list', + choices: [ + { name: 'Default', value: 'none' }, + { name: '@nuxt/typescript-runtime', value: 'ts-runtime' } + ], + when: answers => answers.language === 'ts' && answers.server === 'none' + }, { name: 'features', message: 'Choose Nuxt.js modules', @@ -139,6 +149,7 @@ module.exports = { ], templateData () { const typescript = this.answers.language.includes('ts') + const tsRuntime = this.answers.runtime.includes('ts-runtime') const pwa = this.answers.features.includes('pwa') const eslint = this.answers.linter.includes('eslint') const prettier = this.answers.linter.includes('prettier') @@ -152,6 +163,7 @@ module.exports = { return { typescript, + tsRuntime, pwa, eslint, prettier, diff --git a/template/_package.json b/template/_package.json index 19f11c678..57f7bbce3 100644 --- a/template/_package.json +++ b/template/_package.json @@ -6,10 +6,17 @@ "private": true, "scripts": { <%_ if (server === 'none') { _%> + <%_ if (tsRuntime) { _%> + "dev": "nuxt-ts", + "build": "nuxt-ts build", + "generate": "nuxt-ts generate", + "start": "nuxt-ts start", + <%_ } else { _%> "dev": "nuxt", "build": "nuxt build", "start": "nuxt start", "generate": "nuxt generate", + <%_ } _%> <%_ } else if (server === 'adonis') { _%> "serve:dev": "<%= pmRun %> dev", "dev": "nodemon --watch app --watch bootstrap --watch config --watch .env -x node server.js", @@ -52,6 +59,9 @@ <%_ if (typescript) { _%> "ts-node": "^8.3.0", <%_ } _%> + <%_ if (tsRuntime) { _%> + "@nuxt/typescript-runtime": "^0.1.3", + <%_ } _%> <%_ if (server !== 'none') { _%> "cross-env": "^5.2.0", <%_ } _%> From bf36d5de1f3aa4e222fbd7a4912c24342dfff365 Mon Sep 17 00:00:00 2001 From: ChangJoo Park Date: Thu, 29 Aug 2019 22:21:24 +0900 Subject: [PATCH 05/54] set lang="ts" when using typescript --- template/nuxt/pages/index.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/template/nuxt/pages/index.vue b/template/nuxt/pages/index.vue index 3b11a65e4..e774b84de 100644 --- a/template/nuxt/pages/index.vue +++ b/template/nuxt/pages/index.vue @@ -28,7 +28,11 @@ +<%_ if (typescript) { _%> + - +<%_ } _%>