Skip to content

Preserve all typescript imports, not only .svelte #19

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

Merged
merged 1 commit into from
Jun 26, 2019

Conversation

geakstr
Copy link
Contributor

@geakstr geakstr commented Jun 22, 2019

Hi! Thanks for the project. Library already preserves all .svelte imports. This PR change behaviour to preserve all imports, because imported variables can be not only svelte components but also values which svelte template actually uses. Example:

<script lang="ts">
  import { writable } from "svelte/store";
  import { count } from "./stores";
  import Counter from "./Counter.svelte";

  export let name: number;
  export let age: number;
</script>

<h1>Hello {name} ({age})!</h1>
<p>
  <Counter />
  <Counter value={1}>Counter 1</Counter>
  <Counter value={$count} step={3}>Counter 2</Counter>
</p>

Without the fix compiler throws:

(!) svelte plugin: 'count' is not defined
src/App.svelte
   <Counter />
  <Counter value={1}>Counter 1</Counter>   
  <Counter value={$count} step={3}>Counter 2</Counter>
                  ^
</p>

Relates to:

Hi! Thanks for the project. Library already preserves all `.svelte` imports. This PR change behaviour to preserve _all_ imports, because imported variables can be not only svelte components but also values which svelte template actually uses. Example:

```
<script lang="ts">
  import { writable } from "svelte/store";
  import { count } from "./stores";
  import Counter from "./Counter.svelte";

  export let name: number;
  export let age: number;
</script>

<h1>Hello {name} ({age})!</h1>
<p>
  <Counter />
  <Counter value={1}>Counter 1</Counter>
  <Counter value={$count} step={3}>Counter 2</Counter>
</p>
```

Without the fix compiler throws:

```
(!) svelte plugin: 'count' is not defined
src/App.svelte
   <Counter />
  <Counter value={1}>Counter 1</Counter>   
  <Counter value={$count} step={3}>Counter 2</Counter>
                  ^
</p>
```

Relates to:
- PaulMaly#4 
- microsoft/TypeScript#9191
@PaulMaly PaulMaly merged commit 0742d58 into PaulMaly:master Jun 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants