• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript debug.warn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@ember/debug.warn函数的典型用法代码示例。如果您正苦于以下问题:TypeScript warn函数的具体用法?TypeScript warn怎么用?TypeScript warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了warn函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: makeClosureAction

function makeClosureAction(
  context: any,
  target: any,
  action: any,
  processArgs: any,
  debugKey: any
) {
  let self: any;
  let fn: any;

  assert(
    `Action passed is null or undefined in (action) from ${target}.`,
    action !== undefined && action !== null
  );

  if (typeof action[INVOKE] === 'function') {
    self = action;
    fn = action[INVOKE];
  } else {
    let typeofAction = typeof action;

    if (typeofAction === 'string') {
      self = target;
      fn = target.actions && target.actions[action];

      assert(`An action named '${action}' was not found in ${target}`, fn);
    } else if (typeofAction === 'function') {
      if (EMBER_NATIVE_DECORATOR_SUPPORT) {
        warn(
          `You passed a method, ${debugKey}, to the {{action}} helper which was not decorated with the '@action' decorator. All actions should be decorated with the '@action' decorator.`,
          target[debugKey] !== action || action[ACTION_METHOD] === true,
          {
            id: 'action-without-decorator',
          }
        );
      }

      self = context;
      fn = action;
    } else {
      // tslint:disable-next-line:max-line-length
      assert(
        `An action could not be made for \`${debugKey ||
          action}\` in ${target}. Please confirm that you are using either a quoted action name (i.e. \`(action '${debugKey ||
          'myAction'}')\`) or a function available in ${target}.`,
        false
      );
    }
  }

  return (...args: any[]) => {
    let payload = { target: self, args, label: '@glimmer/closure-action' };
    return flaggedInstrument('interaction.ember-action', payload, () => {
      return join(self, fn, ...processArgs(args));
    });
  };
}
开发者ID:habdelra,项目名称:ember.js,代码行数:57,代码来源:action.ts


示例2: addArg

 function addArg(property: string) {
   warn(
     `Dependent keys containing @each only work one level deep. ` +
       `You used the key "${property}" which is invalid. ` +
       `Please create an intermediary computed property.`,
     DEEP_EACH_REGEX.test(property) === false,
     { id: 'ember-metal.computed-deep-each' }
   );
   args.push(property);
 }
开发者ID:chundabear,项目名称:ember.js,代码行数:10,代码来源:computed.ts


示例3: register

  register(name: string, version: string, isCoreLibrary?: boolean): void {
    let index = this._registry.length;

    if (!this._getLibraryByName(name)) {
      if (isCoreLibrary) {
        index = this._coreLibIndex++;
      }
      this._registry.splice(index, 0, { name, version });
    } else {
      warn(`Library "${name}" is already registered with Ember.`, false, {
        id: 'ember-metal.libraries-register',
      });
    }
  }
开发者ID:cibernox,项目名称:ember.js,代码行数:14,代码来源:libraries.ts


示例4: runInDebug

          runInDebug(function() {
            const message = `The server returned an empty string for ${
              requestData.type
            } ${
              requestData.url
            }, which cannot be parsed into a valid JSON. Return either null or {}.`;
            const validJSONString = !(
              textStatus === 'parsererror' && jqXHR.responseText === ''
            );

            warn(message, validJSONString, {
              id: 'ds.adapter.returned-empty-string-as-JSON'
            });
          });
开发者ID:knownasilya,项目名称:ember-ajax,代码行数:14,代码来源:ajax-request.ts


示例5: async

const datasetUrnToId = async (urn: string): Promise<number> => {
  let datasetId = 0;

  try {
    // The headers object is a Header
    const headers = await getHeaders({ url: datasetIdTranslationUrlByUrn(urn) });
    const stringId = headers.get('datasetid');

    // If stringId is not falsey, parse as int and return, otherwise use default
    if (stringId) {
      datasetId = parseInt(stringId, 10);
    }
  } catch (e) {
    warn(`Exception occurred translating datasetUrn: ${e.message}`);
  }

  return datasetId;
};
开发者ID:linwenxue,项目名称:WhereHows,代码行数:18,代码来源:dataset.ts


