package.json 的开放式对等版本依赖性?

Open ended peer version dependency for package.json?

总结

我假设 @angular/core 的所有主要版本都适用于此。我应该将包对等依赖项指定为:

"peerDependencies": {
  "@angular/core": "x.x"
}

上下文

我正在为将在 NPM 上发布的 angular 服务创建一个包。该模块仅包含一组缓动函数,适用于任何版本的 angular。下面包含简短的片段以供参考。如您所见,服务从 @angular/core 导入 Injectable。我假设它对主要版本 5、6、7 等同样有效。

import {Injectable} from '@angular/core';

@Injectable()
export class RoundProgressEase {
  // t: current time (or position) of the neonate. This can be seconds or frames, steps,
  // seconds, ms, whatever – as long as the unit is the same as is used for the total time.
  // b: beginning value of the property.
  // c: change between the beginning and destination value of the property.
  // d: total time of the neonate.

  linearEase(t: number, b: number, c: number, d: number): number {
    return c * t / d + b;
  };

  easeInQuad(t: number, b: number, c: number, d: number): number {
    return c * (t /= d) * t + b;
  };
}

如果您想要一个开放式范围,请使用星号 (*)

"peerDependencies": {
  "@angular/core": "*"
}