-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow TypeScript in hoisted scripts (#3665)
* Allow TypeScript in hoisted scripts * Pass skipSelf * Fix linting
- Loading branch information
Showing
9 changed files
with
76 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Allow TypeScript inside script tags | ||
|
||
This makes it so that you can use TypeScript inside of script tags like so: | ||
|
||
```html | ||
<script> | ||
interface Person { | ||
name: string; | ||
} | ||
const person: Person = { | ||
name: 'Astro' | ||
}; | ||
console.log(person); | ||
</script> | ||
``` | ||
|
||
Note that the the VSCode extension does not currently support this, however. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
packages/astro/test/fixtures/astro-scripts/src/components/Inline.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
<script> | ||
console.log('some content here.'); | ||
import '../scripts/some-files/one'; | ||
import '../scripts/some-files/two.js'; | ||
|
||
interface Props { | ||
name: string; | ||
} | ||
const props: Props = { name: 'some string' }; | ||
|
||
console.log('some content here.', props); | ||
</script> |
1 change: 1 addition & 0 deletions
1
packages/astro/test/fixtures/astro-scripts/src/scripts/some-files/one.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('some-files/one'); |
1 change: 1 addition & 0 deletions
1
packages/astro/test/fixtures/astro-scripts/src/scripts/some-files/two.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('some-files/two'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.