@inflexa-ai/typecheck 0.5.0 → 0.6.1
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/README.md +16 -3
- package/dist/diagnostics.d.ts +1 -1
- package/dist/diagnostics.js +1 -1
- package/dist/directives.d.ts +1 -1
- package/dist/directives.js +1 -1
- package/dist/engine.d.ts +2 -2
- package/dist/helpers/reflective-calls.d.ts +2 -2
- package/dist/helpers/reflective-calls.js +1 -1
- package/dist/rule-tester.js +1 -1
- package/dist/rule.d.ts +2 -2
- package/dist/rules/must-use-result.js +2 -2
- package/dist/rules/no-generated-empty-object-type.js +2 -2
- package/dist/rules/require-abort-signal.js +3 -3
- package/dist/run.js +2 -2
- package/dist/unstable/ast.d.ts +1 -0
- package/dist/unstable/ast.js +1 -0
- package/dist/unstable/sync.d.ts +1 -0
- package/dist/unstable/sync.js +1 -0
- package/package.json +12 -3
package/README.md
CHANGED
|
@@ -5,10 +5,23 @@ The command `inflexa-typecheck`. It does the type check of `tsc --noEmit` on Typ
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npm install --save-dev @inflexa-ai/typecheck
|
|
8
|
+
npm install --save-dev @inflexa-ai/typecheck
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Hold the two TypeScript aliases in the `devDependencies` of the repository:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
17
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The package reads the program through the unstable sync API of TypeScript 7, which is not under semver. Thus it depends on the exact release `npm:typescript@7.0.2` under the alias name `@typescript/native`, and it declares no `typescript` peer. Keep `@typescript/native` in your `devDependencies` at the same exact version, so npm dedupes the two into one TypeScript 7, and raise the two together when a new release comes.
|
|
23
|
+
|
|
24
|
+
The name `typescript` holds TypeScript 6, which the editor reads. `tsc` and `inflexa-typecheck` check with TypeScript 7 through `@typescript/native`.
|
|
12
25
|
|
|
13
26
|
## Run
|
|
14
27
|
|
|
@@ -101,7 +114,7 @@ getResult()
|
|
|
101
114
|
A repository gives its own rules as a plugin:
|
|
102
115
|
|
|
103
116
|
```ts
|
|
104
|
-
import { isCallExpression, SyntaxKind } from '
|
|
117
|
+
import { isCallExpression, SyntaxKind } from '@inflexa-ai/typecheck/unstable/ast'
|
|
105
118
|
import type { Plugin, RuleModule } from '@inflexa-ai/typecheck'
|
|
106
119
|
|
|
107
120
|
const noRawDate: RuleModule<{ allowIn: string[] }> = {
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Diagnostic, type Program } from 'typescript/unstable/sync';
|
|
1
|
+
import { type Diagnostic, type Program } from '@typescript/native/unstable/sync';
|
|
2
2
|
import type { ProjectFiles } from './projects.ts';
|
|
3
3
|
/**
|
|
4
4
|
* The diagnostics of a program in the order and with the gates of `tsc`: the
|
package/dist/diagnostics.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { DiagnosticCategory } from 'typescript/unstable/sync';
|
|
2
|
+
import { DiagnosticCategory } from '@typescript/native/unstable/sync';
|
|
3
3
|
export function collectDiagnostics(program) {
|
|
4
4
|
const options = program.getCompilerOptions();
|
|
5
5
|
const emitsDeclarations = options.declaration === true || options.composite === true;
|
package/dist/directives.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type SourceFile } from 'typescript/unstable/ast';
|
|
1
|
+
import { type SourceFile } from '@typescript/native/unstable/ast';
|
|
2
2
|
import type { RuleReport } from './engine.ts';
|
|
3
3
|
export declare const DIRECTIVE = "typecheck-disable-next-line";
|
|
4
4
|
/** The id of the problems of a directive, in the place of a rule id. */
|
package/dist/directives.js
CHANGED
package/dist/engine.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SourceFile } from 'typescript/unstable/ast';
|
|
2
|
-
import type { Checker, Program } from 'typescript/unstable/sync';
|
|
1
|
+
import type { SourceFile } from '@typescript/native/unstable/ast';
|
|
2
|
+
import type { Checker, Program } from '@typescript/native/unstable/sync';
|
|
3
3
|
import type { ActiveRule } from './config.ts';
|
|
4
4
|
import type { ReportData } from './rule.ts';
|
|
5
5
|
/** A report of a rule, at the start of its node in a file. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type CallExpression, type Node } from 'typescript/unstable/ast';
|
|
2
|
-
import type { Signature } from 'typescript/unstable/sync';
|
|
1
|
+
import { type CallExpression, type Node } from '@typescript/native/unstable/ast';
|
|
2
|
+
import type { Signature } from '@typescript/native/unstable/sync';
|
|
3
3
|
/**
|
|
4
4
|
* The name of the indirection a call reaches its target through, or `undefined`
|
|
5
5
|
* where it reaches one directly or reaches nothing that matters.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isElementAccessExpression, isFunctionDeclaration, isIdentifier, isInterfaceDeclaration, isMethodSignatureDeclaration, isModuleBlock, isModuleDeclaration, isPropertyAccessExpression, isSpreadElement, SyntaxKind, } from 'typescript/unstable/ast';
|
|
1
|
+
import { isElementAccessExpression, isFunctionDeclaration, isIdentifier, isInterfaceDeclaration, isMethodSignatureDeclaration, isModuleBlock, isModuleDeclaration, isPropertyAccessExpression, isSpreadElement, SyntaxKind, } from '@typescript/native/unstable/ast';
|
|
2
2
|
const FUNCTION_INTERFACES = new Set(['CallableFunction', 'Function']);
|
|
3
3
|
const REFLECTIVE_MEMBERS = new Set(['call', 'apply', 'bind']);
|
|
4
4
|
const DECLARATION_FILE = /\.d\.[cm]?ts$/i;
|
package/dist/rule-tester.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AssertionError } from 'node:assert';
|
|
|
2
2
|
import { readdirSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { isDeepStrictEqual } from 'node:util';
|
|
5
|
-
import { API } from 'typescript/unstable/sync';
|
|
5
|
+
import { API } from '@typescript/native/unstable/sync';
|
|
6
6
|
import { mergeRuleOptions } from './config.js';
|
|
7
7
|
import { runRules } from './engine.js';
|
|
8
8
|
const DEFAULT_FILENAME = 'case.ts';
|
package/dist/rule.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Node, SourceFile, SyntaxKind } from 'typescript/unstable/ast';
|
|
2
|
-
import type { Checker, Program } from 'typescript/unstable/sync';
|
|
1
|
+
import type { Node, SourceFile, SyntaxKind } from '@typescript/native/unstable/ast';
|
|
2
|
+
import type { Checker, Program } from '@typescript/native/unstable/sync';
|
|
3
3
|
/** A value of an option, as JSON writes it. */
|
|
4
4
|
export type OptionValue = string | number | boolean | null | OptionValue[] | {
|
|
5
5
|
[key: string]: OptionValue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isArrayLiteralExpression, isArrowFunction, isAwaitExpression, isBinaryExpression, isCallExpression, isFunctionExpression, isIdentifier, isParenthesizedExpression, isPropertyAccessExpression, isSourceFile, isVariableDeclaration, isYieldExpression, SyntaxKind, } from 'typescript/unstable/ast';
|
|
2
|
-
import { isUnionType } from 'typescript/unstable/sync';
|
|
1
|
+
import { isArrayLiteralExpression, isArrowFunction, isAwaitExpression, isBinaryExpression, isCallExpression, isFunctionExpression, isIdentifier, isParenthesizedExpression, isPropertyAccessExpression, isSourceFile, isVariableDeclaration, isYieldExpression, SyntaxKind, } from '@typescript/native/unstable/ast';
|
|
2
|
+
import { isUnionType } from '@typescript/native/unstable/sync';
|
|
3
3
|
import { stringArraysOnly } from '../rule-options.js';
|
|
4
4
|
const RESULT_PROPERTIES = ['mapErr', 'map', 'andThen', 'orElse', 'match', 'unwrapOr'];
|
|
5
5
|
const HANDLED_METHODS = new Set(['match', 'unwrapOr', '_unsafeUnwrap', '_unsafeUnwrapErr', 'isOk', 'isErr']);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isTypeReferenceNode, SyntaxKind } from 'typescript/unstable/ast';
|
|
2
|
-
import { isObjectType, isUnionType, ObjectFlags, SignatureKind } from 'typescript/unstable/sync';
|
|
1
|
+
import { isTypeReferenceNode, SyntaxKind } from '@typescript/native/unstable/ast';
|
|
2
|
+
import { isObjectType, isUnionType, ObjectFlags, SignatureKind } from '@typescript/native/unstable/sync';
|
|
3
3
|
export const noGeneratedEmptyObjectType = {
|
|
4
4
|
meta: {
|
|
5
5
|
docs: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isCallExpression, isIdentifier, isSignatureDeclaration, SyntaxKind } from 'typescript/unstable/ast';
|
|
2
|
-
import { isUnionType, SignatureKind, SymbolFlags, TypeFlags } from 'typescript/unstable/sync';
|
|
1
|
+
import { isCallExpression, isIdentifier, isSignatureDeclaration, SyntaxKind } from '@typescript/native/unstable/ast';
|
|
2
|
+
import { isUnionType, SignatureKind, SymbolFlags, TypeFlags } from '@typescript/native/unstable/sync';
|
|
3
3
|
import { indirectionOf } from '../helpers/reflective-calls.js';
|
|
4
4
|
import { stringArraysOnly } from '../rule-options.js';
|
|
5
5
|
const DECLARATION_FILE = /\.d\.[cm]?ts$/i;
|
|
@@ -18,7 +18,7 @@ export const requireAbortSignal = {
|
|
|
18
18
|
defaultOptions: { declaredIn: [] },
|
|
19
19
|
messages: {
|
|
20
20
|
indirectCall: 'This call goes through `{{through}}`, where the options cannot be read, so nothing here can tell whether the request carries a `signal`. Call the method directly, `api.get(path, { signal })`: app code has no need for the indirection, and reaching for it is how a request ends up with nothing to cancel it.',
|
|
21
|
-
missingSignal: 'This call cannot be cancelled: {{problem}}. Pass a `signal` typed `AbortSignal`, not `AbortSignal | undefined`. Inside a query function it is the `signal` of the context the library hands you. Where nothing can cancel the call, a mutation among them, it is a deadline: `AbortSignal.timeout(ms)`. Where both exist, combine them with `AbortSignal.any([signal, AbortSignal.timeout(ms)])`. A wrapper declares `signal: AbortSignal` in its own options and the compiler asks its callers.',
|
|
21
|
+
missingSignal: 'This call cannot be cancelled: {{problem}}. Pass a `signal` typed `AbortSignal`, not `AbortSignal | undefined`. Inside a query function it is the `signal` of the context the library hands you. Where nothing can cancel the call, a mutation among them, it is a deadline: `AbortSignal.timeout(ms)`. Where both exist, combine them with `AbortSignal.any([signal, AbortSignal.timeout(ms)])`. `AbortSignal.any` first shipped in Chrome 116, Edge 116, Firefox 124 and Safari 17.4, and the document of this rule gives a form for an older browser. A wrapper declares `signal: AbortSignal` in its own options and the compiler asks its callers.',
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
checkOptions: stringArraysOnly,
|
package/dist/run.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { API } from 'typescript/unstable/sync';
|
|
3
|
+
import { API } from '@typescript/native/unstable/sync';
|
|
4
4
|
import { loadConfig, resolveRules } from './config.js';
|
|
5
5
|
import { applyDirectives, DIRECTIVE } from './directives.js';
|
|
6
|
-
import { computeLineStarts } from 'typescript/unstable/ast';
|
|
6
|
+
import { computeLineStarts } from '@typescript/native/unstable/ast';
|
|
7
7
|
import { collectDiagnostics, displayPath, formatDiagnostic, sortAndDeduplicate, withRealConfig } from './diagnostics.js';
|
|
8
8
|
import { runRules } from './engine.js';
|
|
9
9
|
import { TypecheckLoadError } from './errors.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@typescript/native/unstable/ast';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@typescript/native/unstable/ast';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@typescript/native/unstable/sync';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@typescript/native/unstable/sync';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inflexa-ai/typecheck",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "The type check of Inflexa on TypeScript 7: the diagnostics of tsc --noEmit and the typed rules in one command.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -28,6 +28,14 @@
|
|
|
28
28
|
"types": "./dist/helpers/*.d.ts",
|
|
29
29
|
"default": "./dist/helpers/*.js"
|
|
30
30
|
},
|
|
31
|
+
"./unstable/ast": {
|
|
32
|
+
"types": "./dist/unstable/ast.d.ts",
|
|
33
|
+
"default": "./dist/unstable/ast.js"
|
|
34
|
+
},
|
|
35
|
+
"./unstable/sync": {
|
|
36
|
+
"types": "./dist/unstable/sync.d.ts",
|
|
37
|
+
"default": "./dist/unstable/sync.js"
|
|
38
|
+
},
|
|
31
39
|
"./package.json": "./package.json"
|
|
32
40
|
},
|
|
33
41
|
"bin": {
|
|
@@ -43,7 +51,8 @@
|
|
|
43
51
|
"publishConfig": {
|
|
44
52
|
"access": "public"
|
|
45
53
|
},
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
|
|
54
|
+
"peerDependencies": {},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@typescript/native": "npm:typescript@7.0.2"
|
|
48
57
|
}
|
|
49
58
|
}
|