tstyche 6.0.0-beta.0 → 6.0.0-beta.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/build/tstyche.js +210 -184
- package/package.json +1 -1
package/build/tstyche.js
CHANGED
|
@@ -4472,7 +4472,7 @@ class MatchWorker {
|
|
|
4472
4472
|
function isStringOrNumberLiteralType(compiler, type) {
|
|
4473
4473
|
return !!(type.flags & compiler.TypeFlags.StringOrNumberLiteral);
|
|
4474
4474
|
}
|
|
4475
|
-
function isUnionType
|
|
4475
|
+
function isUnionType(compiler, type) {
|
|
4476
4476
|
return !!(type.flags & compiler.TypeFlags.Union);
|
|
4477
4477
|
}
|
|
4478
4478
|
function isUniqueSymbolType(compiler, type) {
|
|
@@ -4541,7 +4541,7 @@ class ToAcceptProps {
|
|
|
4541
4541
|
}
|
|
4542
4542
|
return true;
|
|
4543
4543
|
};
|
|
4544
|
-
if (sourceType != null && isUnionType
|
|
4544
|
+
if (sourceType != null && isUnionType(this.#compiler, sourceType)) {
|
|
4545
4545
|
return sourceType.types.some((sourceType) => check(sourceType, targetType));
|
|
4546
4546
|
}
|
|
4547
4547
|
return check(sourceType, targetType);
|
|
@@ -4609,7 +4609,7 @@ class ToAcceptProps {
|
|
|
4609
4609
|
}
|
|
4610
4610
|
return { diagnostics, isMatch: false };
|
|
4611
4611
|
};
|
|
4612
|
-
if (sourceType != null && isUnionType
|
|
4612
|
+
if (sourceType != null && isUnionType(this.#compiler, sourceType)) {
|
|
4613
4613
|
let accumulator = [];
|
|
4614
4614
|
const isMatch = sourceType.types.some((sourceType) => {
|
|
4615
4615
|
const text = matchWorker.assertionNode.isNot
|
|
@@ -4666,43 +4666,38 @@ class ToAcceptProps {
|
|
|
4666
4666
|
function ensureArray(input) {
|
|
4667
4667
|
return input ?? [];
|
|
4668
4668
|
}
|
|
4669
|
-
function
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
return !!(type.objectFlags & compiler.ObjectFlags.Class);
|
|
4675
|
-
}
|
|
4676
|
-
function isConditionalType(type, compiler) {
|
|
4677
|
-
return !!(type.flags & compiler.TypeFlags.Conditional);
|
|
4678
|
-
}
|
|
4679
|
-
function isFreshLiteralType(type, compiler) {
|
|
4680
|
-
return !!(type.flags & compiler.TypeFlags.Freshable) && type.freshType === type;
|
|
4681
|
-
}
|
|
4682
|
-
function isIntersectionType(type, compiler) {
|
|
4683
|
-
return !!(type.flags & compiler.TypeFlags.Intersection);
|
|
4684
|
-
}
|
|
4685
|
-
function isNoInferType(type, compiler) {
|
|
4686
|
-
return !!(type.flags & compiler.TypeFlags.Substitution &&
|
|
4687
|
-
type.constraint.flags & compiler.TypeFlags.Unknown);
|
|
4669
|
+
function getIndexSignatures(type, compiler, typeChecker) {
|
|
4670
|
+
if (type.flags & compiler.TypeFlags.Intersection) {
|
|
4671
|
+
return type.types.flatMap((type) => getIndexSignatures(type, compiler, typeChecker));
|
|
4672
|
+
}
|
|
4673
|
+
return typeChecker.getIndexInfosOfType(type);
|
|
4688
4674
|
}
|
|
4689
|
-
function
|
|
4690
|
-
|
|
4675
|
+
function getSignatures(type, kind, compiler, typeChecker) {
|
|
4676
|
+
if (type.flags & compiler.TypeFlags.Intersection) {
|
|
4677
|
+
return type.types.flatMap((type) => getSignatures(type, kind, compiler, typeChecker));
|
|
4678
|
+
}
|
|
4679
|
+
return typeChecker.getSignaturesOfType(type, kind);
|
|
4691
4680
|
}
|
|
4692
|
-
function
|
|
4693
|
-
|
|
4681
|
+
function getTypeParameterModifiers(typeParameter, compiler) {
|
|
4682
|
+
if (!typeParameter.symbol.declarations) {
|
|
4683
|
+
return compiler.ModifierFlags.None;
|
|
4684
|
+
}
|
|
4685
|
+
return (typeParameter.symbol.declarations.reduce((modifiers, declaration) => modifiers | compiler.getEffectiveModifierFlags(declaration), compiler.ModifierFlags.None) &
|
|
4686
|
+
(compiler.ModifierFlags.In | compiler.ModifierFlags.Out | compiler.ModifierFlags.Const));
|
|
4694
4687
|
}
|
|
4695
|
-
function
|
|
4696
|
-
return
|
|
4688
|
+
function getTargetSymbol(symbol, compiler) {
|
|
4689
|
+
return isCheckFlagSet(symbol, compiler.CheckFlags.Instantiated, compiler)
|
|
4690
|
+
? symbol.links.target
|
|
4691
|
+
: symbol;
|
|
4697
4692
|
}
|
|
4698
|
-
function
|
|
4699
|
-
return
|
|
4693
|
+
function isCheckFlagSet(symbol, flag, compiler) {
|
|
4694
|
+
return !!(symbol.flags & compiler.SymbolFlags.Transient && symbol.links.checkFlags & flag);
|
|
4700
4695
|
}
|
|
4701
|
-
function
|
|
4702
|
-
return !!(
|
|
4696
|
+
function isSymbolFromDefaultLibrary(symbol, program) {
|
|
4697
|
+
return !!symbol.declarations?.every((declaration) => program.isSourceFileDefaultLibrary(declaration.getSourceFile()));
|
|
4703
4698
|
}
|
|
4704
|
-
function
|
|
4705
|
-
return
|
|
4699
|
+
function length(array) {
|
|
4700
|
+
return array?.length ?? 0;
|
|
4706
4701
|
}
|
|
4707
4702
|
|
|
4708
4703
|
function getParameterFactsFromTuple(type, position, compiler) {
|
|
@@ -4712,41 +4707,30 @@ function getParameterFactsFromTuple(type, position, compiler) {
|
|
|
4712
4707
|
getType: (typeChecker) => typeChecker.getTypeArguments(type)[position],
|
|
4713
4708
|
};
|
|
4714
4709
|
}
|
|
4715
|
-
function getParameterFacts(signature,
|
|
4716
|
-
if (
|
|
4710
|
+
function getParameterFacts(signature, parameterIndex, compiler, typeChecker) {
|
|
4711
|
+
if (parameterIndex >= signature.parameters.length - 1 && compiler.hasRestParameter(signature.getDeclaration())) {
|
|
4717
4712
|
const restType = typeChecker.getTypeOfSymbol(signature.parameters.at(-1));
|
|
4718
|
-
if (
|
|
4713
|
+
if (typeChecker.isTupleType(restType)) {
|
|
4719
4714
|
const fixedLength = signature.parameters.length - 1;
|
|
4720
|
-
return getParameterFactsFromTuple(restType,
|
|
4715
|
+
return getParameterFactsFromTuple(restType, parameterIndex - fixedLength, compiler);
|
|
4721
4716
|
}
|
|
4722
4717
|
}
|
|
4723
|
-
const parameter = signature.parameters[
|
|
4724
|
-
const isRest = isRestParameter(parameter, compiler);
|
|
4718
|
+
const parameter = signature.parameters[parameterIndex];
|
|
4725
4719
|
return {
|
|
4726
4720
|
isOptional: isOptionalParameter(parameter, compiler),
|
|
4727
|
-
isRest,
|
|
4728
|
-
getType: (typeChecker) => getParameterType(
|
|
4721
|
+
isRest: isRestParameter(parameter, compiler),
|
|
4722
|
+
getType: (typeChecker) => typeChecker.getParameterType(signature, parameterIndex),
|
|
4729
4723
|
};
|
|
4730
4724
|
}
|
|
4731
|
-
function getParameterType(parameter, signature, isRest, compiler, typeChecker) {
|
|
4732
|
-
const type = typeChecker.getTypeOfSymbolAtLocation(parameter, signature.declaration);
|
|
4733
|
-
if (isRest && isObjectType(type, compiler) && isTypeReference(type, compiler)) {
|
|
4734
|
-
return typeChecker.getTypeArguments(type).at(0);
|
|
4735
|
-
}
|
|
4736
|
-
return type;
|
|
4737
|
-
}
|
|
4738
4725
|
function getParameterCount(signature, compiler, typeChecker) {
|
|
4739
|
-
if (hasRestParameter(signature
|
|
4726
|
+
if (signature.declaration != null && compiler.hasRestParameter(signature.declaration)) {
|
|
4740
4727
|
const restType = typeChecker.getTypeOfSymbol(signature.parameters.at(-1));
|
|
4741
|
-
if (
|
|
4728
|
+
if (typeChecker.isTupleType(restType)) {
|
|
4742
4729
|
return signature.parameters.length + typeChecker.getTypeArguments(restType).length - 1;
|
|
4743
4730
|
}
|
|
4744
4731
|
}
|
|
4745
4732
|
return signature.parameters.length;
|
|
4746
4733
|
}
|
|
4747
|
-
function hasRestParameter(signature, compiler) {
|
|
4748
|
-
return signature.declaration != null && compiler.hasRestParameter(signature.declaration);
|
|
4749
|
-
}
|
|
4750
4734
|
function isOptionalParameter(symbol, compiler) {
|
|
4751
4735
|
return (symbol.valueDeclaration != null &&
|
|
4752
4736
|
compiler.isParameter(symbol.valueDeclaration) &&
|
|
@@ -4758,29 +4742,18 @@ function isRestParameter(symbol, compiler) {
|
|
|
4758
4742
|
symbol.valueDeclaration.dotDotDotToken != null);
|
|
4759
4743
|
}
|
|
4760
4744
|
|
|
4761
|
-
function getTargetSymbol(symbol, compiler) {
|
|
4762
|
-
return isCheckFlagSet(symbol, compiler.CheckFlags.Instantiated, compiler)
|
|
4763
|
-
? symbol.links.target
|
|
4764
|
-
: symbol;
|
|
4765
|
-
}
|
|
4766
|
-
function isCheckFlagSet(symbol, flag, compiler) {
|
|
4767
|
-
return !!(symbol.flags & compiler.SymbolFlags.Transient && symbol.links.checkFlags & flag);
|
|
4768
|
-
}
|
|
4769
|
-
function isSymbolFromDefaultLibrary(symbol, program) {
|
|
4770
|
-
if (!symbol.declarations) {
|
|
4771
|
-
return false;
|
|
4772
|
-
}
|
|
4773
|
-
return symbol.declarations.every((declaration) => program.isSourceFileDefaultLibrary(declaration.getSourceFile()));
|
|
4774
|
-
}
|
|
4775
|
-
|
|
4776
4745
|
function getPropertyType(symbol, compiler, compilerOptions, typeChecker) {
|
|
4777
4746
|
const type = typeChecker.getTypeOfSymbol(symbol);
|
|
4778
4747
|
if (compilerOptions.exactOptionalPropertyTypes && isOptionalProperty(symbol, compiler)) {
|
|
4779
|
-
if (
|
|
4780
|
-
|
|
4781
|
-
if (type.types.length
|
|
4782
|
-
return type
|
|
4748
|
+
if (type.flags & compiler.TypeFlags.Union) {
|
|
4749
|
+
const filteredType = type.types.filter((type) => !("debugIntrinsicName" in type && type.debugIntrinsicName === "missing"));
|
|
4750
|
+
if (filteredType.length === type.types.length) {
|
|
4751
|
+
return type;
|
|
4783
4752
|
}
|
|
4753
|
+
if (filteredType.length === 1) {
|
|
4754
|
+
return filteredType.at(0);
|
|
4755
|
+
}
|
|
4756
|
+
return { ...type, types: filteredType };
|
|
4784
4757
|
}
|
|
4785
4758
|
}
|
|
4786
4759
|
return type;
|
|
@@ -4795,11 +4768,26 @@ function isReadonlyProperty(symbol, compiler) {
|
|
|
4795
4768
|
(symbol.flags & compiler.SymbolFlags.Accessor && !(symbol.flags & compiler.SymbolFlags.SetAccessor)));
|
|
4796
4769
|
}
|
|
4797
4770
|
|
|
4771
|
+
class SeenService {
|
|
4772
|
+
#cache = new Map();
|
|
4773
|
+
memoized(a, b, compare) {
|
|
4774
|
+
const key = [a.id, b.id].sort().join(":");
|
|
4775
|
+
const result = this.#cache.get(key);
|
|
4776
|
+
if (result !== undefined) {
|
|
4777
|
+
return result !== 2;
|
|
4778
|
+
}
|
|
4779
|
+
this.#cache.set(key, 0);
|
|
4780
|
+
const isSame = compare();
|
|
4781
|
+
this.#cache.set(key, isSame ? 1 : 2);
|
|
4782
|
+
return isSame;
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
|
|
4798
4786
|
class Structure {
|
|
4799
4787
|
#compiler;
|
|
4800
4788
|
#compilerOptions;
|
|
4801
4789
|
#program;
|
|
4802
|
-
#
|
|
4790
|
+
#seen = new SeenService();
|
|
4803
4791
|
#typeChecker;
|
|
4804
4792
|
constructor(compiler, program) {
|
|
4805
4793
|
this.#compiler = compiler;
|
|
@@ -4821,7 +4809,7 @@ class Structure {
|
|
|
4821
4809
|
compare(a, b) {
|
|
4822
4810
|
a = this.#normalize(a);
|
|
4823
4811
|
b = this.#normalize(b);
|
|
4824
|
-
if (a === b) {
|
|
4812
|
+
if (a.id === b.id) {
|
|
4825
4813
|
return true;
|
|
4826
4814
|
}
|
|
4827
4815
|
if (a.flags & this.#compiler.TypeFlags.Any) {
|
|
@@ -4833,75 +4821,132 @@ class Structure {
|
|
|
4833
4821
|
if (a.flags & this.#compiler.TypeFlags.Undefined) {
|
|
4834
4822
|
return !!(b.flags & this.#compiler.TypeFlags.Undefined);
|
|
4835
4823
|
}
|
|
4836
|
-
if (
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
a.
|
|
4840
|
-
|
|
4841
|
-
return true;
|
|
4842
|
-
}
|
|
4843
|
-
return (this.compareProperties(a, b) &&
|
|
4844
|
-
this.compareSignatures(a, b, this.#compiler.SignatureKind.Call) &&
|
|
4845
|
-
this.compareSignatures(a, b, this.#compiler.SignatureKind.Construct) &&
|
|
4846
|
-
this.compareIndexSignatures(a, b));
|
|
4824
|
+
if ((a.flags | b.flags) & this.#compiler.TypeFlags.Intersection) {
|
|
4825
|
+
return (((a.flags & b.flags & this.#compiler.TypeFlags.Intersection) !== 0 &&
|
|
4826
|
+
this.compareIntersections(a, b)) ||
|
|
4827
|
+
(((a.flags & b.flags) | this.#compiler.TypeFlags.StructuredType) !== 0 &&
|
|
4828
|
+
this.#seen.memoized(a, b, () => this.compareStructuredTypes(a, b))));
|
|
4847
4829
|
}
|
|
4848
|
-
if (
|
|
4849
|
-
if (
|
|
4830
|
+
if ((a.flags | b.flags) & this.#compiler.TypeFlags.Union) {
|
|
4831
|
+
if (a.flags & b.flags & this.#compiler.TypeFlags.Union) {
|
|
4850
4832
|
return this.compareUnions(a, b);
|
|
4851
4833
|
}
|
|
4852
4834
|
return false;
|
|
4853
4835
|
}
|
|
4854
|
-
if (
|
|
4855
|
-
if (
|
|
4856
|
-
return this.
|
|
4836
|
+
if ((a.flags | b.flags) & this.#compiler.TypeFlags.Object) {
|
|
4837
|
+
if (a.flags & b.flags & this.#compiler.TypeFlags.Object) {
|
|
4838
|
+
return this.#seen.memoized(a, b, () => this.compareObjects(a, b));
|
|
4839
|
+
}
|
|
4840
|
+
return false;
|
|
4841
|
+
}
|
|
4842
|
+
if ((a.flags | b.flags) & this.#compiler.TypeFlags.TypeParameter) {
|
|
4843
|
+
if (a.flags & b.flags & this.#compiler.TypeFlags.TypeParameter) {
|
|
4844
|
+
return this.compareTypeParameters(a, b);
|
|
4845
|
+
}
|
|
4846
|
+
return false;
|
|
4847
|
+
}
|
|
4848
|
+
if ((a.flags | b.flags) & this.#compiler.TypeFlags.Index) {
|
|
4849
|
+
if (a.flags & b.flags & this.#compiler.TypeFlags.Index) {
|
|
4850
|
+
return this.compare(a.type, b.type);
|
|
4857
4851
|
}
|
|
4858
4852
|
return false;
|
|
4859
4853
|
}
|
|
4860
|
-
if (
|
|
4861
|
-
if (
|
|
4862
|
-
return this.
|
|
4854
|
+
if ((a.flags | b.flags) & this.#compiler.TypeFlags.IndexedAccess) {
|
|
4855
|
+
if (a.flags & b.flags & this.#compiler.TypeFlags.IndexedAccess) {
|
|
4856
|
+
return this.compareIndexedAccessTypes(a, b);
|
|
4863
4857
|
}
|
|
4864
4858
|
return false;
|
|
4865
4859
|
}
|
|
4866
|
-
if (
|
|
4867
|
-
if (
|
|
4860
|
+
if ((a.flags | b.flags) & this.#compiler.TypeFlags.Conditional) {
|
|
4861
|
+
if (a.flags & b.flags & this.#compiler.TypeFlags.Conditional) {
|
|
4868
4862
|
return this.compareConditionalTypes(a, b);
|
|
4869
4863
|
}
|
|
4870
4864
|
return false;
|
|
4871
4865
|
}
|
|
4872
|
-
if (
|
|
4873
|
-
if (
|
|
4874
|
-
return this.
|
|
4866
|
+
if ((a.flags | b.flags) & this.#compiler.TypeFlags.Substitution) {
|
|
4867
|
+
if (a.flags & b.flags & this.#compiler.TypeFlags.Substitution) {
|
|
4868
|
+
return this.compareSubstitutionTypes(a, b);
|
|
4875
4869
|
}
|
|
4876
4870
|
return false;
|
|
4877
4871
|
}
|
|
4878
4872
|
return false;
|
|
4879
4873
|
}
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4874
|
+
compareIntersections(a, b) {
|
|
4875
|
+
if (a.types.length !== b.types.length) {
|
|
4876
|
+
return false;
|
|
4877
|
+
}
|
|
4878
|
+
return a.types.every((aType, i) => this.compare(aType, b.types[i]));
|
|
4885
4879
|
}
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
const bSignatures = this.#getIndexSignatures(b);
|
|
4889
|
-
if (aSignatures.length !== bSignatures.length) {
|
|
4880
|
+
compareUnions(a, b) {
|
|
4881
|
+
if (a.types.length !== b.types.length) {
|
|
4890
4882
|
return false;
|
|
4891
4883
|
}
|
|
4892
|
-
|
|
4893
|
-
|
|
4884
|
+
return a.types.every((aType) => b.types.some((bType) => this.compare(aType, bType)));
|
|
4885
|
+
}
|
|
4886
|
+
compareObjects(a, b) {
|
|
4887
|
+
if (a.objectFlags & b.objectFlags & this.#compiler.ObjectFlags.Reference) {
|
|
4888
|
+
const isSame = this.compareTypeReferences(a, b);
|
|
4889
|
+
if (isSame != null) {
|
|
4890
|
+
return isSame;
|
|
4891
|
+
}
|
|
4892
|
+
}
|
|
4893
|
+
return this.compareStructuredTypes(a, b);
|
|
4894
|
+
}
|
|
4895
|
+
compareTypeReferences(a, b) {
|
|
4896
|
+
if ((a.target.objectFlags | b.target.objectFlags) & this.#compiler.ObjectFlags.Tuple) {
|
|
4897
|
+
if (a.target.objectFlags & b.target.objectFlags & this.#compiler.ObjectFlags.Tuple) {
|
|
4898
|
+
return this.compareTuples(a, b);
|
|
4899
|
+
}
|
|
4900
|
+
return false;
|
|
4901
|
+
}
|
|
4902
|
+
if ((a.objectFlags | b.objectFlags) & this.#compiler.ObjectFlags.Class) {
|
|
4903
|
+
return this.compareStructuredTypes(a, b);
|
|
4904
|
+
}
|
|
4905
|
+
if (!this.#compareTypeOfSymbol(a.symbol, b.symbol)) {
|
|
4906
|
+
if (isSymbolFromDefaultLibrary(a.symbol, this.#program) || isSymbolFromDefaultLibrary(b.symbol, this.#program)) {
|
|
4894
4907
|
return false;
|
|
4895
4908
|
}
|
|
4896
|
-
|
|
4909
|
+
return;
|
|
4910
|
+
}
|
|
4911
|
+
if (length(a.typeArguments) !== length(b.typeArguments)) {
|
|
4912
|
+
return false;
|
|
4913
|
+
}
|
|
4914
|
+
return ensureArray(a.typeArguments).every((type, i) => this.compare(type, ensureArray(b.typeArguments)[i]));
|
|
4915
|
+
}
|
|
4916
|
+
compareTuples(a, b) {
|
|
4917
|
+
if (a.target.readonly !== b.target.readonly) {
|
|
4918
|
+
return false;
|
|
4919
|
+
}
|
|
4920
|
+
const aTypeArguments = this.#typeChecker.getTypeArguments(a);
|
|
4921
|
+
const bTypeArguments = this.#typeChecker.getTypeArguments(b);
|
|
4922
|
+
if (length(aTypeArguments) !== length(bTypeArguments)) {
|
|
4923
|
+
return false;
|
|
4924
|
+
}
|
|
4925
|
+
for (let i = 0; i < aTypeArguments.length; i++) {
|
|
4926
|
+
if (a.target.elementFlags[i] !== b.target.elementFlags[i]) {
|
|
4897
4927
|
return false;
|
|
4898
4928
|
}
|
|
4899
|
-
if (!this.compare(
|
|
4929
|
+
if (!this.compare(aTypeArguments[i], bTypeArguments[i])) {
|
|
4900
4930
|
return false;
|
|
4901
4931
|
}
|
|
4902
4932
|
}
|
|
4903
4933
|
return true;
|
|
4904
4934
|
}
|
|
4935
|
+
compareStructuredTypes(a, b) {
|
|
4936
|
+
if (!this.compareProperties(a, b)) {
|
|
4937
|
+
return false;
|
|
4938
|
+
}
|
|
4939
|
+
if (!this.compareSignatures(a, b, this.#compiler.SignatureKind.Call)) {
|
|
4940
|
+
return false;
|
|
4941
|
+
}
|
|
4942
|
+
if (!this.compareSignatures(a, b, this.#compiler.SignatureKind.Construct)) {
|
|
4943
|
+
return false;
|
|
4944
|
+
}
|
|
4945
|
+
if (!this.compareIndexSignatures(a, b)) {
|
|
4946
|
+
return false;
|
|
4947
|
+
}
|
|
4948
|
+
return true;
|
|
4949
|
+
}
|
|
4905
4950
|
compareProperties(a, b) {
|
|
4906
4951
|
const aProperties = this.#typeChecker.getPropertiesOfType(a);
|
|
4907
4952
|
const bProperties = this.#typeChecker.getPropertiesOfType(b);
|
|
@@ -4942,50 +4987,26 @@ class Structure {
|
|
|
4942
4987
|
}
|
|
4943
4988
|
return true;
|
|
4944
4989
|
}
|
|
4945
|
-
compareObjects(a, b) {
|
|
4946
|
-
const key = this.#getCacheKey(a, b);
|
|
4947
|
-
const result = this.#resultCache.get(key);
|
|
4948
|
-
if (result != null) {
|
|
4949
|
-
return result !== 2;
|
|
4950
|
-
}
|
|
4951
|
-
this.#resultCache.set(key, 0);
|
|
4952
|
-
if (isTypeReference(a, this.#compiler) &&
|
|
4953
|
-
!isClass(a, this.#compiler) &&
|
|
4954
|
-
isTypeReference(b, this.#compiler) &&
|
|
4955
|
-
!isClass(b, this.#compiler)) {
|
|
4956
|
-
const isSame = this.compareTypeReferences(a, b);
|
|
4957
|
-
if (isSame != null) {
|
|
4958
|
-
this.#resultCache.set(key, isSame ? 1 : 2);
|
|
4959
|
-
return isSame;
|
|
4960
|
-
}
|
|
4961
|
-
}
|
|
4962
|
-
const isSame = this.compareProperties(a, b) &&
|
|
4963
|
-
this.compareSignatures(a, b, this.#compiler.SignatureKind.Call) &&
|
|
4964
|
-
this.compareSignatures(a, b, this.#compiler.SignatureKind.Construct) &&
|
|
4965
|
-
this.compareIndexSignatures(a, b);
|
|
4966
|
-
this.#resultCache.set(key, isSame ? 1 : 2);
|
|
4967
|
-
return isSame;
|
|
4968
|
-
}
|
|
4969
4990
|
compareSignatures(a, b, kind) {
|
|
4970
|
-
const aSignatures =
|
|
4971
|
-
const bSignatures =
|
|
4972
|
-
if (length
|
|
4991
|
+
const aSignatures = getSignatures(a, kind, this.#compiler, this.#typeChecker);
|
|
4992
|
+
const bSignatures = getSignatures(b, kind, this.#compiler, this.#typeChecker);
|
|
4993
|
+
if (aSignatures.length !== bSignatures.length) {
|
|
4973
4994
|
return false;
|
|
4974
4995
|
}
|
|
4975
4996
|
for (let i = 0; i < aSignatures.length; i++) {
|
|
4976
|
-
if (!this
|
|
4997
|
+
if (!this.#compareSignature(aSignatures[i], bSignatures[i])) {
|
|
4977
4998
|
return false;
|
|
4978
4999
|
}
|
|
4979
5000
|
}
|
|
4980
5001
|
return true;
|
|
4981
5002
|
}
|
|
4982
|
-
compareSignature(a, b) {
|
|
5003
|
+
#compareSignature(a, b) {
|
|
4983
5004
|
if (length(a.typeParameters) !== length(b.typeParameters)) {
|
|
4984
5005
|
return false;
|
|
4985
5006
|
}
|
|
4986
5007
|
if (a.typeParameters != null && b.typeParameters != null) {
|
|
4987
5008
|
for (let i = 0; i < a.typeParameters.length; i++) {
|
|
4988
|
-
if (!this.
|
|
5009
|
+
if (!this.compareTypeParameters(a.typeParameters[i], b.typeParameters[i])) {
|
|
4989
5010
|
return false;
|
|
4990
5011
|
}
|
|
4991
5012
|
}
|
|
@@ -5028,76 +5049,81 @@ class Structure {
|
|
|
5028
5049
|
}
|
|
5029
5050
|
return true;
|
|
5030
5051
|
}
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
const aTypeArguments = this.#typeChecker.getTypeArguments(a);
|
|
5036
|
-
const bTypeArguments = this.#typeChecker.getTypeArguments(b);
|
|
5037
|
-
if (length(aTypeArguments) !== length(bTypeArguments)) {
|
|
5052
|
+
compareIndexSignatures(a, b) {
|
|
5053
|
+
const aSignatures = getIndexSignatures(a, this.#compiler, this.#typeChecker);
|
|
5054
|
+
const bSignatures = getIndexSignatures(b, this.#compiler, this.#typeChecker);
|
|
5055
|
+
if (aSignatures.length !== bSignatures.length) {
|
|
5038
5056
|
return false;
|
|
5039
5057
|
}
|
|
5040
|
-
for (let i = 0; i <
|
|
5041
|
-
if (
|
|
5058
|
+
for (let i = 0; i < aSignatures.length; i++) {
|
|
5059
|
+
if (aSignatures[i].isReadonly !== bSignatures[i].isReadonly) {
|
|
5042
5060
|
return false;
|
|
5043
5061
|
}
|
|
5044
|
-
if (!this.compare(
|
|
5062
|
+
if (!this.compare(aSignatures[i].keyType, bSignatures[i].keyType)) {
|
|
5063
|
+
return false;
|
|
5064
|
+
}
|
|
5065
|
+
if (!this.compare(aSignatures[i].type, bSignatures[i].type)) {
|
|
5045
5066
|
return false;
|
|
5046
5067
|
}
|
|
5047
5068
|
}
|
|
5048
5069
|
return true;
|
|
5049
5070
|
}
|
|
5050
|
-
|
|
5051
|
-
if (
|
|
5052
|
-
|
|
5071
|
+
compareTypeParameters(a, b) {
|
|
5072
|
+
if (getTypeParameterModifiers(a, this.#compiler) !== getTypeParameterModifiers(b, this.#compiler)) {
|
|
5073
|
+
return false;
|
|
5074
|
+
}
|
|
5075
|
+
if (!this.#compareMaybeNullish(this.#typeChecker.getBaseConstraintOfType(a), this.#typeChecker.getBaseConstraintOfType(b))) {
|
|
5076
|
+
return false;
|
|
5077
|
+
}
|
|
5078
|
+
if (!this.#compareMaybeNullish(this.#typeChecker.getDefaultFromTypeParameter(a), this.#typeChecker.getDefaultFromTypeParameter(b))) {
|
|
5053
5079
|
return false;
|
|
5054
5080
|
}
|
|
5055
5081
|
return true;
|
|
5056
5082
|
}
|
|
5057
|
-
|
|
5058
|
-
if (!this
|
|
5059
|
-
|
|
5060
|
-
return false;
|
|
5061
|
-
}
|
|
5062
|
-
return;
|
|
5083
|
+
compareIndexedAccessTypes(a, b) {
|
|
5084
|
+
if (!this.compare(a.objectType, b.objectType)) {
|
|
5085
|
+
return false;
|
|
5063
5086
|
}
|
|
5064
|
-
if (
|
|
5087
|
+
if (!this.compare(a.indexType, b.indexType)) {
|
|
5065
5088
|
return false;
|
|
5066
5089
|
}
|
|
5067
|
-
return
|
|
5090
|
+
return true;
|
|
5068
5091
|
}
|
|
5069
|
-
|
|
5070
|
-
if (a.
|
|
5092
|
+
compareConditionalTypes(a, b) {
|
|
5093
|
+
if (!this.compare(a.checkType, b.checkType)) {
|
|
5071
5094
|
return false;
|
|
5072
5095
|
}
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
return type.types.flatMap((type) => this.#getSignatures(type, kind));
|
|
5096
|
+
if (!this.compare(a.extendsType, b.extendsType)) {
|
|
5097
|
+
return false;
|
|
5098
|
+
}
|
|
5099
|
+
if (!this.compare(this.#typeChecker.getTypeAtLocation(a.root.node.trueType), this.#typeChecker.getTypeAtLocation(b.root.node.trueType))) {
|
|
5100
|
+
return false;
|
|
5101
|
+
}
|
|
5102
|
+
if (!this.compare(this.#typeChecker.getTypeAtLocation(a.root.node.falseType), this.#typeChecker.getTypeAtLocation(b.root.node.falseType))) {
|
|
5103
|
+
return false;
|
|
5082
5104
|
}
|
|
5083
|
-
return
|
|
5105
|
+
return true;
|
|
5084
5106
|
}
|
|
5085
|
-
|
|
5086
|
-
if (
|
|
5087
|
-
return
|
|
5107
|
+
compareSubstitutionTypes(a, b) {
|
|
5108
|
+
if (!this.compare(a.baseType, b.baseType)) {
|
|
5109
|
+
return false;
|
|
5088
5110
|
}
|
|
5089
|
-
|
|
5111
|
+
if (!this.compare(a.constraint, b.constraint)) {
|
|
5112
|
+
return false;
|
|
5113
|
+
}
|
|
5114
|
+
return true;
|
|
5090
5115
|
}
|
|
5091
5116
|
#normalize(type) {
|
|
5092
|
-
if (
|
|
5117
|
+
if (type.flags & this.#compiler.TypeFlags.Freshable && type.freshType === type) {
|
|
5093
5118
|
return type.regularType;
|
|
5094
5119
|
}
|
|
5095
|
-
if (
|
|
5120
|
+
if (type.flags & this.#compiler.TypeFlags.Substitution &&
|
|
5121
|
+
type.constraint.flags & this.#compiler.TypeFlags.Unknown) {
|
|
5096
5122
|
return type.baseType;
|
|
5097
5123
|
}
|
|
5098
|
-
if (
|
|
5124
|
+
if (type.flags & this.#compiler.TypeFlags.UnionOrIntersection) {
|
|
5099
5125
|
const candidateType = this.#normalize(type.types[0]);
|
|
5100
|
-
if (type.types.every((
|
|
5126
|
+
if (type.types.every((t) => this.compare(this.#normalize(t), candidateType))) {
|
|
5101
5127
|
return candidateType;
|
|
5102
5128
|
}
|
|
5103
5129
|
}
|
|
@@ -5951,7 +5977,7 @@ class FileRunner {
|
|
|
5951
5977
|
class Runner {
|
|
5952
5978
|
#eventEmitter = new EventEmitter();
|
|
5953
5979
|
#resolvedConfig;
|
|
5954
|
-
static version = "6.0.0-beta.
|
|
5980
|
+
static version = "6.0.0-beta.1";
|
|
5955
5981
|
constructor(resolvedConfig) {
|
|
5956
5982
|
this.#resolvedConfig = resolvedConfig;
|
|
5957
5983
|
}
|