From d55d79749ba679c8f743a4d83098e5424a3f71c1 Mon Sep 17 00:00:00 2001 From: "KJ(Kaijie) Huang" Date: Mon, 8 Nov 2021 16:42:33 -0500 Subject: [PATCH] chore: upgrade ts to 3.8 (#9122) * upgrade ts to 3.8 to use export type syntax * update prettier to 2.4.2 to avoid conflict with the local version in rn * fix prettier conflict with nohoist * fix analytics jest test config by esModuleInterop * add ts3.7 backward compatibility by typesVersions field Co-authored-by: Sam Martinez Co-authored-by: Ashika <35131273+ashika01@users.noreply.github.com> --- package.json | 8 ++++-- packages/analytics/package.json | 3 +- packages/analytics/tsconfig.json | 27 ------------------ packages/api/index.v37.d.ts | 12 ++++++++ packages/api/package.json | 7 +++++ packages/api/src/index.ts | 2 +- packages/api/src/types/index.ts | 48 ++++++++++++++++---------------- 7 files changed, 51 insertions(+), 56 deletions(-) delete mode 100755 packages/analytics/tsconfig.json create mode 100644 packages/api/index.v37.d.ts diff --git a/package.json b/package.json index 613dd2b0db6..6efa36888d0 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,9 @@ ], "nohoist": [ "**/@types/react-native", - "**/@types/react-native/**" + "**/@types/react-native/**", + "aws-amplify-react-native/prettier", + "aws-amplify-react-native/eslint-plugin-prettier" ] }, "repository": { @@ -71,7 +73,7 @@ "jest-config": "24.8.0", "json-loader": "^0.5.7", "lerna": "^3.13.1", - "prettier": "^1.19.0", + "prettier": "^2.4.1", "pretty-quick": "^1.11.1", "rimraf": "^2.6.2", "rollup": "^0.67.4", @@ -85,7 +87,7 @@ "tslint": "^5.7.0", "tslint-config-airbnb": "^5.8.0", "typedoc": "^0.16.9", - "typescript": "~3.7.7", + "typescript": "~3.8.3", "uglifyjs-webpack-plugin": "^0.4.6", "uuid-validate": "^0.0.3", "webpack": "^4.32.0", diff --git a/packages/analytics/package.json b/packages/analytics/package.json index 3abce6f0577..8075ad85fee 100644 --- a/packages/analytics/package.json +++ b/packages/analytics/package.json @@ -65,7 +65,8 @@ "esnext.asynciterable", "es2017.object" ], - "allowJs": true + "allowJs": true, + "esModuleInterop": true } } }, diff --git a/packages/analytics/tsconfig.json b/packages/analytics/tsconfig.json deleted file mode 100755 index cdae996f049..00000000000 --- a/packages/analytics/tsconfig.json +++ /dev/null @@ -1,27 +0,0 @@ -//WARNING: If you are manually specifying files to compile then the tsconfig.json is completely ignored, you must use command line flags -{ - "compilerOptions": { - "outDir": "./lib/", - "target": "es5", - "noImplicitAny": false, - "lib": [ - "es5", - "es2015", - "dom", - "esnext.asynciterable", - "es2017.object", - "es2018.promise", - "es2016" - ], - "sourceMap": true, - "module": "commonjs", - "moduleResolution": "node", - "allowJs": false, - "declaration": true, - "typeRoots": ["./node_modules/@types", "../../node_modules/@types"], - "types": ["node"], - "esModuleInterop": true - }, - "include": ["src/**/*"], - "exclude": ["src/setupTests.ts"] -} diff --git a/packages/api/index.v37.d.ts b/packages/api/index.v37.d.ts new file mode 100644 index 00000000000..917207408f8 --- /dev/null +++ b/packages/api/index.v37.d.ts @@ -0,0 +1,12 @@ +// the original ts3.7 version declaration file, used by "typesVersions" field in package.json +// https://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html#file-redirects +// can consider using third-party tool like downlevel-dts in the build process to automate this. +import { API } from './lib-esm/API'; +export { API, APIClass } from './lib-esm/API'; +export { + graphqlOperation, + GraphQLAuthError, + GRAPHQL_AUTH_MODE, + GraphQLResult, +} from '@aws-amplify/api-graphql'; +export default API; diff --git a/packages/api/package.json b/packages/api/package.json index e4a7740d92d..9ba5fc8f802 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -5,6 +5,13 @@ "main": "./lib/index.js", "module": "./lib-esm/index.js", "typings": "./lib-esm/index.d.ts", + "typesVersions": { + "<3.8": { + "lib-esm/index.d.ts": [ + "index.v37.d.ts" + ] + } + }, "react-native": { "./lib/index": "./lib-esm/index.js" }, diff --git a/packages/api/src/index.ts b/packages/api/src/index.ts index 865a130576a..b15247fe01a 100644 --- a/packages/api/src/index.ts +++ b/packages/api/src/index.ts @@ -16,11 +16,11 @@ import { API } from './API'; export { API, APIClass } from './API'; export { graphqlOperation, - GraphQLResult, GraphQLAuthError, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql'; +export type { GraphQLResult } from '@aws-amplify/api-graphql'; /* * @deprecated use named import */ diff --git a/packages/api/src/types/index.ts b/packages/api/src/types/index.ts index 98f688a6649..d5c6446b6e1 100644 --- a/packages/api/src/types/index.ts +++ b/packages/api/src/types/index.ts @@ -1,24 +1,24 @@ -/* - * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with - * the License. A copy of the License is located at - * - * http://aws.amazon.com/apache2.0/ - * - * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions - * and limitations under the License. - */ - -/** - * This exports from the types directory is a temporary workaround, since Amplify CLI currently - * generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863 - * This will be removed in future release when CLI and customers moves to recommeneded import styles. - */ -export { - graphqlOperation, - GraphQLAuthError, - GraphQLResult, - GRAPHQL_AUTH_MODE, -} from '@aws-amplify/api-graphql'; +/* + * Copyright 2017-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with + * the License. A copy of the License is located at + * + * http://aws.amazon.com/apache2.0/ + * + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +/** + * This exports from the types directory is a temporary workaround, since Amplify CLI currently + * generates code that relies on this import path https://github.com/aws-amplify/amplify-cli/issues/3863 + * This will be removed in future release when CLI and customers moves to recommeneded import styles. + */ +export { + graphqlOperation, + GraphQLAuthError, + GraphQLResult, + GRAPHQL_AUTH_MODE, +} from '@aws-amplify/api-graphql';