1
0
Эх сурвалжийг харах

feat(core): Update to TypeScript v4.0.3

BREAKING CHANGE: All Vendure packages are now built on TypeScript v4.0.3. With new TypeScript versions come the possibility that its improved type-checking abilities will uncover new errors that it had not detected previously.
Michael Bromley 5 жил өмнө
parent
commit
e1ce807923

+ 1 - 1
package.json

@@ -53,7 +53,7 @@
     "ts-jest": "^25.2.1",
     "ts-node": "^8.4.1",
     "tslint": "^5.11.0",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   },
   "resolutions": {
     "npm-packlist": "1.1.12"

+ 1 - 1
packages/admin-ui-plugin/package.json

@@ -23,7 +23,7 @@
     "@vendure/core": "^0.15.2",
     "express": "^4.17.1",
     "rimraf": "^3.0.2",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   },
   "dependencies": {
     "fs-extra": "^9.0.1"

+ 2 - 2
packages/admin-ui/package.json

@@ -27,6 +27,7 @@
     "@angular/platform-browser": "10.1.4",
     "@angular/platform-browser-dynamic": "10.1.4",
     "@angular/router": "10.1.4",
+    "@apollo/client": "^3.0.0",
     "@biesbjerg/ngx-translate-extract-marker": "^1.0.0",
     "@clr/angular": "^4.0.3",
     "@clr/core": "^4.0.3",
@@ -57,8 +58,7 @@
     "prosemirror-state": "^1.3.3",
     "rxjs": "^6.6.3",
     "tslib": "^2.0.0",
-    "zone.js": "~0.10.2",
-    "@apollo/client": "^3.0.0"
+    "zone.js": "~0.10.2"
   },
   "devDependencies": {
     "@angular-devkit/build-angular": "~0.1001.4",

+ 1 - 1
packages/asset-server-plugin/package.json

@@ -28,7 +28,7 @@
     "express": "^4.17.1",
     "node-fetch": "^2.6.1",
     "rimraf": "^3.0.2",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   },
   "dependencies": {
     "file-type": "^15.0.1",

+ 1 - 1
packages/common/package.json

@@ -18,6 +18,6 @@
   ],
   "devDependencies": {
     "rimraf": "^3.0.2",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   }
 }

+ 10 - 13
packages/common/src/omit.ts

@@ -21,21 +21,18 @@ export function omit<T extends any, K extends keyof T>(
     }
 
     if (recursive && Array.isArray(obj)) {
-        return obj.map((item: any) => omit(item, keysToOmit, true));
+        return obj.map((item: any) => omit(item, keysToOmit, true)) as T;
     }
 
-    return Object.keys(obj).reduce(
-        (output: any, key) => {
-            if (keysToOmit.includes(key)) {
-                return output;
-            }
-            if (recursive) {
-                return { ...output, [key]: omit((obj as any)[key], keysToOmit, true) };
-            }
-            return { ...output, [key]: (obj as any)[key] };
-        },
-        {} as Omit<T, K>,
-    );
+    return Object.keys(obj as object).reduce((output: any, key) => {
+        if (keysToOmit.includes(key)) {
+            return output;
+        }
+        if (recursive) {
+            return { ...output, [key]: omit((obj as any)[key], keysToOmit, true) };
+        }
+        return { ...output, [key]: (obj as any)[key] };
+    }, {} as Omit<T, K>);
 }
 
 function isObject(input: any): input is object {

+ 1 - 1
packages/core/package.json

@@ -97,6 +97,6 @@
     "rimraf": "^3.0.2",
     "sql.js": "1.3.2",
     "sqlite3": "^5.0.0",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   }
 }

+ 1 - 1
packages/core/src/api/resolvers/admin/auth.resolver.ts

@@ -46,7 +46,7 @@ export class AuthResolver extends BaseAuthResolver {
         if (nativeAuthStrategyError) {
             return nativeAuthStrategyError;
         }
-        return (await super.login(args, ctx, req, res)) as AuthenticationResult;
+        return (await super.baseLogin(args, ctx, req, res)) as AuthenticationResult;
     }
 
     @Transaction()

+ 2 - 2
packages/core/src/api/resolvers/base/base-auth.resolver.ts

