diff --git a/typescript/src/completions/fixPropertiesSorting.ts b/typescript/src/completions/fixPropertiesSorting.ts
index a196b8f..ac8b3f5 100644
--- a/typescript/src/completions/fixPropertiesSorting.ts
+++ b/typescript/src/completions/fixPropertiesSorting.ts
@@ -31,7 +31,7 @@ export default (entries: ts.CompletionEntry[]) => {
const typeChecker = program.getTypeChecker()
let sourceProps: string[]
if (isJsxElem) {
- const type = typeChecker.getContextualType((node as ts.JsxOpeningElement).attributes)
+ const type = typeChecker.getContextualType((targetNode as ts.JsxOpeningElement).attributes)
if (!type) return
// usually component own props defined first like interface Props extends ... {} or type A = Props & ..., but this is not a case with mui...
sourceProps = (type.isIntersection() ? type.types.flatMap(type => type.getProperties()) : type.getProperties()).map(symbol => symbol.name)
diff --git a/typescript/test/completions.spec.ts b/typescript/test/completions.spec.ts
index 458585b..9c6f580 100644
--- a/typescript/test/completions.spec.ts
+++ b/typescript/test/completions.spec.ts
@@ -527,26 +527,38 @@ test('Fix properties sorting', () => {
a.b({/*2*/})./*3*/
}
+ let a: { b:{}, a() } = {
+ /*5*/
+ }
+
declare function MyComponent(props: { b?; c? } & { a? }): JSX.Element
;
;
-
- let a: { b:{}, a() } = {
- /*5*/
- }
+ ;
+ ;
`)
const assertSorted = (marker: number, expected: string[]) => {
const { entriesSorted } = getCompletionsAtPosition(currentTestingContext.markers[marker]!)!
- expect(entriesSorted.map(x => x.name)).toEqual(expected)
+ expect(
+ entriesSorted.map(x => x.name),
+ `${marker}`,
+ ).toEqual(expected)
}
assertSorted(1, ['c', 'b'])
assertSorted(2, ['c', 'b'])
assertSorted(3, ['c', 'b'])
assertSorted(4, ['b', 'c', 'a'])
- assertSorted(41, ['b', 'a'])
+ assertSorted(41, ['b', 'c', 'a'])
+ assertSorted(42, ['b', 'c', 'a'])
assertSorted(5, ['b', 'b', 'a', 'a'])
settingsOverride.fixSuggestionsSorting = false
})