@@ -20,6 +20,7 @@ import {
2020 PluginPackage ,
2121 PluginPackageAuthenticationProvider ,
2222 PluginPackageCommand ,
23+ PluginPackageContribution ,
2324 PluginPackageCustomEditor ,
2425 PluginPackageLanguageContribution ,
2526 PluginPackageNotebook ,
@@ -31,7 +32,7 @@ import {
3132 * This function will update the manifest based on the plugin contributions.
3233 */
3334export function updateActivationEvents ( manifest : PluginPackage ) : void {
34- if ( ! isObject ( manifest ) || ! isObject ( manifest . contributes ) || ! manifest . contributes ) {
35+ if ( ! isObject < PluginPackage > ( manifest ) || ! isObject < PluginPackageContribution > ( manifest . contributes ) || ! manifest . contributes ) {
3536 return ;
3637 }
3738
@@ -42,8 +43,8 @@ export function updateActivationEvents(manifest: PluginPackage): void {
4243 const commands = Array . isArray ( value ) ? value : [ value ] ;
4344 updateCommandsContributions ( commands , activationEvents ) ;
4445 }
45- if ( Array . isArray ( manifest . contributes . views ) ) {
46- const views = flatten ( Object . values ( manifest . contributes . views ) ) as PluginPackageView [ ] ;
46+ if ( isObject ( manifest . contributes . views ) ) {
47+ const views = flatten ( Object . values ( manifest . contributes . views ) ) ;
4748 updateViewsContribution ( views , activationEvents ) ;
4849 }
4950 if ( Array . isArray ( manifest . contributes . customEditors ) ) {
@@ -64,47 +65,47 @@ export function updateActivationEvents(manifest: PluginPackage): void {
6465
6566function updateViewsContribution ( views : PluginPackageView [ ] , activationEvents : Set < string > ) : void {
6667 for ( const view of views ) {
67- if ( isObject ( view ) && typeof view . id === 'string' ) {
68+ if ( isObject < PluginPackageView > ( view ) && typeof view . id === 'string' ) {
6869 activationEvents . add ( `onView:${ view . id } ` ) ;
6970 }
7071 }
7172}
7273
7374function updateCustomEditorsContribution ( customEditors : PluginPackageCustomEditor [ ] , activationEvents : Set < string > ) : void {
7475 for ( const customEditor of customEditors ) {
75- if ( isObject ( customEditor ) && typeof customEditor . viewType === 'string' ) {
76+ if ( isObject < PluginPackageCustomEditor > ( customEditor ) && typeof customEditor . viewType === 'string' ) {
7677 activationEvents . add ( `onCustomEditor:${ customEditor . viewType } ` ) ;
7778 }
7879 }
7980}
8081
8182function updateCommandsContributions ( commands : PluginPackageCommand [ ] , activationEvents : Set < string > ) : void {
8283 for ( const command of commands ) {
83- if ( isObject ( command ) && typeof command . command === 'string' ) {
84+ if ( isObject < PluginPackageCommand > ( command ) && typeof command . command === 'string' ) {
8485 activationEvents . add ( `onCommand:${ command . command } ` ) ;
8586 }
8687 }
8788}
8889
8990function updateAuthenticationProviderContributions ( authProviders : PluginPackageAuthenticationProvider [ ] , activationEvents : Set < string > ) : void {
9091 for ( const authProvider of authProviders ) {
91- if ( isObject ( authProvider ) && typeof authProvider . id === 'string' ) {
92+ if ( isObject < PluginPackageAuthenticationProvider > ( authProvider ) && typeof authProvider . id === 'string' ) {
9293 activationEvents . add ( `onAuthenticationRequest:${ authProvider . id } ` ) ;
9394 }
9495 }
9596}
9697
9798function updateLanguageContributions ( languages : PluginPackageLanguageContribution [ ] , activationEvents : Set < string > ) : void {
9899 for ( const language of languages ) {
99- if ( isObject ( language ) && typeof language . id === 'string' ) {
100+ if ( isObject < PluginPackageLanguageContribution > ( language ) && typeof language . id === 'string' ) {
100101 activationEvents . add ( `onLanguage:${ language . id } ` ) ;
101102 }
102103 }
103104}
104105
105106function updateNotebookContributions ( notebooks : PluginPackageNotebook [ ] , activationEvents : Set < string > ) : void {
106107 for ( const notebook of notebooks ) {
107- if ( isObject ( notebook ) && typeof notebook . type === 'string' ) {
108+ if ( isObject < PluginPackageNotebook > ( notebook ) && typeof notebook . type === 'string' ) {
108109 activationEvents . add ( `onNotebookSerializer:${ notebook . type } ` ) ;
109110 }
110111 }
0 commit comments