Sha256: 2209c7c52e218cbbfe344c52e7a71066021d1a77249ebd15dbb68ccb096156eb

Contents?: true

Size: 716 Bytes

Versions: 3

Compression:

Stored size: 716 Bytes

Contents

import { assert } from '@ember/debug';

const VALIDATED_TYPES = {
  route: ['assert', 'isRouteFactory', 'Ember.Route'],
  component: ['deprecate', 'isComponentFactory', 'Ember.Component'],
  view: ['deprecate', 'isViewFactory', 'Ember.View'],
  service: ['deprecate', 'isServiceFactory', 'Ember.Service'],
};

export default function validateType(resolvedType, parsedName) {
  let validationAttributes = VALIDATED_TYPES[parsedName.type];

  if (!validationAttributes) {
    return;
  }

  let [, factoryFlag, expectedType] = validationAttributes;

  assert(
    `Expected ${parsedName.fullName} to resolve to an ${expectedType} but ` +
      `instead it was ${resolvedType}.`,
    !!resolvedType[factoryFlag]
  );
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
discourse-ember-source-3.6.0.0 dist/es/@ember/application/lib/validate-type.js
discourse-ember-source-3.5.1.1 dist/es/@ember/application/lib/validate-type.js
discourse-ember-source-3.5.1.0 dist/dist/es/@ember/application/lib/validate-type.js