當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript deprecations.deprecate函數代碼示例

本文整理匯總了TypeScript中@ember/application/deprecations.deprecate函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript deprecate函數的具體用法?TypeScript deprecate怎麽用?TypeScript deprecate使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了deprecate函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: selector

/**
  @private
  @param {string} [selector] the selector to search for relative to element
  @returns {jQuery} a jQuery object representing the selector (or element itself if no selector)
*/
function jQuerySelector(selector: string): any {
  deprecate(
    'Using this.$() in a rendering test has been deprecated, consider using this.element instead.',
    false,
    {
      id: 'ember-test-helpers.rendering-context.jquery-element',
      until: '2.0.0',
      // @ts-ignore
      url: 'https://emberjs.com/deprecations/v3.x#toc_jquery-apis',
    }
  );

  let { element } = getContext() as RenderingTestContext;

  // emulates Ember internal behavor of `this.$` in a component
  // https://github.com/emberjs/ember.js/blob/v2.5.1/packages/ember-views/lib/views/states/has_element.js#L18
  return selector ? global.jQuery(selector, element) : global.jQuery(element);
}
開發者ID:switchfly,項目名稱:ember-test-helpers,代碼行數:23,代碼來源:setup-rendering-context.ts

示例2: buildFileEvent

// eslint-disable-next-line require-jsdoc
function buildFileEvent(
  type: FileSelectionEventType,
  element: HTMLInputElement,
  options: any = {}
): Event {
  let event = buildBasicEvent(type);
  let files;
  if (Array.isArray(options)) {
    deprecate(
      'Passing the `options` param as an array to `triggerEvent` for file inputs is deprecated. Please pass an object with a key `files` containing the array instead.',
      false,
      {
        id: 'ember-test-helpers.trigger-event.options-blob-array',
        until: '2.0.0',
      }
    );

    files = options;
  } else {
    files = options.files;
  }

  if (files.length > 0) {
    Object.defineProperty(files, 'item', {
      value(index: number) {
        return typeof index === 'number' ? this[index] : null;
      },
    });
    Object.defineProperty(element, 'files', {
      value: files,
      configurable: true,
    });
  }

  Object.defineProperty(event, 'target', {
    value: element,
  });

  return event;
}
開發者ID:switchfly,項目名稱:ember-test-helpers,代碼行數:41,代碼來源:fire-event.ts

示例3: deprecate

import { deprecate, deprecateFunc } from '@ember/application/deprecations';

deprecate('this is no longer advised', false, {
    id: 'no-longer-advised',
    until: 'v4.0'
});
deprecate('this is no longer advised', false);

deprecateFunc('this is no longer advised', () => {});
deprecateFunc(
    'this is no longer advised',
    { id: 'no-longer-do-this', until: 'v4.0' },
    () => {}
);
開發者ID:worr,項目名稱:DefinitelyTyped,代碼行數:14,代碼來源:deprecations.ts

示例4: deprecate

import { deprecate, deprecateFunc } from '@ember/application/deprecations';

deprecate('this is no longer advised', false, {
  id: 'no-longer-advised',
  until: 'v4.0'
});
deprecate('this is no longer advised', false, {
    id: 'no-longer-advised',
    until: 'v4.0',
    url: 'https://emberjs.com'
});
deprecate('this is no longer advised', false); // $ExpectError

deprecateFunc('this is no longer advised', () => {}); // $ExpectError
deprecateFunc(
    'this is no longer advised',
    { id: 'no-longer-do-this', until: 'v4.0' },
    () => {}
);
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:19,代碼來源:deprecations.ts


注:本文中的@ember/application/deprecations.deprecate函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。