Skip to content

Commit 4c5f4d5

Browse files
committed
chore: upgrade TypeScript to 5.8.3
Upgrade TypeScript 3.8.3 -> 5.8.3 across the monorepo, aligning the v5-stable compiler with the version already used on main. ts-jest 24 cannot compile TypeScript 5 (it relies on ts.getMutableClone, removed in TS 5.0), so the jest toolchain is moved to the 29.x line (jest, ts-jest, @types/jest, jest-environment-jsdom) to match the stack already used on main. Includes the minimal behavior-preserving source and test adjustments the new compiler and test runner require.
1 parent 69166f4 commit 4c5f4d5

76 files changed

Lines changed: 2160 additions & 1234 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,23 @@
6262
"homepage": "https://aws-amplify.github.io/",
6363
"devDependencies": {
6464
"@babel/cli": "7.17.0",
65-
"@babel/core": "7.17.2",
65+
"@babel/core": "^7.29.6",
6666
"@babel/preset-env": "^7.0.0",
6767
"@babel/preset-react": "^7.0.0",
6868
"@size-limit/file": "^11.2.0",
6969
"@size-limit/webpack": "^11.2.0",
7070
"@size-limit/webpack-why": "^11.2.0",
71-
"@types/jest": "^24.0.18",
71+
"@types/jest": "^29.5.8",
7272
"@types/lodash": "4.14.182",
7373
"@types/node": "^8.9.5",
7474
"@types/puppeteer": "1.3.0",
75-
"babel-jest": "^24.9.0",
75+
"babel-jest": "^29.7.0",
7676
"babel-loader": "^8.3.0",
7777
"codecov": "^3.6.5",
7878
"husky": "^3.0.5",
79-
"jest": "^24.x.x",
80-
"jest-config": "24.8.0",
79+
"jest": "^29.7.0",
80+
"jest-config": "^29.7.0",
81+
"jest-environment-jsdom": "^29.7.0",
8182
"json-loader": "^0.5.7",
8283
"lerna": "^6.6.1",
8384
"license-check-and-add": "^4.0.5",
@@ -93,12 +94,12 @@
9394
"size-limit": "^11.2.0",
9495
"source-map-loader": "^3.0.2",
9596
"terser-webpack-plugin": "^5.3.6",
96-
"ts-jest": "^24.x.x",
97+
"ts-jest": "^29.1.1",
9798
"ts-loader": "^9.4.3",
9899
"tslint": "^5.7.0",
99100
"tslint-config-airbnb": "^5.8.0",
100101
"typedoc": "^0.17.0",
101-
"typescript": "~3.8.3",
102+
"typescript": "5.8.3",
102103
"typescript-coverage-report": "^0.6.4",
103104
"uuid-validate": "^0.0.3",
104105
"webpack": "^5.75.0",
@@ -108,6 +109,7 @@
108109
"wml": "0.0.83"
109110
},
110111
"resolutions": {
112+
"@babel/core": "^7.29.6",
111113
"@types/babel__traverse": "7.20.0",
112114
"path-scurry": "1.10.0",
113115
"**/glob/minipass": "6.0.2",

packages/amazon-cognito-identity-js/__tests__/CognitoUser.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,8 +571,8 @@ describe('getDeviceResponse()', () => {
571571

572572
afterAll(() => {
573573
jest.restoreAllMocks();
574-
jest.onFailure.mockClear();
575-
jest.onSuccess.mockClear();
574+
callback.onFailure.mockClear();
575+
callback.onSuccess.mockClear();
576576
});
577577

578578
afterEach(() => {

packages/amazon-cognito-identity-js/__tests__/cryptoSecureRandomInt.test.js

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ jest.mock('crypto', () => ({
77
})),
88
}));
99

10-
const mockCrypto = crypto;
11-
1210
describe('cryptoSecureRandomInt test', () => {
1311
let windowSpy;
1412

@@ -53,26 +51,52 @@ describe('cryptoSecureRandomInt test', () => {
5351
crypto: null,
5452
}));
5553

56-
const originalGetRandomValues = mockCrypto.getRandomValues;
57-
58-
mockCrypto.getRandomValues = undefined;
59-
60-
const cryptoSecureRandomInt =
61-
require('../src/utils/cryptoSecureRandomInt').default;
62-
expect(cryptoSecureRandomInt()).toBe(54321);
63-
64-
mockCrypto.getRandomValues = originalGetRandomValues;
54+
const savedGlobalCrypto = globalThis.crypto;
55+
Object.defineProperty(globalThis, 'crypto', {
56+
value: undefined,
57+
configurable: true,
58+
writable: true,
59+
});
60+
try {
61+
const currentMockCrypto = require('crypto');
62+
currentMockCrypto.getRandomValues = undefined;
63+
64+
const cryptoSecureRandomInt =
65+
require('../src/utils/cryptoSecureRandomInt').default;
66+
expect(cryptoSecureRandomInt()).toBe(54321);
67+
} finally {
68+
Object.defineProperty(globalThis, 'crypto', {
69+
value: savedGlobalCrypto,
70+
configurable: true,
71+
writable: true,
72+
});
73+
}
6574
});
6675

6776
test('crypto is set for Node (>= 18)', () => {
6877
windowSpy.mockImplementationOnce(() => ({
6978
crypto: null,
7079
}));
7180

72-
mockCrypto.getRandomValues.mockReturnValueOnce([54321]);
73-
74-
const cryptoSecureRandomInt =
75-
require('../src/utils/cryptoSecureRandomInt').default;
76-
expect(cryptoSecureRandomInt()).toBe(54321);
81+
const savedGlobalCrypto = globalThis.crypto;
82+
Object.defineProperty(globalThis, 'crypto', {
83+
value: undefined,
84+
configurable: true,
85+
writable: true,
86+
});
87+
try {
88+
const currentMockCrypto = require('crypto');
89+
currentMockCrypto.getRandomValues.mockReturnValueOnce([54321]);
90+
91+
const cryptoSecureRandomInt =
92+
require('../src/utils/cryptoSecureRandomInt').default;
93+
expect(cryptoSecureRandomInt()).toBe(54321);
94+
} finally {
95+
Object.defineProperty(globalThis, 'crypto', {
96+
value: savedGlobalCrypto,
97+
configurable: true,
98+
writable: true,
99+
});
100+
}
77101
});
78102
});

