From 3906decaf5fb43850f31f78a9f6e1604a5d360f1 Mon Sep 17 00:00:00 2001 From: hkjpotato Date: Wed, 27 Oct 2021 22:32:07 -0400 Subject: [PATCH 1/8] upgrade ts to 3.8 to use export type syntax --- package.json | 4 +-- packages/analytics/tsconfig.json | 27 ------------------ packages/api/src/index.ts | 2 +- packages/api/src/types/index.ts | 48 ++++++++++++++++---------------- 4 files changed, 27 insertions(+), 54 deletions(-) delete mode 100755 packages/analytics/tsconfig.json diff --git a/package.json b/package.json index 613dd2b0db6..32281c12153 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "jest-config": "24.8.0", "json-loader": "^0.5.7", "lerna": "^3.13.1", - "prettier": "^1.19.0", + "prettier": "^2.0.0", "pretty-quick": "^1.11.1", "rimraf": "^2.6.2", "rollup": "^0.67.4", @@ -85,7 +85,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/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/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..c07f22b6419 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-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, + GRAPHQL_AUTH_MODE, +} from '@aws-amplify/api-graphql'; +export type { GraphQLResult } from '@aws-amplify/api-graphql'; From 80d3ec78a07d123e9f11dfc9aff6c7881e8d9a34 Mon Sep 17 00:00:00 2001 From: hkjpotato Date: Thu, 28 Oct 2021 15:16:44 -0400 Subject: [PATCH 2/8] update prettier to 2.4.2 to avoid conflict with the local version in rn --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 32281c12153..0ec1b00291b 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "jest-config": "24.8.0", "json-loader": "^0.5.7", "lerna": "^3.13.1", - "prettier": "^2.0.0", + "prettier": "^2.4.2", "pretty-quick": "^1.11.1", "rimraf": "^2.6.2", "rollup": "^0.67.4", From da61bdd01ee5f9d2b0359a2d808973d45141a1e8 Mon Sep 17 00:00:00 2001 From: hkjpotato Date: Thu, 28 Oct 2021 17:20:28 -0400 Subject: [PATCH 3/8] fix prettier conflict with nohoist --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0ec1b00291b..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": "^2.4.2", + "prettier": "^2.4.1", "pretty-quick": "^1.11.1", "rimraf": "^2.6.2", "rollup": "^0.67.4", From 16e0512860fc0cfed1a00fa31a998082eb3c0a84 Mon Sep 17 00:00:00 2001 From: hkjpotato Date: Thu, 28 Oct 2021 18:51:33 -0400 Subject: [PATCH 4/8] fix analytics jest test config by esModuleInterop --- packages/analytics/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/analytics/package.json b/packages/analytics/package.json index d2bbfe8eb99..62996d557b0 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 } } }, From 7078fdf8c773b553e1e1cf418238a77201c1551e Mon Sep 17 00:00:00 2001 From: hkjpotato Date: Tue, 2 Nov 2021 12:43:52 -0400 Subject: [PATCH 5/8] add ts3.7 backward compatibility --- packages/api/package.json | 7 +++++++ packages/api/types/ts3.7/index.d.ts | 11 +++++++++++ 2 files changed, 18 insertions(+) create mode 100644 packages/api/types/ts3.7/index.d.ts diff --git a/packages/api/package.json b/packages/api/package.json index 11db46e91fd..d327f9ba2df 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": [ + "types/ts3.7/index.d.ts" + ] + } + }, "react-native": { "./lib/index": "./lib-esm/index.js" }, diff --git a/packages/api/types/ts3.7/index.d.ts b/packages/api/types/ts3.7/index.d.ts new file mode 100644 index 00000000000..1efbc52e1d8 --- /dev/null +++ b/packages/api/types/ts3.7/index.d.ts @@ -0,0 +1,11 @@ +// the original ts3.7 version declaration file, used by "typesVersions" field in package.json +// can consider introducing tool like downlevel-dts in the build process in the future +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; From a3d66e7ba140901dbf264a5927c0d0b7f4ef099f Mon Sep 17 00:00:00 2001 From: hkjpotato Date: Tue, 2 Nov 2021 17:06:23 -0400 Subject: [PATCH 6/8] update to use direct file reference --- packages/api/index.v37.d.ts | 12 ++++++++++++ packages/api/package.json | 4 ++-- packages/api/types/ts3.7/index.d.ts | 11 ----------- 3 files changed, 14 insertions(+), 13 deletions(-) create mode 100644 packages/api/index.v37.d.ts delete mode 100644 packages/api/types/ts3.7/index.d.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 d327f9ba2df..a9d562899f5 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -7,8 +7,8 @@ "typings": "./lib-esm/index.d.ts", "typesVersions": { "<3.8": { - "./lib-esm/index.d.ts": [ - "types/ts3.7/index.d.ts" + "lib-esm/index.d.ts": [ + "index.v37.d.ts" ] } }, diff --git a/packages/api/types/ts3.7/index.d.ts b/packages/api/types/ts3.7/index.d.ts deleted file mode 100644 index 1efbc52e1d8..00000000000 --- a/packages/api/types/ts3.7/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -// the original ts3.7 version declaration file, used by "typesVersions" field in package.json -// can consider introducing tool like downlevel-dts in the build process in the future -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; From 06632b10b53555cd11607ead1f3b991185d6a922 Mon Sep 17 00:00:00 2001 From: hkjpotato Date: Tue, 2 Nov 2021 17:35:21 -0400 Subject: [PATCH 7/8] undo unrequired type change --- packages/api/src/types/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/types/index.ts b/packages/api/src/types/index.ts index c07f22b6419..9720173db49 100644 --- a/packages/api/src/types/index.ts +++ b/packages/api/src/types/index.ts @@ -19,6 +19,6 @@ export { graphqlOperation, GraphQLAuthError, + GraphQLResult, GRAPHQL_AUTH_MODE, } from '@aws-amplify/api-graphql'; -export type { GraphQLResult } from '@aws-amplify/api-graphql'; From 8596633e069f332644e7209d9a61d9d05a4abba9 Mon Sep 17 00:00:00 2001 From: "KJ(Kaijie) Huang" Date: Wed, 3 Nov 2021 17:59:01 -0400 Subject: [PATCH 8/8] Update packages/api/src/types/index.ts Co-authored-by: Sam Martinez --- packages/api/src/types/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/src/types/index.ts b/packages/api/src/types/index.ts index 9720173db49..d5c6446b6e1 100644 --- a/packages/api/src/types/index.ts +++ b/packages/api/src/types/index.ts @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * 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