Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS4058: Return type of exported function has or is using name WebSiteLeaf from external module ... but cannot be named #193

Closed
btakita opened this issue Mar 7, 2024 · 3 comments

Comments

@btakita
Copy link

btakita commented Mar 7, 2024

When declaring an object to be a WebSite type, a TS4058 appears.

export function jsonld_WebSite_() { // TS4058
	return <WebSite>{
		'@type': 'WebSite',
		'@id': jsonld_WebSite_id,
		url: website,
		name: title,
		mainEntity: jsonld_Person_(),
	}
}

Looking at the source,

export type WebSite = WebSiteLeaf;

WebSiteLeaf is not in use anywhere else nor is it exported. It seems that WebSiteLeaf should be renamed to WebSite. The intermediate type is not necessary.

@btakita
Copy link
Author

btakita commented Mar 7, 2024

Another solution is to add exports for all of the Leaf & Base types.

See microsoft/TypeScript#9944 & microsoft/TypeScript#9944

When I manually add an export to WebSiteLeaf, the error goes away:

export interface WebSiteLeaf extends WebSiteBase {
    "@type": "WebSite";
}

btakita added a commit to btakita/schema-dts that referenced this issue Mar 7, 2024
@btakita
Copy link
Author

btakita commented Mar 7, 2024

I published the @btakita/schema-dts package with #194. I will use this we can find a resolution for this issue.

@btakita
Copy link
Author

btakita commented Mar 15, 2024

I was able to resolve the issue by setting composite: false in my tsconfig.json file.

See microsoft/TypeScript#42873 (comment)

Closing since my issue if fixed.

@btakita btakita closed this as completed Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant