Skip to content

Commit

Permalink
fix: handle TypeScript $$Generic special type (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
SomaticIT authored Sep 9, 2021
1 parent 8a34f9b commit e9f0250
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
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 @@
[]

0 comments on commit e9f0250

Please sign in to comment.