Skip to content

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

Merged
johnsoncodehk merged 1 commit intomasterfrom
service-plugin-generic
Feb 28, 2024
Merged

feat(language-service): add provide generic to ServicePlugin type#143
johnsoncodehk merged 1 commit intomasterfrom
service-plugin-generic

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
@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.

2 participants