Skip to content

Commit 8571f49

Browse files
Upgrade tfjs repo to 4.0.0 (#6927)
This major release upgrades TypeScript from 3.5.3 to 4.8.4 (#6346). It is intended to be as non-breaking as possible, but it technically has breaking changes for users of `typescript<4.4`. All other users should be unaffected. When compiling projects that depend on TFJS with `typescript<4.4`, the following error will appear. ``` node_modules/@webgpu/types/dist/index.d.ts:587:16 - error TS2304: Cannot find name 'PredefinedColorSpace'. 587 colorSpace?: PredefinedColorSpace; ~~~~~~~~~~~~~~~~~~~~ ... ``` This can be fixed by upgrading TypeScript to 4.4.2 or greater, or by adding the file `predefined_color_space.d.ts` (name and path can be changed) with the following contents to your project to define the missing type. If this file is added, it will need to be removed when TypeScript is upgraded past 4.3. ```typescript type PredefinedColorSpace = "display-p3" | "srgb"; ``` `typescript<3.7` has the following additional error. ``` node_modules/@tensorflow/tfjs-core/dist/engine.d.ts:127:9 - error TS1086: An accessor cannot be declared in an ambient context. 127 get backend(): KernelBackend; ~~~~~~~ ... ``` Enabling [`skipLibCheck`](https://www.typescriptlang.org/tsconfig#skipLibCheck) suppresses this error, and upgrading to at least TypeScript 3.6.2 fixes it (although the above fix for `PredefinedColorSpace` will also need to be applied).
1 parent 567754e commit 8571f49

Some content is hidden

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

57 files changed

+1329
-424
lines changed

e2e/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"tsify": "^3.0.4",
3939
"tslint": "^6.1.3",
4040
"tslint-no-circular-imports": "~0.7.0",
41-
"typescript": "3.5.3"
41+
"typescript": "4.8.4"
4242
},
4343
"scripts": {
4444
"build": "tsc",

e2e/yarn.lock

+13-8
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,15 @@
10371037
"@types/node" "*"
10381038
form-data "^3.0.0"
10391039

1040-
"@types/node@*", "@types/node@>=10.0.0":
1041-
version "17.0.23"
1042-
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.23.tgz#3b41a6e643589ac6442bdbd7a4a3ded62f33f7da"
1043-
integrity sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==
1040+
"@types/node@*":
1041+
version "17.0.19"
1042+
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.19.tgz#726171367f404bfbe8512ba608a09ebad810c7e6"
1043+
integrity sha512-PfeQhvcMR4cPFVuYfBN4ifG7p9c+Dlh3yUZR6k+5yQK7wX3gDgVxBly4/WkBRs9x4dmcy1TVl08SY67wwtEvmA==
1044+
1045+
"@types/node@>=10.0.0":
1046+
version "14.14.36"
1047+
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.36.tgz#5637905dbb15c30a33a3c65b9ef7c20e3c85ebad"
1048+
integrity sha512-kjivUwDJfIjngzbhooRnOLhGYz6oRFi+L+EpMjxroDYXwDw9lHrJJ43E+dJ6KAd3V3WxWAJ/qZE9XKYHhjPOFQ==
10441049

10451050
"@types/offscreencanvas@~2019.3.0":
10461051
version "2019.3.0"
@@ -4028,10 +4033,10 @@ typed-function@^2.0.0:
40284033
resolved "https://registry.yarnpkg.com/typed-function/-/typed-function-2.1.0.tgz#ded6f8a442ba8749ff3fe75bc41419c8d46ccc3f"
40294034
integrity sha512-bctQIOqx2iVbWGDGPWwIm18QScpu2XRmkC19D8rQGFsjKSgteq/o1hTZvIG/wuDq8fanpBDrLkLq+aEN/6y5XQ==
40304035

4031-
typescript@3.5.3:
4032-
version "3.5.3"
4033-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
4034-
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
4036+
typescript@4.4.2:
4037+
version "4.4.2"
4038+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
4039+
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
40354040

40364041
ua-parser-js@^0.7.30:
40374042
version "0.7.31"

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
"@types/mkdirp": "^0.5.2",
2222
"@types/node": "^12.7.5",
2323
"@types/node-fetch": "~2.1.2",
24-
"@types/offscreencanvas": "~2019.3.0",
24+
"@types/offscreencanvas": "^2019.7.0",
2525
"@types/rollup-plugin-visualizer": "^4.2.1",
2626
"@types/seedrandom": "^2.4.28",
2727
"@types/shelljs": "^0.8.7",
2828
"@types/webgl-ext": "0.0.30",
2929
"@types/webgl2": "0.0.6",
30-
"@webgpu/types": "0.1.16",
30+
"@webgpu/types": "0.1.21",
3131
"ajv": "~6.12.3",
3232
"argparse": "^1.0.10",
3333
"chalk": "~2.4.2",
@@ -68,7 +68,7 @@
6868
"tslib": "^2.4.0",
6969
"tslint": "^6.1.3",
7070
"tslint-no-circular-imports": "~0.7.0",
71-
"typescript": "3.5.3"
71+
"typescript": "4.8.4"
7272
},
7373
"scripts": {
7474
"lint": "tslint -p tsconfig_tslint.json",

tfjs-automl/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"ts-node": "^8.8.2",
5555
"tslint": "~6.1.3",
5656
"tslint-no-circular-imports": "^0.7.0",
57-
"typescript": "3.5.3",
57+
"typescript": "4.8.4",
5858
"yalc": "~1.0.0-pre.21"
5959
},
6060
"peerDependencies": {

tfjs-automl/yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -3737,10 +3737,10 @@ type-is@~1.6.17:
37373737
media-typer "0.3.0"
37383738
mime-types "~2.1.24"
37393739

3740-
typescript@3.5.3:
3741-
version "3.5.3"
3742-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
3743-
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
3740+
typescript@4.4.2:
3741+
version "4.4.2"
3742+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
3743+
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
37443744

37453745
ua-parser-js@^0.7.30:
37463746
version "0.7.31"

tfjs-backend-webgl/src/canvas_util.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ function getWebGLRenderingContext(
9999

100100
if (webGLVersion === 1) {
101101
return (canvas.getContext('webgl', WEBGL_ATTRIBUTES) ||
102-
canvas.getContext('experimental-webgl', WEBGL_ATTRIBUTES)) as
103-
WebGLRenderingContext;
102+
(canvas as HTMLCanvasElement)
103+
.getContext('experimental-webgl', WEBGL_ATTRIBUTES));
104104
}
105105
return canvas.getContext('webgl2', WEBGL_ATTRIBUTES) as WebGLRenderingContext;
106106
}

tfjs-backend-webgl/src/kernels/FromPixels.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function fromPixels(args: {
6464
willReadFrequently = newWillReadFrequently;
6565
fromPixels2DContext =
6666
document.createElement('canvas').getContext(
67-
'2d', {willReadFrequently}) as CanvasRenderingContext2D;
67+
'2d', {willReadFrequently});
6868
}
6969

7070
fromPixels2DContext.canvas.width = width;

tfjs-backend-webgpu/src/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ ts_library(
5151
"//tfjs-backend-cpu/src:tfjs-backend-cpu_src_lib",
5252
"//tfjs-core/src:tfjs-core_lib",
5353
"//tfjs-core/src:tfjs-core_src_lib",
54+
"@npm//@types/offscreencanvas",
5455
"@npm//@webgpu/types",
5556
],
5657
)

