-
-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make tuple and custom array declared as interface compatible #413
Open
devgony
wants to merge
41
commits into
dudykr:main
Choose a base branch
from
devgony:arityAndOrderCompatibility
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
370071b
feat: implement interface array case
devgony ce4cf98
fix: filter array by `type_of_ts_entity_name`
devgony fc48981
temp-1
devgony 71cefdd
fix: implement handling interface at `assign/mod.rs`
devgony 0399886
Merge branch 'arityAndOrderCompatibility-n' into arityAndOrderCompati…
devgony 96f4567
fix: remove previous implement
devgony f27ad7e
fix: remove imports
devgony 43f4aec
chore: remove redundant diff
devgony 3194496
Merge remote-tracking branch 'upstream/main' into arityAndOrderCompat…
devgony 20f4513
fix: compare types of lhs and rhs
devgony bd11c05
fix: zip and iterate each lkind and rkind
devgony 259c374
fix: early return `assign_with_opts`
devgony 5928792
chore: remove unused import
devgony 2e880cb
fix: remove unused params
devgony 135e2b3
fix: remove wrong spell
devgony e40402d
Merge remote-tracking branch 'upstream/main' into arityAndOrderCompat…
devgony bba28d3
fix: thanks clippy
devgony 939a9c0
Merge remote-tracking branch 'upstream/main' into arityAndOrderCompat…
devgony 7e87f8e
style: cargo fmt
devgony 78011c1
style: thanks clippy
devgony b794a61
Merge remote-tracking branch 'upstream/main' into arityAndOrderCompat…
devgony 9d463e3
Merge branch 'main' into arityAndOrderCompatibility
devgony 4976748
test: add a case that should pass
devgony 3d3fcca
fix: replace the order of lhs and rhs
devgony e85466f
Merge remote-tracking branch 'origin/arityAndOrderCompatibility' into…
devgony e4a786b
feat: correct errors.json
devgony fb8d765
refactor: remove redundant line, reduce clone
devgony 0a08ed7
fix: renamt lhss to lsh_types
devgony bdf5da0
fix: remove unresolved test cases
devgony 5759dc2
chore: run check.sh
devgony 0da1d65
fix: correct error line number
devgony 594c1e1
Merge remote-tracking branch 'upstream/main' into arityAndOrderCompat…
devgony 4a839ca
fix: recover official tsc conformance test suite
devgony 6ba341b
fix: remove error on line 39
devgony 3df5f8b
fix: amend matched_error to 17
devgony b8551db
fix: remove formatting
devgony 3ea7e93
fix: recover solved issue
devgony 5f8c1df
feat: handle line16
devgony 97256d8
feat: handle line17, 19
devgony 66ecbd5
test: add arityAndOrderCompatibility02 case
devgony ed10347
chore: add test log
devgony File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,10 @@ use stc_ts_generics::ExpandGenericOpts; | |
use stc_ts_type_ops::{tuple_normalization::TupleNormalizer, Fix}; | ||
use stc_ts_types::{ | ||
name::Name, Accessor, Array, Class, ClassDef, ClassMember, ClassMetadata, ComputedKey, Conditional, ConditionalMetadata, | ||
ConstructorSignature, EnumVariant, FnParam, Id, IdCtx, IndexSignature, IndexedAccessType, Instance, InstanceMetadata, Intersection, | ||
IntrinsicKind, Key, KeywordType, KeywordTypeMetadata, LitType, LitTypeMetadata, MethodSignature, Operator, PropertySignature, | ||
QueryExpr, QueryType, Ref, StringMapping, ThisType, ThisTypeMetadata, TplElem, TplType, Type, TypeElement, TypeLit, TypeLitMetadata, | ||
TypeParam, TypeParamInstantiation, Union, | ||
ConstructorSignature, EnumVariant, FnParam, Id, IdCtx, IndexSignature, IndexedAccessType, Instance, InstanceMetadata, Interface, | ||
InterfaceMetadata, Intersection, IntrinsicKind, Key, KeywordType, KeywordTypeMetadata, LitType, LitTypeMetadata, MethodSignature, | ||
Operator, PropertySignature, QueryExpr, QueryType, Ref, StringMapping, ThisType, ThisTypeMetadata, TplElem, TplType, Type, TypeElement, | ||
TypeLit, TypeLitMetadata, TypeParam, TypeParamInstantiation, Union, | ||
}; | ||
use stc_ts_utils::run; | ||
use stc_utils::{ | ||
|
@@ -108,7 +108,6 @@ impl Analyzer<'_, '_> { | |
match ty.normalize() { | ||
Type::Lit(..) | ||
| Type::TypeLit(..) | ||
| Type::Interface(..) | ||
| Type::Class(..) | ||
| Type::ClassDef(..) | ||
| Type::Tuple(..) | ||
|
@@ -117,6 +116,22 @@ impl Analyzer<'_, '_> { | |
| Type::EnumVariant(..) | ||
| Type::Param(_) | ||
| Type::Module(_) => return Ok(ty), | ||
Type::Interface(Interface { | ||
span, | ||
name, | ||
type_params, | ||
extends, | ||
body, | ||
metadata: InterfaceMetadata { common }, | ||
tracker, | ||
}) => { | ||
for parent in extends { | ||
let parent = self.type_of_ts_entity_name(parent.span(), &parent.expr, parent.type_args.as_deref())?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A user can add methods to their own array type. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this does not handle tuple types correctly |
||
if let Type::Array(_) = &parent { | ||
return Ok(Cow::Owned(parent)); | ||
} | ||
} | ||
} | ||
_ => {} | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach is wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean we should add more condition here to decrease the range of match arm?
Or It is totally wrong location to implement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the latter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you give any tips like where to start first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some match expressions should be added to
stc/crates/stc_ts_file_analyzer/src/analyzer/assign/mod.rs
Line 1036 in 4033e8b