File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 33 "description" : " Typescript declaration generator for svelte with typescript" ,
44 "main" : " dist/index.js" ,
55 "types" : " dist/index.ts" ,
6- "version" : " 0.3.3 " ,
6+ "version" : " 0.3.4 " ,
77 "license" : " MIT" ,
88 "homepage" : " https://github.com/andrelmlins/svelte-dts" ,
99 "repository" : " https://github.com/andrelmlins/svelte-dts" ,
Original file line number Diff line number Diff line change @@ -55,6 +55,16 @@ class SvelteTransformer implements ITransformer {
5555 ) ;
5656 }
5757
58+ private addTypeForSearch ( newType : ts . TypeReferenceNode ) : void {
59+ const includeType = this . typesForSearch . map (
60+ ( item ) => item . getText ( this . sourceFile ) === newType . getText ( this . sourceFile )
61+ ) ;
62+
63+ if ( ! includeType ) {
64+ this . typesForSearch . push ( newType ) ;
65+ }
66+ }
67+
5868 private compileProperty ( node : ts . VariableStatement ) : void {
5969 node . declarationList . declarations . forEach ( ( declaration ) => {
6070 const name = declaration . name . getText ( this . sourceFile ) ;
@@ -66,7 +76,7 @@ class SvelteTransformer implements ITransformer {
6676 type = declaration . type . getText ( this . sourceFile ) ;
6777
6878 if ( ts . isTypeReferenceNode ( declaration . type ) ) {
69- this . typesForSearch . push ( declaration . type ) ;
79+ this . addTypeForSearch ( declaration . type ) ;
7080 }
7181
7282 if ( ts . isUnionTypeNode ( declaration . type ) ) {
@@ -102,7 +112,7 @@ class SvelteTransformer implements ITransformer {
102112 const type = member . type ?. getText ( this . sourceFile ) || 'any' ;
103113
104114 if ( member . type && ts . isTypeReferenceNode ( member . type ) ) {
105- this . typesForSearch . push ( member . type ) ;
115+ this . addTypeForSearch ( member . type ) ;
106116 }
107117
108118 this . events . push ( { name, type } ) ;
You can’t perform that action at this time.
0 commit comments