Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 45bf41a

Browse files
TypeScript Teamalexeagle
authored andcommitted
fix: use Buffer.from instead of the deprecated Buffer constructor
Fixes #313 PiperOrigin-RevId: 224595491
1 parent 2205863 commit 45bf41a

File tree

6 files changed

+264
-1
lines changed

6 files changed

+264
-1
lines changed

internal/karma/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function initConcatJs(logger, emitter, basePath) {
5555
}
5656
});
5757

58-
bundleFile.sha = sha1(new Buffer(bundleFile.content));
58+
bundleFile.sha = sha1(Buffer.from(bundleFile.content));
5959
bundleFile.mtime = new Date();
6060
included.unshift(bundleFile);
6161

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright 2017 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
licenses(["notice"]) # Apache 2.0
16+
17+
load("//internal:defaults.bzl", "ts_library")
18+
19+
error_message = "error TS21224: Value passed.*"
20+
21+
ts_library(
22+
name = "jasmine",
23+
testonly = 1,
24+
srcs = [
25+
"jasmine_types.ts",
26+
],
27+
)
28+
29+
ts_library(
30+
name = "positives",
31+
testonly = 1,
32+
tsconfig = "//internal/tsetse:tsconfig.json",
33+
srcs = [
34+
"positives.ts",
35+
],
36+
expected_diagnostics = [
37+
"\(29,5\).*" + error_message,
38+
"\(30,5\).*" + error_message,
39+
"\(31,5\).*" + error_message,
40+
"\(32,5\).*" + error_message,
41+
"\(33,5\).*" + error_message,
42+
"\(34,5\).*" + error_message,
43+
"\(35,5\).*" + error_message,
44+
],
45+
deps = [
46+
":jasmine",
47+
],
48+
)
49+
50+
ts_library(
51+
name = "negatives",
52+
testonly = 1,
53+
tsconfig = "//internal/tsetse:tsconfig.json",
54+
srcs = [
55+
"negatives.ts",
56+
],
57+
deps = [
58+
":jasmine",
59+
],
60+
)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Copyright 2017 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
licenses(["notice"]) # Apache 2.0
16+
17+
load("//internal:defaults.bzl", "ts_library")
18+
19+
error_message = "error TS21226: Found a thenable.*"
20+
21+
ts_library(
22+
name = "jasmine",
23+
testonly = 1,
24+
)
25+
26+
ts_library(
27+
name = "positives",
28+
testonly = 1,
29+
tsconfig = "//internal/tsetse:tsconfig.json",
30+
srcs = [
31+
"positives.ts",
32+
],
33+
expected_diagnostics = [
34+
"\(7,7\).*" + error_message,
35+
"\(15,7\).*" + error_message,
36+
"\(23,19\).*" + error_message,
37+
"\(25,10\).*" + error_message,
38+
"\(30,34\).*" + error_message,
39+
"\(31,34\).*" + error_message,
40+
"\(37,19\).*" + error_message,
41+
"\(39,10\).*" + error_message,
42+
"\(44,34\).*" + error_message,
43+
"\(45,34\).*" + error_message,
44+
],
45+
deps = [
46+
],
47+
)
48+
49+
ts_library(
50+
name = "negatives",
51+
testonly = 1,
52+
tsconfig = "//internal/tsetse:tsconfig.json",
53+
srcs = ["negatives.ts"],
54+
deps = [
55+
],
56+
)
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Copyright 2017 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
licenses(["notice"]) # Apache 2.0
16+
17+
load("//internal:defaults.bzl", "ts_library")
18+
19+
20+
error_message = "TS21222: return value is unused.\\n\\tSee http://tsetse.info/check-return-value"
21+
22+
ts_library(
23+
name = "no_expected_diagnostics_test",
24+
testonly = 1,
25+
srcs = ["no_expected_diagnostics.ts"],
26+
tsconfig = "//third_party/bazel_rules/rules_typescript/internal/tsetse:tsconfig.json",
27+
)
28+
29+
ts_library(
30+
name = "expected_diagnostics_test",
31+
testonly = 1,
32+
srcs = ["expected_diagnostics.ts"],
33+
expected_diagnostics = [
34+
"\(6,1\).*" + error_message,
35+
"\(8,1\).*" + error_message,
36+
"\(12,1\).*" + error_message,
37+
"\(16,1\).*" + error_message,
38+
"\(19,1\).*" + error_message,
39+
],
40+
tsconfig = "//third_party/bazel_rules/rules_typescript/internal/tsetse:tsconfig.json",
41+
)
42+
43+
ts_library(
44+
name = "user_defined_check_return_value",
45+
testonly = 1,
46+
srcs = ["user_defined_check_return_value.ts"],
47+
tsconfig = "//third_party/bazel_rules/rules_typescript/internal/tsetse:tsconfig.json",
48+
)
49+
50+
ts_library(
51+
name = "unused_return_value_user_defined_function",
52+
testonly = 1,
53+
srcs = ["unused_return_value_user_defined_function.ts"],
54+
expected_diagnostics = [
55+
"\(4,1\).*" + error_message,
56+
"\(5,1\).*" + error_message,
57+
"\(7,1\).*" + error_message,
58+
"\(9,1\).*" + error_message,
59+
"\(15,1\).*" + error_message,
60+
"\(16,1\).*" + error_message,
61+
],
62+
tsconfig = "//third_party/bazel_rules/rules_typescript/internal/tsetse:tsconfig.json",
63+
deps = [
64+
":user_defined_check_return_value",
65+
"@npm//@types/jasmine",
66+
],
67+
)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright 2017 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
licenses(["notice"]) # Apache 2.0
16+
17+
load("//internal:defaults.bzl", "ts_library")
18+
19+
20+
ts_library(
21+
name = "positives",
22+
testonly = 1,
23+
srcs = [
24+
"positives.ts",
25+
],
26+
expected_diagnostics = [
27+
"\(2,19\): error TS21223: x === NaN is always false; use isNaN\(x\) instead",
28+
"\(6,5\): error TS21223: x === NaN is always false; use isNaN\(x\) instead",
29+
"\(7,5\): error TS21223: x == NaN is always false; use isNaN\(x\) instead",
30+
"\(8,5\): error TS21223: x !== NaN is always true; use !isNaN\(x\) instead",
31+
"\(9,5\): error TS21223: x != NaN is always true; use !isNaN\(x\) instead",
32+
"\(11,1\): error TS21223: x === NaN is always false; use isNaN\(x\) instead",
33+
"\(12,1\): error TS21223: x === NaN is always false; use isNaN\(x\) instead",
34+
],
35+
)
36+
37+
ts_library(
38+
name = "negatives",
39+
testonly = 1,
40+
srcs = [
41+
"negatives.ts",
42+
],
43+
)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2017 The Bazel Authors. All rights reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
licenses(["notice"]) # Apache 2.0
16+
17+
load("//internal:defaults.bzl", "ts_library")
18+
19+
20+
error_message = "TS21225: All Promises in async functions must either be awaited or used in an expression."
21+
22+
ts_library(
23+
name = "positives",
24+
testonly = 1,
25+
srcs = [
26+
"positives.ts",
27+
],
28+
tsconfig = "//third_party/bazel_rules/rules_typescript/internal/tsetse:tsconfig.json",
29+
expected_diagnostics = [
30+
"\(29,3\)" + error_message,
31+
"\(30,3\)" + error_message,
32+
"\(31,3\)" + error_message,
33+
"\(32,3\)" + error_message,
34+
"\(34,3\)" + error_message,
35+
],
36+
deps = ["//third_party/javascript/node_modules/typescript:es2015.promise"],
37+
)

0 commit comments

Comments
 (0)