Skip to content

Commit

Permalink
fix(language-service): initialize scope with null prototype object (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Sep 18, 2024
1 parent 66c9ab6 commit 5a02676
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/language-server/tests/inlayHints.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,28 @@ describe('Definitions', async () => {
`);
});

it('#4855', async () => {
expect(
await requestInlayHintsResult('fixture.vue', 'vue', `
<script setup lang="ts">
import { toString } from './utils';
const { foo } = defineProps<{ foo: string }>();
console.log(foo);
</script>
`)
).toMatchInlineSnapshot(`
"
<script setup lang="ts">
import { toString } from './utils';
const { foo } = defineProps<{ foo: string }>();
console.log(/* props. */foo);
</script>
"
`);
});

const openedDocuments: TextDocument[] = [];

afterEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/language-service/lib/plugins/vue-inlayhints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function findDestructuredProps(
ast: ts.SourceFile,
props: Set<string>
) {
const rootScope: Scope = {};
const rootScope: Scope = Object.create(null);
const scopeStack: Scope[] = [rootScope];
let currentScope: Scope = rootScope;
const excludedIds = new WeakSet<ts.Identifier>();
Expand Down

0 comments on commit 5a02676

Please sign in to comment.