@@ -199,18 +199,26 @@ export default class CFDefinitionsBuilder {
199199 declaration : InterfaceDeclaration ,
200200 field : Field ,
201201 ) : void => {
202+ const type = renderProp ( field ) ;
202203 declaration . addProperty ( {
203204 name : field . id ,
204205 hasQuestionToken : field . omitted || ( ! field . required ) ,
205- type : renderProp ( field ) ,
206+ type,
206207 } ) ;
207208
208- // eslint-disable-next-line no-warning-comments
209- // TODO: dynamically define imports based on usage
210- file . addImportDeclaration ( {
211- moduleSpecifier : 'contentful' ,
212- namespaceImport : 'Contentful' ,
213- } ) ;
209+ if ( type . includes ( 'Contentful.' ) ) {
210+ file . addImportDeclaration ( {
211+ moduleSpecifier : 'contentful' ,
212+ namespaceImport : 'Contentful' ,
213+ } ) ;
214+ }
215+
216+ if ( type . includes ( 'EntryLink' ) ) {
217+ file . addImportDeclaration ( {
218+ moduleSpecifier : '@src/types/contentful/static' ,
219+ namedImports : [ 'EntryLink' ] ,
220+ } ) ;
221+ }
214222
215223 file . addImportDeclaration ( {
216224 moduleSpecifier : '@contentful/rich-text-types' ,
0 commit comments