Skip to content

Commit 8f44b58

Browse files
committed
enhance error message
1 parent 255f1ed commit 8f44b58

File tree

7 files changed

+8
-8
lines changed

7 files changed

+8
-8
lines changed

packages/svelte/messages/compile-errors/script.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@ Using a `$` prefix to refer to the value of a store is only possible inside `.sv
162162

163163
## typescript_invalid_feature
164164

165-
> TypeScript language features like %feature% are not natively supported, and their use is generally discouraged. You will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler
165+
> TypeScript language features like %feature% 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 })`)

packages/svelte/src/compiler/errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,13 @@ export function store_invalid_subscription_module(node) {
435435
}
436436

437437
/**
438-
* TypeScript language features like %feature% are not natively supported, and their use is generally discouraged. You will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler
438+
* TypeScript language features like %feature% 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 })`)
439439
* @param {null | number | NodeLike} node
440440
* @param {string} feature
441441
* @returns {never}
442442
*/
443443
export function typescript_invalid_feature(node, feature) {
444-
e(node, "typescript_invalid_feature", `TypeScript language features like ${feature} are not natively supported, and their use is generally discouraged. You will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler`);
444+
e(node, "typescript_invalid_feature", `TypeScript language features like ${feature} 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 })\`)`);
445445
}
446446

447447
/**

packages/svelte/tests/validator/samples/ts-unsupported-accessor/errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "typescript_invalid_feature",
4-
"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. You will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler",
4+
"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 })`)",
55
"start": {
66
"line": 3,
77
"column": 2

packages/svelte/tests/validator/samples/ts-unsupported-decorator/errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "typescript_invalid_feature",
4-
"message": "TypeScript language features like decorators (related TSC proposal is not stage 4 yet) are not natively supported, and their use is generally discouraged. You will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler",
4+
"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 })`)",
55
"start": {
66
"line": 2,
77
"column": 4

packages/svelte/tests/validator/samples/ts-unsupported-enum/errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "typescript_invalid_feature",
4-
"message": "TypeScript language features like enums are not natively supported, and their use is generally discouraged. You will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler",
4+
"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 })`)",
55
"start": {
66
"line": 2,
77
"column": 1

packages/svelte/tests/validator/samples/ts-unsupported-modifier/errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "typescript_invalid_feature",
4-
"message": "TypeScript language features like accessibility modifiers on constructor parameters are not natively supported, and their use is generally discouraged. You will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler",
4+
"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 })`)",
55
"start": {
66
"line": 3,
77
"column": 14

packages/svelte/tests/validator/samples/ts-unsupported-namespace/errors.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
33
"code": "typescript_invalid_feature",
4-
"message": "TypeScript language features like namespaces with non-type nodes are not natively supported, and their use is generally discouraged. You will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler",
4+
"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 })`)",
55
"start": {
66
"line": 2,
77
"column": 1

0 commit comments

Comments
 (0)