Skip to content

Commit 756f0e3

Browse files
authored
Merge pull request #20702 from simonihmig/array-prototype-deprecation
Deprecate array prototype extensions
2 parents 438ff67 + 09dc249 commit 756f0e3

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
working-directory: smoke-tests/scenarios
3636
run: |
3737
matrix_json=$(pnpm scenario-tester list --require @swc-node/register --files "*-test.ts" --matrix "pnpm run test --filter %s" )
38-
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
38+
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
3939
4040
types:
4141
name: Type Checking (current version)
@@ -105,9 +105,11 @@ jobs:
105105
ENABLE_OPTIONAL_FEATURES: "true"
106106
- name: "Extend prototypes"
107107
EXTEND_PROTOTYPES: "true"
108+
RAISE_ON_DEPRECATION: "false"
108109
- name: "Extend prototypes, with optional features"
109110
EXTEND_PROTOTYPES: "true"
110111
ENABLE_OPTIONAL_FEATURES: "true"
112+
RAISE_ON_DEPRECATION: "false"
111113

112114
steps:
113115
- uses: actions/checkout@v3
@@ -120,6 +122,7 @@ jobs:
120122
OVERRIDE_DEPRECATION_VERSION: ${{ matrix.OVERRIDE_DEPRECATION_VERSION }}
121123
EXTEND_PROTOTYPES: ${{ matrix.EXTEND_PROTOTYPES }}
122124
ENABLE_OPTIONAL_FEATURES: ${{ matrix.ENABLE_OPTIONAL_FEATURES }}
125+
RAISE_ON_DEPRECATION: ${{ matrix.RAISE_ON_DEPRECATION }}
123126

124127
run: pnpm test
125128

bin/run-tests.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* eslint-disable no-console */
22
'use strict';
33

4-
/*
4+
/*
55
Test Variants
66
77
These are all accepted as environment variables when running `ember test` or
8-
as query params when directly invoking the test suite in the browser.
8+
as query params when directly invoking the test suite in the browser.
99
*/
1010
const variants = [
1111
// When true, even deprecations that are not yet at the "enabled" version will
@@ -25,6 +25,9 @@ const variants = [
2525
// This enables all canary feature flags for unreleased feature within Ember
2626
// itself.
2727
'ENABLE_OPTIONAL_FEATURES',
28+
29+
// Throw on unexpected deprecations. Defaults to true if not set explicitly.
30+
'RAISE_ON_DEPRECATION',
2831
];
2932

3033
const chalk = require('chalk');

index.html

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@
3232
EmberENV.ENABLE_OPTIONAL_FEATURES = true;
3333
}
3434

35-
EmberENV['RAISE_ON_DEPRECATION'] = true;
35+
EmberENV['RAISE_ON_DEPRECATION'] = QUnit.urlParams.RAISE_ON_DEPRECATION
36+
? QUnit.urlParams.RAISE_ON_DEPRECATION === 'true'
37+
: true;
3638

3739
if (QUnit.urlParams.ALL_DEPRECATIONS_ENABLED) {
38-
EmberENV['_ALL_DEPRECATIONS_ENABLED'] = true;
39-
}
40+
EmberENV['_ALL_DEPRECATIONS_ENABLED'] = true;
41+
}
4042

41-
if (QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION) {
42-
EmberENV['_OVERRIDE_DEPRECATION_VERSION'] = QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION;
43-
}
43+
if (QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION) {
44+
EmberENV['_OVERRIDE_DEPRECATION_VERSION'] = QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION;
45+
}
4446
</script>
4547

4648
<script type="module">

packages/@ember/-internals/deprecations/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ export const DEPRECATIONS = {
129129
enabled: '5.10.0',
130130
},
131131
}),
132+
DEPRECATE_ARRAY_PROTOTYPE_EXTENSIONS: deprecation({
133+
id: 'deprecate-array-prototype-extensions',
134+
url: 'https://deprecations.emberjs.com/id/deprecate-deprecate-array-prototype-extensions',
135+
until: '6.0.0',
136+
for: 'ember-source',
137+
since: {
138+
available: '5.10.0',
139+
enabled: '5.10.0',
140+
},
141+
}),
132142
};
133143

134144
export function deprecateUntil(message: string, deprecation: DeprecationObject) {
@@ -144,3 +154,14 @@ export function deprecateUntil(message: string, deprecation: DeprecationObject)
144154
}
145155
deprecate(message, deprecation.test, options);
146156
}
157+
158+
const { EXTEND_PROTOTYPES } = ENV as {
159+
EXTEND_PROTOTYPES: { Array?: boolean };
160+
};
161+
162+
if (EXTEND_PROTOTYPES.Array !== false) {
163+
deprecateUntil(
164+
'Array prototype extensions are deprecated. Follow the deprecation guide for migration instructions, and set EmberENV.EXTEND_PROTOTYPES to false in your config/environment.js',
165+
DEPRECATIONS.DEPRECATE_ARRAY_PROTOTYPE_EXTENSIONS
166+
);
167+
}

0 commit comments

Comments
 (0)