示例6: updateLink

  updateLink(link: string | null) {
    warn(
      `You pushed a record of type '${this.recordData.modelName}' with a relationship '${
        this.key
      }' configured as 'async: false'. You've included a link but no primary data, this may be an error in your payload. EmberData will treat this relationship as known-to-be-empty.`,
      this.isAsync || this.hasAnyRelationshipData,
      {
        id: 'ds.store.push-link-for-sync-relationship',
      }
    );
    assert(
      `You have pushed a record of type '${this.recordData.modelName}' with '${
        this.key
      }' as a link, but the value of that link is not a string.`,
      typeof link === 'string' || link === null
    );

    this.link = link;
  }
开发者ID:emberjs,项目名称:data,代码行数:19,代码来源:relationship.ts


示例7: warn

    }

    if (get(this, 'bubbles') === false) {
      event.stopPropagation();
    }

    if (this._isDisabled) {
      return false;
    }

    if (get(this, 'loading')) {
      // tslint:disable-next-line:max-line-length
      warn(
        'This link-to is in an inactive loading state because at least one of its parameters presently has a null/undefined value, or the provided route name is invalid.',
        false,
        {
          id: 'ember-glimmer.link-to.inactive-loading-state',
        }
      );
      return false;
    }

    if (targetAttribute && targetAttribute !== '_self') {
      return false;
    }

    let qualifiedRouteName = get(this, 'qualifiedRouteName');
    let models = get(this, 'models');
    let queryParams = get(this, 'queryParams.values');
    let shouldReplace = get(this, 'replace');
开发者ID:habdelra,项目名称:ember.js,代码行数:30,代码来源:link-to.ts


示例8: runInDebug

import { runInDebug, warn, debug, assert, registerWarnHandler, registerDeprecationHandler } from "@ember/debug";

/**
 * @ember/debug tests
 */
runInDebug(); // $ExpectError
runInDebug(() => console.log('Should not show up in prod')); // $ExpectType void

// Log a warning if we have more than 3 tomsters
const tomsterCount = 2;
warn('Too many tomsters!'); // $ExpectType void
warn('Too many tomsters!', tomsterCount <= 3); // $ExpectType void
warn('Too many tomsters!', tomsterCount <= 3, { // $ExpectType void
    id: 'ember-debug.too-many-tomsters'
});

debug(); // $ExpectError
debug('Too many tomsters!'); // $ExpectType void
debug('Too many tomsters!', 'foo'); // $ExpectError

// Test for truthiness
const str = 'hello';
assert('Must pass a string', typeof str === 'string'); // $ExpectType void

// Fail unconditionally
assert('This code path should never be run'); // $ExpectType void

