mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
fix(isolated_declarations): try fix new line issue
This commit is contained in:
parent
ee748b0c05
commit
9b3f763a49
23 changed files with 55 additions and 2 deletions
|
|
@ -29,7 +29,8 @@ fn transform(path: &Path, source_text: &str) -> String {
|
||||||
.build(&id_ret.program)
|
.build(&id_ret.program)
|
||||||
.source_text;
|
.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() {
|
if !id_ret.errors.is_empty() {
|
||||||
let source = Arc::new(source_text.to_string());
|
let source = Arc::new(source_text.to_string());
|
||||||
let error_messages = id_ret
|
let error_messages = id_ret
|
||||||
|
|
@ -41,7 +42,7 @@ fn transform(path: &Path, source_text: &str) -> String {
|
||||||
.join("\n");
|
.join("\n");
|
||||||
|
|
||||||
snapshot.push_str(&format!(
|
snapshot.push_str(&format!(
|
||||||
"==================== Errors ====================\n\n{error_messages}\n\n"
|
"==================== Errors ====================\n\n{error_messages}\n\n```"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/arrow-function-return-type.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/arrow-function-return-type.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare function A(): unknown;
|
declare function A(): unknown;
|
||||||
|
|
@ -38,3 +39,6 @@ declare const D: () => string;
|
||||||
: ^
|
: ^
|
||||||
10 |
|
10 |
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/as-const.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/as-const.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare const F: {
|
declare const F: {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/async-function.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/async-function.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare function asyncFunctionGood(): Promise<number>;
|
declare function asyncFunctionGood(): Promise<number>;
|
||||||
|
|
@ -44,3 +45,6 @@ declare class AsyncClassBad {
|
||||||
: ^^^^^^
|
: ^^^^^^
|
||||||
26 | return 42;
|
26 | return 42;
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/class.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/class.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
export declare class Foo {
|
export declare class Foo {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/declare-global.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/declare-global.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare function MyFunction(): string;
|
declare function MyFunction(): string;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/eliminate-imports.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/eliminate-imports.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
import { AExtend, BExtend, Type, CImplements1, CImplements2, CType, ThisType1, ThisType2 } from "mod";
|
import { AExtend, BExtend, Type, CImplements1, CImplements2, CType, ThisType1, ThisType2 } from "mod";
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
type A = string;
|
type A = string;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export2.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/empty-export2.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
export {};
|
export {};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/expando-function.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/expando-function.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
export declare function foo(): void;
|
export declare function foo(): void;
|
||||||
|
|
@ -60,3 +61,6 @@ export default qux;
|
||||||
: ^^^^^^^^^^
|
: ^^^^^^^^^^
|
||||||
11 | }
|
11 | }
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-overloads.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-overloads.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare function a(a: number): number;
|
declare function a(a: number): number;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-parameters.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/function-parameters.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
export declare function fnDeclGood(p?: T, rParam?: string): void;
|
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;
|
27 | return 2;
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/generator.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/generator.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare function generatorGood(): Generator<number>;
|
declare function generatorGood(): Generator<number>;
|
||||||
|
|
@ -33,3 +34,6 @@ declare class GeneratorClassBad {
|
||||||
: ^^^^^^
|
: ^^^^^^
|
||||||
22 | yield 50;
|
22 | yield 50;
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-expression.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-expression.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare const n: number;
|
declare const n: number;
|
||||||
|
|
@ -41,3 +42,6 @@ declare const unaryE: {};
|
||||||
18 | const unaryE = {E: -"str"} as const
|
18 | const unaryE = {E: -"str"} as const
|
||||||
: ^^^^^^
|
: ^^^^^^
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-return-type.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-return-type.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare function foo(): number;
|
declare function foo(): number;
|
||||||
|
|
@ -21,3 +22,6 @@ declare function quux(): string;
|
||||||
: ^^^
|
: ^^^
|
||||||
15 | if (a) {
|
15 | if (a) {
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-template-literal.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/infer-template-literal.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
export declare const CSS_VARS_HELPER = "useCssVars";
|
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
|
14 | export let BAD2 = `useCssV${v}ars` as const
|
||||||
: ^^^^
|
: ^^^^
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/mapped-types.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/mapped-types.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
import { K } from "foo";
|
import { K } from "foo";
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/module-declaration.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/module-declaration.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
import "foo";
|
import "foo";
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/non-exported-binding-elements.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/non-exported-binding-elements.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
export declare function foo(): number;
|
export declare function foo(): number;
|
||||||
|
|
@ -53,3 +54,6 @@ export declare const;
|
||||||
: ^
|
: ^
|
||||||
10 | export { c, d, e }
|
10 | export { c, d, e }
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/readonly.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/readonly.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
export declare const EMPTY_OBJ: { readonly [key: string]: any };
|
export declare const EMPTY_OBJ: { readonly [key: string]: any };
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/set-get-accessor.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/set-get-accessor.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare class Cls {
|
declare class Cls {
|
||||||
|
|
@ -28,3 +29,6 @@ declare class ClsBad {
|
||||||
: ^
|
: ^
|
||||||
22 | return;
|
22 | return;
|
||||||
`----
|
`----
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/signatures.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/signatures.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
export interface X {
|
export interface X {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
source: crates/oxc_isolated_declarations/tests/mod.rs
|
source: crates/oxc_isolated_declarations/tests/mod.rs
|
||||||
input_file: crates/oxc_isolated_declarations/tests/fixtures/strip-internal.ts
|
input_file: crates/oxc_isolated_declarations/tests/fixtures/strip-internal.ts
|
||||||
---
|
---
|
||||||
|
```
|
||||||
==================== .D.TS ====================
|
==================== .D.TS ====================
|
||||||
|
|
||||||
declare class StripInternalClassFields {}
|
declare class StripInternalClassFields {}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue