Skip to content

Commit

Permalink
(docs) update TS setup instructions
Browse files Browse the repository at this point in the history
- remove depracted type/lang options
- differentiate between ESM and CJS style projects
  • Loading branch information
dummdidumm authored Oct 1, 2021
1 parent 0f0d9cf commit d0e1a5f
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions docs/preprocessors/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,25 @@ Adding it to an existing project? [The official blog post explains how to do it]

#### 2. Getting it to work in the editor

To tell us to treat your script tags as typescript, add a `type` or `lang` attribute to your script tags like so:
To tell us to treat your script tags as typescript, add a `lang` attribute to your script tags like so:

```html
<!-- Add type="text/typescript" -->
<script type="text/typescript">
export let name: string;
</script>

<!-- Or add lang="typescript" or lang="ts" -->
<script lang="typescript">
<script lang="ts">
export let name: string;
</script>
```

You may optionally want to add a `svelte.config.js` file - but it is not required as long as you only use TypeScript.
You may optionally want to add a `svelte.config.js` file - but it is not required as long as you only use TypeScript.Depending on your setup, this config file needs to be written either in ESM-style or CJS-Style.

ESM-style (for everything with `"type": "module"` in its `package.json`, like SvelteKit):
```js
import sveltePreprocess from 'svelte-preprocess';

export default {
preprocess: sveltePreprocess()
};
```
CJS-style:
```js
const sveltePreprocess = require('svelte-preprocess');

Expand Down

0 comments on commit d0e1a5f

Please sign in to comment.