From e8fab3392ffd565cdb1b6fa85228eceb4dccbe93 Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Tue, 21 Feb 2023 07:55:39 -0700 Subject: [PATCH] [CLEANUP] Remove deprecated `@ember/error` package --- ember-cli-build.js | 1 - packages/@ember/error/index.ts | 53 ------------------- packages/@ember/error/tests/index_test.js | 50 ----------------- .../@ember/error/type-tests/index.test.ts | 5 -- packages/ember/index.ts | 4 -- packages/ember/tests/reexports_test.js | 3 -- type-tests/@ember/error-tests.ts | 7 --- types/preview/ember/index.d.ts | 2 - 8 files changed, 125 deletions(-) delete mode 100644 packages/@ember/error/index.ts delete mode 100644 packages/@ember/error/tests/index_test.js delete mode 100644 packages/@ember/error/type-tests/index.test.ts delete mode 100644 type-tests/@ember/error-tests.ts diff --git a/ember-cli-build.js b/ember-cli-build.js index 76932bd8232..c9ba25558ca 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -220,7 +220,6 @@ function templateCompilerBundle(emberPackages, transpileTree) { '@ember/canary-features/**', '@ember/debug/**', '@ember/deprecated-features/**', - '@ember/error/**', '@ember/polyfills/**', 'ember/version.js', 'ember-babel.js', diff --git a/packages/@ember/error/index.ts b/packages/@ember/error/index.ts deleted file mode 100644 index cee6dede8e3..00000000000 --- a/packages/@ember/error/index.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { deprecate } from '@ember/debug'; -import { DEBUG } from '@glimmer/env'; - -/** - @module @ember/error -*/ - -/** ErrorConstructor without node extensions */ -interface BrowserErrorConstructor { - new (message?: string): Error; - (message?: string): Error; - readonly prototype: Error; -} - -/** - The JavaScript Error object used by Ember.assert. - - @class Error - @namespace Ember - @extends Error - @constructor - @public - @deprecated -*/ -let EmberError: BrowserErrorConstructor; -if (DEBUG) { - // eslint-disable-next-line no-inner-declarations - function EmberDebugConstructor(message?: string) { - deprecate( - 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.', - false, - { - id: 'deprecate-ember-error', - until: '5.0.0', - url: 'https://deprecations.emberjs.com/v4.x/#toc_deprecate-ember-error', - for: 'ember-source', - since: { - available: '4.10.0', - enabled: '4.10.0', - }, - } - ); - return new Error(message); - } - EmberDebugConstructor.prototype = Error.prototype; - - // SAFETY: We need this cast since our EmberDebugConstructor doesn't define a type for `new` even though it will work with `new`. - EmberError = EmberDebugConstructor as BrowserErrorConstructor; -} else { - EmberError = Error; -} - -export default EmberError; diff --git a/packages/@ember/error/tests/index_test.js b/packages/@ember/error/tests/index_test.js deleted file mode 100644 index f2b37f069fe..00000000000 --- a/packages/@ember/error/tests/index_test.js +++ /dev/null @@ -1,50 +0,0 @@ -import { moduleFor, AbstractTestCase as TestCase } from 'internal-test-helpers'; -import EmberError from '@ember/error'; - -moduleFor( - 'Ember Error Throwing', - class extends TestCase { - ['@test new EmberError displays provided message'](assert) { - assert.throws( - () => { - expectDeprecation(() => { - throw new EmberError('A Message'); - }, 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.'); - }, - function (e) { - return e.message === 'A Message'; - }, - 'the assigned message was displayed' - ); - } - ['@test new EmberError is instanceof EmberError'](assert) { - expectDeprecation(() => { - assert.ok( - new EmberError('A Message') instanceof EmberError, - 'new EmberError is instanceof EmberError' - ); - }, 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.'); - } - ['@test EmberError(...) displays provided message'](assert) { - assert.throws( - () => { - expectDeprecation(() => { - throw EmberError('A Message'); - }, 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.'); - }, - function (e) { - return e.message === 'A Message'; - }, - 'the assigned message was displayed' - ); - } - ['@test EmberError(...) is instanceof EmberError'](assert) { - expectDeprecation(() => { - assert.ok( - EmberError('A Message') instanceof EmberError, - 'new EmberError is instanceof EmberError' - ); - }, 'The @ember/error package merely re-exported the native Error and is deprecated. Please use a native Error directly instead.'); - } - } -); diff --git a/packages/@ember/error/type-tests/index.test.ts b/packages/@ember/error/type-tests/index.test.ts deleted file mode 100644 index b13ea57ca98..00000000000 --- a/packages/@ember/error/type-tests/index.test.ts +++ /dev/null @@ -1,5 +0,0 @@ -import EmberError from '@ember/error'; -import { expectTypeOf } from 'expect-type'; - -expectTypeOf(EmberError("Blah")).toEqualTypeOf(); -expectTypeOf(new EmberError("Blah")).toEqualTypeOf(); diff --git a/packages/ember/index.ts b/packages/ember/index.ts index 16f9e3aeb1e..dc47c59a3f2 100644 --- a/packages/ember/index.ts +++ b/packages/ember/index.ts @@ -70,7 +70,6 @@ import VERSION from './version'; import * as views from '@ember/-internals/views'; import ContainerDebugAdapter from '@ember/debug/container-debug-adapter'; import DataAdapter from '@ember/debug/data-adapter'; -import EmberError from '@ember/error'; import { run } from '@ember/runloop'; import { getOnerror, setOnerror } from '@ember/-internals/error-handling'; import EmberArray, { A, NativeArray, isArray, makeArray } from '@ember/array'; @@ -293,9 +292,6 @@ const PartialEmber = { // ****@ember/enumerable/mutable**** MutableEnumerable, - // ****@ember/error**** - Error: EmberError, - // ****@ember/instrumentation**** instrument: instrumentation.instrument, subscribe: instrumentation.subscribe, diff --git a/packages/ember/tests/reexports_test.js b/packages/ember/tests/reexports_test.js index 0c0cdb5912a..2c047d7495f 100644 --- a/packages/ember/tests/reexports_test.js +++ b/packages/ember/tests/reexports_test.js @@ -182,9 +182,6 @@ let allExports = [ // @ember/enumerable ['Enumerable', '@ember/enumerable', 'default'], - // @ember/error - ['Error', '@ember/error', 'default'], - // @ember/instrumentation ['instrument', '@ember/instrumentation', 'instrument'], ['subscribe', '@ember/instrumentation', 'subscribe'], diff --git a/type-tests/@ember/error-tests.ts b/type-tests/@ember/error-tests.ts deleted file mode 100644 index ce279389dd0..00000000000 --- a/type-tests/@ember/error-tests.ts +++ /dev/null @@ -1,7 +0,0 @@ -import EmberError from '@ember/error'; -import { expectTypeOf } from 'expect-type'; - -expectTypeOf(new EmberError('Fuuuuuuuu')).toEqualTypeOf(); - -// allows to extend from EmberError -class AjaxError extends Error {} diff --git a/types/preview/ember/index.d.ts b/types/preview/ember/index.d.ts index 16e22326ce0..a19cf737285 100755 --- a/types/preview/ember/index.d.ts +++ b/types/preview/ember/index.d.ts @@ -40,8 +40,6 @@ declare module 'ember' { import EmberArrayProxy from '@ember/array/proxy'; import type EmberEnumerable from '@ember/array/-private/enumerable'; import type EmberMutableEnumerable from '@ember/array/-private/mutable-enumerable'; - // @ember/error - import type EmberError from '@ember/error'; type EmberArray = EmberArrayNs.default; import type EmberActionHandler from '@ember/object/-private/action-handler';