mirror of https://github.com/sveltejs/svelte
fix: error at compile time on unsupported TypeScript language features (#12982)
part of #11502 - to close it completely, we also need to look at using and possibly implement heuristics within bundler plugins to give more details --------- Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>pull/13113/head
parent
81b32d8b5a
commit
194570dc70
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: error at compile time on unsupported TypeScript language features
|
@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "typescript_invalid_feature",
|
||||||
|
"message": "TypeScript language features like accessor fields (related TSC proposal is not stage 4 yet) are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)",
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 2
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,5 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
class Foo {
|
||||||
|
accessor y = 1;
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "typescript_invalid_feature",
|
||||||
|
"message": "TypeScript language features like decorators (related TSC proposal is not stage 4 yet) are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)",
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 4
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,4 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
@foo()
|
||||||
|
class Foo {}
|
||||||
|
</script>
|
@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "typescript_invalid_feature",
|
||||||
|
"message": "TypeScript language features like enums are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)",
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 1
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,5 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
enum Foo {
|
||||||
|
bar = 1
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "typescript_invalid_feature",
|
||||||
|
"message": "TypeScript language features like accessibility modifiers on constructor parameters are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)",
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 14
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 31
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,5 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
class Foo {
|
||||||
|
constructor(private x: number) {}
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,14 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"code": "typescript_invalid_feature",
|
||||||
|
"message": "TypeScript language features like namespaces with non-type nodes are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)",
|
||||||
|
"start": {
|
||||||
|
"line": 2,
|
||||||
|
"column": 1
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 4,
|
||||||
|
"column": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
@ -0,0 +1,5 @@
|
|||||||
|
<script module lang="ts">
|
||||||
|
namespace SomeNamespace {
|
||||||
|
export const foo = true;
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in new issue