fix(isolated_declarations): try fix new line issue

This commit is contained in:
Boshen 2024-09-21 01:14:40 +08:00
parent ee748b0c05
commit 9b3f763a49
No known key found for this signature in database
GPG key ID: 67715A371E534061
23 changed files with 55 additions and 2 deletions

View file

@ -29,7 +29,8 @@ fn transform(path: &Path, source_text: &str) -> String {
.build(&id_ret.program)
.source_text;
let mut snapshot = format!("==================== .D.TS ====================\n\n{code}\n\n");
let mut snapshot =
format!("```\n==================== .D.TS ====================\n\n{code}\n\n");
if !id_ret.errors.is_empty() {
let source = Arc::new(source_text.to_string());
let error_messages = id_ret
@ -41,7 +42,7 @@ fn transform(path: &Path, source_text: &str) -> String {
.join("\n");
snapshot.push_str(&format!(
"==================== Errors ====================\n\n{error_messages}\n\n"
"==================== Errors ====================\n\n{error_messages}\n\n```"
));
}

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/arrow-function-return-type.ts
---
```
==================== .D.TS ====================
declare function A(): unknown;
@ -38,3 +39,6 @@ declare const D: () => string;
: ^
10 |
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/as-const.ts
---
```
==================== .D.TS ====================
declare const F: {

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/async-function.ts
---
```
==================== .D.TS ====================
declare function asyncFunctionGood(): Promise<number>;
@ -44,3 +45,6 @@ declare class AsyncClassBad {
: ^^^^^^
26 | return 42;
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/class.ts
---
```
==================== .D.TS ====================
export declare class Foo {

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/declare-global.ts
---
```
==================== .D.TS ====================
declare function MyFunction(): string;

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/eliminate-imports.ts
---
```
==================== .D.TS ====================
import { AExtend, BExtend, Type, CImplements1, CImplements2, CType, ThisType1, ThisType2 } from "mod";

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts
---
```
==================== .D.TS ====================
type A = string;

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export2.ts
---
```
==================== .D.TS ====================
export {};

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/expando-function.ts
---
```
==================== .D.TS ====================
export declare function foo(): void;
@ -60,3 +61,6 @@ export default qux;
: ^^^^^^^^^^
11 | }
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-overloads.ts
---
```
==================== .D.TS ====================
declare function a(a: number): number;

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-parameters.ts
---
```
==================== .D.TS ====================
export declare function fnDeclGood(p?: T, rParam?: string): void;
@ -73,3 +74,6 @@ export declare function withUnknown(a: unknown, b: string): void;
: ^^^^^^^^^^^^^^^^^^^^^^^
27 | return 2;
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/generator.ts
---
```
==================== .D.TS ====================
declare function generatorGood(): Generator<number>;
@ -33,3 +34,6 @@ declare class GeneratorClassBad {
: ^^^^^^
22 | yield 50;
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-expression.ts
---
```
==================== .D.TS ====================
declare const n: number;
@ -41,3 +42,6 @@ declare const unaryE: {};
18 | const unaryE = {E: -"str"} as const
: ^^^^^^
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-return-type.ts
---
```
==================== .D.TS ====================
declare function foo(): number;
@ -21,3 +22,6 @@ declare function quux(): string;
: ^^^
15 | if (a) {
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-template-literal.ts
---
```
==================== .D.TS ====================
export declare const CSS_VARS_HELPER = "useCssVars";
@ -33,3 +34,6 @@ export declare let BAD2: unknown;
14 | export let BAD2 = `useCssV${v}ars` as const
: ^^^^
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/mapped-types.ts
---
```
==================== .D.TS ====================
import { K } from "foo";

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/module-declaration.ts
---
```
==================== .D.TS ====================
import "foo";

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/non-exported-binding-elements.ts
---
```
==================== .D.TS ====================
export declare function foo(): number;
@ -53,3 +54,6 @@ export declare const;
: ^
10 | export { c, d, e }
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/readonly.ts
---
```
==================== .D.TS ====================
export declare const EMPTY_OBJ: { readonly [key: string]: any };

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/set-get-accessor.ts
---
```
==================== .D.TS ====================
declare class Cls {
@ -28,3 +29,6 @@ declare class ClsBad {
: ^
22 | return;
`----
```

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/signatures.ts
---
```
==================== .D.TS ====================
export interface X {

View file

@ -2,6 +2,7 @@
source: crates/oxc_isolated_declarations/tests/mod.rs
input_file: crates/oxc_isolated_declarations/tests/fixtures/strip-internal.ts
---
```
==================== .D.TS ====================
declare class StripInternalClassFields {}