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

feat(language-service): add provide generic to ServicePlugin type #143

Merged
merged 1 commit into from Feb 28, 2024

Conversation

remcohaszing
Copy link
Member

@remcohaszing remcohaszing commented Feb 27, 2024

This allows a service plugin instance provide value to be inferred without the need for an explicit type annotation on the create method.

This allows a service plugin instance provide value to be inferred
without the need for an explicit type annotation on the create function.
@johnsoncodehk
Copy link
Member

Thanks! btw I recommend always type-annotating the create method, otherwise unknown options cannot be caught:

const servicePlugin: ServicePlugin = {
	create() {
		return {
			aTypoOption: 123, // Expected report type error but didn't
		};
	},
};

const servicePlugin: ServicePlugin = {
	create(): ServicePluginInstance {
		return {
			aTypoOption: 123, // Now report as expected
		};
	},
};

@johnsoncodehk johnsoncodehk merged commit 410fa15 into master Feb 28, 2024
6 checks passed
@johnsoncodehk johnsoncodehk deleted the service-plugin-generic branch February 28, 2024 03:23
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 this pull request may close these issues.

None yet

2 participants