Skip to content

isolatedDeclaration: The related types inside declare global {} should also be kept in the result even if they are not exported #3981

@erwinheldy

Description

@erwinheldy

For example:

function MyFunction() {
  return 'here is my function'
}

function MyOtherFunction() {
  return 'here is my other function'
}

export { MyOtherFunction }

declare global {
  interface Window {
    MyFunction: typeof MyFunction
  }
}

window.MyFunction = MyFunction

MyFunction is not exported but is attached to the global window object, so the MyFunction types should be included in the d.ts file even if it is not exported.

The following are the results of the comparison using tsc and oxc-transform:

// by tsc
declare function MyFunction(): string;
declare function MyOtherFunction(): string;
export { MyOtherFunction };
declare global {
    interface Window {
        MyFunction: typeof MyFunction;
    }
}
// by oxc-transform
declare function MyOtherFunction(): string;
export { MyOtherFunction };
declare global {
	interface Window {
		MyFunction: typeof MyFunction;
	}
}

The file generated by oxc-transform is missing: declare function MyFunction(): string;

Metadata

Metadata

Assignees

Labels

C-bugCategory - Bug

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions