@tslite/checker 1.1.0 → 1.2.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.cjs +1 -1
- package/dist/index.d.cts +63 -2
- package/dist/index.d.ts +63 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema, Schemes, TypeScheme, ObjectSchema, Completion } from './types/index.cjs';
|
|
2
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,
|
|
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
|
|
|
@@ -600,6 +600,67 @@ type BindingMap = WeakMap<BaseNode, BaseNode>;
|
|
|
600
600
|
*/
|
|
601
601
|
declare function collectBindings(root: BaseNode): BindingMap;
|
|
602
602
|
|
|
603
|
+
/** O que um nome denota. */
|
|
604
|
+
type ReferenceSymbol = {
|
|
605
|
+
readonly kind: "local";
|
|
606
|
+
/** O `Identifier` que declara — a identidade, por referência. */
|
|
607
|
+
readonly declaration: BaseNode;
|
|
608
|
+
} | {
|
|
609
|
+
readonly kind: "environment";
|
|
610
|
+
/** O caminho a partir da raiz da DI: `["params"]`, `["params", "id"]`. */
|
|
611
|
+
readonly path: readonly string[];
|
|
612
|
+
};
|
|
613
|
+
/**
|
|
614
|
+
* Onde o nome aparece como SHORTHAND, e portanto nomeia duas coisas ao mesmo tempo
|
|
615
|
+
* — o `prefixText`/`suffixText` do `findRenameLocations` do TypeScript:
|
|
616
|
+
*
|
|
617
|
+
* - `"property"`: o nome é o valor e também a PROPRIEDADE (`{ x }`, ou `const { x
|
|
618
|
+
* } = o` renomeando o `x` local). A propriedade continua com o nome antigo:
|
|
619
|
+
* `{ x: x2 }`;
|
|
620
|
+
* - `"binding"`: o nome é a propriedade e também um BINDING (`const { id } =
|
|
621
|
+
* params`, renomeando o `params.id`). O binding continua com o nome antigo:
|
|
622
|
+
* `{ id2: id }`;
|
|
623
|
+
* - `"import"`: o nome importado é também o local (`import { a } from "m"`,
|
|
624
|
+
* renomeando o local): `import { a as a2 }`.
|
|
625
|
+
*/
|
|
626
|
+
type Shorthand = "property" | "binding" | "import";
|
|
627
|
+
/** Uma referência a tipo nomeado escrita numa anotação (a `typeRefs` do parser). */
|
|
628
|
+
interface TypeRefSite {
|
|
629
|
+
readonly name: string;
|
|
630
|
+
readonly loc: SourceLocation;
|
|
631
|
+
}
|
|
632
|
+
/** Um lugar onde o nome aparece. */
|
|
633
|
+
type Occurrence = {
|
|
634
|
+
/** O nó cujo texto É o nome: `Identifier`, `JSXIdentifier` ou a chave literal. */
|
|
635
|
+
readonly site: "node";
|
|
636
|
+
readonly node: BaseNode;
|
|
637
|
+
readonly symbol: ReferenceSymbol;
|
|
638
|
+
/** A declaração do símbolo, e não um uso. */
|
|
639
|
+
readonly isDeclaration?: true;
|
|
640
|
+
readonly shorthand?: Shorthand;
|
|
641
|
+
} | {
|
|
642
|
+
/** Um segmento do `typeof a.b` numa anotação: o nó não tem posição por segmento. */
|
|
643
|
+
readonly site: "typeQuery";
|
|
644
|
+
readonly node: BaseNode;
|
|
645
|
+
readonly segment: number;
|
|
646
|
+
readonly symbol: ReferenceSymbol;
|
|
647
|
+
} | {
|
|
648
|
+
/** Um nome de tipo numa anotação, que não é nó (E6 do editor). */
|
|
649
|
+
readonly site: "typeRef";
|
|
650
|
+
readonly ref: TypeRefSite;
|
|
651
|
+
readonly symbol: ReferenceSymbol;
|
|
652
|
+
};
|
|
653
|
+
/** Os dois símbolos são o mesmo? */
|
|
654
|
+
declare function sameSymbol(a: ReferenceSymbol, b: ReferenceSymbol): boolean;
|
|
655
|
+
/**
|
|
656
|
+
* Todas as ocorrências de nome do programa, cada uma com o símbolo que denota.
|
|
657
|
+
*
|
|
658
|
+
* Quem renomeia escolhe o símbolo sob o cursor (`occurrenceAt` do editor) e pega as
|
|
659
|
+
* ocorrências com `sameSymbol`; quem renomeia um caminho do ambiente sem cursor (o
|
|
660
|
+
* host que renomeou a declaração no `Env`) filtra pelo caminho direto.
|
|
661
|
+
*/
|
|
662
|
+
declare function collectReferences(root: BaseNode): readonly Occurrence[];
|
|
663
|
+
|
|
603
664
|
/** Anota uma ligação/parâmetro: `x` → `x: T`. */
|
|
604
665
|
declare const annotate: <N extends BaseNode>(node: N, type: Schema) => N & {
|
|
605
666
|
typeAnnotation: Schema;
|
|
@@ -722,4 +783,4 @@ declare function anchorDiagnostics<A>(root: object, diagnostics: readonly Diagno
|
|
|
722
783
|
*/
|
|
723
784
|
declare function spanOf(text: string, loc: SourceLocation | null | undefined): Span | undefined;
|
|
724
785
|
|
|
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 };
|
|
786
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema, Schemes, TypeScheme, ObjectSchema, Completion } from './types/index.js';
|
|
2
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,
|
|
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
|
|
|
@@ -600,6 +600,67 @@ type BindingMap = WeakMap<BaseNode, BaseNode>;
|
|
|
600
600
|
*/
|
|
601
601
|
declare function collectBindings(root: BaseNode): BindingMap;
|
|
602
602
|
|
|
603
|
+
/** O que um nome denota. */
|
|
604
|
+
type ReferenceSymbol = {
|
|
605
|
+
readonly kind: "local";
|
|
606
|
+
/** O `Identifier` que declara — a identidade, por referência. */
|
|
607
|
+
readonly declaration: BaseNode;
|
|
608
|
+
} | {
|
|
609
|
+
readonly kind: "environment";
|
|
610
|
+
/** O caminho a partir da raiz da DI: `["params"]`, `["params", "id"]`. */
|
|
611
|
+
readonly path: readonly string[];
|
|
612
|
+
};
|
|
613
|
+
/**
|
|
614
|
+
* Onde o nome aparece como SHORTHAND, e portanto nomeia duas coisas ao mesmo tempo
|
|
615
|
+
* — o `prefixText`/`suffixText` do `findRenameLocations` do TypeScript:
|
|
616
|
+
*
|
|
617
|
+
* - `"property"`: o nome é o valor e também a PROPRIEDADE (`{ x }`, ou `const { x
|
|
618
|
+
* } = o` renomeando o `x` local). A propriedade continua com o nome antigo:
|
|
619
|
+
* `{ x: x2 }`;
|
|
620
|
+
* - `"binding"`: o nome é a propriedade e também um BINDING (`const { id } =
|
|
621
|
+
* params`, renomeando o `params.id`). O binding continua com o nome antigo:
|
|
622
|
+
* `{ id2: id }`;
|
|
623
|
+
* - `"import"`: o nome importado é também o local (`import { a } from "m"`,
|
|
624
|
+
* renomeando o local): `import { a as a2 }`.
|
|
625
|
+
*/
|
|
626
|
+
type Shorthand = "property" | "binding" | "import";
|
|
627
|
+
/** Uma referência a tipo nomeado escrita numa anotação (a `typeRefs` do parser). */
|
|
628
|
+
interface TypeRefSite {
|
|
629
|
+
readonly name: string;
|
|
630
|
+
readonly loc: SourceLocation;
|
|
631
|
+
}
|
|
632
|
+
/** Um lugar onde o nome aparece. */
|
|
633
|
+
type Occurrence = {
|
|
634
|
+
/** O nó cujo texto É o nome: `Identifier`, `JSXIdentifier` ou a chave literal. */
|
|
635
|
+
readonly site: "node";
|
|
636
|
+
readonly node: BaseNode;
|
|
637
|
+
readonly symbol: ReferenceSymbol;
|
|
638
|
+
/** A declaração do símbolo, e não um uso. */
|
|
639
|
+
readonly isDeclaration?: true;
|
|
640
|
+
readonly shorthand?: Shorthand;
|
|
641
|
+
} | {
|
|
642
|
+
/** Um segmento do `typeof a.b` numa anotação: o nó não tem posição por segmento. */
|
|
643
|
+
readonly site: "typeQuery";
|
|
644
|
+
readonly node: BaseNode;
|
|
645
|
+
readonly segment: number;
|
|
646
|
+
readonly symbol: ReferenceSymbol;
|
|
647
|
+
} | {
|
|
648
|
+
/** Um nome de tipo numa anotação, que não é nó (E6 do editor). */
|
|
649
|
+
readonly site: "typeRef";
|
|
650
|
+
readonly ref: TypeRefSite;
|
|
651
|
+
readonly symbol: ReferenceSymbol;
|
|
652
|
+
};
|
|
653
|
+
/** Os dois símbolos são o mesmo? */
|
|
654
|
+
declare function sameSymbol(a: ReferenceSymbol, b: ReferenceSymbol): boolean;
|
|
655
|
+
/**
|
|
656
|
+
* Todas as ocorrências de nome do programa, cada uma com o símbolo que denota.
|
|
657
|
+
*
|
|
658
|
+
* Quem renomeia escolhe o símbolo sob o cursor (`occurrenceAt` do editor) e pega as
|
|
659
|
+
* ocorrências com `sameSymbol`; quem renomeia um caminho do ambiente sem cursor (o
|
|
660
|
+
* host que renomeou a declaração no `Env`) filtra pelo caminho direto.
|
|
661
|
+
*/
|
|
662
|
+
declare function collectReferences(root: BaseNode): readonly Occurrence[];
|
|
663
|
+
|
|
603
664
|
/** Anota uma ligação/parâmetro: `x` → `x: T`. */
|
|
604
665
|
declare const annotate: <N extends BaseNode>(node: N, type: Schema) => N & {
|
|
605
666
|
typeAnnotation: Schema;
|
|
@@ -722,4 +783,4 @@ declare function anchorDiagnostics<A>(root: object, diagnostics: readonly Diagno
|
|
|
722
783
|
*/
|
|
723
784
|
declare function spanOf(text: string, loc: SourceLocation | null | undefined): Span | undefined;
|
|
724
785
|
|
|
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 };
|
|
786
|
+
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 };
|