From eee943316053134c6de861ce77a2ad1124f094cd Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 28 Mar 2024 14:38:09 -0400 Subject: [PATCH 1/3] fix(fast_check_dts): ensure top level non-exported functions have `declare` keyword --- src/fast_check/transform_dts.rs | 128 +++++++++--------- tests/specs/graph/jsr/DynamicImport.txt | 2 +- tests/specs/graph/jsr/FastCheck.txt | 10 +- .../graph/jsr/FastCheck_AutoAccessors.txt | 4 +- .../specs/graph/jsr/FastCheck_ClassCtors.txt | 24 ++-- .../jsr/FastCheck_ClassGettersAndSetters.txt | 2 +- .../jsr/FastCheck_ClassMemberRefFound.txt | 2 +- .../FastCheck_ClassMethodsWithTsPrivate.txt | 8 +- .../graph/jsr/FastCheck_ClassProperties.txt | 8 +- .../jsr/FastCheck_ClassPropertiesLeavable.txt | 2 +- ...FastCheck_ClassPropertiesWithTsPrivate.txt | 2 +- .../FastCheck_ClassStaticMemberRefFound.txt | 2 +- .../specs/graph/jsr/FastCheck_ClassSuper.txt | 4 +- tests/specs/graph/jsr/FastCheck_Comments.txt | 2 +- .../jsr/FastCheck_CrossFileRefAliased.txt | 4 +- .../jsr/FastCheck_CrossFileRefImportType.txt | 2 +- .../jsr/FastCheck_CrossFileRefModule.txt | 4 +- .../jsr/FastCheck_DefaultExportExprVar.txt | 2 +- tests/specs/graph/jsr/FastCheck_Dts.txt | 2 +- tests/specs/graph/jsr/FastCheck_Enums.txt | 10 +- tests/specs/graph/jsr/FastCheck_Functions.txt | 12 +- .../jsr/FastCheck_InferredUniqueSymbols.txt | 2 +- .../jsr/FastCheck_InitIdentsAndMembers.txt | 2 +- .../specs/graph/jsr/FastCheck_Issue22829.txt | 6 +- tests/specs/graph/jsr/FastCheck_Methods.txt | 4 +- .../FastCheck_NestedJavaScriptDeclFile.txt | 8 +- tests/specs/graph/jsr/FastCheck_NpmTypes.txt | 2 +- .../specs/graph/jsr/FastCheck_Properties.txt | 2 +- .../specs/graph/jsr/FastCheck_RefObjType.txt | 2 +- .../graph/jsr/FastCheck_RefVarNoType.txt | 2 +- .../specs/graph/jsr/FastCheck_RefVarType.txt | 2 +- tests/specs/graph/jsr/FastCheck_TsAsConst.txt | 8 +- tests/specs/graph/jsr/FastCheck_TsModule.txt | 4 +- .../graph/jsr/FastCheck_TypeAssertion.txt | 10 +- .../graph/jsr/FastCheck_VarArrowLeavable.txt | 6 +- .../jsr/FastCheck_VarFunctionLeavable.txt | 6 +- tests/specs/graph/jsr/FastCheck_Vars.txt | 44 +++--- .../jsr/FastCheck_WorkspaceFastCheck.txt | 4 +- .../graph/jsr/SamePackageMultipleTimes.txt | 2 +- 39 files changed, 178 insertions(+), 174 deletions(-) diff --git a/src/fast_check/transform_dts.rs b/src/fast_check/transform_dts.rs index beab1ae49..908472c6a 100644 --- a/src/fast_check/transform_dts.rs +++ b/src/fast_check/transform_dts.rs @@ -161,8 +161,10 @@ impl<'a> FastCheckDtsTransformer<'a> { continue; } - if let Some(decl) = self.decl_to_type_decl(export_decl.decl.clone()) - { + if let Some(decl) = self.decl_to_type_decl( + /* is_export_decl */ true, + export_decl.decl.clone(), + ) { new_items.push(ModuleItem::ModuleDecl(ModuleDecl::ExportDecl( ExportDecl { decl, @@ -280,7 +282,10 @@ impl<'a> FastCheckDtsTransformer<'a> { | Decl::Fn(_) | Decl::Var(_) | Decl::TsModule(_) => { - if let Some(decl) = self.decl_to_type_decl(decl.clone()) { + if let Some(decl) = self.decl_to_type_decl( + /* is_export_decl */ false, + decl.clone(), + ) { new_items.push(ModuleItem::Stmt(Stmt::Decl(decl))); } else { self.mark_diagnostic_unable_to_infer(decl.range()) @@ -497,15 +502,21 @@ impl<'a> FastCheckDtsTransformer<'a> { } } - fn decl_to_type_decl(&mut self, decl: Decl) -> Option { + fn decl_to_type_decl( + &mut self, + is_export_decl: bool, + decl: Decl, + ) -> Option { + let is_declare = self.is_top_level && !is_export_decl; match decl { Decl::Class(mut class_decl) => { class_decl.class.body = self.class_body_to_type(class_decl.class.body); - class_decl.declare = self.is_top_level; + class_decl.declare = is_declare; Some(Decl::Class(class_decl)) } Decl::Fn(mut fn_decl) => { fn_decl.function.body = None; + fn_decl.declare = is_declare; for param in &mut fn_decl.function.params { match &mut param.pat { @@ -570,7 +581,7 @@ impl<'a> FastCheckDtsTransformer<'a> { Some(Decl::Fn(fn_decl)) } Decl::Var(mut var_decl) => { - var_decl.declare = self.is_top_level; + var_decl.declare = is_declare; for decl in &mut var_decl.decls { if let Pat::Ident(ident) = &mut decl.name { @@ -602,7 +613,7 @@ impl<'a> FastCheckDtsTransformer<'a> { Some(Decl::Var(var_decl)) } Decl::TsEnum(mut ts_enum) => { - ts_enum.declare = self.is_top_level; + ts_enum.declare = is_declare; for member in &mut ts_enum.members { if let Some(init) = &member.init { @@ -619,7 +630,7 @@ impl<'a> FastCheckDtsTransformer<'a> { Some(Decl::TsEnum(ts_enum)) } Decl::TsModule(mut ts_module) => { - ts_module.declare = self.is_top_level; + ts_module.declare = is_declare; if let Some(body) = ts_module.body.clone() { ts_module.body = Some(self.transform_ts_ns_body(body)); @@ -1066,7 +1077,7 @@ export function foo(a: any): number { } }"#, - r#"export declare class Foo { + r#"export class Foo { a: number; static b: number; constructor(value: string); @@ -1084,7 +1095,7 @@ export function foo(a: any): number { r#"export class Foo { constructor(...args: string[]) {} }"#, - r#"export declare class Foo { + r#"export class Foo { constructor(...args: string[]); }"#, ) @@ -1099,7 +1110,7 @@ export function foo(a: any): number { constructor(arg: number); constructor(arg: any) {} }"#, - r#"export declare class Foo { + r#"export class Foo { constructor(arg: string); constructor(arg: number); }"#, @@ -1112,7 +1123,7 @@ export function foo(a: any): number { foo(arg: number); foo(arg: any) {} }"#, - r#"export declare class Foo { + r#"export class Foo { foo(arg: string); foo(arg: number); }"#, @@ -1133,7 +1144,7 @@ export function foo(a: any): number { foo(arg: number); foo(arg: any) {} }"#, - r#"export declare class Foo { + r#"export class Foo { constructor(arg: string); constructor(arg: number); bar(arg: number): number; @@ -1148,7 +1159,7 @@ export function foo(a: any): number { async fn dts_class_decl_prop_test() { transform_dts_test( r#"export class Foo { private a!: string }"#, - r#"export declare class Foo { + r#"export class Foo { private a: string; }"#, ) @@ -1156,7 +1167,7 @@ export function foo(a: any): number { transform_dts_test( r#"export class Foo { declare a: string }"#, - r#"export declare class Foo { + r#"export class Foo { a: string; }"#, ) @@ -1167,14 +1178,14 @@ export function foo(a: any): number { async fn dts_class_decl_prop_infer_test() { transform_dts_test( r#"export class Foo { foo = (a: string): string => ({} as any) }"#, - r#"export declare class Foo { + r#"export class Foo { foo: (a: string) => string; }"#, ) .await; transform_dts_test( r#"export class Foo { foo = function(a: string): void {} }"#, - r#"export declare class Foo { + r#"export class Foo { foo: (a: string) => void; }"#, ) @@ -1185,30 +1196,29 @@ export function foo(a: any): number { async fn dts_var_decl_test() { transform_dts_test( r#"export const foo: number = 42;"#, - "export declare const foo: number;", + "export const foo: number;", ) .await; transform_dts_test( r#"export var foo: number = 42;"#, - "export declare var foo: number;", + "export var foo: number;", ) .await; transform_dts_test( r#"export let foo: number = 42;"#, - "export declare let foo: number;", + "export let foo: number;", ) .await; // Default to any if it cannot be determined transform_dts_test( r#"export const foo = adsf.b;"#, - "export declare const foo: any;", + "export const foo: any;", ) .await; - transform_dts_test(r#"export let foo;"#, "export declare let foo: any;") - .await; + transform_dts_test(r#"export let foo;"#, "export let foo: any;").await; } #[tokio::test] @@ -1232,7 +1242,7 @@ export function foo(a: any): number { async fn dts_inference() { transform_dts_test( r#"export const foo = null as string as number;"#, - "export declare const foo: number;", + "export const foo: number;", ) .await; } @@ -1241,18 +1251,18 @@ export function foo(a: any): number { async fn dts_as_const() { transform_dts_test( r#"export const foo = [1, 2] as const;"#, - "export declare const foo: readonly [1, 2];", + "export const foo: readonly [1, 2];", ) .await; transform_dts_test( r#"export const foo = [1, ,2] as const;"#, - "export declare const foo: readonly [1, any, 2];", + "export const foo: readonly [1, any, 2];", ) .await; transform_dts_test( r#"export const foo = { str: "bar", bool: true, bool2: false, num: 42, nullish: null } as const;"#, - r#"export declare const foo: { + r#"export const foo: { readonly str: "bar"; readonly bool: true; readonly bool2: false; @@ -1263,7 +1273,7 @@ export function foo(a: any): number { transform_dts_test( r#"export const foo = { str: [1, 2] as const } as const;"#, - r#"export declare const foo: { + r#"export const foo: { readonly str: readonly [1, 2]; };"#, ) @@ -1272,7 +1282,7 @@ export function foo(a: any): number { // TODO: Requires type resolving transform_dts_test( r#"export const foo = { bar } as const;"#, - r#"export declare const foo: { + r#"export const foo: { };"#, ) .await; @@ -1282,17 +1292,17 @@ export function foo(a: any): number { async fn dts_literal_inference_ann() { transform_dts_test( r#"export const foo: number = "abc";"#, - "export declare const foo: number;", + "export const foo: number;", ) .await; transform_dts_test( r#"export let foo: number = "abc";"#, - "export declare let foo: number;", + "export let foo: number;", ) .await; transform_dts_test( r#"export var foo: number = "abc";"#, - "export declare var foo: number;", + "export var foo: number;", ) .await; } @@ -1301,44 +1311,38 @@ export function foo(a: any): number { async fn dts_literal_inference() { transform_dts_test( r#"export const foo = 42;"#, - "export declare const foo: number;", + "export const foo: number;", ) .await; transform_dts_test( r#"export const foo = "foo";"#, - "export declare const foo: string;", + "export const foo: string;", ) .await; transform_dts_test( r#"export const foo = true;"#, - "export declare const foo: boolean;", + "export const foo: boolean;", ) .await; transform_dts_test( r#"export const foo = false;"#, - "export declare const foo: boolean;", + "export const foo: boolean;", ) .await; transform_dts_test( r#"export const foo = null;"#, - "export declare const foo: null;", + "export const foo: null;", ) .await; transform_dts_test( r#"export let foo = undefined;"#, - "export declare let foo: any;", - ) - .await; - transform_dts_test( - r#"export let foo = 10n;"#, - "export declare let foo: bigint;", - ) - .await; - transform_dts_test( - r#"export let foo = /foo/;"#, - "export declare let foo: RegExp;", + "export let foo: any;", ) .await; + transform_dts_test(r#"export let foo = 10n;"#, "export let foo: bigint;") + .await; + transform_dts_test(r#"export let foo = /foo/;"#, "export let foo: RegExp;") + .await; } #[tokio::test] @@ -1347,27 +1351,27 @@ export function foo(a: any): number { r#"export let foo = function add(a: number, b: number): number { return a + b; }"#, - "export declare let foo: (a: number, b: number) => number;", + "export let foo: (a: number, b: number) => number;", ) .await; transform_dts_test( r#"export let foo = function add([a, b]: T): void {}"#, - "export declare let foo: ([a, b]: T) => void;", + "export let foo: ([a, b]: T) => void;", ) .await; transform_dts_test( r#"export let foo = function add({a, b}: T): void {}"#, - "export declare let foo: ({ a, b }: T) => void;", + "export let foo: ({ a, b }: T) => void;", ) .await; transform_dts_test( r#"export let foo = function add(a = 2): void {}"#, - "export declare let foo: (a: number) => void;", + "export let foo: (a: number) => void;", ) .await; transform_dts_test( r#"export let foo = function add(...params: any[]): void {}"#, - "export declare let foo: (...params: any[]) => void;", + "export let foo: (...params: any[]) => void;", ) .await; } @@ -1378,28 +1382,28 @@ export function foo(a: any): number { r#"export let foo = (a: number, b: number): number => { return a + b; }"#, - "export declare let foo: (a: number, b: number) => number;", + "export let foo: (a: number, b: number) => number;", ) .await; transform_dts_test( r#"export let foo = ([a, b]: T): void => {}"#, - "export declare let foo: ([a, b]: T) => void;", + "export let foo: ([a, b]: T) => void;", ) .await; transform_dts_test( r#"export let foo = ({a, b}: T): void => {}"#, - "export declare let foo: ({ a, b }: T) => void;", + "export let foo: ({ a, b }: T) => void;", ) .await; transform_dts_test( r#"export let foo = (a = 2): void => {}"#, - "export declare let foo: (a: number) => void;", + "export let foo: (a: number) => void;", ) .await; transform_dts_test( r#"export let foo = (...params: any[]): void => {}"#, - "export declare let foo: (...params: any[]) => void;", + "export let foo: (...params: any[]) => void;", ) .await; } @@ -1425,18 +1429,18 @@ export function foo(a: any): number { async fn dts_enum_export() { transform_dts_test( r#"export enum Foo { A, B }"#, - "export declare enum Foo {\n A,\n B\n}", + "export enum Foo {\n A,\n B\n}", ) .await; transform_dts_test( r#"export const enum Foo { A, B }"#, - "export declare const enum Foo {\n A,\n B\n}", + "export const enum Foo {\n A,\n B\n}", ) .await; transform_dts_test( r#"export enum Foo { A = "foo", B = "bar" }"#, - r#"export declare enum Foo { + r#"export enum Foo { A = "foo", B = "bar" }"#, @@ -1506,7 +1510,7 @@ export default _dts_1;"#, transform_dts_test( r#"import { foo } from "bar";export const foobar = foo;"#, r#"import { foo } from "bar"; -export declare const foobar: any;"#, +export const foobar: any;"#, ) .await; } diff --git a/tests/specs/graph/jsr/DynamicImport.txt b/tests/specs/graph/jsr/DynamicImport.txt index 3744a472c..116302fe4 100644 --- a/tests/specs/graph/jsr/DynamicImport.txt +++ b/tests/specs/graph/jsr/DynamicImport.txt @@ -105,7 +105,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: export class Test { } --- DTS --- - export declare class Test { + export class Test { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: diff --git a/tests/specs/graph/jsr/FastCheck.txt b/tests/specs/graph/jsr/FastCheck.txt index a1eb0a877..2db086d29 100644 --- a/tests/specs/graph/jsr/FastCheck.txt +++ b/tests/specs/graph/jsr/FastCheck.txt @@ -212,9 +212,9 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: export { A4 } from "./a4.ts"; export * from "./a6.ts"; --- DTS --- - export declare class A1 { + export class A1 { } - export declare class A3 { + export class A3 { } export { A4 } from "./a4.ts"; export * from "./a6.ts"; @@ -224,7 +224,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a4.ts: export class A4 { } --- DTS --- - export declare class A4 { + export class A4 { } Fast check https://jsr.io/@scope/a/1.0.0/a6.ts: @@ -232,7 +232,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a6.ts: export class A6 { } --- DTS --- - export declare class A6 { + export class A6 { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: @@ -269,7 +269,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- import { A1, A3 as RenamedA3, A4, A6 } from "./a.ts"; - export declare class Test { + export class Test { /** Testing */ noReturnTypeVoid(param?: number, param2?: string): void; noReturnTypeAsync(): Promise; returnTypeGenerator(): Generator; diff --git a/tests/specs/graph/jsr/FastCheck_AutoAccessors.txt b/tests/specs/graph/jsr/FastCheck_AutoAccessors.txt index 7cc1b4bc7..b3a15629f 100644 --- a/tests/specs/graph/jsr/FastCheck_AutoAccessors.txt +++ b/tests/specs/graph/jsr/FastCheck_AutoAccessors.txt @@ -81,12 +81,12 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: #private!: unknown; } --- DTS --- - export declare class AutoAccessor { + export class AutoAccessor { /** Some comment */ public_accessor: string; private private_accessor: any; static static_accessor: number; private static private_static: any; private static private_static_unanalyzable: any; } - export declare class PrivateAccessor { + export class PrivateAccessor { } diff --git a/tests/specs/graph/jsr/FastCheck_ClassCtors.txt b/tests/specs/graph/jsr/FastCheck_ClassCtors.txt index fca176bcd..4afe00302 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassCtors.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassCtors.txt @@ -176,47 +176,47 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: class Public5 { } --- DTS --- - /** A */ export declare class ClassBasic { + /** A */ export class ClassBasic { /** B */ constructor(prop: string, other?: number); } - export declare class ClassPrivateCtor { + export class ClassPrivateCtor { private constructor(); } - export declare class ClassPrivateCtorWithOverloads { + export class ClassPrivateCtorWithOverloads { private constructor(); } - export declare class ClassDeclarePrivateCtor { + export class ClassDeclarePrivateCtor { private constructor(prop: string, other: Private1); } - export declare class ClassProtectedCtor { + export class ClassProtectedCtor { protected constructor(prop: string, other?: number); } - export declare class ClassProtectedCtorWithOverloads { + export class ClassProtectedCtorWithOverloads { protected constructor(prop: Public1); } - export declare class ClassCtorWithOverloads { + export class ClassCtorWithOverloads { constructor(prop: Public1); } - export declare class ClassPrivateCtorPublicParamProp { + export class ClassPrivateCtorPublicParamProp { param1: Public2; private param2: any; private constructor(); } - export declare class ClassCtorPublicParamProp { + export class ClassCtorPublicParamProp { param1: Public3; private param2: any; private param3: any; constructor(param1: Public3, param2: Public4, param3?: Public5); } - export declare class ClassCtorPublicParamPropInit { + export class ClassCtorPublicParamPropInit { param1: Public3; constructor(param1?: Public3); } - export declare class ClassCtorPublicParamPropOptional { + export class ClassCtorPublicParamPropOptional { param1?: string; constructor(param1?: string); } - export declare class AmbientClassCtor { + export class AmbientClassCtor { constructor(public param: string, private value: number); constructor(public param: string); } diff --git a/tests/specs/graph/jsr/FastCheck_ClassGettersAndSetters.txt b/tests/specs/graph/jsr/FastCheck_ClassGettersAndSetters.txt index c9a18b238..daaf3d26f 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassGettersAndSetters.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassGettersAndSetters.txt @@ -72,7 +72,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: set value(_value: string) {} } --- DTS --- - export declare class MyClass { + export class MyClass { get value(): string; set value(_value: string); } diff --git a/tests/specs/graph/jsr/FastCheck_ClassMemberRefFound.txt b/tests/specs/graph/jsr/FastCheck_ClassMemberRefFound.txt index f4c5d7562..5ac38492c 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassMemberRefFound.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassMemberRefFound.txt @@ -69,7 +69,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: declare prop: string; } --- DTS --- - export declare class Export { + export class Export { prop: typeof Public1.prototype.prop; } declare class Public1 { diff --git a/tests/specs/graph/jsr/FastCheck_ClassMethodsWithTsPrivate.txt b/tests/specs/graph/jsr/FastCheck_ClassMethodsWithTsPrivate.txt index 18a263f40..dfe017294 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassMethodsWithTsPrivate.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassMethodsWithTsPrivate.txt @@ -169,14 +169,14 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: private override test!: any; } --- DTS --- - export declare class PrivateMethodOverloadable { + export class PrivateMethodOverloadable { private constructor(); private method: any; private methodWithOverload: any; private "stringAndIdent": any; private "stringOnly": any; } - export declare class AmbientPrivateMethodOverloadable { + export class AmbientPrivateMethodOverloadable { private constructor(value: string); private constructor(private: Private); private method(value: string): string; @@ -187,7 +187,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: private "stringOnly"(value: string): string; private "stringOnly"(): string; } - export declare module Test { + export module Test { export class AmbientClassInModule { private constructor(value: string); private constructor(private: Private); @@ -195,6 +195,6 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } declare class Base { } - export declare class TsPrivateMethodWithOverrideKeyword extends Base { + export class TsPrivateMethodWithOverrideKeyword extends Base { private override test: any; } diff --git a/tests/specs/graph/jsr/FastCheck_ClassProperties.txt b/tests/specs/graph/jsr/FastCheck_ClassProperties.txt index 3c8e39e3b..941733976 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassProperties.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassProperties.txt @@ -122,7 +122,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: override foo!: string; } --- DTS --- - export declare class RedBlackNode extends BinarySearchNode { + export class RedBlackNode extends BinarySearchNode { parent: RedBlackNode | null; left: RedBlackNode | null; right: RedBlackNode | null; @@ -132,14 +132,14 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } declare const isSecure: Symbol; declare const public2: Symbol; - export declare class CookieMapBase { + export class CookieMapBase { [isSecure]: boolean; [public2](): number; } - export declare class Bar { + export class Bar { abstract foo: string; bar: number; } - export declare class Baz extends Bar { + export class Baz extends Bar { override foo: string; } diff --git a/tests/specs/graph/jsr/FastCheck_ClassPropertiesLeavable.txt b/tests/specs/graph/jsr/FastCheck_ClassPropertiesLeavable.txt index 530434c83..c4c4693a5 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassPropertiesLeavable.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassPropertiesLeavable.txt @@ -125,7 +125,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- import type { Foo, Bar } from "./b.ts"; - export declare class Foo { + export class Foo { fizz: (a: string) => string; foo: () => Foo; bar: (b: Bar) => number; diff --git a/tests/specs/graph/jsr/FastCheck_ClassPropertiesWithTsPrivate.txt b/tests/specs/graph/jsr/FastCheck_ClassPropertiesWithTsPrivate.txt index b7616aa06..6fd83e571 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassPropertiesWithTsPrivate.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassPropertiesWithTsPrivate.txt @@ -73,7 +73,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: --- DTS --- declare class Base { } - export declare class WithTsPrivate extends Base { + export class WithTsPrivate extends Base { private regular: any; private override withOverride: any; } diff --git a/tests/specs/graph/jsr/FastCheck_ClassStaticMemberRefFound.txt b/tests/specs/graph/jsr/FastCheck_ClassStaticMemberRefFound.txt index 95410ffab..298b555fa 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassStaticMemberRefFound.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassStaticMemberRefFound.txt @@ -69,7 +69,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: declare static prop: string; } --- DTS --- - export declare class Export { + export class Export { prop: typeof Public1.prop; } declare class Public1 { diff --git a/tests/specs/graph/jsr/FastCheck_ClassSuper.txt b/tests/specs/graph/jsr/FastCheck_ClassSuper.txt index adb3ab7e8..90ae61521 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassSuper.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassSuper.txt @@ -94,12 +94,12 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: declare class Base { constructor(a: number, b: number); } - export declare class Child extends Base { + export class Child extends Base { constructor(); } declare class SpreadBase { constructor(...params: string[]); } - export declare class SpreadChild extends SpreadBase { + export class SpreadChild extends SpreadBase { constructor(); } diff --git a/tests/specs/graph/jsr/FastCheck_Comments.txt b/tests/specs/graph/jsr/FastCheck_Comments.txt index aa0622b2d..6cbf27a57 100644 --- a/tests/specs/graph/jsr/FastCheck_Comments.txt +++ b/tests/specs/graph/jsr/FastCheck_Comments.txt @@ -64,4 +64,4 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export const value1: number = {} as any; --- DTS --- // @ts-ignore broken line - export declare const value1: number; + export const value1: number; diff --git a/tests/specs/graph/jsr/FastCheck_CrossFileRefAliased.txt b/tests/specs/graph/jsr/FastCheck_CrossFileRefAliased.txt index 45214c038..ff5e9f36b 100644 --- a/tests/specs/graph/jsr/FastCheck_CrossFileRefAliased.txt +++ b/tests/specs/graph/jsr/FastCheck_CrossFileRefAliased.txt @@ -141,7 +141,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: declare member: string; } --- DTS --- - export declare class A { + export class A { member: string; } @@ -191,6 +191,6 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- import { B } from "./b.ts"; - export declare class Export { + export class Export { prop: typeof B.prototype.member; } diff --git a/tests/specs/graph/jsr/FastCheck_CrossFileRefImportType.txt b/tests/specs/graph/jsr/FastCheck_CrossFileRefImportType.txt index a978bd4c0..f95123d20 100644 --- a/tests/specs/graph/jsr/FastCheck_CrossFileRefImportType.txt +++ b/tests/specs/graph/jsr/FastCheck_CrossFileRefImportType.txt @@ -92,7 +92,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: --- DTS --- export default class Test { } - export declare class A { + export class A { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: diff --git a/tests/specs/graph/jsr/FastCheck_CrossFileRefModule.txt b/tests/specs/graph/jsr/FastCheck_CrossFileRefModule.txt index f0735559a..9a76d08a0 100644 --- a/tests/specs/graph/jsr/FastCheck_CrossFileRefModule.txt +++ b/tests/specs/graph/jsr/FastCheck_CrossFileRefModule.txt @@ -144,7 +144,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: declare member2: string; } --- DTS --- - export declare class A { + export class A { member: string; member2: string; } @@ -196,7 +196,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- import * as mod from "./b.ts"; - export declare class Export { + export class Export { prop: typeof mod.B.prototype.member; prop2: typeof mod.B.prototype.member2; } diff --git a/tests/specs/graph/jsr/FastCheck_DefaultExportExprVar.txt b/tests/specs/graph/jsr/FastCheck_DefaultExportExprVar.txt index 48810576e..969fa6c46 100644 --- a/tests/specs/graph/jsr/FastCheck_DefaultExportExprVar.txt +++ b/tests/specs/graph/jsr/FastCheck_DefaultExportExprVar.txt @@ -73,5 +73,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export interface $Type { prop: boolean; } - export declare const $: $Type; + export const $: $Type; export default $; diff --git a/tests/specs/graph/jsr/FastCheck_Dts.txt b/tests/specs/graph/jsr/FastCheck_Dts.txt index 53bc984af..988076f65 100644 --- a/tests/specs/graph/jsr/FastCheck_Dts.txt +++ b/tests/specs/graph/jsr/FastCheck_Dts.txt @@ -129,7 +129,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.d.ts: declare function random(): number; declare var public: number; --- DTS --- - export declare class Test { + export class Test { prop: typeof random; method(): typeof public; static prop: number; diff --git a/tests/specs/graph/jsr/FastCheck_Enums.txt b/tests/specs/graph/jsr/FastCheck_Enums.txt index 445d9a51c..4e6751d25 100644 --- a/tests/specs/graph/jsr/FastCheck_Enums.txt +++ b/tests/specs/graph/jsr/FastCheck_Enums.txt @@ -132,20 +132,20 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: I = 1 + NUM } --- DTS --- - export declare enum EnumWithNoInits { + export enum EnumWithNoInits { Value1, Value2 } - export declare enum EnumWithNumInits { + export enum EnumWithNumInits { Value1 = 1, Value2 = 2 } - export declare enum EnumWithStringInits { + export enum EnumWithStringInits { Value1 = "a", Value2 = "b" } declare const value: number; - export declare enum EnumWithNonConstInits { + export enum EnumWithNonConstInits { Value1, Value2 } @@ -157,7 +157,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: Value } declare const NUM: any; - export declare enum Foo1 { + export enum Foo1 { A = 1, B = "2", C = 1 << 2, diff --git a/tests/specs/graph/jsr/FastCheck_Functions.txt b/tests/specs/graph/jsr/FastCheck_Functions.txt index 9d216a850..c74426521 100644 --- a/tests/specs/graph/jsr/FastCheck_Functions.txt +++ b/tests/specs/graph/jsr/FastCheck_Functions.txt @@ -192,9 +192,9 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export function test6(param?: number): T; export function test7(param?: number): number; export function test7(param?: number, param2?: PublicOther2): number; - function test8(param: number): number; - function test8(param: string): string; - function test8(param0?: any): any; + declare function test8(param: number): number; + declare function test8(param: string): string; + declare function test8(param0?: any): any; export { test8 }; export default function test9(param: number): number; export default function test9(param: string): string; @@ -214,6 +214,6 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } declare class PublicDeclareFunc { } - export declare function declareFunc(param: number): number; - export declare function declareFunc(param: string): string; - export declare function declareFunc(param: PublicDeclareFunc): string; + export function declareFunc(param: number): number; + export function declareFunc(param: string): string; + export function declareFunc(param: PublicDeclareFunc): string; diff --git a/tests/specs/graph/jsr/FastCheck_InferredUniqueSymbols.txt b/tests/specs/graph/jsr/FastCheck_InferredUniqueSymbols.txt index b065e2d18..7f8924f61 100644 --- a/tests/specs/graph/jsr/FastCheck_InferredUniqueSymbols.txt +++ b/tests/specs/graph/jsr/FastCheck_InferredUniqueSymbols.txt @@ -72,7 +72,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: --- DTS --- declare const key: unique symbol; declare const key2: unique symbol; - export declare class MyClass { + export class MyClass { [key]: number; [key2]: string; } diff --git a/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt b/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt index 0b3495d62..af3f38ffe 100644 --- a/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt +++ b/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt @@ -144,7 +144,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export class A { } } - export declare const handlers: { + export const handlers: { readonly Private; readonly C; }; diff --git a/tests/specs/graph/jsr/FastCheck_Issue22829.txt b/tests/specs/graph/jsr/FastCheck_Issue22829.txt index 06c0ef09f..884739be3 100644 --- a/tests/specs/graph/jsr/FastCheck_Issue22829.txt +++ b/tests/specs/graph/jsr/FastCheck_Issue22829.txt @@ -118,12 +118,12 @@ Fast check https://jsr.io/@scope/a/1.0.0/functions.ts: declare abstract class Internal { prop: T; } - function func(): void; + declare function func(): void; export function other_func(): void; - export declare const functions: { + export const functions: { readonly other; }; - export declare module functions { + export module functions { type Function = Internal; } --- DTS Diagnostics --- diff --git a/tests/specs/graph/jsr/FastCheck_Methods.txt b/tests/specs/graph/jsr/FastCheck_Methods.txt index f555c3895..84ea5fd4a 100644 --- a/tests/specs/graph/jsr/FastCheck_Methods.txt +++ b/tests/specs/graph/jsr/FastCheck_Methods.txt @@ -141,7 +141,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: class PublicOther2 { } --- DTS --- - export declare class Test { + export class Test { test1(): void; test2(): number; test3(param: number): number; @@ -153,7 +153,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: test8(param: number): number; test8(param: string): string; } - export declare class Test2 { + export class Test2 { public method1(): void; protected method2(): void; private tsPrivateMethod: any; diff --git a/tests/specs/graph/jsr/FastCheck_NestedJavaScriptDeclFile.txt b/tests/specs/graph/jsr/FastCheck_NestedJavaScriptDeclFile.txt index 8c4621a71..c6045d977 100644 --- a/tests/specs/graph/jsr/FastCheck_NestedJavaScriptDeclFile.txt +++ b/tests/specs/graph/jsr/FastCheck_NestedJavaScriptDeclFile.txt @@ -190,12 +190,12 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.d.ts: export class A3 { } --- DTS --- - export declare class A1 { + export class A1 { method(): string; } - export declare class A2 { + export class A2 { } - export declare class A3 { + export class A3 { } Fast check https://jsr.io/@scope/a/1.0.0/b.d.ts: @@ -204,7 +204,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/b.d.ts: prop: string; } --- DTS --- - export declare class B1 { + export class B1 { prop: string; } diff --git a/tests/specs/graph/jsr/FastCheck_NpmTypes.txt b/tests/specs/graph/jsr/FastCheck_NpmTypes.txt index ee47348c2..25ccfaaaa 100644 --- a/tests/specs/graph/jsr/FastCheck_NpmTypes.txt +++ b/tests/specs/graph/jsr/FastCheck_NpmTypes.txt @@ -134,5 +134,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- export * from "./a.js"; - export declare class Other { + export class Other { } diff --git a/tests/specs/graph/jsr/FastCheck_Properties.txt b/tests/specs/graph/jsr/FastCheck_Properties.txt index 58514a7c7..4e629e1f5 100644 --- a/tests/specs/graph/jsr/FastCheck_Properties.txt +++ b/tests/specs/graph/jsr/FastCheck_Properties.txt @@ -86,7 +86,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: class PublicOther2 { } --- DTS --- - export declare class Test { + export class Test { prop1: PublicOther; protected prop2?: PublicOther2; private prop3: any; diff --git a/tests/specs/graph/jsr/FastCheck_RefObjType.txt b/tests/specs/graph/jsr/FastCheck_RefObjType.txt index 1557cc598..fb36b826e 100644 --- a/tests/specs/graph/jsr/FastCheck_RefObjType.txt +++ b/tests/specs/graph/jsr/FastCheck_RefObjType.txt @@ -76,7 +76,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: }; export type Status = typeof STATUS_CODE.Continue; --- DTS --- - export declare const STATUS_CODE: { + export const STATUS_CODE: { readonly /** RFC 7231, 6.2.1 */ Continue: number; readonly /** RFC 7231, 6.2.2 */ SwitchingProtocols: number; readonly /** RFC 2518, 10.1 */ Processing: number; diff --git a/tests/specs/graph/jsr/FastCheck_RefVarNoType.txt b/tests/specs/graph/jsr/FastCheck_RefVarNoType.txt index 68d9c8e99..5e7f6be40 100644 --- a/tests/specs/graph/jsr/FastCheck_RefVarNoType.txt +++ b/tests/specs/graph/jsr/FastCheck_RefVarNoType.txt @@ -68,7 +68,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: }; export type Status = typeof symbols.writable; --- DTS --- - export declare const symbols: { + export const symbols: { readonly writable: () => void; readonly readable: number; }; diff --git a/tests/specs/graph/jsr/FastCheck_RefVarType.txt b/tests/specs/graph/jsr/FastCheck_RefVarType.txt index 2be095226..cd93e3323 100644 --- a/tests/specs/graph/jsr/FastCheck_RefVarType.txt +++ b/tests/specs/graph/jsr/FastCheck_RefVarType.txt @@ -73,5 +73,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: interface Symbols { readable: unique symbol; } - export declare const symbols: Symbols; + export const symbols: Symbols; export type Status = typeof symbols.readable; diff --git a/tests/specs/graph/jsr/FastCheck_TsAsConst.txt b/tests/specs/graph/jsr/FastCheck_TsAsConst.txt index c818b8a78..b9fcbeacc 100644 --- a/tests/specs/graph/jsr/FastCheck_TsAsConst.txt +++ b/tests/specs/graph/jsr/FastCheck_TsAsConst.txt @@ -91,16 +91,16 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: ...obj } as const; --- DTS --- - export declare const foo: readonly [1, 2]; - export declare const bar: readonly [1, any, 2]; - export declare const obj: { + export const foo: readonly [1, 2]; + export const bar: readonly [1, any, 2]; + export const obj: { readonly str: "bar"; readonly bool: true; readonly bool2: false; readonly num: 42; readonly nullish: null; }; - export declare const spread: { + export const spread: { readonly foo: 1; }; --- DTS Diagnostics --- diff --git a/tests/specs/graph/jsr/FastCheck_TsModule.txt b/tests/specs/graph/jsr/FastCheck_TsModule.txt index 68c914071..0e945b7b7 100644 --- a/tests/specs/graph/jsr/FastCheck_TsModule.txt +++ b/tests/specs/graph/jsr/FastCheck_TsModule.txt @@ -78,9 +78,9 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: class Public1 { } --- DTS --- - export declare module Test { + export module Test { } - export declare module Test { + export module Test { export class MyClass2 extends Public1 { } } diff --git a/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt b/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt index 45feda660..9dc782012 100644 --- a/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt +++ b/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt @@ -125,20 +125,20 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: data: Public7; } = {} as any; --- DTS --- - export declare class Application { + export class Application { prop: S; } - export declare const str: "foo" & { + export const str: "foo" & { __brand: "foo"; }; export function createMockApp = Record>(state?: S): Application; - export declare class A { + export class A { prop: Public1; constructor(prop?: Public1); handler: Public2; secondProp: Public4; } - export declare const var1: Public5; + export const var1: Public5; interface Public1 { } interface Public2 { @@ -153,6 +153,6 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } declare class Public7 { } - export declare const str2: "foo" & { + export const str2: "foo" & { data: Public7; }; diff --git a/tests/specs/graph/jsr/FastCheck_VarArrowLeavable.txt b/tests/specs/graph/jsr/FastCheck_VarArrowLeavable.txt index f1029422b..c47f9c7da 100644 --- a/tests/specs/graph/jsr/FastCheck_VarArrowLeavable.txt +++ b/tests/specs/graph/jsr/FastCheck_VarArrowLeavable.txt @@ -93,7 +93,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/b.ts: } --- DTS --- export type Foo = string; - export declare class Bar { + export class Bar { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: @@ -119,5 +119,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export const bar = (): Bar =>({} as any); --- DTS --- import type { Foo, Bar } from "./b.ts"; - export declare const foo: (foo: Foo) => string; - export declare const bar: () => Bar; + export const foo: (foo: Foo) => string; + export const bar: () => Bar; diff --git a/tests/specs/graph/jsr/FastCheck_VarFunctionLeavable.txt b/tests/specs/graph/jsr/FastCheck_VarFunctionLeavable.txt index cd17e14ba..943309665 100644 --- a/tests/specs/graph/jsr/FastCheck_VarFunctionLeavable.txt +++ b/tests/specs/graph/jsr/FastCheck_VarFunctionLeavable.txt @@ -93,7 +93,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/b.ts: } --- DTS --- export type Foo = string; - export declare class Bar { + export class Bar { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: @@ -123,5 +123,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: }; --- DTS --- import type { Foo, Bar } from "./b.ts"; - export declare const foo: (foo: Foo) => string; - export declare const bar: () => Bar; + export const foo: (foo: Foo) => string; + export const bar: () => Bar; diff --git a/tests/specs/graph/jsr/FastCheck_Vars.txt b/tests/specs/graph/jsr/FastCheck_Vars.txt index 770cd7e04..1ad1617d5 100644 --- a/tests/specs/graph/jsr/FastCheck_Vars.txt +++ b/tests/specs/graph/jsr/FastCheck_Vars.txt @@ -182,8 +182,8 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: readonly "Forbidden": 403; }; export type ErrorStatusKeys = keyof typeof ERROR_STATUS_MAP; - export declare const asIs1: readonly [number, number, number]; - export declare const asIs2: { + export const asIs1: readonly [number, number, number]; + export const asIs2: { readonly a: readonly [number, number, number]; readonly b: boolean; readonly c: number; @@ -194,23 +194,23 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: readonly g; readonly h: readonly [readonly [number, number], readonly [string]]; }; - export declare const func1: () => string; - export declare const func2: () => string; - export declare const func3: () => string; - export declare const func4: () => any; - export declare const func5: () => Promise; - export declare const func6: () => Promise<1>; - export declare const func7: () => Promise<1>; - export declare const func8: () => any; - export declare const inferred1: 1; - export declare const inferred2: string; - export declare const inferred3: true; - export declare const inferred4: RegExp; - export declare const inferred5: boolean; - export declare const inferred6: boolean; - export declare const inferred7: 1 | 2 | 3 & 4; - export declare const inferred8: ["test", 1]; - export declare const inferred9: [...string]; - export declare const inferred10: (1 | 2n)[]; - export declare const inferred11: (keyof string)[]; - export declare const inferred12: number; + export const func1: () => string; + export const func2: () => string; + export const func3: () => string; + export const func4: () => any; + export const func5: () => Promise; + export const func6: () => Promise<1>; + export const func7: () => Promise<1>; + export const func8: () => any; + export const inferred1: 1; + export const inferred2: string; + export const inferred3: true; + export const inferred4: RegExp; + export const inferred5: boolean; + export const inferred6: boolean; + export const inferred7: 1 | 2 | 3 & 4; + export const inferred8: ["test", 1]; + export const inferred9: [...string]; + export const inferred10: (1 | 2n)[]; + export const inferred11: (keyof string)[]; + export const inferred12: number; diff --git a/tests/specs/graph/jsr/FastCheck_WorkspaceFastCheck.txt b/tests/specs/graph/jsr/FastCheck_WorkspaceFastCheck.txt index 33982e19e..19d3a259c 100644 --- a/tests/specs/graph/jsr/FastCheck_WorkspaceFastCheck.txt +++ b/tests/specs/graph/jsr/FastCheck_WorkspaceFastCheck.txt @@ -132,7 +132,7 @@ Fast check file:///mod.ts: } --- DTS --- import { C } from "jsr:@scope/c"; - export declare class MyClass { + export class MyClass { prop: Public1; c: C; } @@ -144,5 +144,5 @@ Fast check https://jsr.io/@scope/c/1.0.0/mod.ts: export class C { } --- DTS --- - export declare class C { + export class C { } diff --git a/tests/specs/graph/jsr/SamePackageMultipleTimes.txt b/tests/specs/graph/jsr/SamePackageMultipleTimes.txt index b33d721ec..99d14db36 100644 --- a/tests/specs/graph/jsr/SamePackageMultipleTimes.txt +++ b/tests/specs/graph/jsr/SamePackageMultipleTimes.txt @@ -159,6 +159,6 @@ Fast check https://jsr.io/@scope/b/1.1.0/mod.ts: method(value: string): void {} } --- DTS --- - export declare class Test { + export class Test { method(value: string): void; } From ed881ee328caccad39ceba8f253d9f4e705161d4 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 28 Mar 2024 15:57:09 -0400 Subject: [PATCH 2/3] Partial revert --- src/fast_check/transform_dts.rs | 120 +++++++++--------- tests/specs/graph/jsr/DynamicImport.txt | 2 +- tests/specs/graph/jsr/FastCheck.txt | 10 +- .../graph/jsr/FastCheck_AutoAccessors.txt | 4 +- .../specs/graph/jsr/FastCheck_ClassCtors.txt | 24 ++-- .../jsr/FastCheck_ClassGettersAndSetters.txt | 2 +- .../jsr/FastCheck_ClassMemberRefFound.txt | 2 +- .../FastCheck_ClassMethodsWithTsPrivate.txt | 8 +- .../graph/jsr/FastCheck_ClassProperties.txt | 8 +- .../jsr/FastCheck_ClassPropertiesLeavable.txt | 2 +- ...FastCheck_ClassPropertiesWithTsPrivate.txt | 2 +- .../FastCheck_ClassStaticMemberRefFound.txt | 2 +- .../specs/graph/jsr/FastCheck_ClassSuper.txt | 4 +- tests/specs/graph/jsr/FastCheck_Comments.txt | 2 +- .../jsr/FastCheck_CrossFileRefAliased.txt | 4 +- .../jsr/FastCheck_CrossFileRefImportType.txt | 2 +- .../jsr/FastCheck_CrossFileRefModule.txt | 4 +- .../jsr/FastCheck_DefaultExportExprVar.txt | 2 +- tests/specs/graph/jsr/FastCheck_Dts.txt | 2 +- tests/specs/graph/jsr/FastCheck_Enums.txt | 10 +- tests/specs/graph/jsr/FastCheck_Functions.txt | 12 +- .../jsr/FastCheck_InferredUniqueSymbols.txt | 2 +- .../jsr/FastCheck_InitIdentsAndMembers.txt | 2 +- .../specs/graph/jsr/FastCheck_Issue22829.txt | 6 +- tests/specs/graph/jsr/FastCheck_Methods.txt | 4 +- .../FastCheck_NestedJavaScriptDeclFile.txt | 8 +- tests/specs/graph/jsr/FastCheck_NpmTypes.txt | 2 +- .../specs/graph/jsr/FastCheck_Properties.txt | 2 +- .../specs/graph/jsr/FastCheck_RefObjType.txt | 2 +- .../graph/jsr/FastCheck_RefVarNoType.txt | 2 +- .../specs/graph/jsr/FastCheck_RefVarType.txt | 2 +- tests/specs/graph/jsr/FastCheck_TsAsConst.txt | 8 +- tests/specs/graph/jsr/FastCheck_TsModule.txt | 4 +- .../graph/jsr/FastCheck_TypeAssertion.txt | 10 +- .../graph/jsr/FastCheck_VarArrowLeavable.txt | 6 +- .../jsr/FastCheck_VarFunctionLeavable.txt | 6 +- tests/specs/graph/jsr/FastCheck_Vars.txt | 44 +++---- .../jsr/FastCheck_WorkspaceFastCheck.txt | 4 +- .../graph/jsr/SamePackageMultipleTimes.txt | 2 +- 39 files changed, 171 insertions(+), 173 deletions(-) diff --git a/src/fast_check/transform_dts.rs b/src/fast_check/transform_dts.rs index 908472c6a..d0a4152fe 100644 --- a/src/fast_check/transform_dts.rs +++ b/src/fast_check/transform_dts.rs @@ -161,10 +161,8 @@ impl<'a> FastCheckDtsTransformer<'a> { continue; } - if let Some(decl) = self.decl_to_type_decl( - /* is_export_decl */ true, - export_decl.decl.clone(), - ) { + if let Some(decl) = self.decl_to_type_decl(export_decl.decl.clone()) + { new_items.push(ModuleItem::ModuleDecl(ModuleDecl::ExportDecl( ExportDecl { decl, @@ -282,10 +280,7 @@ impl<'a> FastCheckDtsTransformer<'a> { | Decl::Fn(_) | Decl::Var(_) | Decl::TsModule(_) => { - if let Some(decl) = self.decl_to_type_decl( - /* is_export_decl */ false, - decl.clone(), - ) { + if let Some(decl) = self.decl_to_type_decl(decl.clone()) { new_items.push(ModuleItem::Stmt(Stmt::Decl(decl))); } else { self.mark_diagnostic_unable_to_infer(decl.range()) @@ -502,12 +497,8 @@ impl<'a> FastCheckDtsTransformer<'a> { } } - fn decl_to_type_decl( - &mut self, - is_export_decl: bool, - decl: Decl, - ) -> Option { - let is_declare = self.is_top_level && !is_export_decl; + fn decl_to_type_decl(&mut self, decl: Decl) -> Option { + let is_declare = self.is_top_level; match decl { Decl::Class(mut class_decl) => { class_decl.class.body = self.class_body_to_type(class_decl.class.body); @@ -1077,7 +1068,7 @@ export function foo(a: any): number { } }"#, - r#"export class Foo { + r#"export declare class Foo { a: number; static b: number; constructor(value: string); @@ -1095,7 +1086,7 @@ export function foo(a: any): number { r#"export class Foo { constructor(...args: string[]) {} }"#, - r#"export class Foo { + r#"export declare class Foo { constructor(...args: string[]); }"#, ) @@ -1110,7 +1101,7 @@ export function foo(a: any): number { constructor(arg: number); constructor(arg: any) {} }"#, - r#"export class Foo { + r#"export declare class Foo { constructor(arg: string); constructor(arg: number); }"#, @@ -1123,7 +1114,7 @@ export function foo(a: any): number { foo(arg: number); foo(arg: any) {} }"#, - r#"export class Foo { + r#"export declare class Foo { foo(arg: string); foo(arg: number); }"#, @@ -1144,7 +1135,7 @@ export function foo(a: any): number { foo(arg: number); foo(arg: any) {} }"#, - r#"export class Foo { + r#"export declare class Foo { constructor(arg: string); constructor(arg: number); bar(arg: number): number; @@ -1159,7 +1150,7 @@ export function foo(a: any): number { async fn dts_class_decl_prop_test() { transform_dts_test( r#"export class Foo { private a!: string }"#, - r#"export class Foo { + r#"export declare class Foo { private a: string; }"#, ) @@ -1167,7 +1158,7 @@ export function foo(a: any): number { transform_dts_test( r#"export class Foo { declare a: string }"#, - r#"export class Foo { + r#"export declare class Foo { a: string; }"#, ) @@ -1178,14 +1169,14 @@ export function foo(a: any): number { async fn dts_class_decl_prop_infer_test() { transform_dts_test( r#"export class Foo { foo = (a: string): string => ({} as any) }"#, - r#"export class Foo { + r#"export declare class Foo { foo: (a: string) => string; }"#, ) .await; transform_dts_test( r#"export class Foo { foo = function(a: string): void {} }"#, - r#"export class Foo { + r#"export declare class Foo { foo: (a: string) => void; }"#, ) @@ -1196,29 +1187,30 @@ export function foo(a: any): number { async fn dts_var_decl_test() { transform_dts_test( r#"export const foo: number = 42;"#, - "export const foo: number;", + "export declare const foo: number;", ) .await; transform_dts_test( r#"export var foo: number = 42;"#, - "export var foo: number;", + "export declare var foo: number;", ) .await; transform_dts_test( r#"export let foo: number = 42;"#, - "export let foo: number;", + "export declare let foo: number;", ) .await; // Default to any if it cannot be determined transform_dts_test( r#"export const foo = adsf.b;"#, - "export const foo: any;", + "export declare const foo: any;", ) .await; - transform_dts_test(r#"export let foo;"#, "export let foo: any;").await; + transform_dts_test(r#"export let foo;"#, "export declare let foo: any;") + .await; } #[tokio::test] @@ -1242,7 +1234,7 @@ export function foo(a: any): number { async fn dts_inference() { transform_dts_test( r#"export const foo = null as string as number;"#, - "export const foo: number;", + "export declare const foo: number;", ) .await; } @@ -1251,18 +1243,18 @@ export function foo(a: any): number { async fn dts_as_const() { transform_dts_test( r#"export const foo = [1, 2] as const;"#, - "export const foo: readonly [1, 2];", + "export declare const foo: readonly [1, 2];", ) .await; transform_dts_test( r#"export const foo = [1, ,2] as const;"#, - "export const foo: readonly [1, any, 2];", + "export declare const foo: readonly [1, any, 2];", ) .await; transform_dts_test( r#"export const foo = { str: "bar", bool: true, bool2: false, num: 42, nullish: null } as const;"#, - r#"export const foo: { + r#"export declare const foo: { readonly str: "bar"; readonly bool: true; readonly bool2: false; @@ -1273,7 +1265,7 @@ export function foo(a: any): number { transform_dts_test( r#"export const foo = { str: [1, 2] as const } as const;"#, - r#"export const foo: { + r#"export declare const foo: { readonly str: readonly [1, 2]; };"#, ) @@ -1282,7 +1274,7 @@ export function foo(a: any): number { // TODO: Requires type resolving transform_dts_test( r#"export const foo = { bar } as const;"#, - r#"export const foo: { + r#"export declare const foo: { };"#, ) .await; @@ -1292,17 +1284,17 @@ export function foo(a: any): number { async fn dts_literal_inference_ann() { transform_dts_test( r#"export const foo: number = "abc";"#, - "export const foo: number;", + "export declare const foo: number;", ) .await; transform_dts_test( r#"export let foo: number = "abc";"#, - "export let foo: number;", + "export declare let foo: number;", ) .await; transform_dts_test( r#"export var foo: number = "abc";"#, - "export var foo: number;", + "export declare var foo: number;", ) .await; } @@ -1311,38 +1303,44 @@ export function foo(a: any): number { async fn dts_literal_inference() { transform_dts_test( r#"export const foo = 42;"#, - "export const foo: number;", + "export declare const foo: number;", ) .await; transform_dts_test( r#"export const foo = "foo";"#, - "export const foo: string;", + "export declare const foo: string;", ) .await; transform_dts_test( r#"export const foo = true;"#, - "export const foo: boolean;", + "export declare const foo: boolean;", ) .await; transform_dts_test( r#"export const foo = false;"#, - "export const foo: boolean;", + "export declare const foo: boolean;", ) .await; transform_dts_test( r#"export const foo = null;"#, - "export const foo: null;", + "export declare const foo: null;", ) .await; transform_dts_test( r#"export let foo = undefined;"#, - "export let foo: any;", + "export declare let foo: any;", + ) + .await; + transform_dts_test( + r#"export let foo = 10n;"#, + "export declare let foo: bigint;", + ) + .await; + transform_dts_test( + r#"export let foo = /foo/;"#, + "export declare let foo: RegExp;", ) .await; - transform_dts_test(r#"export let foo = 10n;"#, "export let foo: bigint;") - .await; - transform_dts_test(r#"export let foo = /foo/;"#, "export let foo: RegExp;") - .await; } #[tokio::test] @@ -1351,27 +1349,27 @@ export function foo(a: any): number { r#"export let foo = function add(a: number, b: number): number { return a + b; }"#, - "export let foo: (a: number, b: number) => number;", + "export declare let foo: (a: number, b: number) => number;", ) .await; transform_dts_test( r#"export let foo = function add([a, b]: T): void {}"#, - "export let foo: ([a, b]: T) => void;", + "export declare let foo: ([a, b]: T) => void;", ) .await; transform_dts_test( r#"export let foo = function add({a, b}: T): void {}"#, - "export let foo: ({ a, b }: T) => void;", + "export declare let foo: ({ a, b }: T) => void;", ) .await; transform_dts_test( r#"export let foo = function add(a = 2): void {}"#, - "export let foo: (a: number) => void;", + "export declare let foo: (a: number) => void;", ) .await; transform_dts_test( r#"export let foo = function add(...params: any[]): void {}"#, - "export let foo: (...params: any[]) => void;", + "export declare let foo: (...params: any[]) => void;", ) .await; } @@ -1382,28 +1380,28 @@ export function foo(a: any): number { r#"export let foo = (a: number, b: number): number => { return a + b; }"#, - "export let foo: (a: number, b: number) => number;", + "export declare let foo: (a: number, b: number) => number;", ) .await; transform_dts_test( r#"export let foo = ([a, b]: T): void => {}"#, - "export let foo: ([a, b]: T) => void;", + "export declare let foo: ([a, b]: T) => void;", ) .await; transform_dts_test( r#"export let foo = ({a, b}: T): void => {}"#, - "export let foo: ({ a, b }: T) => void;", + "export declare let foo: ({ a, b }: T) => void;", ) .await; transform_dts_test( r#"export let foo = (a = 2): void => {}"#, - "export let foo: (a: number) => void;", + "export declare let foo: (a: number) => void;", ) .await; transform_dts_test( r#"export let foo = (...params: any[]): void => {}"#, - "export let foo: (...params: any[]) => void;", + "export declare let foo: (...params: any[]) => void;", ) .await; } @@ -1429,18 +1427,18 @@ export function foo(a: any): number { async fn dts_enum_export() { transform_dts_test( r#"export enum Foo { A, B }"#, - "export enum Foo {\n A,\n B\n}", + "export declare enum Foo {\n A,\n B\n}", ) .await; transform_dts_test( r#"export const enum Foo { A, B }"#, - "export const enum Foo {\n A,\n B\n}", + "export declare const enum Foo {\n A,\n B\n}", ) .await; transform_dts_test( r#"export enum Foo { A = "foo", B = "bar" }"#, - r#"export enum Foo { + r#"export declare enum Foo { A = "foo", B = "bar" }"#, @@ -1510,7 +1508,7 @@ export default _dts_1;"#, transform_dts_test( r#"import { foo } from "bar";export const foobar = foo;"#, r#"import { foo } from "bar"; -export const foobar: any;"#, +export declare const foobar: any;"#, ) .await; } diff --git a/tests/specs/graph/jsr/DynamicImport.txt b/tests/specs/graph/jsr/DynamicImport.txt index 116302fe4..3744a472c 100644 --- a/tests/specs/graph/jsr/DynamicImport.txt +++ b/tests/specs/graph/jsr/DynamicImport.txt @@ -105,7 +105,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: export class Test { } --- DTS --- - export class Test { + export declare class Test { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: diff --git a/tests/specs/graph/jsr/FastCheck.txt b/tests/specs/graph/jsr/FastCheck.txt index 2db086d29..a1eb0a877 100644 --- a/tests/specs/graph/jsr/FastCheck.txt +++ b/tests/specs/graph/jsr/FastCheck.txt @@ -212,9 +212,9 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: export { A4 } from "./a4.ts"; export * from "./a6.ts"; --- DTS --- - export class A1 { + export declare class A1 { } - export class A3 { + export declare class A3 { } export { A4 } from "./a4.ts"; export * from "./a6.ts"; @@ -224,7 +224,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a4.ts: export class A4 { } --- DTS --- - export class A4 { + export declare class A4 { } Fast check https://jsr.io/@scope/a/1.0.0/a6.ts: @@ -232,7 +232,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a6.ts: export class A6 { } --- DTS --- - export class A6 { + export declare class A6 { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: @@ -269,7 +269,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- import { A1, A3 as RenamedA3, A4, A6 } from "./a.ts"; - export class Test { + export declare class Test { /** Testing */ noReturnTypeVoid(param?: number, param2?: string): void; noReturnTypeAsync(): Promise; returnTypeGenerator(): Generator; diff --git a/tests/specs/graph/jsr/FastCheck_AutoAccessors.txt b/tests/specs/graph/jsr/FastCheck_AutoAccessors.txt index b3a15629f..7cc1b4bc7 100644 --- a/tests/specs/graph/jsr/FastCheck_AutoAccessors.txt +++ b/tests/specs/graph/jsr/FastCheck_AutoAccessors.txt @@ -81,12 +81,12 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: #private!: unknown; } --- DTS --- - export class AutoAccessor { + export declare class AutoAccessor { /** Some comment */ public_accessor: string; private private_accessor: any; static static_accessor: number; private static private_static: any; private static private_static_unanalyzable: any; } - export class PrivateAccessor { + export declare class PrivateAccessor { } diff --git a/tests/specs/graph/jsr/FastCheck_ClassCtors.txt b/tests/specs/graph/jsr/FastCheck_ClassCtors.txt index 4afe00302..fca176bcd 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassCtors.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassCtors.txt @@ -176,47 +176,47 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: class Public5 { } --- DTS --- - /** A */ export class ClassBasic { + /** A */ export declare class ClassBasic { /** B */ constructor(prop: string, other?: number); } - export class ClassPrivateCtor { + export declare class ClassPrivateCtor { private constructor(); } - export class ClassPrivateCtorWithOverloads { + export declare class ClassPrivateCtorWithOverloads { private constructor(); } - export class ClassDeclarePrivateCtor { + export declare class ClassDeclarePrivateCtor { private constructor(prop: string, other: Private1); } - export class ClassProtectedCtor { + export declare class ClassProtectedCtor { protected constructor(prop: string, other?: number); } - export class ClassProtectedCtorWithOverloads { + export declare class ClassProtectedCtorWithOverloads { protected constructor(prop: Public1); } - export class ClassCtorWithOverloads { + export declare class ClassCtorWithOverloads { constructor(prop: Public1); } - export class ClassPrivateCtorPublicParamProp { + export declare class ClassPrivateCtorPublicParamProp { param1: Public2; private param2: any; private constructor(); } - export class ClassCtorPublicParamProp { + export declare class ClassCtorPublicParamProp { param1: Public3; private param2: any; private param3: any; constructor(param1: Public3, param2: Public4, param3?: Public5); } - export class ClassCtorPublicParamPropInit { + export declare class ClassCtorPublicParamPropInit { param1: Public3; constructor(param1?: Public3); } - export class ClassCtorPublicParamPropOptional { + export declare class ClassCtorPublicParamPropOptional { param1?: string; constructor(param1?: string); } - export class AmbientClassCtor { + export declare class AmbientClassCtor { constructor(public param: string, private value: number); constructor(public param: string); } diff --git a/tests/specs/graph/jsr/FastCheck_ClassGettersAndSetters.txt b/tests/specs/graph/jsr/FastCheck_ClassGettersAndSetters.txt index daaf3d26f..c9a18b238 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassGettersAndSetters.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassGettersAndSetters.txt @@ -72,7 +72,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: set value(_value: string) {} } --- DTS --- - export class MyClass { + export declare class MyClass { get value(): string; set value(_value: string); } diff --git a/tests/specs/graph/jsr/FastCheck_ClassMemberRefFound.txt b/tests/specs/graph/jsr/FastCheck_ClassMemberRefFound.txt index 5ac38492c..f4c5d7562 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassMemberRefFound.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassMemberRefFound.txt @@ -69,7 +69,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: declare prop: string; } --- DTS --- - export class Export { + export declare class Export { prop: typeof Public1.prototype.prop; } declare class Public1 { diff --git a/tests/specs/graph/jsr/FastCheck_ClassMethodsWithTsPrivate.txt b/tests/specs/graph/jsr/FastCheck_ClassMethodsWithTsPrivate.txt index dfe017294..18a263f40 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassMethodsWithTsPrivate.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassMethodsWithTsPrivate.txt @@ -169,14 +169,14 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: private override test!: any; } --- DTS --- - export class PrivateMethodOverloadable { + export declare class PrivateMethodOverloadable { private constructor(); private method: any; private methodWithOverload: any; private "stringAndIdent": any; private "stringOnly": any; } - export class AmbientPrivateMethodOverloadable { + export declare class AmbientPrivateMethodOverloadable { private constructor(value: string); private constructor(private: Private); private method(value: string): string; @@ -187,7 +187,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: private "stringOnly"(value: string): string; private "stringOnly"(): string; } - export module Test { + export declare module Test { export class AmbientClassInModule { private constructor(value: string); private constructor(private: Private); @@ -195,6 +195,6 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } declare class Base { } - export class TsPrivateMethodWithOverrideKeyword extends Base { + export declare class TsPrivateMethodWithOverrideKeyword extends Base { private override test: any; } diff --git a/tests/specs/graph/jsr/FastCheck_ClassProperties.txt b/tests/specs/graph/jsr/FastCheck_ClassProperties.txt index 941733976..3c8e39e3b 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassProperties.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassProperties.txt @@ -122,7 +122,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: override foo!: string; } --- DTS --- - export class RedBlackNode extends BinarySearchNode { + export declare class RedBlackNode extends BinarySearchNode { parent: RedBlackNode | null; left: RedBlackNode | null; right: RedBlackNode | null; @@ -132,14 +132,14 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } declare const isSecure: Symbol; declare const public2: Symbol; - export class CookieMapBase { + export declare class CookieMapBase { [isSecure]: boolean; [public2](): number; } - export class Bar { + export declare class Bar { abstract foo: string; bar: number; } - export class Baz extends Bar { + export declare class Baz extends Bar { override foo: string; } diff --git a/tests/specs/graph/jsr/FastCheck_ClassPropertiesLeavable.txt b/tests/specs/graph/jsr/FastCheck_ClassPropertiesLeavable.txt index c4c4693a5..530434c83 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassPropertiesLeavable.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassPropertiesLeavable.txt @@ -125,7 +125,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- import type { Foo, Bar } from "./b.ts"; - export class Foo { + export declare class Foo { fizz: (a: string) => string; foo: () => Foo; bar: (b: Bar) => number; diff --git a/tests/specs/graph/jsr/FastCheck_ClassPropertiesWithTsPrivate.txt b/tests/specs/graph/jsr/FastCheck_ClassPropertiesWithTsPrivate.txt index 6fd83e571..b7616aa06 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassPropertiesWithTsPrivate.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassPropertiesWithTsPrivate.txt @@ -73,7 +73,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: --- DTS --- declare class Base { } - export class WithTsPrivate extends Base { + export declare class WithTsPrivate extends Base { private regular: any; private override withOverride: any; } diff --git a/tests/specs/graph/jsr/FastCheck_ClassStaticMemberRefFound.txt b/tests/specs/graph/jsr/FastCheck_ClassStaticMemberRefFound.txt index 298b555fa..95410ffab 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassStaticMemberRefFound.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassStaticMemberRefFound.txt @@ -69,7 +69,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: declare static prop: string; } --- DTS --- - export class Export { + export declare class Export { prop: typeof Public1.prop; } declare class Public1 { diff --git a/tests/specs/graph/jsr/FastCheck_ClassSuper.txt b/tests/specs/graph/jsr/FastCheck_ClassSuper.txt index 90ae61521..adb3ab7e8 100644 --- a/tests/specs/graph/jsr/FastCheck_ClassSuper.txt +++ b/tests/specs/graph/jsr/FastCheck_ClassSuper.txt @@ -94,12 +94,12 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: declare class Base { constructor(a: number, b: number); } - export class Child extends Base { + export declare class Child extends Base { constructor(); } declare class SpreadBase { constructor(...params: string[]); } - export class SpreadChild extends SpreadBase { + export declare class SpreadChild extends SpreadBase { constructor(); } diff --git a/tests/specs/graph/jsr/FastCheck_Comments.txt b/tests/specs/graph/jsr/FastCheck_Comments.txt index 6cbf27a57..aa0622b2d 100644 --- a/tests/specs/graph/jsr/FastCheck_Comments.txt +++ b/tests/specs/graph/jsr/FastCheck_Comments.txt @@ -64,4 +64,4 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export const value1: number = {} as any; --- DTS --- // @ts-ignore broken line - export const value1: number; + export declare const value1: number; diff --git a/tests/specs/graph/jsr/FastCheck_CrossFileRefAliased.txt b/tests/specs/graph/jsr/FastCheck_CrossFileRefAliased.txt index ff5e9f36b..45214c038 100644 --- a/tests/specs/graph/jsr/FastCheck_CrossFileRefAliased.txt +++ b/tests/specs/graph/jsr/FastCheck_CrossFileRefAliased.txt @@ -141,7 +141,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: declare member: string; } --- DTS --- - export class A { + export declare class A { member: string; } @@ -191,6 +191,6 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- import { B } from "./b.ts"; - export class Export { + export declare class Export { prop: typeof B.prototype.member; } diff --git a/tests/specs/graph/jsr/FastCheck_CrossFileRefImportType.txt b/tests/specs/graph/jsr/FastCheck_CrossFileRefImportType.txt index f95123d20..a978bd4c0 100644 --- a/tests/specs/graph/jsr/FastCheck_CrossFileRefImportType.txt +++ b/tests/specs/graph/jsr/FastCheck_CrossFileRefImportType.txt @@ -92,7 +92,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: --- DTS --- export default class Test { } - export class A { + export declare class A { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: diff --git a/tests/specs/graph/jsr/FastCheck_CrossFileRefModule.txt b/tests/specs/graph/jsr/FastCheck_CrossFileRefModule.txt index 9a76d08a0..f0735559a 100644 --- a/tests/specs/graph/jsr/FastCheck_CrossFileRefModule.txt +++ b/tests/specs/graph/jsr/FastCheck_CrossFileRefModule.txt @@ -144,7 +144,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.ts: declare member2: string; } --- DTS --- - export class A { + export declare class A { member: string; member2: string; } @@ -196,7 +196,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- import * as mod from "./b.ts"; - export class Export { + export declare class Export { prop: typeof mod.B.prototype.member; prop2: typeof mod.B.prototype.member2; } diff --git a/tests/specs/graph/jsr/FastCheck_DefaultExportExprVar.txt b/tests/specs/graph/jsr/FastCheck_DefaultExportExprVar.txt index 969fa6c46..48810576e 100644 --- a/tests/specs/graph/jsr/FastCheck_DefaultExportExprVar.txt +++ b/tests/specs/graph/jsr/FastCheck_DefaultExportExprVar.txt @@ -73,5 +73,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export interface $Type { prop: boolean; } - export const $: $Type; + export declare const $: $Type; export default $; diff --git a/tests/specs/graph/jsr/FastCheck_Dts.txt b/tests/specs/graph/jsr/FastCheck_Dts.txt index 988076f65..53bc984af 100644 --- a/tests/specs/graph/jsr/FastCheck_Dts.txt +++ b/tests/specs/graph/jsr/FastCheck_Dts.txt @@ -129,7 +129,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.d.ts: declare function random(): number; declare var public: number; --- DTS --- - export class Test { + export declare class Test { prop: typeof random; method(): typeof public; static prop: number; diff --git a/tests/specs/graph/jsr/FastCheck_Enums.txt b/tests/specs/graph/jsr/FastCheck_Enums.txt index 4e6751d25..445d9a51c 100644 --- a/tests/specs/graph/jsr/FastCheck_Enums.txt +++ b/tests/specs/graph/jsr/FastCheck_Enums.txt @@ -132,20 +132,20 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: I = 1 + NUM } --- DTS --- - export enum EnumWithNoInits { + export declare enum EnumWithNoInits { Value1, Value2 } - export enum EnumWithNumInits { + export declare enum EnumWithNumInits { Value1 = 1, Value2 = 2 } - export enum EnumWithStringInits { + export declare enum EnumWithStringInits { Value1 = "a", Value2 = "b" } declare const value: number; - export enum EnumWithNonConstInits { + export declare enum EnumWithNonConstInits { Value1, Value2 } @@ -157,7 +157,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: Value } declare const NUM: any; - export enum Foo1 { + export declare enum Foo1 { A = 1, B = "2", C = 1 << 2, diff --git a/tests/specs/graph/jsr/FastCheck_Functions.txt b/tests/specs/graph/jsr/FastCheck_Functions.txt index c74426521..9d216a850 100644 --- a/tests/specs/graph/jsr/FastCheck_Functions.txt +++ b/tests/specs/graph/jsr/FastCheck_Functions.txt @@ -192,9 +192,9 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export function test6(param?: number): T; export function test7(param?: number): number; export function test7(param?: number, param2?: PublicOther2): number; - declare function test8(param: number): number; - declare function test8(param: string): string; - declare function test8(param0?: any): any; + function test8(param: number): number; + function test8(param: string): string; + function test8(param0?: any): any; export { test8 }; export default function test9(param: number): number; export default function test9(param: string): string; @@ -214,6 +214,6 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } declare class PublicDeclareFunc { } - export function declareFunc(param: number): number; - export function declareFunc(param: string): string; - export function declareFunc(param: PublicDeclareFunc): string; + export declare function declareFunc(param: number): number; + export declare function declareFunc(param: string): string; + export declare function declareFunc(param: PublicDeclareFunc): string; diff --git a/tests/specs/graph/jsr/FastCheck_InferredUniqueSymbols.txt b/tests/specs/graph/jsr/FastCheck_InferredUniqueSymbols.txt index 7f8924f61..b065e2d18 100644 --- a/tests/specs/graph/jsr/FastCheck_InferredUniqueSymbols.txt +++ b/tests/specs/graph/jsr/FastCheck_InferredUniqueSymbols.txt @@ -72,7 +72,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: --- DTS --- declare const key: unique symbol; declare const key2: unique symbol; - export class MyClass { + export declare class MyClass { [key]: number; [key2]: string; } diff --git a/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt b/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt index af3f38ffe..0b3495d62 100644 --- a/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt +++ b/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt @@ -144,7 +144,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export class A { } } - export const handlers: { + export declare const handlers: { readonly Private; readonly C; }; diff --git a/tests/specs/graph/jsr/FastCheck_Issue22829.txt b/tests/specs/graph/jsr/FastCheck_Issue22829.txt index 884739be3..06c0ef09f 100644 --- a/tests/specs/graph/jsr/FastCheck_Issue22829.txt +++ b/tests/specs/graph/jsr/FastCheck_Issue22829.txt @@ -118,12 +118,12 @@ Fast check https://jsr.io/@scope/a/1.0.0/functions.ts: declare abstract class Internal { prop: T; } - declare function func(): void; + function func(): void; export function other_func(): void; - export const functions: { + export declare const functions: { readonly other; }; - export module functions { + export declare module functions { type Function = Internal; } --- DTS Diagnostics --- diff --git a/tests/specs/graph/jsr/FastCheck_Methods.txt b/tests/specs/graph/jsr/FastCheck_Methods.txt index 84ea5fd4a..f555c3895 100644 --- a/tests/specs/graph/jsr/FastCheck_Methods.txt +++ b/tests/specs/graph/jsr/FastCheck_Methods.txt @@ -141,7 +141,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: class PublicOther2 { } --- DTS --- - export class Test { + export declare class Test { test1(): void; test2(): number; test3(param: number): number; @@ -153,7 +153,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: test8(param: number): number; test8(param: string): string; } - export class Test2 { + export declare class Test2 { public method1(): void; protected method2(): void; private tsPrivateMethod: any; diff --git a/tests/specs/graph/jsr/FastCheck_NestedJavaScriptDeclFile.txt b/tests/specs/graph/jsr/FastCheck_NestedJavaScriptDeclFile.txt index c6045d977..8c4621a71 100644 --- a/tests/specs/graph/jsr/FastCheck_NestedJavaScriptDeclFile.txt +++ b/tests/specs/graph/jsr/FastCheck_NestedJavaScriptDeclFile.txt @@ -190,12 +190,12 @@ Fast check https://jsr.io/@scope/a/1.0.0/a.d.ts: export class A3 { } --- DTS --- - export class A1 { + export declare class A1 { method(): string; } - export class A2 { + export declare class A2 { } - export class A3 { + export declare class A3 { } Fast check https://jsr.io/@scope/a/1.0.0/b.d.ts: @@ -204,7 +204,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/b.d.ts: prop: string; } --- DTS --- - export class B1 { + export declare class B1 { prop: string; } diff --git a/tests/specs/graph/jsr/FastCheck_NpmTypes.txt b/tests/specs/graph/jsr/FastCheck_NpmTypes.txt index 25ccfaaaa..ee47348c2 100644 --- a/tests/specs/graph/jsr/FastCheck_NpmTypes.txt +++ b/tests/specs/graph/jsr/FastCheck_NpmTypes.txt @@ -134,5 +134,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } --- DTS --- export * from "./a.js"; - export class Other { + export declare class Other { } diff --git a/tests/specs/graph/jsr/FastCheck_Properties.txt b/tests/specs/graph/jsr/FastCheck_Properties.txt index 4e629e1f5..58514a7c7 100644 --- a/tests/specs/graph/jsr/FastCheck_Properties.txt +++ b/tests/specs/graph/jsr/FastCheck_Properties.txt @@ -86,7 +86,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: class PublicOther2 { } --- DTS --- - export class Test { + export declare class Test { prop1: PublicOther; protected prop2?: PublicOther2; private prop3: any; diff --git a/tests/specs/graph/jsr/FastCheck_RefObjType.txt b/tests/specs/graph/jsr/FastCheck_RefObjType.txt index fb36b826e..1557cc598 100644 --- a/tests/specs/graph/jsr/FastCheck_RefObjType.txt +++ b/tests/specs/graph/jsr/FastCheck_RefObjType.txt @@ -76,7 +76,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: }; export type Status = typeof STATUS_CODE.Continue; --- DTS --- - export const STATUS_CODE: { + export declare const STATUS_CODE: { readonly /** RFC 7231, 6.2.1 */ Continue: number; readonly /** RFC 7231, 6.2.2 */ SwitchingProtocols: number; readonly /** RFC 2518, 10.1 */ Processing: number; diff --git a/tests/specs/graph/jsr/FastCheck_RefVarNoType.txt b/tests/specs/graph/jsr/FastCheck_RefVarNoType.txt index 5e7f6be40..68d9c8e99 100644 --- a/tests/specs/graph/jsr/FastCheck_RefVarNoType.txt +++ b/tests/specs/graph/jsr/FastCheck_RefVarNoType.txt @@ -68,7 +68,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: }; export type Status = typeof symbols.writable; --- DTS --- - export const symbols: { + export declare const symbols: { readonly writable: () => void; readonly readable: number; }; diff --git a/tests/specs/graph/jsr/FastCheck_RefVarType.txt b/tests/specs/graph/jsr/FastCheck_RefVarType.txt index cd93e3323..2be095226 100644 --- a/tests/specs/graph/jsr/FastCheck_RefVarType.txt +++ b/tests/specs/graph/jsr/FastCheck_RefVarType.txt @@ -73,5 +73,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: interface Symbols { readable: unique symbol; } - export const symbols: Symbols; + export declare const symbols: Symbols; export type Status = typeof symbols.readable; diff --git a/tests/specs/graph/jsr/FastCheck_TsAsConst.txt b/tests/specs/graph/jsr/FastCheck_TsAsConst.txt index b9fcbeacc..c818b8a78 100644 --- a/tests/specs/graph/jsr/FastCheck_TsAsConst.txt +++ b/tests/specs/graph/jsr/FastCheck_TsAsConst.txt @@ -91,16 +91,16 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: ...obj } as const; --- DTS --- - export const foo: readonly [1, 2]; - export const bar: readonly [1, any, 2]; - export const obj: { + export declare const foo: readonly [1, 2]; + export declare const bar: readonly [1, any, 2]; + export declare const obj: { readonly str: "bar"; readonly bool: true; readonly bool2: false; readonly num: 42; readonly nullish: null; }; - export const spread: { + export declare const spread: { readonly foo: 1; }; --- DTS Diagnostics --- diff --git a/tests/specs/graph/jsr/FastCheck_TsModule.txt b/tests/specs/graph/jsr/FastCheck_TsModule.txt index 0e945b7b7..68c914071 100644 --- a/tests/specs/graph/jsr/FastCheck_TsModule.txt +++ b/tests/specs/graph/jsr/FastCheck_TsModule.txt @@ -78,9 +78,9 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: class Public1 { } --- DTS --- - export module Test { + export declare module Test { } - export module Test { + export declare module Test { export class MyClass2 extends Public1 { } } diff --git a/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt b/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt index 9dc782012..45feda660 100644 --- a/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt +++ b/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt @@ -125,20 +125,20 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: data: Public7; } = {} as any; --- DTS --- - export class Application { + export declare class Application { prop: S; } - export const str: "foo" & { + export declare const str: "foo" & { __brand: "foo"; }; export function createMockApp = Record>(state?: S): Application; - export class A { + export declare class A { prop: Public1; constructor(prop?: Public1); handler: Public2; secondProp: Public4; } - export const var1: Public5; + export declare const var1: Public5; interface Public1 { } interface Public2 { @@ -153,6 +153,6 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: } declare class Public7 { } - export const str2: "foo" & { + export declare const str2: "foo" & { data: Public7; }; diff --git a/tests/specs/graph/jsr/FastCheck_VarArrowLeavable.txt b/tests/specs/graph/jsr/FastCheck_VarArrowLeavable.txt index c47f9c7da..f1029422b 100644 --- a/tests/specs/graph/jsr/FastCheck_VarArrowLeavable.txt +++ b/tests/specs/graph/jsr/FastCheck_VarArrowLeavable.txt @@ -93,7 +93,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/b.ts: } --- DTS --- export type Foo = string; - export class Bar { + export declare class Bar { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: @@ -119,5 +119,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export const bar = (): Bar =>({} as any); --- DTS --- import type { Foo, Bar } from "./b.ts"; - export const foo: (foo: Foo) => string; - export const bar: () => Bar; + export declare const foo: (foo: Foo) => string; + export declare const bar: () => Bar; diff --git a/tests/specs/graph/jsr/FastCheck_VarFunctionLeavable.txt b/tests/specs/graph/jsr/FastCheck_VarFunctionLeavable.txt index 943309665..cd17e14ba 100644 --- a/tests/specs/graph/jsr/FastCheck_VarFunctionLeavable.txt +++ b/tests/specs/graph/jsr/FastCheck_VarFunctionLeavable.txt @@ -93,7 +93,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/b.ts: } --- DTS --- export type Foo = string; - export class Bar { + export declare class Bar { } Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: @@ -123,5 +123,5 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: }; --- DTS --- import type { Foo, Bar } from "./b.ts"; - export const foo: (foo: Foo) => string; - export const bar: () => Bar; + export declare const foo: (foo: Foo) => string; + export declare const bar: () => Bar; diff --git a/tests/specs/graph/jsr/FastCheck_Vars.txt b/tests/specs/graph/jsr/FastCheck_Vars.txt index 1ad1617d5..770cd7e04 100644 --- a/tests/specs/graph/jsr/FastCheck_Vars.txt +++ b/tests/specs/graph/jsr/FastCheck_Vars.txt @@ -182,8 +182,8 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: readonly "Forbidden": 403; }; export type ErrorStatusKeys = keyof typeof ERROR_STATUS_MAP; - export const asIs1: readonly [number, number, number]; - export const asIs2: { + export declare const asIs1: readonly [number, number, number]; + export declare const asIs2: { readonly a: readonly [number, number, number]; readonly b: boolean; readonly c: number; @@ -194,23 +194,23 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: readonly g; readonly h: readonly [readonly [number, number], readonly [string]]; }; - export const func1: () => string; - export const func2: () => string; - export const func3: () => string; - export const func4: () => any; - export const func5: () => Promise; - export const func6: () => Promise<1>; - export const func7: () => Promise<1>; - export const func8: () => any; - export const inferred1: 1; - export const inferred2: string; - export const inferred3: true; - export const inferred4: RegExp; - export const inferred5: boolean; - export const inferred6: boolean; - export const inferred7: 1 | 2 | 3 & 4; - export const inferred8: ["test", 1]; - export const inferred9: [...string]; - export const inferred10: (1 | 2n)[]; - export const inferred11: (keyof string)[]; - export const inferred12: number; + export declare const func1: () => string; + export declare const func2: () => string; + export declare const func3: () => string; + export declare const func4: () => any; + export declare const func5: () => Promise; + export declare const func6: () => Promise<1>; + export declare const func7: () => Promise<1>; + export declare const func8: () => any; + export declare const inferred1: 1; + export declare const inferred2: string; + export declare const inferred3: true; + export declare const inferred4: RegExp; + export declare const inferred5: boolean; + export declare const inferred6: boolean; + export declare const inferred7: 1 | 2 | 3 & 4; + export declare const inferred8: ["test", 1]; + export declare const inferred9: [...string]; + export declare const inferred10: (1 | 2n)[]; + export declare const inferred11: (keyof string)[]; + export declare const inferred12: number; diff --git a/tests/specs/graph/jsr/FastCheck_WorkspaceFastCheck.txt b/tests/specs/graph/jsr/FastCheck_WorkspaceFastCheck.txt index 19d3a259c..33982e19e 100644 --- a/tests/specs/graph/jsr/FastCheck_WorkspaceFastCheck.txt +++ b/tests/specs/graph/jsr/FastCheck_WorkspaceFastCheck.txt @@ -132,7 +132,7 @@ Fast check file:///mod.ts: } --- DTS --- import { C } from "jsr:@scope/c"; - export class MyClass { + export declare class MyClass { prop: Public1; c: C; } @@ -144,5 +144,5 @@ Fast check https://jsr.io/@scope/c/1.0.0/mod.ts: export class C { } --- DTS --- - export class C { + export declare class C { } diff --git a/tests/specs/graph/jsr/SamePackageMultipleTimes.txt b/tests/specs/graph/jsr/SamePackageMultipleTimes.txt index 99d14db36..b33d721ec 100644 --- a/tests/specs/graph/jsr/SamePackageMultipleTimes.txt +++ b/tests/specs/graph/jsr/SamePackageMultipleTimes.txt @@ -159,6 +159,6 @@ Fast check https://jsr.io/@scope/b/1.1.0/mod.ts: method(value: string): void {} } --- DTS --- - export class Test { + export declare class Test { method(value: string): void; } From 807245d3669529affe0d26123fc4d5247bac611c Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 28 Mar 2024 16:00:55 -0400 Subject: [PATCH 3/3] Some reverts and add back declare keyword to align with typescript's emit --- src/fast_check/transform_dts.rs | 12 +++---- src/graph.rs | 2 +- .../jsr/FastCheck_EntrypointJsWithTsDecl.txt | 2 +- tests/specs/graph/jsr/FastCheck_Functions.txt | 34 +++++++++---------- .../jsr/FastCheck_InitIdentsAndMembers.txt | 2 +- .../specs/graph/jsr/FastCheck_Issue22829.txt | 4 +-- .../graph/jsr/FastCheck_JsWithTsDecl.txt | 2 +- .../graph/jsr/FastCheck_TypeAssertion.txt | 2 +- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/fast_check/transform_dts.rs b/src/fast_check/transform_dts.rs index d0a4152fe..96b09cf6e 100644 --- a/src/fast_check/transform_dts.rs +++ b/src/fast_check/transform_dts.rs @@ -997,7 +997,7 @@ mod tests { r#"export function foo(a: number): number { return {}; }"#, - "export function foo(a: number): number;", + "export declare function foo(a: number): number;", ) .await; transform_dts_test( @@ -1005,35 +1005,35 @@ mod tests { export function foo(a: any): number { return {}; }"#, - r#"export function foo(a: string): number;"#, + r#"export declare function foo(a: string): number;"#, ) .await; transform_dts_test( r#"export function foo(a = 2): number { return 2; }"#, - r#"export function foo(a?: number): number;"#, + r#"export declare function foo(a?: number): number;"#, ) .await; transform_dts_test( r#"export function foo(a: string = 2): number { return 2; }"#, - r#"export function foo(a?: string): number;"#, + r#"export declare function foo(a?: string): number;"#, ) .await; transform_dts_test( r#"export function foo([a, b] = [1, 2]): number { return 2; }"#, - r#"export function foo([a, b]?: [number, number]): number;"#, + r#"export declare function foo([a, b]?: [number, number]): number;"#, ) .await; transform_dts_test( r#"export function foo({a, b} = { a: 1, b: 2 }): number { return 2; }"#, - r#"export function foo({ a, b }?: { + r#"export declare function foo({ a, b }?: { a: number; b: number; }): number;"#, diff --git a/src/graph.rs b/src/graph.rs index 0b99942f4..6e1833685 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -5383,7 +5383,7 @@ mod tests { let dts = fsm.dts.unwrap(); assert_eq!( dts.text.to_string().trim(), - "export function add(a: number, b: number): number;" + "export declare function add(a: number, b: number): number;" ); assert!(dts.diagnostics.is_empty()); } diff --git a/tests/specs/graph/jsr/FastCheck_EntrypointJsWithTsDecl.txt b/tests/specs/graph/jsr/FastCheck_EntrypointJsWithTsDecl.txt index 7973a67ed..6f1228c80 100644 --- a/tests/specs/graph/jsr/FastCheck_EntrypointJsWithTsDecl.txt +++ b/tests/specs/graph/jsr/FastCheck_EntrypointJsWithTsDecl.txt @@ -87,4 +87,4 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.d.ts: {} export function getRandom(): number; --- DTS --- - export function getRandom(): number; + export declare function getRandom(): number; diff --git a/tests/specs/graph/jsr/FastCheck_Functions.txt b/tests/specs/graph/jsr/FastCheck_Functions.txt index 9d216a850..a7bdddc02 100644 --- a/tests/specs/graph/jsr/FastCheck_Functions.txt +++ b/tests/specs/graph/jsr/FastCheck_Functions.txt @@ -184,30 +184,30 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export declare function declareFunc(param: string): string; export declare function declareFunc(param: PublicDeclareFunc): string; --- DTS --- - export function test1(): void; - export function test2(): number; - /** Some Doc **/ export function test3(param: number): number; - export function test4(param?: number): number; - export function test5(param?: number): T; - export function test6(param?: number): T; - export function test7(param?: number): number; - export function test7(param?: number, param2?: PublicOther2): number; - function test8(param: number): number; - function test8(param: string): string; - function test8(param0?: any): any; + export declare function test1(): void; + export declare function test2(): number; + /** Some Doc **/ export declare function test3(param: number): number; + export declare function test4(param?: number): number; + export declare function test5(param?: number): T; + export declare function test6(param?: number): T; + export declare function test7(param?: number): number; + export declare function test7(param?: number, param2?: PublicOther2): number; + declare function test8(param: number): number; + declare function test8(param: string): string; + declare function test8(param0?: any): any; export { test8 }; export default function test9(param: number): number; export default function test9(param: string): string; - export function test10(...params: string[]): string[]; - export function test11(options?: { + export declare function test10(...params: string[]): string[]; + export declare function test11(options?: { copy: boolean; }): void; export interface GlobOptions { } - export function test12({}?: GlobOptions): void; - export function test13([]?: number[]): void; - export function test14(): never; - export function test15(): Generator; + export declare function test12({}?: GlobOptions): void; + export declare function test13([]?: number[]): void; + export declare function test14(): never; + export declare function test15(): Generator; declare class PublicOther { } declare class PublicOther2 { diff --git a/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt b/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt index 0b3495d62..d7ce0c437 100644 --- a/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt +++ b/tests/specs/graph/jsr/FastCheck_InitIdentsAndMembers.txt @@ -167,7 +167,7 @@ Fast check https://jsr.io/@scope/b/1.0.0/mod.ts: export class A { } } - export function test(a?: any, C?: any): void; + export declare function test(a?: any, C?: any): void; --- DTS Diagnostics --- unable to infer type, falling back to any type at https://jsr.io/@scope/b/1.0.0/mod.ts@140 diff --git a/tests/specs/graph/jsr/FastCheck_Issue22829.txt b/tests/specs/graph/jsr/FastCheck_Issue22829.txt index 06c0ef09f..a268eed48 100644 --- a/tests/specs/graph/jsr/FastCheck_Issue22829.txt +++ b/tests/specs/graph/jsr/FastCheck_Issue22829.txt @@ -118,8 +118,8 @@ Fast check https://jsr.io/@scope/a/1.0.0/functions.ts: declare abstract class Internal { prop: T; } - function func(): void; - export function other_func(): void; + declare function func(): void; + export declare function other_func(): void; export declare const functions: { readonly other; }; diff --git a/tests/specs/graph/jsr/FastCheck_JsWithTsDecl.txt b/tests/specs/graph/jsr/FastCheck_JsWithTsDecl.txt index 0acca050e..73f5f9f79 100644 --- a/tests/specs/graph/jsr/FastCheck_JsWithTsDecl.txt +++ b/tests/specs/graph/jsr/FastCheck_JsWithTsDecl.txt @@ -136,4 +136,4 @@ Fast check https://jsr.io/@scope/a/1.0.0/random.d.ts: {} export function getRandom(): number; --- DTS --- - export function getRandom(): number; + export declare function getRandom(): number; diff --git a/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt b/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt index 45feda660..8a3fe966b 100644 --- a/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt +++ b/tests/specs/graph/jsr/FastCheck_TypeAssertion.txt @@ -131,7 +131,7 @@ Fast check https://jsr.io/@scope/a/1.0.0/mod.ts: export declare const str: "foo" & { __brand: "foo"; }; - export function createMockApp = Record>(state?: S): Application; + export declare function createMockApp = Record>(state?: S): Application; export declare class A { prop: Public1; constructor(prop?: Public1);