Skip to content

Commit

Permalink
Merge pull request #1788 from yoyo930021/fix-readonly-array-in-vfor
Browse files Browse the repository at this point in the history
Fix template interpolation in vfor when readonly array
  • Loading branch information
ktsn authored Mar 17, 2020
2 parents 4455605 + fe0e845 commit 8b3ecb6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/src/services/typescriptService/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export declare const ${componentHelperName}: {
): any;
};
export declare const ${iterationHelperName}: {
<T>(list: T[], fn: (value: T, index: number) => any): any;
<T>(list: readonly T[], fn: (value: T, index: number) => any): any;
<T>(obj: { [key: string]: T }, fn: (value: T, key: string, index: number) => any): any;
(num: number, fn: (value: number) => any): any;
<T>(obj: object, fn: (value: any, key: string, index: number) => any): any;
Expand Down
8 changes: 7 additions & 1 deletion test/interpolation/fixture/hover/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
{{ item }}
</li>
</ul>
<ul>
<li v-for="(item, i) in readonlyList" :key="i">
{{ item }}
</li>
</ul>
</div>
</template>

Expand All @@ -15,7 +20,8 @@ export default {
data () {
return {
msg: 'Vetur means "Winter" in icelandic.',
list: [0, 1, 2]
list: [0, 1, 2],
readonlyList: ['foo', 'bar'] as Readonly<string[]>
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/interpolation/hover/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ describe('Should do hover interpolation for <template>', () => {
range: sameLineRange(5, 18, 22)
});
});

it('shows hover for v-for variable on readonly array', async () => {
await testHover(docUri, position(10, 20), {
contents: ['\n```ts\n(parameter) item: string\n```\n'],
range: sameLineRange(10, 18, 22)
});
});
});

async function testHover(docUri: vscode.Uri, position: vscode.Position, expectedHover: vscode.Hover) {
Expand Down

0 comments on commit 8b3ecb6

Please sign in to comment.