-
-
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
Exclude MissingFields
if RHS have an index signature
#741
Comments
What's causing me issues here is that it seems like the type gets converted to type
dbg!("before fold white: ", &ty);
ty = ty.fold_with(&mut TypeFactsHandler { analyzer: self, facts });
dbg!("after fold with: ", &ty); [crates/stc_ts_file_analyzer/src/ty/type_facts.rs:72] "before fold with: " = "before fold with: "
[crates/stc_ts_file_analyzer/src/ty/type_facts.rs:72] &ty = Instance { span: Span { lo: BytePos(1229), hi: BytePos(1242), ctxt: #0 }, ty: StringTo<any>, metadata: InstanceMetadata { common: CommonTypeMetadata { implicit: false, infected_by_this_in_object_literal: false, prevent_converting_to_children: false, contains_infer_type: false, prevent_complex_simplification: false, resolved_from_var: false, prevent_generalization: false, destructure_key: DestructureId(0) } }, tracker: Tracker { _priv: () } }
[crates/stc_ts_file_analyzer/src/ty/type_facts.rs:74] "after fold with: " = "after fold with: "
[crates/stc_ts_file_analyzer/src/ty/type_facts.rs:74] &ty = Instance { span: Span { lo: BytePos(1229), hi: BytePos(1242), ctxt: #0 }, ty: Interface { span: Span { lo: BytePos(1229), hi: BytePos(1242), ctxt: #0 }, name: StringTo#2, type_params: Some(<T#3>), extends: [], body: [IndexSignature { span: Span { lo: BytePos(27), hi: BytePos(42), ctxt: #0 }, params: [(string)], type_ann: Some(any), readonly: false, is_static: false }], metadata: InterfaceMetadata { common: CommonTypeMetadata { implicit: false, infected_by_this_in_object_literal: false, prevent_converting_to_children: false, contains_infer_type: false, prevent_complex_simplification: false, resolved_from_var: false, prevent_generalization: false, destructure_key: DestructureId(0) } }, tracker: Tracker { _priv: () } }, metadata: InstanceMetadata { common: CommonTypeMetadata { implicit: false, infected_by_this_in_object_literal: false, prevent_converting_to_children: false, contains_infer_type: false, prevent_complex_simplification: false, resolved_from_var: false, prevent_generalization: false, destructure_key: DestructureId(0) } }, tracker: Tracker { _priv: () } } Is this intended? The ts code im using is this: (not representing the test code but im just using it to debug) interface StringTo<T> {
[x: string]: T;
}
interface NumberTo<T> {
[x: number]: T;
}
interface StringAndNumberTo<T> extends StringTo<T>, NumberTo<T> {}
interface Obj {
hello: string;
world: number;
}
type NumberToNumber = NumberTo<number>;
interface StringToAnyNumberToNumber extends StringTo<any>, NumberToNumber {}
function f3(
sToAny: StringTo<any>,
nToNumber: NumberToNumber,
strToAnyNumToNum: StringToAnyNumberToNumber,
someObj: Obj
) {
someObj = sToAny;
} |
I think it's a bug of the TypeFactHandler, but not sure how it did happen |
I came back to my macbook, and checked the source code of
|
If it's any help I've deduced that this line is directly responsible:
You can try putting ty = ty.fold_children_with(self);
return ty; you will get |
I'll try resolving this one |
Closing as it's now normalized. |
Related test case:
stc/crates/stc_ts_type_checker/tests/conformance/types/members/objectTypeWithStringAndNumberIndexSignatureToAny.ts
Line 92 in 5d3aa0b
stc fails with
but it should success because the RHS contains an index signature
The text was updated successfully, but these errors were encountered: