Skip to content

Commit

Permalink
fix(docz-core): typescript doesn't work with several exports (#771)
Browse files Browse the repository at this point in the history
* fix(babel-plugin-export-metadata): export default doesn't work

* fix(babel-plugin-export-metadata): write tests for new version

* fix(docz-core): docgen doesn't parse several exports in one file in TS

* fix(docz): <Props /> doesn't check by displayName

* fix(docz-core): ts doesn't work with several exports
  • Loading branch information
lesha1201 authored and pedronauck committed Apr 6, 2019
1 parent e3f6273 commit c96878d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions core/docz-core/src/utils/docgen/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,19 @@ const parseFiles = (files: string[], config: Config, tsconfig: string) => {
loadFiles(files)
const parser = reactDocgenTs.withCustomConfig(tsconfig, opts)
const compilerOptions = _.get('options', getTSConfigFile(tsconfig))
const props = parser.parseWithProgramProvider(files, () => {

const programProvider = () => {
if (languageService) return languageService.getProgram()!
const servicesHost = createServiceHost(compilerOptions, filesMap)
const documentRegistry = ts.createDocumentRegistry()
languageService = ts.createLanguageService(servicesHost, documentRegistry)
return languageService.getProgram()!
})

const parseFilepathProp = (prop: any, idx: number) =>
prop && {
key: _.get(idx, files),
value: [prop],
}
}

return props.map(parseFilepathProp).filter(Boolean)
return files.map(filepath => ({
key: filepath,
value: parser.parseWithProgramProvider(filepath, programProvider),
}))
}

export const tsParser = (
Expand Down
2 changes: 1 addition & 1 deletion core/docz/src/components/AsyncRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { SFC } from 'react'
import { get } from 'lodash/fp'
import {lazy} from '@loadable/component'
import { lazy } from '@loadable/component'

import { Entry } from '../state'
import { useComponents, ComponentsMap } from '../hooks/useComponents'
Expand Down

0 comments on commit c96878d

Please sign in to comment.