// next is not called, so no warnings get the default behavior
registerWarnHandler(); // $ExpectError
registerWarnHandler(() => {}); // $ExpectType void
registerWarnHandler((message, { id }, next) => { // $ExpectType void
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:31,代码来源:ember__debug-tests.ts


示例9: _setupRelationships

  _setupRelationships(data) {
    let relationships = this.storeWrapper.relationshipsDefinitionFor(this.modelName);
    let keys = Object.keys(relationships);
    for (let i = 0; i < keys.length; i++) {
      let relationshipName = keys[i];

      if (!data.relationships[relationshipName]) {
        continue;
      }

      // in debug, assert payload validity eagerly
      let relationshipData = data.relationships[relationshipName];

      if (DEBUG) {
        let store = this.store;
        let recordData = this;
        let relationshipMeta = relationships[relationshipName];
        if (!relationshipData || !relationshipMeta) {
          continue;
        }

        if (relationshipData.links) {
          let isAsync = relationshipMeta.options && relationshipMeta.options.async !== false;
          let relationship = this._relationships.get(relationshipName);
          warn(
            `You pushed a record of type '${
              this.modelName
            }' with a relationship '${relationshipName}' configured as 'async: false'. You've included a link but no primary data, this may be an error in your payload. EmberData will treat this relationship as known-to-be-empty.`,
            isAsync || relationshipData.data || relationship.hasAnyRelationshipData,
            {
              id: 'ds.store.push-link-for-sync-relationship',
            }
          );
        } else if (relationshipData.data) {
          if (relationshipMeta.kind === 'belongsTo') {
            assert(
              `A ${
                this.modelName
              } record was pushed into the store with the value of ${relationshipName} being ${inspect(
                relationshipData.data
              )}, but ${relationshipName} is a belongsTo relationship so the value must not be an array. You should probably check your data payload or serializer.`,
              !Array.isArray(relationshipData.data)
            );
            assertRelationshipData(store, recordData, relationshipData.data, relationshipMeta);
          } else if (relationshipMeta.kind === 'hasMany') {
            assert(
              `A ${
                this.modelName
              } record was pushed into the store with the value of ${relationshipName} being '${inspect(
                relationshipData.data
              )}', but ${relationshipName} is a hasMany relationship so the value must be an array. You should probably check your data payload or serializer.`,
              Array.isArray(relationshipData.data)
            );
            if (Array.isArray(relationshipData.data)) {
              for (let i = 0; i < relationshipData.data.length; i++) {
                assertRelationshipData(
                  store,
                  recordData,
                  relationshipData.data[i],
                  relationshipMeta
                );
              }
            }
          }
        }
      }

      let relationship = this._relationships.get(relationshipName);

      relationship.push(relationshipData);
    }
  }
开发者ID:code0100fun,项目名称:data,代码行数:72,代码来源:record-data.ts


示例10: create

  create(
    element: Simple.Element,
    _state: Opaque,
    args: Arguments,
    _dynamicScope: DynamicScope,
    dom: any
  ) {
    let { named, positional, tag } = args.capture();
    let implicitTarget: any;
    let actionName;
    let actionNameRef: any;
    if (positional.length > 1) {
      implicitTarget = positional.at(0);
      actionNameRef = positional.at(1);

      if (actionNameRef[INVOKE]) {
        actionName = actionNameRef;
      } else {
        let actionLabel = actionNameRef._propertyKey;
        actionName = actionNameRef.value();

        assert(
          'You specified a quoteless path, `' +
            actionLabel +
            '`, to the ' +
            '{{action}} modifier which did not resolve to an action name (a ' +
            'string). Perhaps you meant to use a quoted actionName? (e.g. ' +
            '{{action "' +
            actionLabel +
            '"}}).',
          typeof actionName === 'string' || typeof actionName === 'function'
        );

        if (DEBUG && EMBER_NATIVE_DECORATOR_SUPPORT) {
          let implicitTargetValue = implicitTarget.value();

          warn(
            `You passed a method, ${actionLabel}, to the {{action}} modifier which was not decorated with the '@action' decorator. All actions should be decorated with the '@action' decorator.`,
            typeof actionName !== 'function' ||
              !implicitTargetValue ||
              implicitTargetValue[actionLabel] !== actionName ||
              actionName[ACTION_METHOD] === true,
            {
              id: 'action-without-decorator',
            }
          );
        }
      }
    }

    let actionArgs: any[] = [];
    // The first two arguments are (1) `this` and (2) the action name.
    // Everything else is a param.
    for (let i = 2; i < positional.length; i++) {
      actionArgs.push(positional.at(i));
    }

    let actionId = uuid();
    return new ActionState(
      element,
      actionId,
      actionName,
      actionArgs,
      named,
      positional,
      implicitTarget,
      dom,
      tag
    );
  }
开发者ID:habdelra,项目名称:ember.js,代码行数:70,代码来源:action.ts



注:本文中的@ember/debug.warn函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript instrumentation.flaggedInstrument函数代码示例发布时间:2022-05-28
下一篇:
TypeScript debug.inspect函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap