Skip to content

Commit

Permalink
test(tsc): add tests for #3779, #3820 (#3838)
Browse files Browse the repository at this point in the history
  • Loading branch information
so1ve authored Aug 25, 2024
1 parent e4d3683 commit de50847
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/language-server/tests/renaming.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ describe('Renaming', async () => {

const position = document.positionAt(offset);
const edit = await server.sendRenameRequest(document.uri, position, newName);
expect(edit).toBeDefined();
expect(edit?.changes).toBeDefined();

for (const [uri, edits] of Object.entries(edit!.changes!)) {
delete edit!.changes![uri];
Expand Down
10 changes: 10 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3.5/#3779/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script setup lang="ts">
import { exactType } from '../../shared';
defineProps<{
optionalBoolean?: boolean;
}>();
</script>

<template>
<h1>{{ exactType(optionalBoolean, {} as boolean | undefined) }}</h1>
</template>
10 changes: 10 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3.5/#3779/named.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script setup lang="ts">
import { exactType } from '../../shared';
defineProps<{
optionalBoolean?: boolean;
}>();
</script>

<template>
<h1>{{ exactType(optionalBoolean, {} as boolean | undefined) }}</h1>
</template>
19 changes: 19 additions & 0 deletions test-workspace/tsc/passedFixtures/vue3.5/#3820/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script setup lang="ts" generic="T extends { name: string }">
const props = defineProps<{
one: T;
all: Array<T>;
}>();
</script>

<template>
<div>
<!-- incorrect inference -->
<div>{{ one.name }}</div>
<!-- correct inference -->
<div>{{ props.one.name }}</div>
<ul>
<!-- correct inference -->
<li v-for="el in all">{{ el.name }}</li>
</ul>
</div>
</template>
1 change: 1 addition & 0 deletions test-workspace/tsc/passedFixtures/vue3.5/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../../tsconfig.base.json",
"vueCompilerOptions": {
"lib": "vue3.5",
"target": 3.5,
},
"include": [
Expand Down

0 comments on commit de50847

Please sign in to comment.