@typescript-eslint/type-utils 6.0.0-alpha.120 → 6.0.0-alpha.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,16 @@
1
1
  import * as ts from 'typescript';
2
2
  /**
3
- * Gets all of the type flags in a type, iterating through unions automatically
3
+ * Gets all of the type flags in a type, iterating through unions automatically.
4
4
  */
5
5
  export declare function getTypeFlags(type: ts.Type): ts.TypeFlags;
6
6
  /**
7
- * Checks if the given type is (or accepts) the given flags
8
- * @param isReceiver true if the type is a receiving type (i.e. the type of a called function's parameter)
7
+ * @param flagsToCheck The composition of one or more `ts.TypeFlags`.
8
+ * @param isReceiver Whether the type is a receiving type (e.g. the type of a
9
+ * called function's parameter).
10
+ * @remarks
11
+ * Note that if the type is a union, this function will decompose it into the
12
+ * parts and get the flags of every union constituent. If this is not desired,
13
+ * use the `isTypeFlag` function from tsutils.
9
14
  */
10
15
  export declare function isTypeFlagSet(type: ts.Type, flagsToCheck: ts.TypeFlags, isReceiver?: boolean): boolean;
11
16
  //# sourceMappingURL=typeFlagUtils.d.ts.map
@@ -1,11 +1,16 @@
1
1
  import * as ts from 'typescript';
2
2
  /**
3
- * Gets all of the type flags in a type, iterating through unions automatically
3
+ * Gets all of the type flags in a type, iterating through unions automatically.
4
4
  */
5
5
  export declare function getTypeFlags(type: ts.Type): ts.TypeFlags;
6
6
  /**
7
- * Checks if the given type is (or accepts) the given flags
8
- * @param isReceiver true if the type is a receiving type (i.e. the type of a called function's parameter)
7
+ * @param flagsToCheck The composition of one or more `ts.TypeFlags`.
8
+ * @param isReceiver Whether the type is a receiving type (e.g. the type of a
9
+ * called function's parameter).
10
+ * @remarks
11
+ * Note that if the type is a union, this function will decompose it into the
12
+ * parts and get the flags of every union constituent. If this is not desired,
13
+ * use the `isTypeFlag` function from tsutils.
9
14
  */
10
15
  export declare function isTypeFlagSet(type: ts.Type, flagsToCheck: ts.TypeFlags, isReceiver?: boolean): boolean;
11
16
  //# sourceMappingURL=typeFlagUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"typeFlagUtils.d.ts","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,SAAS,CAOxD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,YAAY,EAAE,EAAE,CAAC,SAAS,EAC1B,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAQT"}
1
+ {"version":3,"file":"typeFlagUtils.d.ts","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAIjC;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,SAAS,CAOxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,YAAY,EAAE,EAAE,CAAC,SAAS,EAC1B,UAAU,CAAC,EAAE,OAAO,GACnB,OAAO,CAQT"}
@@ -26,8 +26,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.isTypeFlagSet = exports.getTypeFlags = void 0;
27
27
  const tsutils = __importStar(require("ts-api-utils"));
28
28
  const ts = __importStar(require("typescript"));
29
+ const ANY_OR_UNKNOWN = ts.TypeFlags.Any | ts.TypeFlags.Unknown;
29
30
  /**
30
- * Gets all of the type flags in a type, iterating through unions automatically
31
+ * Gets all of the type flags in a type, iterating through unions automatically.
31
32
  */
32
33
  function getTypeFlags(type) {
33
34
  // @ts-expect-error Since typescript 5.0, this is invalid, but uses 0 as the default value of TypeFlags.
@@ -39,12 +40,17 @@ function getTypeFlags(type) {
39
40
  }
40
41
  exports.getTypeFlags = getTypeFlags;
41
42
  /**
42
- * Checks if the given type is (or accepts) the given flags
43
- * @param isReceiver true if the type is a receiving type (i.e. the type of a called function's parameter)
43
+ * @param flagsToCheck The composition of one or more `ts.TypeFlags`.
44
+ * @param isReceiver Whether the type is a receiving type (e.g. the type of a
45
+ * called function's parameter).
46
+ * @remarks
47
+ * Note that if the type is a union, this function will decompose it into the
48
+ * parts and get the flags of every union constituent. If this is not desired,
49
+ * use the `isTypeFlag` function from tsutils.
44
50
  */
45
51
  function isTypeFlagSet(type, flagsToCheck, isReceiver) {
46
52
  const flags = getTypeFlags(type);
47
- if (isReceiver && flags & (ts.TypeFlags.Any | ts.TypeFlags.Unknown)) {
53
+ if (isReceiver && flags & ANY_OR_UNKNOWN) {
48
54
  return true;
49
55
  }
50
56
  return (flags & flagsToCheck) !== 0;
@@ -1 +1 @@
1
- {"version":3,"file":"typeFlagUtils.js","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,+CAAiC;AAEjC;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAa;IACxC,wGAAwG;IACxG,IAAI,KAAK,GAAiB,CAAC,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;QAC5C,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;KAClB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,oCAOC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAC3B,IAAa,EACb,YAA0B,EAC1B,UAAoB;IAEpB,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAEjC,IAAI,UAAU,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QACnE,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAZD,sCAYC"}
1
+ {"version":3,"file":"typeFlagUtils.js","sourceRoot":"","sources":["../src/typeFlagUtils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,+CAAiC;AAEjC,MAAM,cAAc,GAAG,EAAE,CAAC,SAAS,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;AAE/D;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAa;IACxC,wGAAwG;IACxG,IAAI,KAAK,GAAiB,CAAC,CAAC;IAC5B,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE;QAC5C,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;KAClB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,oCAOC;AAED;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAC3B,IAAa,EACb,YAA0B,EAC1B,UAAoB;IAEpB,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAEjC,IAAI,UAAU,IAAI,KAAK,GAAG,cAAc,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC;AAZD,sCAYC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/type-utils",
3
- "version": "6.0.0-alpha.120+a35a2bb9d",
3
+ "version": "6.0.0-alpha.124+277fdb5ac",
4
4
  "description": "Type utilities for working with TypeScript + ESLint together",
5
5
  "files": [
6
6
  "dist",
@@ -45,13 +45,13 @@
45
45
  "typecheck": "tsc -p tsconfig.json --noEmit"
46
46
  },
47
47
  "dependencies": {
48
- "@typescript-eslint/typescript-estree": "6.0.0-alpha.120+a35a2bb9d",
49
- "@typescript-eslint/utils": "6.0.0-alpha.120+a35a2bb9d",
48
+ "@typescript-eslint/typescript-estree": "6.0.0-alpha.124+277fdb5ac",
49
+ "@typescript-eslint/utils": "6.0.0-alpha.124+277fdb5ac",
50
50
  "debug": "^4.3.4",
51
51
  "ts-api-utils": "^0.0.44"
52
52
  },
53
53
  "devDependencies": {
54
- "@typescript-eslint/parser": "6.0.0-alpha.120+a35a2bb9d",
54
+ "@typescript-eslint/parser": "6.0.0-alpha.124+277fdb5ac",
55
55
  "ajv": "^8.12.0",
56
56
  "typescript": "*"
57
57
  },
@@ -74,5 +74,5 @@
74
74
  ]
75
75
  }
76
76
  },
77
- "gitHead": "a35a2bb9d2e967216a11f55cd745b0eca49bab5c"
77
+ "gitHead": "277fdb5ac76bd761ae6f5d1052445dcff2e848a1"
78
78
  }