tfjs-backend-webgpu/src/kernels/FromPixels.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export function fromPixels(args: {
9797
willReadFrequently = newWillReadFrequently;
9898
fromPixels2DContext =
9999
document.createElement('canvas').getContext(
100-
'2d', {willReadFrequently}) as CanvasRenderingContext2D;
100+
'2d', {willReadFrequently});
101101
}
102102
fromPixels2DContext.canvas.width = width;
103103
fromPixels2DContext.canvas.height = height;

tfjs-backend-webgpu/yarn.lock

+1-61
Original file line numberDiff line numberDiff line change
@@ -909,36 +909,11 @@
909909
resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.12.tgz#6b2c510a7ad7039e98e7b8d3d6598f4359e5c080"
910910
integrity sha512-vt+kDhq/M2ayberEtJcIN/hxXy1Pk+59g2FV/ZQceeaTyCtCucjL2Q7FXlFjtWn4n15KCr1NE2lNNFhp0lEThw==
911911

912-
"@types/long@^4.0.1":
913-
version "4.0.2"
914-
resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.2.tgz#b74129719fc8d11c01868010082d483b7545591a"
915-
integrity sha512-MqTGEo5bj5t157U6fA/BiDynNkn0YknVdh48CMPkTSpFTVmvao5UQmm7uEF6xBEo7qIMAlY/JSleYaE6VOdpaA==
916-
917912
"@types/node@>=10.0.0":
918913
version "16.4.12"
919914
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.12.tgz#961e3091f263e6345d2d84afab4e047a60b4b11b"
920915
integrity sha512-zxrTNFl9Z8boMJXs6ieqZP0wAhvkdzmHSxTlJabM16cf5G9xBc1uPRH5Bbv2omEDDiM8MzTfqTJXBf0Ba4xFWA==
921916

922-
"@types/offscreencanvas@~2019.3.0":
923-
version "2019.3.0"
924-
resolved "https://registry.yarnpkg.com/@types/offscreencanvas/-/offscreencanvas-2019.3.0.tgz#3336428ec7e9180cf4566dfea5da04eb586a6553"
925-
integrity sha512-esIJx9bQg+QYF0ra8GnvfianIY8qWB0GBx54PK5Eps6m+xTj86KLavHv6qDhzKcu5UUOgNfJ2pWaIIV7TRUd9Q==
926-
927-
"@types/seedrandom@^2.4.28":
928-
version "2.4.30"
929-
resolved "https://registry.yarnpkg.com/@types/seedrandom/-/seedrandom-2.4.30.tgz#d2efe425869b84163c2d56e779dddadb9372cbfa"
930-
integrity sha512-AnxLHewubLVzoF/A4qdxBGHCKifw8cY32iro3DQX9TPcetE95zBeVt3jnsvtvAUf1vwzMfwzp4t/L2yqPlnjkQ==
931-
932-
933-
version "0.0.30"
934-
resolved "https://registry.yarnpkg.com/@types/webgl-ext/-/webgl-ext-0.0.30.tgz#0ce498c16a41a23d15289e0b844d945b25f0fb9d"
935-
integrity sha512-LKVgNmBxN0BbljJrVUwkxwRYqzsAEPcZOe6S2T6ZaBDIrFp0qu4FNlpc5sM1tGbXUYFgdVQIoeLk1Y1UoblyEg==
936-
937-
"@webgpu/types@^0.1.16":
938-
version "0.1.21"
939-
resolved "https://registry.yarnpkg.com/@webgpu/types/-/types-0.1.21.tgz#b181202daec30d66ccd67264de23814cfd176d3a"
940-
integrity sha512-pUrWq3V5PiSGFLeLxoGqReTZmiiXwY3jRkIG5sLLKjyqNxrwm/04b4nw7LSmGWJcKk59XOM/YRTUwOzo4MMlow==
941-
942917
accepts@~1.3.4:
943918
version "1.3.7"
944919
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd"
@@ -2154,7 +2129,7 @@ istanbul-reports@^3.0.0:
21542129
html-escaper "^2.0.0"
21552130
istanbul-lib-report "^3.0.0"
21562131

2157-
jasmine-core@^4.1.0, jasmine-core@^4.2.0:
2132+
jasmine-core@^4.1.0:
21582133
version "4.2.0"
21592134
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-4.2.0.tgz#0605bea284d6d78276f43c47de2532ecd4a73b00"
21602135
integrity sha512-OcFpBrIhnbmb9wfI8cqPSJ50pv3Wg4/NSgoZIqHzIwO/2a9qivJWzv8hUvaREIMYYJBas6AvfXATFdVuzzCqVw==
@@ -2347,11 +2322,6 @@ log4js@^6.3.0, log4js@^6.4.1:
23472322
rfdc "^1.3.0"
23482323
streamroller "^3.0.2"
23492324

2350-
2351-
version "4.0.0"
2352-
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
2353-
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==
2354-
23552325
magic-string@^0.25.7:
23562326
version "0.25.7"
23572327
resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.25.7.tgz#3f497d6fd34c669c6798dcb821f2ef31f5445051"
@@ -2459,13 +2429,6 @@ [email protected]:
24592429
resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb"
24602430
integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==
24612431

2462-
node-fetch@~2.6.1:
2463-
version "2.6.7"
2464-
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
2465-
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
2466-
dependencies:
2467-
whatwg-url "^5.0.0"
2468-
24692432
node-releases@^1.1.73:
24702433
version "1.1.73"
24712434
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.73.tgz#dd4e81ddd5277ff846b80b52bb40c49edf7a7b20"
@@ -2807,11 +2770,6 @@ safe-buffer@~5.1.1:
28072770
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
28082771
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
28092772

