@tslite/checker 1.4.0 → 1.5.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-FY7J7P5X.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +104 -10
- package/dist/index.d.ts +104 -10
- package/dist/index.js +1 -1
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.d.cts +111 -7
- package/dist/types/index.d.ts +111 -7
- package/dist/types/index.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-DFZOAHNG.js +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
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,
|
|
1
|
+
import { VarSchema, 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, PathSegment, Prop, ScalarSchema, TYPE_EVAL_DEPTH_LIMIT, TupleSchema, TypeEvalLimitError, TypeEvalLimits, TypeForm, TypePosition, UnionSchema, UnionTooComplexError, UnknownSchema, VarCandidates, WriteKey, 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, readonlyMember, renameTypeParams, resetInstantiationCount, resetTypeLimits, resolveConditional, resolveOp, resolveTypeOp, restIndex, restTypeAtPosition, s, sampleValue, silentNever, substitute, subtype, typeAtPosition, typeDiff, typeFeatures, typeLimits, typeNeedsParens, typeParamArity, unify, widen, widenInferred, widenLiteral, widenOrigin, widenType, withUndefined, withoutUndefined } from './types/index.cjs';
|
|
3
3
|
import { Scope as Scope$1, BaseNode, Node, types, SourceLocation, Expression } from '@tslite/ast';
|
|
4
4
|
import { CapabilityProfile, CompiledProfile } from '@tslite/capability';
|
|
5
5
|
import { Span } from '@tslite/language-service';
|
|
6
6
|
|
|
7
|
+
/** As declarações de tipo nominal: o nome e os type params, em ordem. */
|
|
8
|
+
type Nominals = Readonly<Record<string, readonly VarSchema[]>>;
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* Um nível de escopo léxico (nome → `Schema`), sobre o `Scope<T>` genérico do
|
|
9
12
|
* `ast` — a mesma cadeia que o `behavior` usa, com o payload do eixo de tipos.
|
|
@@ -73,6 +76,21 @@ interface Env {
|
|
|
73
76
|
* especificador) é da app (Proposal 005). Default: nenhum.
|
|
74
77
|
*/
|
|
75
78
|
readonly modules?: Readonly<Record<string, Schema>>;
|
|
79
|
+
/**
|
|
80
|
+
* Os aliases da **lib padrão** (`Partial`, `Pick`, `Record`, `Omit`, `ReturnType`…),
|
|
81
|
+
* o texto do `lib.es5.d.ts` do tsc 3.9.10 com o corte do TSLite (D79). Ficam ABAIXO
|
|
82
|
+
* de tudo: um tipo do host ou um alias do programa com o mesmo nome os sombreia.
|
|
83
|
+
* Vazio com `noLib`.
|
|
84
|
+
*/
|
|
85
|
+
readonly lib?: Schemes;
|
|
86
|
+
/**
|
|
87
|
+
* Os tipos **nominais** que um texto de tipo pode citar pelo nome: o nome e os type
|
|
88
|
+
* params de cada um. São os `interface` da lib (`Array`, `ReadonlyArray`, `Promise`)
|
|
89
|
+
* e os que o host declara (`Map`, `Element`…). Um nominal é o `apply` opaco (types
|
|
90
|
+
* TC2): o texto `Promise<User>` e o construtor `s.apply("Promise", [User])` são o
|
|
91
|
+
* mesmo tipo, e a aridade é cobrada como a de um alias.
|
|
92
|
+
*/
|
|
93
|
+
readonly nominals?: Nominals;
|
|
76
94
|
}
|
|
77
95
|
/**
|
|
78
96
|
* O que um `Env` tem além das variáveis. Cada campo espelha o de {@link Env}, e
|
|
@@ -85,6 +103,13 @@ interface EnvOptions {
|
|
|
85
103
|
readonly asserters?: ReadonlySet<string>;
|
|
86
104
|
readonly matchers?: ReadonlySet<string>;
|
|
87
105
|
readonly modules?: Readonly<Record<string, Schema>>;
|
|
106
|
+
/** Os nominais do host, somados aos da lib (ver {@link Env.nominals}). */
|
|
107
|
+
readonly nominals?: Nominals;
|
|
108
|
+
/**
|
|
109
|
+
* Sem a lib padrão — nem os aliases, nem os nominais dela. É o `--noLib` do tsc: os
|
|
110
|
+
* nomes da lib passam a ser `unknown-name`, como lá.
|
|
111
|
+
*/
|
|
112
|
+
readonly noLib?: boolean;
|
|
88
113
|
}
|
|
89
114
|
/**
|
|
90
115
|
* Um catálogo (`Record<string, Schema>`) passado no lugar das opções é o erro que a
|
|
@@ -114,7 +139,7 @@ declare const resolveNamed: (env: Env, name: string) => Schema | undefined;
|
|
|
114
139
|
declare const resolveScheme: (env: Env, name: string) => TypeScheme | undefined;
|
|
115
140
|
|
|
116
141
|
type Severity = "error" | "warning";
|
|
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" | "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";
|
|
142
|
+
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" | "not-spreadable" | "implicit-any" | "props-mismatch" | "no-matching-overload" | "constraint-violation" | "wrong-type-argument-count" | "unsupported" | "unused-name" | "assign-to-const" | "for-in-destructuring" | "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";
|
|
118
143
|
/**
|
|
119
144
|
* A **classe** do diagnóstico — espelha a divisão de passes do `tsc` (que nós
|
|
120
145
|
* fundimos num walk só): `semantic` é o que o **binder** do tsc pega (validade do
|
|
@@ -239,9 +264,46 @@ declare const diag: {
|
|
|
239
264
|
spreadArgument: (node: BaseNode) => Diagnostic;
|
|
240
265
|
requiredAfterOptional: (node: BaseNode) => Diagnostic;
|
|
241
266
|
notIterable: (node: BaseNode, type: Schema) => Diagnostic;
|
|
267
|
+
/**
|
|
268
|
+
* O rest de um padrão de objeto (`{ a, ...rest }`) sobre uma fonte que não é objeto — o
|
|
269
|
+
* TS2700 do tsc, no elemento do rest (`getTypeForBindingElement`, `checker.ts:7439`: o
|
|
270
|
+
* `isValidSpreadType` da fonte). O código é o do conceito — a fonte não se espalha —, par do
|
|
271
|
+
* `not-iterable` do padrão de array.
|
|
272
|
+
*/
|
|
273
|
+
notSpreadable: (node: BaseNode) => Diagnostic;
|
|
274
|
+
/**
|
|
275
|
+
* O `any` que ninguém escreveu — o `noImplicitAny` do tsc 3.9.10, que faz parte do
|
|
276
|
+
* `--strict` e está sempre ligado aqui (D81). Um código só, com o texto de cada caso (o
|
|
277
|
+
* `reportImplicitAny`, `checker.ts:18198`, e os sítios do acesso e do `let` evolving): o
|
|
278
|
+
* código é o conceito, a mensagem diz qual é o caso (D2), como o `possibly-nullish`.
|
|
279
|
+
*/
|
|
280
|
+
implicitAny: {
|
|
281
|
+
/** TS7006, no nome do parâmetro sem anotação e sem contexto. */
|
|
282
|
+
parameter: (node: BaseNode, name: string) => Diagnostic;
|
|
283
|
+
/** TS7019, no nome do rest sem anotação e sem contexto. */
|
|
284
|
+
rest: (node: BaseNode, name: string) => Diagnostic;
|
|
285
|
+
/** TS7031, em cada folha de um parâmetro-padrão sem anotação nem contexto. */
|
|
286
|
+
bindingElement: (node: BaseNode, name: string) => Diagnostic;
|
|
287
|
+
/** TS7034, no nome do `let` evolving que uma closure lê. */
|
|
288
|
+
evolving: (node: BaseNode, name: string) => Diagnostic;
|
|
289
|
+
/** TS7005, na leitura desse `let` dentro da closure. */
|
|
290
|
+
variable: (node: BaseNode, name: string) => Diagnostic;
|
|
291
|
+
/** TS7053, no acesso inteiro: a chave não indexa o objeto. */
|
|
292
|
+
index: (node: BaseNode, key: Schema, target: Schema) => Diagnostic;
|
|
293
|
+
/** TS7015, na chave: o objeto só tem índice numérico, e a chave não é número. */
|
|
294
|
+
indexNotNumber: (node: BaseNode) => Diagnostic;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* A posição de um padrão de array além do comprimento de uma tupla — o TS2493 do tsc, no
|
|
298
|
+
* nome (`getPropertyTypeForIndexType`, `checker.ts:12886`). O código é o `no-such-member`,
|
|
299
|
+
* o mesmo do acesso `t[5]` (TC43): a posição é uma propriedade que a tupla não tem.
|
|
300
|
+
*/
|
|
301
|
+
tupleIndexOutOfRange: (node: BaseNode, tuple: Schema, length: number, index: number) => Diagnostic;
|
|
242
302
|
propsMismatch: (node: BaseNode, props: Schema, detail: string) => Diagnostic;
|
|
243
303
|
noMatchingOverload: (node: BaseNode, type: Schema, argTypes: readonly Schema[]) => Diagnostic;
|
|
244
|
-
|
|
304
|
+
/** O argumento de tipo fora do bound — o texto do TS2344 da tag, com a constraint no
|
|
305
|
+
* lugar do `{1}`. */
|
|
306
|
+
constraintViolation: (node: BaseNode, actual: Schema, bound: Schema) => Diagnostic;
|
|
245
307
|
unsupported: (node: BaseNode, what: string) => Diagnostic;
|
|
246
308
|
/**
|
|
247
309
|
* Argumento de tipo explícito com aridade errada. Assinatura **sem** type params
|
|
@@ -269,11 +331,25 @@ declare const diag: {
|
|
|
269
331
|
*/
|
|
270
332
|
assignToConst: (node: BaseNode, name: string, kind: "const" | "import") => Diagnostic;
|
|
271
333
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
334
|
+
* As chaves de um `for…in` não cabem no alvo dele (`let n: number; for (n in o)`). É a
|
|
335
|
+
* relação que falha — o tipo das chaves contra o tipo declarado do alvo —, e por isso
|
|
336
|
+
* o código é o `not-assignable`; o texto é o do TS2405 (`checkForInStatement`).
|
|
337
|
+
*/
|
|
338
|
+
forInTarget: (node: BaseNode) => Diagnostic;
|
|
339
|
+
/** `for ([a] in o)` — o alvo de um `for…in` é uma chave, não se desestrutura. TS2491. */
|
|
340
|
+
forInDestructuring: (node: BaseNode) => Diagnostic;
|
|
341
|
+
/**
|
|
342
|
+
* Escrita por um ÍNDICE readonly — `readonly T[]` ou `{ readonly [k: string]: V }`. É
|
|
343
|
+
* a outra metade do modificador: a relação (TC29) diz quem pode ser ATRIBUÍDO a quem;
|
|
344
|
+
* isto diz quem pode ser ESCRITO. Texto do TS2542, no acesso inteiro. Os três casos de
|
|
345
|
+
* escrita recusada pelo `readonly` têm um código só (D77): o nó e o texto são os do tsc.
|
|
275
346
|
*/
|
|
276
347
|
readonlyWrite: (node: BaseNode, target: Schema) => Diagnostic;
|
|
348
|
+
/** Escrita numa PROPRIEDADE readonly — o TS2540, no nome (`o.a`) ou no argumento
|
|
349
|
+
* (`o["a"]`). O acesso vira o tipo-erro: a atribuição não é checada depois. D77. */
|
|
350
|
+
readonlyProperty: (node: BaseNode, name: string) => Diagnostic;
|
|
351
|
+
/** `delete` de uma PROPRIEDADE readonly — o TS2704, no operando. D77. */
|
|
352
|
+
readonlyDelete: (node: BaseNode) => Diagnostic;
|
|
277
353
|
/**
|
|
278
354
|
* Cast (`x as T`) entre tipos que não se sobrepõem na régua do tsc (`castOverlaps`:
|
|
279
355
|
* literal da origem alargado + comparabilidade). Erro, como o TS2352 — o texto é o
|
|
@@ -320,10 +396,21 @@ declare const diag: {
|
|
|
320
396
|
*/
|
|
321
397
|
notTextConvertible: (node: BaseNode, t: Schema) => Diagnostic;
|
|
322
398
|
};
|
|
323
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* Coletor de diagnósticos — acumula durante o walk, sem `throw`.
|
|
401
|
+
*
|
|
402
|
+
* Guarda cada diagnóstico UMA vez: um segundo com o mesmo nó, o mesmo código e a mesma
|
|
403
|
+
* mensagem não entra. É a coleção do tsc (`createDiagnosticCollection`, que insere pelo
|
|
404
|
+
* `insertSorted` e não repete o que o `compareDiagnostics` acha igual), e é o que deixa
|
|
405
|
+
* um argumento ser tipado mais de uma vez — as rodadas da chamada (D53, D81) — sem que o
|
|
406
|
+
* erro de dentro dele saia duas vezes.
|
|
407
|
+
*/
|
|
324
408
|
interface DiagnosticSink {
|
|
325
|
-
/** Diagnósticos coletados, na ordem em que foram reportados. */
|
|
409
|
+
/** Diagnósticos coletados, na ordem em que foram reportados, sem repetição. */
|
|
326
410
|
readonly all: readonly Diagnostic[];
|
|
411
|
+
/** Quantas vezes o `report` foi chamado, as repetições inclusive: é o que responde "esta
|
|
412
|
+
* operação acusou algo?", mesmo quando o que ela acusou já tinha sido acusado. */
|
|
413
|
+
readonly reported: number;
|
|
327
414
|
report(d: Diagnostic): void;
|
|
328
415
|
/** `true` se há ao menos um diagnóstico de severidade `error`. */
|
|
329
416
|
hasErrors(): boolean;
|
|
@@ -380,6 +467,13 @@ interface CheckResult {
|
|
|
380
467
|
* paralelas divergem.
|
|
381
468
|
*/
|
|
382
469
|
readonly schemes: Schemes;
|
|
470
|
+
/**
|
|
471
|
+
* Os tipos NOMINAIS que um texto de tipo pode citar (`Promise`, `Array`, e os do
|
|
472
|
+
* host), com os type params de cada um — os que nenhum scheme sombreia. Publicado
|
|
473
|
+
* pela mesma razão dos `schemes`: é a outra metade do catálogo de nomes de tipo
|
|
474
|
+
* (D79).
|
|
475
|
+
*/
|
|
476
|
+
readonly nominals: Nominals;
|
|
383
477
|
}
|
|
384
478
|
/**
|
|
385
479
|
* Tipa `node` no ambiente `env` (a borda da DI: data, states, funções globais).
|
|
@@ -782,4 +876,4 @@ declare function anchorDiagnostics<A>(root: object, diagnostics: readonly Diagno
|
|
|
782
876
|
*/
|
|
783
877
|
declare function spanOf(text: string, loc: SourceLocation | null | undefined): Span | undefined;
|
|
784
878
|
|
|
785
|
-
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 Occurrence, type OpResult, type Profile, type ReferenceSymbol, Schema, Schemes, type Scope, type Severity, type Shorthand, type TypeOverlay, type TypeRefSite, TypeScheme, UNARY_OPS, type UnaryOpSpec, type UnusedOptions, anchorDiagnostics, annotate, annotateReturn, asExpression, binaryOpsProducing, calleeAllowlist, capabilityNodes, check, childScope, collectBindings, collectMutations, collectReferences, 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, sameSymbol, scopeAt, scopeCompletions, spanOf, typeAt, unaryOpsProducing, visibleNames };
|
|
879
|
+
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, type Nominals, ObjectSchema, type Occurrence, type OpResult, type Profile, type ReferenceSymbol, Schema, Schemes, type Scope, type Severity, type Shorthand, type TypeOverlay, type TypeRefSite, TypeScheme, UNARY_OPS, type UnaryOpSpec, type UnusedOptions, VarSchema, anchorDiagnostics, annotate, annotateReturn, asExpression, binaryOpsProducing, calleeAllowlist, capabilityNodes, check, childScope, collectBindings, collectMutations, collectReferences, 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, sameSymbol, scopeAt, scopeCompletions, spanOf, typeAt, unaryOpsProducing, visibleNames };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
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,
|
|
1
|
+
import { VarSchema, 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, PathSegment, Prop, ScalarSchema, TYPE_EVAL_DEPTH_LIMIT, TupleSchema, TypeEvalLimitError, TypeEvalLimits, TypeForm, TypePosition, UnionSchema, UnionTooComplexError, UnknownSchema, VarCandidates, WriteKey, 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, readonlyMember, renameTypeParams, resetInstantiationCount, resetTypeLimits, resolveConditional, resolveOp, resolveTypeOp, restIndex, restTypeAtPosition, s, sampleValue, silentNever, substitute, subtype, typeAtPosition, typeDiff, typeFeatures, typeLimits, typeNeedsParens, typeParamArity, unify, widen, widenInferred, widenLiteral, widenOrigin, widenType, withUndefined, withoutUndefined } from './types/index.js';
|
|
3
3
|
import { Scope as Scope$1, BaseNode, Node, types, SourceLocation, Expression } from '@tslite/ast';
|
|
4
4
|
import { CapabilityProfile, CompiledProfile } from '@tslite/capability';
|
|
5
5
|
import { Span } from '@tslite/language-service';
|
|
6
6
|
|
|
7
|
+
/** As declarações de tipo nominal: o nome e os type params, em ordem. */
|
|
8
|
+
type Nominals = Readonly<Record<string, readonly VarSchema[]>>;
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* Um nível de escopo léxico (nome → `Schema`), sobre o `Scope<T>` genérico do
|
|
9
12
|
* `ast` — a mesma cadeia que o `behavior` usa, com o payload do eixo de tipos.
|
|
@@ -73,6 +76,21 @@ interface Env {
|
|
|
73
76
|
* especificador) é da app (Proposal 005). Default: nenhum.
|
|
74
77
|
*/
|
|
75
78
|
readonly modules?: Readonly<Record<string, Schema>>;
|
|
79
|
+
/**
|
|
80
|
+
* Os aliases da **lib padrão** (`Partial`, `Pick`, `Record`, `Omit`, `ReturnType`…),
|
|
81
|
+
* o texto do `lib.es5.d.ts` do tsc 3.9.10 com o corte do TSLite (D79). Ficam ABAIXO
|
|
82
|
+
* de tudo: um tipo do host ou um alias do programa com o mesmo nome os sombreia.
|
|
83
|
+
* Vazio com `noLib`.
|
|
84
|
+
*/
|
|
85
|
+
readonly lib?: Schemes;
|
|
86
|
+
/**
|
|
87
|
+
* Os tipos **nominais** que um texto de tipo pode citar pelo nome: o nome e os type
|
|
88
|
+
* params de cada um. São os `interface` da lib (`Array`, `ReadonlyArray`, `Promise`)
|
|
89
|
+
* e os que o host declara (`Map`, `Element`…). Um nominal é o `apply` opaco (types
|
|
90
|
+
* TC2): o texto `Promise<User>` e o construtor `s.apply("Promise", [User])` são o
|
|
91
|
+
* mesmo tipo, e a aridade é cobrada como a de um alias.
|
|
92
|
+
*/
|
|
93
|
+
readonly nominals?: Nominals;
|
|
76
94
|
}
|
|
77
95
|
/**
|
|
78
96
|
* O que um `Env` tem além das variáveis. Cada campo espelha o de {@link Env}, e
|
|
@@ -85,6 +103,13 @@ interface EnvOptions {
|
|
|
85
103
|
readonly asserters?: ReadonlySet<string>;
|
|
86
104
|
readonly matchers?: ReadonlySet<string>;
|
|
87
105
|
readonly modules?: Readonly<Record<string, Schema>>;
|
|
106
|
+
/** Os nominais do host, somados aos da lib (ver {@link Env.nominals}). */
|
|
107
|
+
readonly nominals?: Nominals;
|
|
108
|
+
/**
|
|
109
|
+
* Sem a lib padrão — nem os aliases, nem os nominais dela. É o `--noLib` do tsc: os
|
|
110
|
+
* nomes da lib passam a ser `unknown-name`, como lá.
|
|
111
|
+
*/
|
|
112
|
+
readonly noLib?: boolean;
|
|
88
113
|
}
|
|
89
114
|
/**
|
|
90
115
|
* Um catálogo (`Record<string, Schema>`) passado no lugar das opções é o erro que a
|
|
@@ -114,7 +139,7 @@ declare const resolveNamed: (env: Env, name: string) => Schema | undefined;
|
|
|
114
139
|
declare const resolveScheme: (env: Env, name: string) => TypeScheme | undefined;
|
|
115
140
|
|
|
116
141
|
type Severity = "error" | "warning";
|
|
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" | "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";
|
|
142
|
+
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" | "not-spreadable" | "implicit-any" | "props-mismatch" | "no-matching-overload" | "constraint-violation" | "wrong-type-argument-count" | "unsupported" | "unused-name" | "assign-to-const" | "for-in-destructuring" | "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";
|
|
118
143
|
/**
|
|
119
144
|
* A **classe** do diagnóstico — espelha a divisão de passes do `tsc` (que nós
|
|
120
145
|
* fundimos num walk só): `semantic` é o que o **binder** do tsc pega (validade do
|
|
@@ -239,9 +264,46 @@ declare const diag: {
|
|
|
239
264
|
spreadArgument: (node: BaseNode) => Diagnostic;
|
|
240
265
|
requiredAfterOptional: (node: BaseNode) => Diagnostic;
|
|
241
266
|
notIterable: (node: BaseNode, type: Schema) => Diagnostic;
|
|
267
|
+
/**
|
|
268
|
+
* O rest de um padrão de objeto (`{ a, ...rest }`) sobre uma fonte que não é objeto — o
|
|
269
|
+
* TS2700 do tsc, no elemento do rest (`getTypeForBindingElement`, `checker.ts:7439`: o
|
|
270
|
+
* `isValidSpreadType` da fonte). O código é o do conceito — a fonte não se espalha —, par do
|
|
271
|
+
* `not-iterable` do padrão de array.
|
|
272
|
+
*/
|
|
273
|
+
notSpreadable: (node: BaseNode) => Diagnostic;
|
|
274
|
+
/**
|
|
275
|
+
* O `any` que ninguém escreveu — o `noImplicitAny` do tsc 3.9.10, que faz parte do
|
|
276
|
+
* `--strict` e está sempre ligado aqui (D81). Um código só, com o texto de cada caso (o
|
|
277
|
+
* `reportImplicitAny`, `checker.ts:18198`, e os sítios do acesso e do `let` evolving): o
|
|
278
|
+
* código é o conceito, a mensagem diz qual é o caso (D2), como o `possibly-nullish`.
|
|
279
|
+
*/
|
|
280
|
+
implicitAny: {
|
|
281
|
+
/** TS7006, no nome do parâmetro sem anotação e sem contexto. */
|
|
282
|
+
parameter: (node: BaseNode, name: string) => Diagnostic;
|
|
283
|
+
/** TS7019, no nome do rest sem anotação e sem contexto. */
|
|
284
|
+
rest: (node: BaseNode, name: string) => Diagnostic;
|
|
285
|
+
/** TS7031, em cada folha de um parâmetro-padrão sem anotação nem contexto. */
|
|
286
|
+
bindingElement: (node: BaseNode, name: string) => Diagnostic;
|
|
287
|
+
/** TS7034, no nome do `let` evolving que uma closure lê. */
|
|
288
|
+
evolving: (node: BaseNode, name: string) => Diagnostic;
|
|
289
|
+
/** TS7005, na leitura desse `let` dentro da closure. */
|
|
290
|
+
variable: (node: BaseNode, name: string) => Diagnostic;
|
|
291
|
+
/** TS7053, no acesso inteiro: a chave não indexa o objeto. */
|
|
292
|
+
index: (node: BaseNode, key: Schema, target: Schema) => Diagnostic;
|
|
293
|
+
/** TS7015, na chave: o objeto só tem índice numérico, e a chave não é número. */
|
|
294
|
+
indexNotNumber: (node: BaseNode) => Diagnostic;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* A posição de um padrão de array além do comprimento de uma tupla — o TS2493 do tsc, no
|
|
298
|
+
* nome (`getPropertyTypeForIndexType`, `checker.ts:12886`). O código é o `no-such-member`,
|
|
299
|
+
* o mesmo do acesso `t[5]` (TC43): a posição é uma propriedade que a tupla não tem.
|
|
300
|
+
*/
|
|
301
|
+
tupleIndexOutOfRange: (node: BaseNode, tuple: Schema, length: number, index: number) => Diagnostic;
|
|
242
302
|
propsMismatch: (node: BaseNode, props: Schema, detail: string) => Diagnostic;
|
|
243
303
|
noMatchingOverload: (node: BaseNode, type: Schema, argTypes: readonly Schema[]) => Diagnostic;
|
|
244
|
-
|
|
304
|
+
/** O argumento de tipo fora do bound — o texto do TS2344 da tag, com a constraint no
|
|
305
|
+
* lugar do `{1}`. */
|
|
306
|
+
constraintViolation: (node: BaseNode, actual: Schema, bound: Schema) => Diagnostic;
|
|
245
307
|
unsupported: (node: BaseNode, what: string) => Diagnostic;
|
|
246
308
|
/**
|
|
247
309
|
* Argumento de tipo explícito com aridade errada. Assinatura **sem** type params
|
|
@@ -269,11 +331,25 @@ declare const diag: {
|
|
|
269
331
|
*/
|
|
270
332
|
assignToConst: (node: BaseNode, name: string, kind: "const" | "import") => Diagnostic;
|
|
271
333
|
/**
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
334
|
+
* As chaves de um `for…in` não cabem no alvo dele (`let n: number; for (n in o)`). É a
|
|
335
|
+
* relação que falha — o tipo das chaves contra o tipo declarado do alvo —, e por isso
|
|
336
|
+
* o código é o `not-assignable`; o texto é o do TS2405 (`checkForInStatement`).
|
|
337
|
+
*/
|
|
338
|
+
forInTarget: (node: BaseNode) => Diagnostic;
|
|
339
|
+
/** `for ([a] in o)` — o alvo de um `for…in` é uma chave, não se desestrutura. TS2491. */
|
|
340
|
+
forInDestructuring: (node: BaseNode) => Diagnostic;
|
|
341
|
+
/**
|
|
342
|
+
* Escrita por um ÍNDICE readonly — `readonly T[]` ou `{ readonly [k: string]: V }`. É
|
|
343
|
+
* a outra metade do modificador: a relação (TC29) diz quem pode ser ATRIBUÍDO a quem;
|
|
344
|
+
* isto diz quem pode ser ESCRITO. Texto do TS2542, no acesso inteiro. Os três casos de
|
|
345
|
+
* escrita recusada pelo `readonly` têm um código só (D77): o nó e o texto são os do tsc.
|
|
275
346
|
*/
|
|
276
347
|
readonlyWrite: (node: BaseNode, target: Schema) => Diagnostic;
|
|
348
|
+
/** Escrita numa PROPRIEDADE readonly — o TS2540, no nome (`o.a`) ou no argumento
|
|
349
|
+
* (`o["a"]`). O acesso vira o tipo-erro: a atribuição não é checada depois. D77. */
|
|
350
|
+
readonlyProperty: (node: BaseNode, name: string) => Diagnostic;
|
|
351
|
+
/** `delete` de uma PROPRIEDADE readonly — o TS2704, no operando. D77. */
|
|
352
|
+
readonlyDelete: (node: BaseNode) => Diagnostic;
|
|
277
353
|
/**
|
|
278
354
|
* Cast (`x as T`) entre tipos que não se sobrepõem na régua do tsc (`castOverlaps`:
|
|
279
355
|
* literal da origem alargado + comparabilidade). Erro, como o TS2352 — o texto é o
|
|
@@ -320,10 +396,21 @@ declare const diag: {
|
|
|
320
396
|
*/
|
|
321
397
|
notTextConvertible: (node: BaseNode, t: Schema) => Diagnostic;
|
|
322
398
|
};
|
|
323
|
-
/**
|
|
399
|
+
/**
|
|
400
|
+
* Coletor de diagnósticos — acumula durante o walk, sem `throw`.
|
|
401
|
+
*
|
|
402
|
+
* Guarda cada diagnóstico UMA vez: um segundo com o mesmo nó, o mesmo código e a mesma
|
|
403
|
+
* mensagem não entra. É a coleção do tsc (`createDiagnosticCollection`, que insere pelo
|
|
404
|
+
* `insertSorted` e não repete o que o `compareDiagnostics` acha igual), e é o que deixa
|
|
405
|
+
* um argumento ser tipado mais de uma vez — as rodadas da chamada (D53, D81) — sem que o
|
|
406
|
+
* erro de dentro dele saia duas vezes.
|
|
407
|
+
*/
|
|
324
408
|
interface DiagnosticSink {
|
|
325
|
-
/** Diagnósticos coletados, na ordem em que foram reportados. */
|
|
409
|
+
/** Diagnósticos coletados, na ordem em que foram reportados, sem repetição. */
|
|
326
410
|
readonly all: readonly Diagnostic[];
|
|
411
|
+
/** Quantas vezes o `report` foi chamado, as repetições inclusive: é o que responde "esta
|
|
412
|
+
* operação acusou algo?", mesmo quando o que ela acusou já tinha sido acusado. */
|
|
413
|
+
readonly reported: number;
|
|
327
414
|
report(d: Diagnostic): void;
|
|
328
415
|
/** `true` se há ao menos um diagnóstico de severidade `error`. */
|
|
329
416
|
hasErrors(): boolean;
|
|
@@ -380,6 +467,13 @@ interface CheckResult {
|
|
|
380
467
|
* paralelas divergem.
|
|
381
468
|
*/
|
|
382
469
|
readonly schemes: Schemes;
|
|
470
|
+
/**
|
|
471
|
+
* Os tipos NOMINAIS que um texto de tipo pode citar (`Promise`, `Array`, e os do
|
|
472
|
+
* host), com os type params de cada um — os que nenhum scheme sombreia. Publicado
|
|
473
|
+
* pela mesma razão dos `schemes`: é a outra metade do catálogo de nomes de tipo
|
|
474
|
+
* (D79).
|
|
475
|
+
*/
|
|
476
|
+
readonly nominals: Nominals;
|
|
383
477
|
}
|
|
384
478
|
/**
|
|
385
479
|
* Tipa `node` no ambiente `env` (a borda da DI: data, states, funções globais).
|
|
@@ -782,4 +876,4 @@ declare function anchorDiagnostics<A>(root: object, diagnostics: readonly Diagno
|
|
|
782
876
|
*/
|
|
783
877
|
declare function spanOf(text: string, loc: SourceLocation | null | undefined): Span | undefined;
|
|
784
878
|
|
|
785
|
-
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 Occurrence, type OpResult, type Profile, type ReferenceSymbol, Schema, Schemes, type Scope, type Severity, type Shorthand, type TypeOverlay, type TypeRefSite, TypeScheme, UNARY_OPS, type UnaryOpSpec, type UnusedOptions, anchorDiagnostics, annotate, annotateReturn, asExpression, binaryOpsProducing, calleeAllowlist, capabilityNodes, check, childScope, collectBindings, collectMutations, collectReferences, 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, sameSymbol, scopeAt, scopeCompletions, spanOf, typeAt, unaryOpsProducing, visibleNames };
|
|
879
|
+
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, type Nominals, ObjectSchema, type Occurrence, type OpResult, type Profile, type ReferenceSymbol, Schema, Schemes, type Scope, type Severity, type Shorthand, type TypeOverlay, type TypeRefSite, TypeScheme, UNARY_OPS, type UnaryOpSpec, type UnusedOptions, VarSchema, anchorDiagnostics, annotate, annotateReturn, asExpression, binaryOpsProducing, calleeAllowlist, capabilityNodes, check, childScope, collectBindings, collectMutations, collectReferences, 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, sameSymbol, scopeAt, scopeCompletions, spanOf, typeAt, unaryOpsProducing, visibleNames };
|