@typescript-eslint/type-utils 8.45.1-alpha.9 → 8.46.1-alpha.0

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.
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './getDeclaration';
6
6
  export * from './getSourceFileOfNode';
7
7
  export * from './getTypeName';
8
8
  export * from './isSymbolFromDefaultLibrary';
9
+ export * from './isTypeBrandedLiteralLike';
9
10
  export * from './isTypeReadonly';
10
11
  export * from './isUnsafeAssignment';
11
12
  export * from './predicates';
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __exportStar(require("./getDeclaration"), exports);
23
23
  __exportStar(require("./getSourceFileOfNode"), exports);
24
24
  __exportStar(require("./getTypeName"), exports);
25
25
  __exportStar(require("./isSymbolFromDefaultLibrary"), exports);
26
+ __exportStar(require("./isTypeBrandedLiteralLike"), exports);
26
27
  __exportStar(require("./isTypeReadonly"), exports);
27
28
  __exportStar(require("./isUnsafeAssignment"), exports);
28
29
  __exportStar(require("./predicates"), exports);
@@ -0,0 +1,2 @@
1
+ import * as ts from 'typescript';
2
+ export declare function isTypeBrandedLiteralLike(type: ts.Type): boolean;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.isTypeBrandedLiteralLike = isTypeBrandedLiteralLike;
37
+ const tsutils = __importStar(require("ts-api-utils"));
38
+ const ts = __importStar(require("typescript"));
39
+ function isLiteralOrTaggablePrimitiveLike(type) {
40
+ return (type.isLiteral() ||
41
+ tsutils.isTypeFlagSet(type, ts.TypeFlags.BigInt |
42
+ ts.TypeFlags.Number |
43
+ ts.TypeFlags.String |
44
+ ts.TypeFlags.TemplateLiteral));
45
+ }
46
+ function isObjectLiteralLike(type) {
47
+ return (!type.getCallSignatures().length &&
48
+ !type.getConstructSignatures().length &&
49
+ tsutils.isObjectType(type));
50
+ }
51
+ function isTypeBrandedLiteral(type) {
52
+ if (!type.isIntersection()) {
53
+ return false;
54
+ }
55
+ let hadObjectLike = false;
56
+ let hadPrimitiveLike = false;
57
+ for (const constituent of type.types) {
58
+ if (isObjectLiteralLike(constituent)) {
59
+ hadPrimitiveLike = true;
60
+ }
61
+ else if (isLiteralOrTaggablePrimitiveLike(constituent)) {
62
+ hadObjectLike = true;
63
+ }
64
+ else {
65
+ return false;
66
+ }
67
+ }
68
+ return hadPrimitiveLike && hadObjectLike;
69
+ }
70
+ function isTypeBrandedLiteralLike(type) {
71
+ return type.isUnion()
72
+ ? type.types.every(isTypeBrandedLiteral)
73
+ : isTypeBrandedLiteral(type);
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typescript-eslint/type-utils",
3
- "version": "8.45.1-alpha.9",
3
+ "version": "8.46.1-alpha.0",
4
4
  "description": "Type utilities for working with TypeScript + ESLint together",
5
5
  "files": [
6
6
  "dist",
@@ -44,9 +44,9 @@
44
44
  "typecheck": "yarn run -BT nx typecheck"
45
45
  },
46
46
  "dependencies": {
47
- "@typescript-eslint/types": "8.45.1-alpha.9",
48
- "@typescript-eslint/typescript-estree": "8.45.1-alpha.9",
49
- "@typescript-eslint/utils": "8.45.1-alpha.9",
47
+ "@typescript-eslint/types": "8.46.1-alpha.0",
48
+ "@typescript-eslint/typescript-estree": "8.46.1-alpha.0",
49
+ "@typescript-eslint/utils": "8.46.1-alpha.0",
50
50
  "debug": "^4.3.4",
51
51
  "ts-api-utils": "^2.1.0"
52
52
  },
@@ -55,7 +55,7 @@
55
55
  "typescript": ">=4.8.4 <6.0.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@typescript-eslint/parser": "8.45.1-alpha.9",
58
+ "@typescript-eslint/parser": "8.46.1-alpha.0",
59
59
  "@vitest/coverage-v8": "^3.1.3",
60
60
  "ajv": "^6.12.6",
61
61
  "eslint": "*",