@@ -10,7 +10,7 @@ import {
 import { Request, Response } from 'express';
 
 import { isGraphQlErrorResult } from '../../../common/error/error-result';
-import { ForbiddenError, UnauthorizedError } from '../../../common/error/errors';
+import { ForbiddenError } from '../../../common/error/errors';
 import { NativeAuthStrategyError as AdminNativeAuthStrategyError } from '../../../common/error/generated-graphql-admin-errors';
 import {
     InvalidCredentialsError,
@@ -47,7 +47,7 @@ export class BaseAuthResolver {
      * Attempts a login given the username and password of a user. If successful, returns
      * the user data and returns the token either in a cookie or in the response body.
      */
-    async login(
+    async baseLogin(
         args: MutationLoginArgs,
         ctx: RequestContext,
         req: Request,

+ 1 - 1
packages/core/src/api/resolvers/shop/shop-auth.resolver.ts

@@ -72,7 +72,7 @@ export class ShopAuthResolver extends BaseAuthResolver {
         if (nativeAuthStrategyError) {
             return nativeAuthStrategyError;
         }
-        return (await super.login(args, ctx, req, res)) as AuthenticationResult;
+        return (await super.baseLogin(args, ctx, req, res)) as AuthenticationResult;
     }
 
     @Transaction()

+ 1 - 1
packages/core/src/i18n/i18n.service.ts

@@ -65,7 +65,7 @@ export class I18nService implements OnModuleInit {
             error.message = translation;
             // We can now safely remove the variables object so that they do not appear in
             // the error returned by the GraphQL API
-            delete originalError.variables;
+            delete (originalError as any).variables;
         }
 
         return error;

+ 1 - 1
packages/create/package.json

@@ -29,7 +29,7 @@
     "@vendure/core": "^0.15.2",
     "rimraf": "^3.0.2",
     "ts-node": "^9.0.0",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   },
   "dependencies": {
     "@vendure/common": "^0.15.0",

+ 1 - 1
packages/create/src/constants.ts

@@ -4,4 +4,4 @@ export const SERVER_PORT = 3000;
  * The TypeScript version needs to pinned because minor versions often
  * introduce breaking changes.
  */
-export const TYPESCRIPT_VERSION = '3.8.3';
+export const TYPESCRIPT_VERSION = '4.0.3';

+ 1 - 1
packages/dev-server/package.json

@@ -20,7 +20,7 @@
     "@vendure/core": "^0.15.2",
     "@vendure/elasticsearch-plugin": "^0.15.2",
     "@vendure/email-plugin": "^0.15.2",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   },
   "devDependencies": {
     "@types/csv-stringify": "^3.1.0",

+ 1 - 1
packages/elasticsearch-plugin/package.json

@@ -25,6 +25,6 @@
     "@vendure/common": "^0.15.0",
     "@vendure/core": "^0.15.2",
     "rimraf": "^3.0.2",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   }
 }

+ 1 - 1
packages/email-plugin/package.json

@@ -36,6 +36,6 @@
     "@vendure/common": "^0.15.0",
     "@vendure/core": "^0.15.2",
     "rimraf": "^3.0.2",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   }
 }

+ 1 - 1
packages/testing/package.json

@@ -48,6 +48,6 @@
     "mysql": "^2.18.1",
     "pg": "^8.4.0",
     "rimraf": "^3.0.0",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   }
 }

+ 1 - 1
packages/ui-devkit/package.json

@@ -57,6 +57,6 @@
     "rollup-plugin-terser": "^7.0.2",
     "rollup-plugin-typescript2": "^0.27.3",
     "tslib": "^1.10.0",
-    "typescript": "3.8.3"
+    "typescript": "4.0.3"
   }
 }

+ 0 - 5
yarn.lock

@@ -18008,11 +18008,6 @@ typeorm@0.2.28:
     yargonaut "^1.1.2"
     yargs "^16.0.3"
 
-typescript@3.8.3:
-  version "3.8.3"
-  resolved "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
-  integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
-
 typescript@4.0.2:
   version "4.0.2"
   resolved "https://registry.npmjs.org/typescript/-/typescript-4.0.2.tgz#7ea7c88777c723c681e33bf7988be5d008d05ac2"