2810-
seedrandom@^3.0.5:
2811-
version "3.0.5"
2812-
resolved "https://registry.yarnpkg.com/seedrandom/-/seedrandom-3.0.5.tgz#54edc85c95222525b0c7a6f6b3543d8e0b3aa0a7"
2813-
integrity sha512-8OwmbklUNzwezjGInmZ+2clQmExQPvomqjL7LFqOYqtmuxRgQYqOD3mHaU+MvZn5FLUeVxVfQjwLZW/n/JFuqg==
2814-
28152773
28162774
version "7.0.0"
28172775
resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e"
@@ -3037,11 +2995,6 @@ [email protected]:
30372995
resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553"
30382996
integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==
30392997

3040-
tr46@~0.0.3:
3041-
version "0.0.3"
3042-
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
3043-
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==
3044-
30452998
tty-browserify@^0.0.1:
30462999
version "0.0.1"
30473000
resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.1.tgz#3f05251ee17904dfd0677546670db9651682b811"
@@ -3155,19 +3108,6 @@ wcwidth@^1.0.1:
31553108
dependencies:
31563109
defaults "^1.0.3"
31573110

3158-
webidl-conversions@^3.0.0:
3159-
version "3.0.1"
3160-
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
3161-
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==
3162-
3163-
whatwg-url@^5.0.0:
3164-
version "5.0.0"
3165-
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
3166-
integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
3167-
dependencies:
3168-
tr46 "~0.0.3"
3169-
webidl-conversions "^3.0.0"
3170-
31713111
which-boxed-primitive@^1.0.2:
31723112
version "1.0.2"
31733113
resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6"

tfjs-converter/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"opn": "~5.1.0",
3232
"protobufjs": "~6.11.3",
3333
"ts-node": "~8.8.2",
34-
"typescript": "3.5.3",
34+
"typescript": "4.8.4",
3535
"yalc": "~1.0.0-pre.50"
3636
},
3737
"scripts": {

tfjs-converter/src/BUILD.bazel

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ ts_library(
6666
name = "tfjs-converter_test_lib",
6767
testonly = True,
6868
srcs = glob(TEST_SRCS),
69-
module_name = "@tensorflow/tfjs-converter/dist",
7069
deps = [
7170
":tfjs-converter_lib",
7271
":tfjs-converter_src_lib",

tfjs-converter/src/operations/executors/arithmetic_executor_test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ describe('arithmetic', () => {
6262
node.op = op;
6363
executeOp(node, {input1, input2}, context, spyOpsAsTfOps);
6464

65-
// TODO(mattsoulanille): Remove type assertion after TS4
66-
expect(spyOps[uncapitalize(op) as keyof typeof spyOps])
65+
expect(spyOps[uncapitalize(op)])
6766
.toHaveBeenCalledWith(input1[0], input2[0]);
6867
});
6968
}));

tfjs-converter/src/operations/executors/basic_math_executor_test.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,10 @@ describe('basic math', () => {
6363
.forEach(op => {
6464
it('should call tfOps.' + op, () => {
6565
node.op = op;
66-
// TODO(mattsoulanille): Remove type assertion after TS4
67-
// tslint:disable-next-line no-any
68-
(spyOps[uncapitalize(op) as keyof typeof spyOps] as any)
69-
.and.returnValue({});
66+
spyOps[uncapitalize(op)].and.returnValue({});
7067
executeOp(node, {input1}, context, spyOpsAsTfOps);
7168

72-
// TODO(mattsoulanille): Remove type assertion after TS4
73-
expect(spyOps[uncapitalize(op) as keyof typeof spyOps])
74-
.toHaveBeenCalledWith(input1[0]);
69+
expect(spyOps[uncapitalize(op)]).toHaveBeenCalledWith(input1[0]);
7570
});
7671
it('should match op def', () => {
7772
node.op = op;

tfjs-converter/src/operations/executors/logical_executor_test.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,10 @@ describe('logical', () => {
5959
.forEach(op => {
6060
it('should call tfOps.' + op, () => {
6161
node.op = op;
62-
// TODO(mattsoulanille): Remove type assertions after TS4
63-
// tslint:disable-next-line no-any
64-
(spyOps[uncapitalize(op) as keyof typeof spyOps] as any)
65-
.and.returnValue({});
62+
spyOps[uncapitalize(op)].and.returnValue({});
6663
executeOp(node, {input1, input2}, context, spyOpsAsTfOps);
6764

68-
// TODO(mattsoulanille): Remove type assertion after TS4
69-
expect(spyOps[uncapitalize(op) as keyof typeof spyOps])
65+
expect(spyOps[uncapitalize(op)])
7066
.toHaveBeenCalledWith(input1[0], input2[0]);
7167
});
7268
});

tfjs-converter/src/operations/executors/reduction_executor_test.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,10 @@ describe('reduction', () => {
5454
node.op = op;
5555
node.attrParams.keepDims = createBoolAttr(true);
5656
node.attrParams.axis = createNumberAttr(1);
57-
// TODO(mattsoulanille): Remove type assertions after TS4
58-
// tslint:disable-next-line no-any
59-
(spyOps[uncapitalize(op) as keyof typeof spyOps] as any)
60-
.and.returnValue({});
57+
spyOps[uncapitalize(op)].and.returnValue({});
6158
executeOp(node, {input1}, context, spyOpsAsTfOps);
6259

63-
// TODO(mattsoulanille): Remove type assertion after TS4
64-
expect(spyOps[uncapitalize(op) as keyof typeof spyOps])
60+
expect(spyOps[uncapitalize(op)])
6561
.toHaveBeenCalledWith(input1[0], 1, true);
6662
});
6763
});

tfjs-converter/src/operations/executors/test_helper.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export function validateParam(
9696
return matched;
9797
}
9898

99-
// TODO(mattsoulanille): Change the return type to Uncapitalize<Name> in TS4.
100-
export function uncapitalize<Name extends string>(name: Name): string {
101-
return name.charAt(0).toLowerCase() + name.slice(1);
99+
export function uncapitalize<Name extends string>(name: Name): Uncapitalize<Name> {
100+
return name.charAt(0).toLowerCase() + name.slice(1) as Uncapitalize<Name>;
102101
}

tfjs-converter/yarn.lock

+9-4
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,15 @@ ts-node@~8.8.2:
460460
source-map-support "^0.5.6"
461461
yn "3.1.1"
462462

463-
464-
version "3.5.3"
465-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
466-
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
463+
464+
version "4.4.2"
465+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.2.tgz#6d618640d430e3569a1dfb44f7d7e600ced3ee86"
466+
integrity sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==
467+
468+
universalify@^0.1.0:
469+
version "0.1.2"
470+
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
471+
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
467472

468473
universalify@^0.1.0:
469474
version "0.1.2"

tfjs-core/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@
4444
},
4545
"dependencies": {
4646
"@types/long": "^4.0.1",
47-
"@types/offscreencanvas": "~2019.3.0",
47+
"@types/offscreencanvas": "~2019.7.0",
4848
"@types/seedrandom": "^2.4.28",
4949
"@types/webgl-ext": "0.0.30",
50-
"@webgpu/types": "0.1.16",
50+
"@webgpu/types": "0.1.21",
5151
"long": "4.0.0",
5252
"node-fetch": "~2.6.1",
5353
"seedrandom": "^3.0.5"

tfjs-core/scripts/test_snippets/util.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ function getJSDocTag(symbol: ts.Symbol): JSDoc {
166166
for (let i = 0; i < tags.length; i++) {
167167
const jsdocTag = tags[i];
168168
if (jsdocTag.name === 'doc' && jsdocTag.text != null) {
169-
const json = convertDocStringToDocInfoObject(jsdocTag.text.trim());
169+
if (jsdocTag.text.length !== 1) {
170+
throw new Error('Expected exactly one jsdoc SymbolDisplayPart but got'
171+
+ ` ${jsdocTag.text.length} instead: ${jsdocTag.text}`);
172+
}
173+
const text = jsdocTag.text[0].text.trim();
174+
const json = convertDocStringToDocInfoObject(text);
170175
return json;
171176
}
172177
}

tfjs-core/src/BUILD.bazel

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ ts_library(
7676
"@npm//@types/jasmine",
7777
"@npm//@types/long",
7878
"@npm//@types/node",
79+
"@npm//@types/offscreencanvas",
7980
"@npm//@types/seedrandom",
8081
"@npm//@webgpu/types",
8182
"@npm//jasmine",
@@ -232,6 +233,7 @@ ts_library(
232233
":tfjs-core_lib",
233234
":tfjs-core_src_lib",
234235
"//tfjs-backend-cpu/src:tfjs-backend-cpu_lib",
236+
"@npm//@types/offscreencanvas",
235237
],
236238
)
237239

0 commit comments

Comments
 (0)