Skip to content

Commit 255f1ed

Browse files
committed
tests
1 parent e695d3d commit 255f1ed

File tree

11 files changed

+108
-4
lines changed

11 files changed

+108
-4
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"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",
5+
"start": {
6+
"line": 3,
7+
"column": 2
8+
},
9+
"end": {
10+
"line": 3,
11+
"column": 17
12+
}
13+
}
14+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script lang="ts">
2+
class Foo {
3+
accessor y = 1;
4+
}
5+
</script>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"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",
5+
"start": {
6+
"line": 2,
7+
"column": 4
8+
},
9+
"end": {
10+
"line": 2,
11+
"column": 10
12+
}
13+
}
14+
]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<script lang="ts">
2+
@foo()
3+
class Foo {}
4+
</script>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"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",
5+
"start": {
6+
"line": 2,
7+
"column": 1
8+
},
9+
"end": {
10+
"line": 4,
11+
"column": 2
12+
}
13+
}
14+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script lang="ts">
2+
enum Foo {
3+
bar = 1
4+
}
5+
</script>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"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",
5+
"start": {
6+
"line": 3,
7+
"column": 14
8+
},
9+
"end": {
10+
"line": 3,
11+
"column": 31
12+
}
13+
}
14+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script lang="ts">
2+
class Foo {
3+
constructor(private x: number) {}
4+
}
5+
</script>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[
2+
{
3+
"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",
5+
"start": {
6+
"line": 2,
7+
"column": 1
8+
},
9+
"end": {
10+
"line": 4,
11+
"column": 2
12+
}
13+
}
14+
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script module lang="ts">
2+
namespace SomeNamespace {
3+
export const foo = true;
4+
}
5+
</script>

packages/svelte/tests/validator/test.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,20 @@ const { test, run } = suite<ValidatorTest>(async (config, cwd) => {
5353
const expected = expected_errors && expected_errors[0];
5454

5555
if (error && expected) {
56-
assert.equal(error.code, expected.code);
57-
assert.equal(error.message, expected.message);
58-
assert.deepEqual({ line: error.start?.line, column: error.start?.column }, expected.start);
59-
assert.deepEqual({ line: error.end?.line, column: error.end?.column }, expected.end);
56+
assert.deepEqual(
57+
{
58+
code: error.code,
59+
message: error.message,
60+
start: { line: error.start?.line, column: error.start?.column },
61+
end: { line: error.end?.line, column: error.end?.column }
62+
},
63+
{
64+
code: expected.code,
65+
message: expected.message,
66+
start: expected.start,
67+
end: expected.end
68+
}
69+
);
6070
} else if (expected) {
6171
throw new Error(`Expected an error: ${expected.message}`);
6272
} else if (error) {

0 commit comments

Comments
 (0)