Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate array prototype extensions #20702

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
working-directory: smoke-tests/scenarios
run: |
matrix_json=$(pnpm scenario-tester list --require @swc-node/register --files "*-test.ts" --matrix "pnpm run test --filter %s" )
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT

types:
name: Type Checking (current version)
Expand Down Expand Up @@ -105,9 +105,11 @@ jobs:
ENABLE_OPTIONAL_FEATURES: "true"
- name: "Extend prototypes"
EXTEND_PROTOTYPES: "true"
RAISE_ON_DEPRECATION: "false"
- name: "Extend prototypes, with optional features"
EXTEND_PROTOTYPES: "true"
ENABLE_OPTIONAL_FEATURES: "true"
RAISE_ON_DEPRECATION: "false"

steps:
- uses: actions/checkout@v3
Expand All @@ -120,6 +122,7 @@ jobs:
OVERRIDE_DEPRECATION_VERSION: ${{ matrix.OVERRIDE_DEPRECATION_VERSION }}
EXTEND_PROTOTYPES: ${{ matrix.EXTEND_PROTOTYPES }}
ENABLE_OPTIONAL_FEATURES: ${{ matrix.ENABLE_OPTIONAL_FEATURES }}
RAISE_ON_DEPRECATION: ${{ matrix.RAISE_ON_DEPRECATION }}

run: pnpm test

Expand Down
7 changes: 5 additions & 2 deletions bin/run-tests.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable no-console */
'use strict';

/*
/*
Test Variants

These are all accepted as environment variables when running `ember test` or
as query params when directly invoking the test suite in the browser.
as query params when directly invoking the test suite in the browser.
*/
const variants = [
// When true, even deprecations that are not yet at the "enabled" version will
Expand All @@ -25,6 +25,9 @@ const variants = [
// This enables all canary feature flags for unreleased feature within Ember
// itself.
'ENABLE_OPTIONAL_FEATURES',

// Throw on unexpected deprecations. Defaults to true if not set explicitly.
'RAISE_ON_DEPRECATION',
];

const chalk = require('chalk');
Expand Down
14 changes: 8 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@
EmberENV.ENABLE_OPTIONAL_FEATURES = true;
}

EmberENV['RAISE_ON_DEPRECATION'] = true;
EmberENV['RAISE_ON_DEPRECATION'] = QUnit.urlParams.RAISE_ON_DEPRECATION
? QUnit.urlParams.RAISE_ON_DEPRECATION === 'true'
: true;

if (QUnit.urlParams.ALL_DEPRECATIONS_ENABLED) {
EmberENV['_ALL_DEPRECATIONS_ENABLED'] = true;
}
EmberENV['_ALL_DEPRECATIONS_ENABLED'] = true;
}

if (QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION) {
EmberENV['_OVERRIDE_DEPRECATION_VERSION'] = QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION;
}
if (QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION) {
EmberENV['_OVERRIDE_DEPRECATION_VERSION'] = QUnit.urlParams.OVERRIDE_DEPRECATION_VERSION;
}
</script>

<script type="module">
Expand Down
21 changes: 21 additions & 0 deletions packages/@ember/-internals/deprecations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ export const DEPRECATIONS = {
enabled: '5.10.0',
},
}),
DEPRECATE_ARRAY_PROTOTYPE_EXTENSIONS: deprecation({
id: 'deprecate-array-prototype-extensions',
url: 'https://deprecations.emberjs.com/id/deprecate-deprecate-array-prototype-extensions',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This points to ember-learn/deprecation-app#1192, which we also need to get merged.

until: '6.0.0',
for: 'ember-source',
since: {
available: '5.10.0',
enabled: '5.10.0',
},
}),
};

export function deprecateUntil(message: string, deprecation: DeprecationObject) {
Expand All @@ -144,3 +154,14 @@ export function deprecateUntil(message: string, deprecation: DeprecationObject)
}
deprecate(message, deprecation.test, options);
}

const { EXTEND_PROTOTYPES } = ENV as {
EXTEND_PROTOTYPES: { Array?: boolean };
};

if (EXTEND_PROTOTYPES.Array !== false) {
deprecateUntil(
'Array prototype extensions are deprecated. Follow the deprecation guide for migration instructions, and set EmberENV.EXTEND_PROTOTYPES to false in your config/environment.js',
DEPRECATIONS.DEPRECATE_ARRAY_PROTOTYPE_EXTENSIONS
);
}
Loading