Skip to content
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

fix: handle typescript $$Generic special type #131

Merged
merged 2 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/postprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const is_valid_message = (block, message, translation) => {
case 'no-labels': return get_identifier(get_referenced_string(block, message)) !== '$';
case 'no-restricted-syntax': return message.nodeType !== 'LabeledStatement' || get_identifier(get_referenced_string(block, message)) !== '$';
case 'no-self-assign': return !state.var_names.has(get_identifier(get_referenced_string(block, message)));
case 'no-undef': return get_referenced_string(block, message) !== '$$Generic';
case 'no-unused-labels': return get_referenced_string(block, message) !== '$';
case '@typescript-eslint/quotes':
case 'quotes': return !translation.options.in_quoted_attribute;
Expand Down
11 changes: 11 additions & 0 deletions test/samples/typescript-generics/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended'],
plugins: ['@typescript-eslint'],
settings: {
'svelte3/typescript': require('typescript'),
},
rules: {
'no-undef': 'error',
},
};
14 changes: 14 additions & 0 deletions test/samples/typescript-generics/Input.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script lang='ts'>
type T = $$Generic;
type U = $$Generic<string>;
export let items: T[];
export let message: U;
</script>

{#each items as item}
<slot {item} />
{/each}

{#if message}
{message}
{/if}
1 change: 1 addition & 0 deletions test/samples/typescript-generics/expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]