@tslite/checker 0.14.0 → 1.1.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/chunk-BW42VHMU.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +55 -14
- package/dist/index.d.ts +55 -14
- package/dist/index.js +1 -1
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +948 -0
- package/dist/types/index.d.ts +948 -0
- package/dist/types/index.js +1 -0
- package/package.json +13 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Schema, Schemes, TypeScheme, ObjectSchema, Completion } from '
|
|
2
|
-
export
|
|
3
|
-
import { Scope as Scope$1, BaseNode, Node, types, Expression, SourceLocation } from '@tslite/
|
|
1
|
+
import { Schema, Schemes, TypeScheme, ObjectSchema, Completion } from './types/index.cjs';
|
|
2
|
+
export { AnySchema, ApplySchema, ArraySchema, Bindings, DEFAULT_TYPE_LIMITS, Discovery, ElementFlag, FnSchema, GuardSig, INSTANTIATION_COUNT_LIMIT, INSTANTIATION_DEPTH_LIMIT, Incompatibility, IncompatibilityKind, IndexSchema, Instantiation, InstantiationLimitError, KeyofSchema, LiteralSchema, MappedSchema, OverloadSchema, Param, Prop, ScalarSchema, TYPE_EVAL_DEPTH_LIMIT, TupleSchema, TypeEvalLimitError, TypeEvalLimits, TypeForm, TypePosition, UnionSchema, UnionTooComplexError, UnknownSchema, VarCandidates, VarSchema, apparentType, asLiteralOrigin, baseLiteralType, bindTypeParams, comparable, configureTypeLimits, contravariantInference, covariantInference, discover, equals, erasedSignature, expand1, flagAt, format, formatTypeArgs, formatTypeDiff, freeVars, groundVars, inferFromCandidates, inferredTypes, instantiate, instantiateInContextOf, instantiateLoose, isMissingType, isNumericLiteralName, isObjectOrArrayLiteral, isScheme, isSerializable, isVariadicTuple, join, joinAll, missingType, normalizeUnion, ownProp, renameTypeParams, resetInstantiationCount, resetTypeLimits, resolveConditional, resolveOp, resolveTypeOp, restIndex, s, sampleValue, silentNever, substitute, subtype, typeAtPosition, typeDiff, typeFeatures, typeLimits, typeNeedsParens, typeParamArity, unify, widen, widenInferred, widenLiteral, widenOrigin, widenType, withoutUndefined } from './types/index.cjs';
|
|
3
|
+
import { Scope as Scope$1, BaseNode, Node, types, Expression, SourceLocation } from '@tslite/ast';
|
|
4
4
|
import { CapabilityProfile, CompiledProfile } from '@tslite/capability';
|
|
5
5
|
import { Span } from '@tslite/language-service';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Um nível de escopo léxico (nome → `Schema`), sobre o `Scope<T>` genérico do
|
|
9
|
-
* `
|
|
9
|
+
* `ast` — a mesma cadeia que o `behavior` usa, com o payload do eixo de tipos.
|
|
10
10
|
*/
|
|
11
11
|
type Scope = Scope$1<Schema>;
|
|
12
12
|
/** Cria um escopo raiz (sem pai). */
|
|
@@ -17,9 +17,11 @@ declare const childScope: (parent: Scope, vars: Record<string, Schema>) => Scope
|
|
|
17
17
|
declare const lookup: (scope: Scope, name: string) => Schema | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Todos os nomes visíveis a partir de `scope`, com shadowing — o binding mais
|
|
20
|
-
* interno vence. É o que alimenta o autocomplete de identificadores.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* interno vence. É o que alimenta o autocomplete de identificadores. Duas
|
|
21
|
+
* chaves moram no mesmo escopo e não são nomes: a que tem `.` é um caminho
|
|
22
|
+
* estreitado por guard (`narrow`, D13), e a que termina em `#` é o tipo
|
|
23
|
+
* DECLARADO de um binding mutável (D63) — nenhum identificador tem esses
|
|
24
|
+
* caracteres.
|
|
23
25
|
*/
|
|
24
26
|
declare const visibleNames: (scope: Scope) => Map<string, Schema>;
|
|
25
27
|
/**
|
|
@@ -112,7 +114,7 @@ declare const resolveNamed: (env: Env, name: string) => Schema | undefined;
|
|
|
112
114
|
declare const resolveScheme: (env: Env, name: string) => TypeScheme | undefined;
|
|
113
115
|
|
|
114
116
|
type Severity = "error" | "warning";
|
|
115
|
-
type DiagnosticCode = "not-assignable" | "unknown-name" | "not-callable" | "no-such-member" | "not-object" | "const-needs-init" | "cannot-redeclare" | "unknown-module" | "not-a-schema" | "type-as-value" | "asserter-needs-name" | "shadows-schema" | "missing-argument" | "excess-argument" | "excess-property" | "spread-argument" | "required-after-optional" | "not-iterable" | "props-mismatch" | "no-matching-overload" | "constraint-violation" | "wrong-type-argument-count" | "unsupported" | "forbidden-member" | "unused-name" | "assign-to-const" | "readonly-write" | "cast-unsound" | "unprovable-value" | "not-arithmetic-operand" | "operator-not-applicable" | "implicit-coercion" | "node-not-allowed" | "name-not-allowed" | "type-feature-not-allowed" | "any-not-allowed" | "narrowing-cast-not-allowed" | "too-deep" | "too-complex-union" | "too-large" | "wrong-result-type";
|
|
117
|
+
type DiagnosticCode = "not-assignable" | "unknown-name" | "not-callable" | "no-such-member" | "not-object" | "possibly-nullish" | "unknown-value" | "const-needs-init" | "cannot-redeclare" | "circular-type-alias" | "circular-type-annotation" | "unknown-module" | "not-a-schema" | "type-as-value" | "asserter-needs-name" | "shadows-schema" | "missing-argument" | "excess-argument" | "excess-property" | "spread-argument" | "required-after-optional" | "not-iterable" | "props-mismatch" | "no-matching-overload" | "constraint-violation" | "wrong-type-argument-count" | "unsupported" | "forbidden-member" | "unused-name" | "assign-to-const" | "readonly-write" | "cast-unsound" | "unprovable-value" | "not-arithmetic-operand" | "operator-not-applicable" | "implicit-coercion" | "node-not-allowed" | "name-not-allowed" | "type-feature-not-allowed" | "any-not-allowed" | "narrowing-cast-not-allowed" | "too-deep" | "too-complex-union" | "too-large" | "wrong-result-type";
|
|
116
118
|
/**
|
|
117
119
|
* A **classe** do diagnóstico — espelha a divisão de passes do `tsc` (que nós
|
|
118
120
|
* fundimos num walk só): `semantic` é o que o **binder** do tsc pega (validade do
|
|
@@ -187,6 +189,29 @@ declare const diag: {
|
|
|
187
189
|
notCallable: (node: BaseNode, type: Schema) => Diagnostic;
|
|
188
190
|
noSuchMember: (node: BaseNode, type: Schema, key: string) => Diagnostic;
|
|
189
191
|
notObject: (node: BaseNode, type: Schema) => Diagnostic;
|
|
192
|
+
/**
|
|
193
|
+
* Ler ou chamar através de um valor que pode ser `null`/`undefined` — o
|
|
194
|
+
* `checkNonNullTypeWithReporter` do tsc (`checker.ts:24098`), que tem uma mensagem por
|
|
195
|
+
* combinação, e a variante "Cannot invoke" quando o valor é chamado.
|
|
196
|
+
*/
|
|
197
|
+
possiblyNullish: (node: BaseNode, nullish: {
|
|
198
|
+
readonly null: boolean;
|
|
199
|
+
readonly undefined: boolean;
|
|
200
|
+
}, invoked?: boolean) => Diagnostic;
|
|
201
|
+
/**
|
|
202
|
+
* Usar um valor `unknown` como objeto — ler dele, chamá-lo, indexá-lo ou operar
|
|
203
|
+
* sobre ele. É o mesmo `checkNonNullTypeWithReporter` (`checker.ts:24102`), no ramo
|
|
204
|
+
* que vem ANTES do nullish e em três linhas:
|
|
205
|
+
*
|
|
206
|
+
* if (strictNullChecks && type.flags & TypeFlags.Unknown) {
|
|
207
|
+
* error(node, Diagnostics.Object_is_of_type_unknown);
|
|
208
|
+
* return errorType;
|
|
209
|
+
* }
|
|
210
|
+
*
|
|
211
|
+
* Um código só e uma mensagem só, para os seis usos (o TS2571 da 3.9.10 — o
|
|
212
|
+
* TS18046 é de versão posterior e não existe na tag).
|
|
213
|
+
*/
|
|
214
|
+
unknownValue: (node: BaseNode) => Diagnostic;
|
|
190
215
|
constNeedsInit: (node: BaseNode) => Diagnostic;
|
|
191
216
|
missingArgument: (node: BaseNode, name: string, expected: Schema) => Diagnostic;
|
|
192
217
|
notASchema: (node: BaseNode, name: string) => Diagnostic;
|
|
@@ -195,7 +220,21 @@ declare const diag: {
|
|
|
195
220
|
shadowsSchema: (node: BaseNode, name: string) => Diagnostic;
|
|
196
221
|
unknownModule: (node: BaseNode, source: string) => Diagnostic;
|
|
197
222
|
cannotRedeclare: (node: BaseNode, name: string) => Diagnostic;
|
|
223
|
+
circularTypeAlias: (node: BaseNode, name: string) => Diagnostic;
|
|
224
|
+
circularTypeAnnotation: (node: BaseNode, name: string) => Diagnostic;
|
|
198
225
|
excessArgument: (node: BaseNode, expected: number, got: number) => Diagnostic;
|
|
226
|
+
/**
|
|
227
|
+
* A ARIDADE de uma chamada, com o texto do `getArgumentArityError` do tsc
|
|
228
|
+
* (`checker.ts:25477`): `Expected {range} arguments, but got {got}.` (TS2554), e
|
|
229
|
+
* `Expected at least {min} arguments, but got {got}.` quando a assinatura tem rest
|
|
230
|
+
* (TS2555). O `range` é `min` ou `min-max`, e o plural é sempre plural, como lá.
|
|
231
|
+
*
|
|
232
|
+
* O CÓDIGO continua dizendo a direção — `missing-argument` quando faltam, e
|
|
233
|
+
* `excess-argument` quando sobram —, que é informação que o texto do tsc perdeu ao
|
|
234
|
+
* usar um único TS2554 para os dois. A régua é a D2: o código é o contrato, a mensagem
|
|
235
|
+
* é prosa.
|
|
236
|
+
*/
|
|
237
|
+
argumentArity: (node: BaseNode, range: string, got: number, kind: "missing" | "excess", atLeast?: boolean) => Diagnostic;
|
|
199
238
|
excessProperty: (node: BaseNode, name: string, target: Schema) => Diagnostic;
|
|
200
239
|
spreadArgument: (node: BaseNode) => Diagnostic;
|
|
201
240
|
requiredAfterOptional: (node: BaseNode) => Diagnostic;
|
|
@@ -207,10 +246,12 @@ declare const diag: {
|
|
|
207
246
|
/**
|
|
208
247
|
* Argumento de tipo explícito com aridade errada. Assinatura **sem** type params
|
|
209
248
|
* declarados conta como `expected: 0` — é o que o tsc faz quando
|
|
210
|
-
* `Signature.typeParameters` é `undefined` (ele nunca infere a lista).
|
|
211
|
-
* texto do TS2558.
|
|
249
|
+
* `Signature.typeParameters` é `undefined` (ele nunca infere a lista). Com default, o
|
|
250
|
+
* esperado é a faixa (`"1-2"`). Mensagem no texto do TS2558, que é sempre plural.
|
|
212
251
|
*/
|
|
213
|
-
wrongTypeArgumentCount: (node: BaseNode, expected: number, got: number) => Diagnostic;
|
|
252
|
+
wrongTypeArgumentCount: (node: BaseNode, expected: number | string, got: number) => Diagnostic;
|
|
253
|
+
/** Nenhuma sobrecarga aceita a aridade, e há uma abaixo e outra acima (≅ TS2743). */
|
|
254
|
+
noOverloadTypeArgumentCount: (node: BaseNode, got: number, below: number, above: number) => Diagnostic;
|
|
214
255
|
/** Referência a um alias com aridade errada — as frases do tsc: TS2315 para um
|
|
215
256
|
* tipo que não é genérico, TS2314 para o resto (com o intervalo quando há default). */
|
|
216
257
|
genericTypeArity: (node: BaseNode, name: string, min: number, max: number) => Diagnostic;
|
|
@@ -353,7 +394,7 @@ interface CheckOptions {
|
|
|
353
394
|
* Sem ele, `check` faz **só type-checking** (sem opinar sobre capability).
|
|
354
395
|
*
|
|
355
396
|
* Capability **desinstala** features (o que pode existir em runtime — junto do
|
|
356
|
-
* interpret/
|
|
397
|
+
* interpret/codegen); é ortogonal aos `limits`/`resultType` abaixo, que **validam**.
|
|
357
398
|
*/
|
|
358
399
|
readonly profile?: CapabilityProfile;
|
|
359
400
|
/**
|
|
@@ -442,7 +483,7 @@ declare const FUNCTION_KINDS: readonly ["ArrowFunctionExpression", "FunctionExpr
|
|
|
442
483
|
/**
|
|
443
484
|
* O guard de **capability**: percorre `root` e reporta `node-not-allowed` em todo
|
|
444
485
|
* nó proibido por `compiled` — via `nodeViolation`, a **fonte única** de gating
|
|
445
|
-
* compartilhada com o interpret e o
|
|
486
|
+
* compartilhada com o interpret e o codegen. É o que `fromCapability` monta (+ o
|
|
446
487
|
* host allowlist). Garante que os 3 consumidores concordam por construção.
|
|
447
488
|
*/
|
|
448
489
|
declare function capabilityNodes(compiled: CompiledProfile, severity?: Severity): Guard;
|
|
@@ -681,4 +722,4 @@ declare function anchorDiagnostics<A>(root: object, diagnostics: readonly Diagno
|
|
|
681
722
|
*/
|
|
682
723
|
declare function spanOf(text: string, loc: SourceLocation | null | undefined): Span | undefined;
|
|
683
724
|
|
|
684
|
-
export { type AnchorDiagnosticsOptions, type AnchoredDiagnostic, type Anchors, BINARY_OP, BINARY_OPS, type BinaryOpCategory, type BinaryOpSpec, type BindingMap, type CheckOptions, type CheckResult, type CheckerErrorCode, type Diagnostic, type DiagnosticCode, type DiagnosticData, type DiagnosticKind, type DiagnosticSink, type Env, type EnvOptions, FUNCTION_KINDS, type Guard, type GuardContext, LOGICAL_OPS, type LogicalOpSpec, type LowerValueOptions, type MissingProperty, type OpResult, type Profile, type Scope, type Severity, type TypeOverlay, UNARY_OPS, type UnaryOpSpec, type UnusedOptions, anchorDiagnostics, annotate, annotateReturn, asExpression, binaryOpsProducing, calleeAllowlist, capabilityNodes, check, childScope, collectBindings, collectMutations, collectUnused, componentProps, componentPropsOf, contextualTypeAt, createAnchors, createEnv, createSink, diag, diagnosticsAt, extractModuleType, fromCapability, guard, guardsFromCompiled, lookup, lowerValue, makeDiagnostic, maxArgs, maxCallNesting, maxDepth, maxFunctionNesting, maxNestingOf, maxNodes, memberCompletions, memberDepth, opResultSchema, resolveNamed, resolveScheme, resultType, rootScope, scopeAt, scopeCompletions, spanOf, typeAt, unaryOpsProducing, visibleNames };
|
|
725
|
+
export { type AnchorDiagnosticsOptions, type AnchoredDiagnostic, type Anchors, BINARY_OP, BINARY_OPS, type BinaryOpCategory, type BinaryOpSpec, type BindingMap, type CheckOptions, type CheckResult, type CheckerErrorCode, Completion, type Diagnostic, type DiagnosticCode, type DiagnosticData, type DiagnosticKind, type DiagnosticSink, type Env, type EnvOptions, FUNCTION_KINDS, type Guard, type GuardContext, LOGICAL_OPS, type LogicalOpSpec, type LowerValueOptions, type MissingProperty, ObjectSchema, type OpResult, type Profile, Schema, Schemes, type Scope, type Severity, type TypeOverlay, TypeScheme, UNARY_OPS, type UnaryOpSpec, type UnusedOptions, anchorDiagnostics, annotate, annotateReturn, asExpression, binaryOpsProducing, calleeAllowlist, capabilityNodes, check, childScope, collectBindings, collectMutations, collectUnused, componentProps, componentPropsOf, contextualTypeAt, createAnchors, createEnv, createSink, diag, diagnosticsAt, extractModuleType, fromCapability, guard, guardsFromCompiled, lookup, lowerValue, makeDiagnostic, maxArgs, maxCallNesting, maxDepth, maxFunctionNesting, maxNestingOf, maxNodes, memberCompletions, memberDepth, opResultSchema, resolveNamed, resolveScheme, resultType, rootScope, scopeAt, scopeCompletions, spanOf, typeAt, unaryOpsProducing, visibleNames };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Schema, Schemes, TypeScheme, ObjectSchema, Completion } from '
|
|
2
|
-
export
|
|
3
|
-
import { Scope as Scope$1, BaseNode, Node, types, Expression, SourceLocation } from '@tslite/
|
|
1
|
+
import { Schema, Schemes, TypeScheme, ObjectSchema, Completion } from './types/index.js';
|
|
2
|
+
export { AnySchema, ApplySchema, ArraySchema, Bindings, DEFAULT_TYPE_LIMITS, Discovery, ElementFlag, FnSchema, GuardSig, INSTANTIATION_COUNT_LIMIT, INSTANTIATION_DEPTH_LIMIT, Incompatibility, IncompatibilityKind, IndexSchema, Instantiation, InstantiationLimitError, KeyofSchema, LiteralSchema, MappedSchema, OverloadSchema, Param, Prop, ScalarSchema, TYPE_EVAL_DEPTH_LIMIT, TupleSchema, TypeEvalLimitError, TypeEvalLimits, TypeForm, TypePosition, UnionSchema, UnionTooComplexError, UnknownSchema, VarCandidates, VarSchema, apparentType, asLiteralOrigin, baseLiteralType, bindTypeParams, comparable, configureTypeLimits, contravariantInference, covariantInference, discover, equals, erasedSignature, expand1, flagAt, format, formatTypeArgs, formatTypeDiff, freeVars, groundVars, inferFromCandidates, inferredTypes, instantiate, instantiateInContextOf, instantiateLoose, isMissingType, isNumericLiteralName, isObjectOrArrayLiteral, isScheme, isSerializable, isVariadicTuple, join, joinAll, missingType, normalizeUnion, ownProp, renameTypeParams, resetInstantiationCount, resetTypeLimits, resolveConditional, resolveOp, resolveTypeOp, restIndex, s, sampleValue, silentNever, substitute, subtype, typeAtPosition, typeDiff, typeFeatures, typeLimits, typeNeedsParens, typeParamArity, unify, widen, widenInferred, widenLiteral, widenOrigin, widenType, withoutUndefined } from './types/index.js';
|
|
3
|
+
import { Scope as Scope$1, BaseNode, Node, types, Expression, SourceLocation } from '@tslite/ast';
|
|
4
4
|
import { CapabilityProfile, CompiledProfile } from '@tslite/capability';
|
|
5
5
|
import { Span } from '@tslite/language-service';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Um nível de escopo léxico (nome → `Schema`), sobre o `Scope<T>` genérico do
|
|
9
|
-
* `
|
|
9
|
+
* `ast` — a mesma cadeia que o `behavior` usa, com o payload do eixo de tipos.
|
|
10
10
|
*/
|
|
11
11
|
type Scope = Scope$1<Schema>;
|
|
12
12
|
/** Cria um escopo raiz (sem pai). */
|
|
@@ -17,9 +17,11 @@ declare const childScope: (parent: Scope, vars: Record<string, Schema>) => Scope
|
|
|
17
17
|
declare const lookup: (scope: Scope, name: string) => Schema | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Todos os nomes visíveis a partir de `scope`, com shadowing — o binding mais
|
|
20
|
-
* interno vence. É o que alimenta o autocomplete de identificadores.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* interno vence. É o que alimenta o autocomplete de identificadores. Duas
|
|
21
|
+
* chaves moram no mesmo escopo e não são nomes: a que tem `.` é um caminho
|
|
22
|
+
* estreitado por guard (`narrow`, D13), e a que termina em `#` é o tipo
|
|
23
|
+
* DECLARADO de um binding mutável (D63) — nenhum identificador tem esses
|
|
24
|
+
* caracteres.
|
|
23
25
|
*/
|
|
24
26
|
declare const visibleNames: (scope: Scope) => Map<string, Schema>;
|
|
25
27
|
/**
|
|
@@ -112,7 +114,7 @@ declare const resolveNamed: (env: Env, name: string) => Schema | undefined;
|
|
|
112
114
|
declare const resolveScheme: (env: Env, name: string) => TypeScheme | undefined;
|
|
113
115
|
|
|
114
116
|
type Severity = "error" | "warning";
|
|
115
|
-
type DiagnosticCode = "not-assignable" | "unknown-name" | "not-callable" | "no-such-member" | "not-object" | "const-needs-init" | "cannot-redeclare" | "unknown-module" | "not-a-schema" | "type-as-value" | "asserter-needs-name" | "shadows-schema" | "missing-argument" | "excess-argument" | "excess-property" | "spread-argument" | "required-after-optional" | "not-iterable" | "props-mismatch" | "no-matching-overload" | "constraint-violation" | "wrong-type-argument-count" | "unsupported" | "forbidden-member" | "unused-name" | "assign-to-const" | "readonly-write" | "cast-unsound" | "unprovable-value" | "not-arithmetic-operand" | "operator-not-applicable" | "implicit-coercion" | "node-not-allowed" | "name-not-allowed" | "type-feature-not-allowed" | "any-not-allowed" | "narrowing-cast-not-allowed" | "too-deep" | "too-complex-union" | "too-large" | "wrong-result-type";
|
|
117
|
+
type DiagnosticCode = "not-assignable" | "unknown-name" | "not-callable" | "no-such-member" | "not-object" | "possibly-nullish" | "unknown-value" | "const-needs-init" | "cannot-redeclare" | "circular-type-alias" | "circular-type-annotation" | "unknown-module" | "not-a-schema" | "type-as-value" | "asserter-needs-name" | "shadows-schema" | "missing-argument" | "excess-argument" | "excess-property" | "spread-argument" | "required-after-optional" | "not-iterable" | "props-mismatch" | "no-matching-overload" | "constraint-violation" | "wrong-type-argument-count" | "unsupported" | "forbidden-member" | "unused-name" | "assign-to-const" | "readonly-write" | "cast-unsound" | "unprovable-value" | "not-arithmetic-operand" | "operator-not-applicable" | "implicit-coercion" | "node-not-allowed" | "name-not-allowed" | "type-feature-not-allowed" | "any-not-allowed" | "narrowing-cast-not-allowed" | "too-deep" | "too-complex-union" | "too-large" | "wrong-result-type";
|
|
116
118
|
/**
|
|
117
119
|
* A **classe** do diagnóstico — espelha a divisão de passes do `tsc` (que nós
|
|
118
120
|
* fundimos num walk só): `semantic` é o que o **binder** do tsc pega (validade do
|
|
@@ -187,6 +189,29 @@ declare const diag: {
|
|
|
187
189
|
notCallable: (node: BaseNode, type: Schema) => Diagnostic;
|
|
188
190
|
noSuchMember: (node: BaseNode, type: Schema, key: string) => Diagnostic;
|
|
189
191
|
notObject: (node: BaseNode, type: Schema) => Diagnostic;
|
|
192
|
+
/**
|
|
193
|
+
* Ler ou chamar através de um valor que pode ser `null`/`undefined` — o
|
|
194
|
+
* `checkNonNullTypeWithReporter` do tsc (`checker.ts:24098`), que tem uma mensagem por
|
|
195
|
+
* combinação, e a variante "Cannot invoke" quando o valor é chamado.
|
|
196
|
+
*/
|
|
197
|
+
possiblyNullish: (node: BaseNode, nullish: {
|
|
198
|
+
readonly null: boolean;
|
|
199
|
+
readonly undefined: boolean;
|
|
200
|
+
}, invoked?: boolean) => Diagnostic;
|
|
201
|
+
/**
|
|
202
|
+
* Usar um valor `unknown` como objeto — ler dele, chamá-lo, indexá-lo ou operar
|
|
203
|
+
* sobre ele. É o mesmo `checkNonNullTypeWithReporter` (`checker.ts:24102`), no ramo
|
|
204
|
+
* que vem ANTES do nullish e em três linhas:
|
|
205
|
+
*
|
|
206
|
+
* if (strictNullChecks && type.flags & TypeFlags.Unknown) {
|
|
207
|
+
* error(node, Diagnostics.Object_is_of_type_unknown);
|
|
208
|
+
* return errorType;
|
|
209
|
+
* }
|
|
210
|
+
*
|
|
211
|
+
* Um código só e uma mensagem só, para os seis usos (o TS2571 da 3.9.10 — o
|
|
212
|
+
* TS18046 é de versão posterior e não existe na tag).
|
|
213
|
+
*/
|
|
214
|
+
unknownValue: (node: BaseNode) => Diagnostic;
|
|
190
215
|
constNeedsInit: (node: BaseNode) => Diagnostic;
|
|
191
216
|
missingArgument: (node: BaseNode, name: string, expected: Schema) => Diagnostic;
|
|
192
217
|
notASchema: (node: BaseNode, name: string) => Diagnostic;
|
|
@@ -195,7 +220,21 @@ declare const diag: {
|
|
|
195
220
|
shadowsSchema: (node: BaseNode, name: string) => Diagnostic;
|
|
196
221
|
unknownModule: (node: BaseNode, source: string) => Diagnostic;
|
|
197
222
|
cannotRedeclare: (node: BaseNode, name: string) => Diagnostic;
|
|
223
|
+
circularTypeAlias: (node: BaseNode, name: string) => Diagnostic;
|
|
224
|
+
circularTypeAnnotation: (node: BaseNode, name: string) => Diagnostic;
|
|
198
225
|
excessArgument: (node: BaseNode, expected: number, got: number) => Diagnostic;
|
|
226
|
+
/**
|
|
227
|
+
* A ARIDADE de uma chamada, com o texto do `getArgumentArityError` do tsc
|
|
228
|
+
* (`checker.ts:25477`): `Expected {range} arguments, but got {got}.` (TS2554), e
|
|
229
|
+
* `Expected at least {min} arguments, but got {got}.` quando a assinatura tem rest
|
|
230
|
+
* (TS2555). O `range` é `min` ou `min-max`, e o plural é sempre plural, como lá.
|
|
231
|
+
*
|
|
232
|
+
* O CÓDIGO continua dizendo a direção — `missing-argument` quando faltam, e
|
|
233
|
+
* `excess-argument` quando sobram —, que é informação que o texto do tsc perdeu ao
|
|
234
|
+
* usar um único TS2554 para os dois. A régua é a D2: o código é o contrato, a mensagem
|
|
235
|
+
* é prosa.
|
|
236
|
+
*/
|
|
237
|
+
argumentArity: (node: BaseNode, range: string, got: number, kind: "missing" | "excess", atLeast?: boolean) => Diagnostic;
|
|
199
238
|
excessProperty: (node: BaseNode, name: string, target: Schema) => Diagnostic;
|
|
200
239
|
spreadArgument: (node: BaseNode) => Diagnostic;
|
|
201
240
|
requiredAfterOptional: (node: BaseNode) => Diagnostic;
|
|
@@ -207,10 +246,12 @@ declare const diag: {
|
|
|
207
246
|
/**
|
|
208
247
|
* Argumento de tipo explícito com aridade errada. Assinatura **sem** type params
|
|
209
248
|
* declarados conta como `expected: 0` — é o que o tsc faz quando
|
|
210
|
-
* `Signature.typeParameters` é `undefined` (ele nunca infere a lista).
|
|
211
|
-
* texto do TS2558.
|
|
249
|
+
* `Signature.typeParameters` é `undefined` (ele nunca infere a lista). Com default, o
|
|
250
|
+
* esperado é a faixa (`"1-2"`). Mensagem no texto do TS2558, que é sempre plural.
|
|
212
251
|
*/
|
|
213
|
-
wrongTypeArgumentCount: (node: BaseNode, expected: number, got: number) => Diagnostic;
|
|
252
|
+
wrongTypeArgumentCount: (node: BaseNode, expected: number | string, got: number) => Diagnostic;
|
|
253
|
+
/** Nenhuma sobrecarga aceita a aridade, e há uma abaixo e outra acima (≅ TS2743). */
|
|
254
|
+
noOverloadTypeArgumentCount: (node: BaseNode, got: number, below: number, above: number) => Diagnostic;
|
|
214
255
|
/** Referência a um alias com aridade errada — as frases do tsc: TS2315 para um
|
|
215
256
|
* tipo que não é genérico, TS2314 para o resto (com o intervalo quando há default). */
|
|
216
257
|
genericTypeArity: (node: BaseNode, name: string, min: number, max: number) => Diagnostic;
|
|
@@ -353,7 +394,7 @@ interface CheckOptions {
|
|
|
353
394
|
* Sem ele, `check` faz **só type-checking** (sem opinar sobre capability).
|
|
354
395
|
*
|
|
355
396
|
* Capability **desinstala** features (o que pode existir em runtime — junto do
|
|
356
|
-
* interpret/
|
|
397
|
+
* interpret/codegen); é ortogonal aos `limits`/`resultType` abaixo, que **validam**.
|
|
357
398
|
*/
|
|
358
399
|
readonly profile?: CapabilityProfile;
|
|
359
400
|
/**
|
|
@@ -442,7 +483,7 @@ declare const FUNCTION_KINDS: readonly ["ArrowFunctionExpression", "FunctionExpr
|
|
|
442
483
|
/**
|
|
443
484
|
* O guard de **capability**: percorre `root` e reporta `node-not-allowed` em todo
|
|
444
485
|
* nó proibido por `compiled` — via `nodeViolation`, a **fonte única** de gating
|
|
445
|
-
* compartilhada com o interpret e o
|
|
486
|
+
* compartilhada com o interpret e o codegen. É o que `fromCapability` monta (+ o
|
|
446
487
|
* host allowlist). Garante que os 3 consumidores concordam por construção.
|
|
447
488
|
*/
|
|
448
489
|
declare function capabilityNodes(compiled: CompiledProfile, severity?: Severity): Guard;
|
|
@@ -681,4 +722,4 @@ declare function anchorDiagnostics<A>(root: object, diagnostics: readonly Diagno
|
|
|
681
722
|
*/
|
|
682
723
|
declare function spanOf(text: string, loc: SourceLocation | null | undefined): Span | undefined;
|
|
683
724
|
|
|
684
|
-
export { type AnchorDiagnosticsOptions, type AnchoredDiagnostic, type Anchors, BINARY_OP, BINARY_OPS, type BinaryOpCategory, type BinaryOpSpec, type BindingMap, type CheckOptions, type CheckResult, type CheckerErrorCode, type Diagnostic, type DiagnosticCode, type DiagnosticData, type DiagnosticKind, type DiagnosticSink, type Env, type EnvOptions, FUNCTION_KINDS, type Guard, type GuardContext, LOGICAL_OPS, type LogicalOpSpec, type LowerValueOptions, type MissingProperty, type OpResult, type Profile, type Scope, type Severity, type TypeOverlay, UNARY_OPS, type UnaryOpSpec, type UnusedOptions, anchorDiagnostics, annotate, annotateReturn, asExpression, binaryOpsProducing, calleeAllowlist, capabilityNodes, check, childScope, collectBindings, collectMutations, collectUnused, componentProps, componentPropsOf, contextualTypeAt, createAnchors, createEnv, createSink, diag, diagnosticsAt, extractModuleType, fromCapability, guard, guardsFromCompiled, lookup, lowerValue, makeDiagnostic, maxArgs, maxCallNesting, maxDepth, maxFunctionNesting, maxNestingOf, maxNodes, memberCompletions, memberDepth, opResultSchema, resolveNamed, resolveScheme, resultType, rootScope, scopeAt, scopeCompletions, spanOf, typeAt, unaryOpsProducing, visibleNames };
|
|
725
|
+
export { type AnchorDiagnosticsOptions, type AnchoredDiagnostic, type Anchors, BINARY_OP, BINARY_OPS, type BinaryOpCategory, type BinaryOpSpec, type BindingMap, type CheckOptions, type CheckResult, type CheckerErrorCode, Completion, type Diagnostic, type DiagnosticCode, type DiagnosticData, type DiagnosticKind, type DiagnosticSink, type Env, type EnvOptions, FUNCTION_KINDS, type Guard, type GuardContext, LOGICAL_OPS, type LogicalOpSpec, type LowerValueOptions, type MissingProperty, ObjectSchema, type OpResult, type Profile, Schema, Schemes, type Scope, type Severity, type TypeOverlay, TypeScheme, UNARY_OPS, type UnaryOpSpec, type UnusedOptions, anchorDiagnostics, annotate, annotateReturn, asExpression, binaryOpsProducing, calleeAllowlist, capabilityNodes, check, childScope, collectBindings, collectMutations, collectUnused, componentProps, componentPropsOf, contextualTypeAt, createAnchors, createEnv, createSink, diag, diagnosticsAt, extractModuleType, fromCapability, guard, guardsFromCompiled, lookup, lowerValue, makeDiagnostic, maxArgs, maxCallNesting, maxDepth, maxFunctionNesting, maxNestingOf, maxNodes, memberCompletions, memberDepth, opResultSchema, resolveNamed, resolveScheme, resultType, rootScope, scopeAt, scopeCompletions, spanOf, typeAt, unaryOpsProducing, visibleNames };
|