packages/amazon-cognito-identity-js/__tests__/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as exported from '../src/index';
33
describe('import * keys', () => {
44
it('should match snapshot', () => {
55
expect(Object.keys(exported)).toMatchInlineSnapshot(`
6-
Array [
6+
[
77
"AuthenticationDetails",
88
"AuthenticationHelper",
99
"CognitoAccessToken",

packages/amazon-cognito-identity-js/__tests__/internalsIndex.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as exported from '../src/internals/index';
33
describe('import * keys', () => {
44
it('should match snapshot', () => {
55
expect(Object.keys(exported)).toMatchInlineSnapshot(`
6-
Array [
6+
[
77
"addAuthCategoryToCognitoUserAgent",
88
"addFrameworkToCognitoUserAgent",
99
]

packages/amazon-cognito-identity-js/jest.config.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,28 @@ module.exports = {
1818
},
1919
},
2020

21-
globals: {
22-
'ts-jest': {
23-
diagnostics: false,
24-
tsConfig: {
25-
lib: ['es5', 'es2015', 'dom', 'esnext.asynciterable', 'es2017.object'],
26-
allowJs: true,
27-
esModuleInterop: true,
28-
},
29-
},
30-
},
31-
3221
transform: {
33-
'^.+\\.(js|jsx|ts|tsx)$': 'ts-jest',
22+
'^.+\\.(js|jsx|ts|tsx)$': [
23+
'ts-jest',
24+
{
25+
diagnostics: false,
26+
tsconfig: {
27+
lib: [
28+
'es5',
29+
'es2015',
30+
'dom',
31+
'esnext.asynciterable',
32+
'es2017.object',
33+
],
34+
allowJs: true,
35+
esModuleInterop: true,
36+
},
37+
},
38+
],
3439
},
3540
preset: 'ts-jest',
3641
testRegex: ['(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$'],
3742
moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx'],
3843

3944
testEnvironment: 'jsdom',
40-
testURL: 'http://localhost/',
4145
};

packages/analytics/package.json

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"@aws-sdk/client-personalize-events": "3.6.1",
5656
"@aws-sdk/util-utf8-browser": "3.6.1",
5757
"lodash": "^4.18.1",
58-
"tslib": "^1.8.0",
58+
"tslib": "^2.0.0",
5959
"uuid": "^11.1.1"
6060
},
6161
"devDependencies": {
@@ -76,24 +76,24 @@
7676
}
7777
],
7878
"jest": {
79-
"globals": {
80-
"ts-jest": {
81-
"diagnostics": false,
82-
"tsConfig": {
83-
"lib": [
84-
"es5",
85-
"es2015",
86-
"dom",
87-
"esnext.asynciterable",
88-
"es2017.object"
89-
],
90-
"allowJs": true,
91-
"esModuleInterop": true
92-
}
93-
}
94-
},
9579
"transform": {
96-
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
80+
"^.+\\.(js|jsx|ts|tsx)$": [
81+
"ts-jest",
82+
{
83+
"diagnostics": false,
84+
"tsconfig": {
85+
"lib": [
86+
"es5",
87+
"es2015",
88+
"dom",
89+
"esnext.asynciterable",
90+
"es2017.object"
91+
],
92+
"allowJs": true,
93+
"esModuleInterop": true
94+
}
95+
}
96+
]
9797
},
9898
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
9999
"moduleFileExtensions": [
@@ -104,7 +104,6 @@
104104
"jsx"
105105
],
106106
"testEnvironment": "jsdom",
107-
"testURL": "http://localhost/",
108107
"coverageThreshold": {
109108
"global": {
110109
"branches": 0,

packages/api-graphql/__tests__/GraphQLAPI-test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
} from '@aws-amplify/core';
1818
import { InternalPubSub } from '@aws-amplify/pubsub/internals';
1919
import { Cache } from '@aws-amplify/cache';
20-
import * as Observable from 'zen-observable';
20+
import Observable from 'zen-observable';
2121
import axios, { CancelTokenStatic } from 'axios';
2222

2323
axios.CancelToken = <CancelTokenStatic>{
@@ -1002,7 +1002,7 @@ describe('API test', () => {
10021002
);
10031003
});
10041004

1005-
test('happy-case-subscription', async done => {
1005+
test('happy-case-subscription', done => {
10061006
jest
10071007
.spyOn(RestClient.prototype, 'post')
10081008
.mockImplementation(async (url, init) => ({
@@ -1056,7 +1056,7 @@ describe('API test', () => {
10561056
expect(observable).not.toBe(undefined);
10571057
});
10581058

1059-
test('happy case subscription with additionalHeaders', async done => {
1059+
test('happy case subscription with additionalHeaders', done => {
10601060
jest
10611061
.spyOn(RestClient.prototype, 'post')
10621062
.mockImplementation(async (url, init) => ({
@@ -1260,7 +1260,7 @@ describe('API test', () => {
12601260
});
12611261

12621262
test('call isInstanceCreated', () => {
1263-
const createInstanceMock = spyOn(API.prototype, 'createInstance');
1263+
const createInstanceMock = jest.spyOn(API.prototype, 'createInstance');
12641264
const api = new API(config);
12651265
api.createInstanceIfNotCreated();
12661266
expect(createInstanceMock).toHaveBeenCalled();
@@ -1269,7 +1269,7 @@ describe('API test', () => {
12691269
test('should not call createInstance when there is already an instance', () => {
12701270
const api = new API(config);
12711271
api.createInstance();
1272-
const createInstanceMock = spyOn(API.prototype, 'createInstance');
1272+
const createInstanceMock = jest.spyOn(API.prototype, 'createInstance');
12731273
api.createInstanceIfNotCreated();
12741274
expect(createInstanceMock).not.toHaveBeenCalled();
12751275
});
@@ -1466,7 +1466,7 @@ describe('Internal API customUserAgent test', () => {
14661466
expect(spyon).toBeCalledWith(url, init);
14671467
});
14681468

1469-
test('happy case subscription', async done => {
1469+
test('happy case subscription', done => {
14701470
jest
14711471
.spyOn(RestClient.prototype, 'post')
14721472
.mockImplementation(async (url, init) => ({

packages/api-graphql/package.json

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"homepage": "https://aws-amplify.github.io/",
4343
"devDependencies": {
4444
"@types/zen-observable": "^0.8.0",
45-
"typescript": "5.0.2"
45+
"typescript": "5.8.3"
4646
},
4747
"files": [
4848
"lib",
@@ -73,14 +73,22 @@
7373
"moduleNameMapper": {
7474
"axios": "axios/dist/node/axios.cjs"
7575
},
76-
"globals": {
77-
"ts-jest": {
78-
"diagnostics": false,
79-
"tsConfig": false
80-
}
81-
},
8276
"transform": {
83-
"^.+\\.(js|jsx|ts|tsx)$": "ts-jest"
77+
"^.+\\.(js|jsx|ts|tsx)$": [
78+
"ts-jest",
79+
{
80+
"diagnostics": false,
81+
"tsconfig": {
82+
"allowJs": true,
83+
"esModuleInterop": true,
84+
"types": [
85+
"jest",
86+
"node"
87+
],
88+
"noEmitOnError": false
89+
}
90+
}
91+
]
8492
},
8593
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$",
8694
"testPathIgnorePatterns": [
@@ -102,7 +110,6 @@
102110
"statements": 0
103111
}
104112
},
105-
"testURL": "http://localhost/",
106113
"coveragePathIgnorePatterns": [
107114
"/node_modules/",
108115
"dist",

packages/api-rest/__tests__/RestClient-unit-test.ssr.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ jest
1212

1313
jest.mock('axios', () => {
1414
return {
15+
__esModule: true,
1516
default: signed_params => {
1617
return new Promise((res, rej) => {
1718
const withCredentialsSuffix =

0 commit comments

Comments
 (0)