diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-05-22 19:23:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-22 19:23:35 +0200 |
commit | 960f9ccb2e700332dc576163b62c518120c73f15 (patch) | |
tree | 3bca9c5c449c01344f7dea9a945032fe17bffe63 /cli/tests | |
parent | e191c70989a1dbf29b095bf6c2f7b62b90de012a (diff) |
fix: SWC lexer settings and silent errors (#5752)
This commit changes how error occurring in SWC are handled.
Changed lexer settings to properly handle TS decorators.
Changed output of SWC error to annotate with position in file.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration_tests.rs | 12 | ||||
-rw-r--r-- | cli/tests/swc_syntax_error.ts | 3 | ||||
-rw-r--r-- | cli/tests/swc_syntax_error.ts.out | 1 | ||||
-rw-r--r-- | cli/tests/ts_decorators.ts | 14 | ||||
-rw-r--r-- | cli/tests/ts_decorators.ts.out | 2 | ||||
-rw-r--r-- | cli/tests/tsconfig.decorators.json | 5 |
6 files changed, 36 insertions, 1 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 9f73c91b3..457a345dd 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1575,7 +1575,17 @@ itest!(ts_type_imports { args: "run --reload ts_type_imports.ts", output: "ts_type_imports.ts.out", exit_code: 1, - http_server: true, +}); + +itest!(ts_decorators { + args: "run --reload -c tsconfig.decorators.json ts_decorators.ts", + output: "ts_decorators.ts.out", +}); + +itest!(swc_syntax_error { + args: "run --reload swc_syntax_error.ts", + output: "swc_syntax_error.ts.out", + exit_code: 1, }); itest!(types { diff --git a/cli/tests/swc_syntax_error.ts b/cli/tests/swc_syntax_error.ts new file mode 100644 index 000000000..70e0de97d --- /dev/null +++ b/cli/tests/swc_syntax_error.ts @@ -0,0 +1,3 @@ +for await (const req of s) { + let something: +} diff --git a/cli/tests/swc_syntax_error.ts.out b/cli/tests/swc_syntax_error.ts.out new file mode 100644 index 000000000..0896faf68 --- /dev/null +++ b/cli/tests/swc_syntax_error.ts.out @@ -0,0 +1 @@ +error: Unexpected token Some(RBrace) at [WILDCARD]syntax_error.ts:3:0 diff --git a/cli/tests/ts_decorators.ts b/cli/tests/ts_decorators.ts new file mode 100644 index 000000000..67fd0604f --- /dev/null +++ b/cli/tests/ts_decorators.ts @@ -0,0 +1,14 @@ +/* eslint-disable */ + +function Decorate() { + return function (constructor: any): any { + return class extends constructor { + protected someField: string = "asdf"; + }; + }; +} + +@Decorate() +class SomeClass {} + +console.log(new SomeClass()); diff --git a/cli/tests/ts_decorators.ts.out b/cli/tests/ts_decorators.ts.out new file mode 100644 index 000000000..69d5937a9 --- /dev/null +++ b/cli/tests/ts_decorators.ts.out @@ -0,0 +1,2 @@ +Compile [WILDCARD] +SomeClass { someField: "asdf" } diff --git a/cli/tests/tsconfig.decorators.json b/cli/tests/tsconfig.decorators.json new file mode 100644 index 000000000..504cd646e --- /dev/null +++ b/cli/tests/tsconfig.decorators.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "experimentalDecorators": true + } +} |