diff --git a/.gitignore b/.gitignore index 215b9a50..8fb5243e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,8 @@ node_modules lib/ stats.json cypress/ -bundles +bundles/ +typings/ cli/index.js /benchmark/revisions diff --git a/.npmignore b/.npmignore index bb3ee83e..7ffbfdf0 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,6 @@ * !bundles/* +!typings/* !package.json !README.md !LICENSE \ No newline at end of file diff --git a/package.json b/package.json index 8dcc6ce8..441c3045 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "React.js" ], "main": "bundles/redoc.lib.js", + "types": "typings/index.d.ts", "scripts": { "start": "webpack-dev-server --mode=development --env.playground --hot --config demo/webpack.config.ts", "start:prod": "webpack-dev-server --env.playground --mode=production --config demo/webpack.config.ts", @@ -37,6 +38,7 @@ "bundle:standalone": "webpack --env.standalone --mode=production", "bundle:lib": "webpack --mode=production", "bundle": "npm run bundle:clean && npm run bundle:lib && npm run bundle:standalone", + "declarations": "rimraf typings && tsc --emitDeclarationOnly -p tsconfig.lib.json", "stats": "webpack --env.standalone --json --profile --mode=production > stats.json", "prettier": "prettier --write \"src/**/*.{ts,tsx}\"", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1", diff --git a/src/common-elements/dropdown.ts b/src/common-elements/dropdown.ts index f6cccdb2..b134569f 100644 --- a/src/common-elements/dropdown.ts +++ b/src/common-elements/dropdown.ts @@ -1,6 +1,11 @@ +import * as React from 'react'; import Dropdown from 'react-dropdown'; -import styled, { StyledComponentClass, withProps } from '../styled-components'; +import styled, { + ResolvedThemeInterface, + StyledComponentClass, + withProps, +} from '../styled-components'; export interface DropdownOption { label: string; diff --git a/src/common-elements/fields-layout.ts b/src/common-elements/fields-layout.ts index 2c0114b3..baee4635 100644 --- a/src/common-elements/fields-layout.ts +++ b/src/common-elements/fields-layout.ts @@ -1,5 +1,11 @@ import { transparentize } from 'polished'; -import styled, { withProps } from '../styled-components'; +import * as React from 'react'; + +import styled, { + ResolvedThemeInterface, + StyledComponentClass, + withProps, +} from '../styled-components'; import { deprecatedCss } from './mixins'; export const PropertiesTableCaption = styled.caption` diff --git a/src/common-elements/fields.ts b/src/common-elements/fields.ts index a7a30004..bfcac028 100644 --- a/src/common-elements/fields.ts +++ b/src/common-elements/fields.ts @@ -1,5 +1,7 @@ import { transparentize } from 'polished'; -import styled from '../styled-components'; +import * as React from 'react'; + +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components'; import { PropertyNameCell } from './fields-layout'; export const ClickablePropertyNameCell = PropertyNameCell.extend` diff --git a/src/common-elements/headers.ts b/src/common-elements/headers.ts index 456fac0c..4409b0f4 100644 --- a/src/common-elements/headers.ts +++ b/src/common-elements/headers.ts @@ -1,4 +1,7 @@ -import styled, { css } from '../styled-components'; +import * as React from 'react'; +import { InterpolationFunction, Styles, ThemeProps } from 'styled-components'; + +import styled, { css, ResolvedThemeInterface, StyledComponentClass } from '../styled-components'; const headerFontSize = { 1: '1.85714em', diff --git a/src/common-elements/linkify.ts b/src/common-elements/linkify.ts index 4e49900c..c1ff3b6a 100644 --- a/src/common-elements/linkify.ts +++ b/src/common-elements/linkify.ts @@ -1,4 +1,7 @@ -import styled, { css } from '../styled-components'; +import * as React from 'react'; +import { InterpolationFunction, Styles, ThemeProps } from 'styled-components'; + +import styled, { css, ResolvedThemeInterface, StyledComponentClass } from '../styled-components'; // tslint:disable-next-line export const linkifyMixin = className => css` diff --git a/src/common-elements/mixins.ts b/src/common-elements/mixins.ts index 176ee922..7722835e 100644 --- a/src/common-elements/mixins.ts +++ b/src/common-elements/mixins.ts @@ -1,4 +1,6 @@ -import { css } from '../styled-components'; +import { InterpolationFunction, Styles, ThemeProps } from 'styled-components'; + +import { css, StyledComponentClass } from '../styled-components'; export const deprecatedCss = css` text-decoration: line-through; diff --git a/src/common-elements/panels.ts b/src/common-elements/panels.ts index 91ac574e..a083003b 100644 --- a/src/common-elements/panels.ts +++ b/src/common-elements/panels.ts @@ -1,4 +1,5 @@ -import styled, { media } from '../styled-components'; +import * as React from 'react'; +import styled, { media, ResolvedThemeInterface, StyledComponentClass } from '../styled-components'; export const MiddlePanel = styled.div` width: calc(100% - ${props => props.theme.rightPanel.width}); diff --git a/src/common-elements/samples.tsx b/src/common-elements/samples.tsx index 457657b1..384cdaa6 100644 --- a/src/common-elements/samples.tsx +++ b/src/common-elements/samples.tsx @@ -1,4 +1,6 @@ -import styled from '../styled-components'; +import * as React from 'react'; + +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components'; export const SampleControls = styled.div` opacity: 0.4; diff --git a/src/common-elements/schema.ts b/src/common-elements/schema.ts index 81ac2ecd..eb09a739 100644 --- a/src/common-elements/schema.ts +++ b/src/common-elements/schema.ts @@ -1,4 +1,9 @@ -import styled, { withProps } from '../styled-components'; +import * as React from 'react'; +import styled, { + ResolvedThemeInterface, + StyledComponentClass, + withProps, +} from '../styled-components'; export const OneOfList = styled.ul` margin: 0; diff --git a/src/common-elements/shelfs.tsx b/src/common-elements/shelfs.tsx index 9a5df8b4..16998376 100644 --- a/src/common-elements/shelfs.tsx +++ b/src/common-elements/shelfs.tsx @@ -1,5 +1,9 @@ import * as React from 'react'; -import styled, { withProps } from '../styled-components'; +import styled, { + ResolvedThemeInterface, + StyledComponentClass, + withProps, +} from '../styled-components'; const directionMap = { left: '90deg', diff --git a/src/common-elements/tabs.ts b/src/common-elements/tabs.ts index c52a0b6d..cf9409e5 100644 --- a/src/common-elements/tabs.ts +++ b/src/common-elements/tabs.ts @@ -1,5 +1,5 @@ -import { Tabs as ReactTabs } from 'react-tabs'; -import styled from '../styled-components'; +import { Tabs as ReactTabs, TabsProps } from 'react-tabs'; +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../styled-components'; export { Tab, TabList, TabPanel } from 'react-tabs'; diff --git a/src/components/ApiInfo/ApiInfo.tsx b/src/components/ApiInfo/ApiInfo.tsx index 329fc644..7931f2ce 100644 --- a/src/components/ApiInfo/ApiInfo.tsx +++ b/src/components/ApiInfo/ApiInfo.tsx @@ -15,7 +15,7 @@ import { InfoSpanBoxWrap, } from './styled.elements'; -interface ApiInfoProps { +export interface ApiInfoProps { store: AppStore; } diff --git a/src/components/ApiInfo/styled.elements.ts b/src/components/ApiInfo/styled.elements.ts index 58df6b22..7852821f 100644 --- a/src/components/ApiInfo/styled.elements.ts +++ b/src/components/ApiInfo/styled.elements.ts @@ -1,6 +1,7 @@ -import styled from '../../styled-components'; +import { AnchorHTMLAttributes, ClassAttributes, HTMLAttributes } from 'react'; import { H1, MiddlePanel } from '../../common-elements'; +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; const delimiterWidth = 15; diff --git a/src/components/ApiLogo/styled.elements.tsx b/src/components/ApiLogo/styled.elements.tsx index 321256de..ce67639b 100644 --- a/src/components/ApiLogo/styled.elements.tsx +++ b/src/components/ApiLogo/styled.elements.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import styled from '../../styled-components'; +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; export const LogoImgEl = styled.img` max-height: ${props => props.theme.logo.maxHeight}; diff --git a/src/components/ContentItems/ContentItems.tsx b/src/components/ContentItems/ContentItems.tsx index f266854d..0c775a33 100644 --- a/src/components/ContentItems/ContentItems.tsx +++ b/src/components/ContentItems/ContentItems.tsx @@ -22,7 +22,7 @@ export class ContentItems extends React.Component<{ } } -interface ContentItemProps { +export interface ContentItemProps { item: ContentItemModel; } diff --git a/src/components/Endpoint/styled.elements.ts b/src/components/Endpoint/styled.elements.ts index a57219eb..e95df0d8 100644 --- a/src/components/Endpoint/styled.elements.ts +++ b/src/components/Endpoint/styled.elements.ts @@ -1,4 +1,10 @@ -import styled, { withProps } from '../../styled-components'; +import { ClassAttributes, HTMLAttributes, HTMLProps } from 'react'; + +import styled, { + ResolvedThemeInterface, + StyledComponentClass, + withProps, +} from '../../styled-components'; export const OperationEndpointWrap = styled.div` cursor: pointer; diff --git a/src/components/JsonViewer/JsonViewer.tsx b/src/components/JsonViewer/JsonViewer.tsx index fed03c6b..f45e7224 100644 --- a/src/components/JsonViewer/JsonViewer.tsx +++ b/src/components/JsonViewer/JsonViewer.tsx @@ -1,12 +1,12 @@ import * as React from 'react'; -import styled from '../../styled-components'; +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; import { SampleControls } from '../../common-elements'; import { CopyButtonWrapper } from '../../common-elements/CopyButtonWrapper'; import { jsonToHTML } from '../../utils/jsonToHtml'; import { jsonStyles } from './style'; -interface JsonProps { +export interface JsonProps { data: any; className?: string; } diff --git a/src/components/JsonViewer/style.ts b/src/components/JsonViewer/style.ts index 3a4c7147..3bed1f75 100644 --- a/src/components/JsonViewer/style.ts +++ b/src/components/JsonViewer/style.ts @@ -1,4 +1,5 @@ -import { css } from '../../styled-components'; +import { InterpolationFunction, Styles, ThemeProps } from 'styled-components'; +import { css, ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; export const jsonStyles = css` .redoc-json > .collapser { diff --git a/src/components/Loading/Spinner.svg.tsx b/src/components/Loading/Spinner.svg.tsx index fd9d73d8..850e3060 100644 --- a/src/components/Loading/Spinner.svg.tsx +++ b/src/components/Loading/Spinner.svg.tsx @@ -1,5 +1,9 @@ import * as React from 'react'; -import styled, { keyframes } from '../../styled-components'; +import styled, { + keyframes, + ResolvedThemeInterface, + StyledComponentClass, +} from '../../styled-components'; const _Spinner = (props: { className?: string; color: string }) => ( diff --git a/src/components/Markdown/Markdown.tsx b/src/components/Markdown/Markdown.tsx index 1cc58e67..a64db627 100644 --- a/src/components/Markdown/Markdown.tsx +++ b/src/components/Markdown/Markdown.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import styled from '../../styled-components'; +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; import * as DOMPurify from 'dompurify'; import { AppStore, MarkdownRenderer } from '../../services'; diff --git a/src/components/Markdown/styles.ts b/src/components/Markdown/styles.ts index be07a387..da7a4427 100644 --- a/src/components/Markdown/styles.ts +++ b/src/components/Markdown/styles.ts @@ -1,5 +1,7 @@ +import { InterpolationFunction, Styles, ThemeProps } from 'styled-components'; + import { headerCommonMixin, linkifyMixin } from '../../common-elements'; -import { css } from '../../styled-components'; +import { css, ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; export const markdownCss = css` p { diff --git a/src/components/Operation/Operation.tsx b/src/components/Operation/Operation.tsx index 75c8fd92..493c3df8 100644 --- a/src/components/Operation/Operation.tsx +++ b/src/components/Operation/Operation.tsx @@ -35,7 +35,7 @@ const OperationRow = Row.extend` } `; -interface OperationProps { +export interface OperationProps { operation: OperationType; } diff --git a/src/components/OptionsProvider.ts b/src/components/OptionsProvider.ts index abc5b892..5353bd48 100644 --- a/src/components/OptionsProvider.ts +++ b/src/components/OptionsProvider.ts @@ -3,19 +3,6 @@ import * as React from 'react'; import { RedocNormalizedOptions } from '../services/RedocNormalizedOptions'; -// TODO: contribute declarations to @types/react once 16.3 is released -type ReactProviderComponent = React.ComponentType<{ value: T }>; -type ReactConsumerComponent = React.ComponentType<{ children: ((value: T) => React.ReactNode) }>; - -interface ReactContext { - Provider: ReactProviderComponent; - Consumer: ReactConsumerComponent; -} - -declare module 'react' { - function createContext(defatulValue: T): ReactContext; -} - export const OptionsContext = React.createContext(new RedocNormalizedOptions({})); export const OptionsProvider = OptionsContext.Provider; export const OptionsConsumer = OptionsContext.Consumer; diff --git a/src/components/Parameters/Parameters.tsx b/src/components/Parameters/Parameters.tsx index 1c45ff56..9f8d4842 100644 --- a/src/components/Parameters/Parameters.tsx +++ b/src/components/Parameters/Parameters.tsx @@ -17,7 +17,7 @@ function safePush(obj, prop, item) { obj[prop].push(item); } -interface ParametersProps { +export interface ParametersProps { parameters?: FieldModel[]; body?: RequestBodyModel; } diff --git a/src/components/PayloadSamples/styled.elements.ts b/src/components/PayloadSamples/styled.elements.ts index 31334f28..80a29a5b 100644 --- a/src/components/PayloadSamples/styled.elements.ts +++ b/src/components/PayloadSamples/styled.elements.ts @@ -1,6 +1,7 @@ -import styled from '../../styled-components'; +import { ClassAttributes, HTMLAttributes } from 'react'; +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; -import { StyledDropdown } from '../../common-elements'; +import { DropdownProps, StyledDropdown } from '../../common-elements'; export const MimeLabel = styled.div` border-bottom: 1px solid rgba(255, 255, 255, 0.9); diff --git a/src/components/Redoc/Redoc.tsx b/src/components/Redoc/Redoc.tsx index b63642df..61fafc3a 100644 --- a/src/components/Redoc/Redoc.tsx +++ b/src/components/Redoc/Redoc.tsx @@ -32,7 +32,9 @@ export class Redoc extends React.Component { } render() { - const { store: { spec, menu, options, search, marker } } = this.props; + const { + store: { spec, menu, options, search, marker }, + } = this.props; const store = this.props.store; return ( diff --git a/src/components/Redoc/elements.tsx b/src/components/Redoc/elements.tsx index d1a3d16c..6ce5e60f 100644 --- a/src/components/Redoc/elements.tsx +++ b/src/components/Redoc/elements.tsx @@ -1,5 +1,10 @@ -import styled, { media } from '../../styled-components'; -export { ClassAttributes } from 'react'; +import { ClassAttributes, HTMLAttributes } from 'react'; + +import styled, { + media, + ResolvedThemeInterface, + StyledComponentClass, +} from '../../styled-components'; export const RedocWrap = styled.div` font-family: ${props => props.theme.baseFont.family}; diff --git a/src/components/Responses/styled.elements.ts b/src/components/Responses/styled.elements.ts index 20a83a0a..f16587ee 100644 --- a/src/components/Responses/styled.elements.ts +++ b/src/components/Responses/styled.elements.ts @@ -1,8 +1,9 @@ -import styled from '../../styled-components'; - import { transparentize } from 'polished'; +import { ClassAttributes, HTMLAttributes } from 'react'; + import { UnderlinedHeader } from '../../common-elements'; -import { ResponseTitle } from './ResponseTitle'; +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; +import { ResponseTitle, ResponseTitleProps } from './ResponseTitle'; export const StyledResponseTitle = styled(ResponseTitle)` padding: 10px; diff --git a/src/components/Schema/ObjectSchema.tsx b/src/components/Schema/ObjectSchema.tsx index 5f426095..f8db1401 100644 --- a/src/components/Schema/ObjectSchema.tsx +++ b/src/components/Schema/ObjectSchema.tsx @@ -24,7 +24,11 @@ export class ObjectSchema extends React.Component { } render() { - const { schema: { fields = [] }, showTitle, discriminator } = this.props; + const { + schema: { fields = [] }, + showTitle, + discriminator, + } = this.props; const needFilter = this.props.skipReadOnly || this.props.skipWriteOnly; diff --git a/src/components/Schema/OneOfSchema.tsx b/src/components/Schema/OneOfSchema.tsx index d0a46dcf..bc7364c9 100644 --- a/src/components/Schema/OneOfSchema.tsx +++ b/src/components/Schema/OneOfSchema.tsx @@ -34,7 +34,10 @@ export class OneOfButton extends React.Component { @observer export class OneOfSchema extends React.Component { render() { - const { schema: { oneOf }, schema } = this.props; + const { + schema: { oneOf }, + schema, + } = this.props; if (oneOf === undefined) { return null; diff --git a/src/components/SearchBox/SearchBox.tsx b/src/components/SearchBox/SearchBox.tsx index ff5b00ae..288ee076 100644 --- a/src/components/SearchBox/SearchBox.tsx +++ b/src/components/SearchBox/SearchBox.tsx @@ -7,7 +7,13 @@ import { MenuItem } from '../SideMenu/MenuItem'; import { MarkerService } from '../../services/MarkerService'; import { SearchDocument } from '../../services/SearchWorker.worker'; -import { ClearIcon, SearchIcon, SearchInput, SearchResultsBox, SearchWrap } from './elements'; +import { + ClearIcon, + SearchIcon, + SearchInput, + SearchResultsBox, + SearchWrap, +} from './styled.elements'; export interface SearchBoxProps { search: SearchStore; diff --git a/src/components/SearchBox/elements.tsx b/src/components/SearchBox/styled.elements.tsx similarity index 96% rename from src/components/SearchBox/elements.tsx rename to src/components/SearchBox/styled.elements.tsx index 23de176f..ca3bdb3b 100644 --- a/src/components/SearchBox/elements.tsx +++ b/src/components/SearchBox/styled.elements.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; -import styled from '../../styled-components'; + +import styled, { ResolvedThemeInterface, StyledComponentClass } from '../../styled-components'; import { MenuItemLabel } from '../SideMenu/styled.elements'; export const SearchWrap = styled.div` diff --git a/src/components/SecurityRequirement/SecuirityRequirement.tsx b/src/components/SecurityRequirement/SecuirityRequirement.tsx index 7919ba01..194e6856 100644 --- a/src/components/SecurityRequirement/SecuirityRequirement.tsx +++ b/src/components/SecurityRequirement/SecuirityRequirement.tsx @@ -1,5 +1,6 @@ import { transparentize } from 'polished'; import * as React from 'react'; + import styled from '../../styled-components'; import { UnderlinedHeader } from '../../common-elements/headers'; diff --git a/src/components/SideMenu/MenuItem.tsx b/src/components/SideMenu/MenuItem.tsx index 4f903e54..b2d19578 100644 --- a/src/components/SideMenu/MenuItem.tsx +++ b/src/components/SideMenu/MenuItem.tsx @@ -6,7 +6,7 @@ import { IMenuItem, OperationModel } from '../../services'; import { MenuItems } from './MenuItems'; import { MenuItemLabel, MenuItemLi, MenuItemTitle, OperationBadge } from './styled.elements'; -interface MenuItemProps { +export interface MenuItemProps { item: IMenuItem; onActivate?: (item: IMenuItem) => void; withoutChildren?: boolean; diff --git a/src/components/SideMenu/MenuItems.tsx b/src/components/SideMenu/MenuItems.tsx index 16fa79ea..c980a2e0 100644 --- a/src/components/SideMenu/MenuItems.tsx +++ b/src/components/SideMenu/MenuItems.tsx @@ -6,7 +6,7 @@ import { IMenuItem } from '../../services'; import { MenuItem } from './MenuItem'; import { MenuItemUl } from './styled.elements'; -interface MenuItemsProps { +export interface MenuItemsProps { items: IMenuItem[]; active?: boolean; onActivate?: (item: IMenuItem) => void; diff --git a/src/components/SideMenu/index.ts b/src/components/SideMenu/index.ts new file mode 100644 index 00000000..90fe8716 --- /dev/null +++ b/src/components/SideMenu/index.ts @@ -0,0 +1,4 @@ +export * from './MenuItem'; +export * from './MenuItems'; +export * from './SideMenu'; +export * from './styled.elements'; diff --git a/src/components/SideMenu/styled.elements.ts b/src/components/SideMenu/styled.elements.ts index 379cb24d..a620fdb5 100644 --- a/src/components/SideMenu/styled.elements.ts +++ b/src/components/SideMenu/styled.elements.ts @@ -1,7 +1,14 @@ import * as classnames from 'classnames'; +import * as React from 'react'; +import { InterpolationFunction, Styles, ThemeProps } from 'styled-components'; import { deprecatedCss } from '../../common-elements'; -import styled, { css, withProps } from '../../styled-components'; +import styled, { + css, + ResolvedThemeInterface, + StyledComponentClass, + withProps, +} from '../../styled-components'; export const OperationBadge = withProps<{ type: string }>(styled.span).attrs({ className: props => `operation-type ${props.type}`, diff --git a/src/components/StoreProvider.ts b/src/components/StoreProvider.ts index 09d77490..9809e71a 100644 --- a/src/components/StoreProvider.ts +++ b/src/components/StoreProvider.ts @@ -5,7 +5,7 @@ import { RedocRawOptions } from '../services/RedocNormalizedOptions'; import { OpenAPISpec } from '../types'; import { loadAndBundleSpec } from '../utils'; -interface StoreProviderProps { +export interface StoreProviderProps { specUrl?: string; spec?: object; store?: AppStore; @@ -15,7 +15,7 @@ interface StoreProviderProps { children: (props: { loading: boolean; store?: AppStore }) => any; } -interface StoreProviderState { +export interface StoreProviderState { error?: Error; loading: boolean; store?: AppStore; diff --git a/src/components/index.ts b/src/components/index.ts index 45a4ead1..7f58edc0 100644 --- a/src/components/index.ts +++ b/src/components/index.ts @@ -10,4 +10,6 @@ export * from './JsonViewer'; export * from './ErrorBoundary'; export * from './StoreProvider'; -// re-export the rest of components +export * from './SideMenu/'; +export * from './StickySidebar/StickyResponsiveSidebar'; +export * from './SearchBox/SearchBox'; diff --git a/src/index.ts b/src/index.ts index bb468787..5dc04e42 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,6 @@ export * from './components'; export * from './services'; export * from './utils'; + +export * from './styled-components'; +export { default as styled } from './styled-components'; diff --git a/src/services/HistoryService.ts b/src/services/HistoryService.ts index 2ae14c3d..23febc9d 100644 --- a/src/services/HistoryService.ts +++ b/src/services/HistoryService.ts @@ -8,7 +8,7 @@ function isSameHash(a: string, b: string): boolean { return a === b || '#' + a === b || a === '#' + b; } -class IntHistoryService { +export class IntHistoryService { private causedHashChange: boolean = false; private _emiter; diff --git a/src/services/MarkdownRenderer.ts b/src/services/MarkdownRenderer.ts index b651a14b..74d11aeb 100644 --- a/src/services/MarkdownRenderer.ts +++ b/src/services/MarkdownRenderer.ts @@ -19,7 +19,7 @@ export function buildComponentComment(name: string) { return ``; } -interface MarkdownHeading { +export interface MarkdownHeading { id: string; name: string; items?: MarkdownHeading[]; diff --git a/src/services/SearchStore.ts b/src/services/SearchStore.ts index 8723554c..0b0d68bd 100644 --- a/src/services/SearchStore.ts +++ b/src/services/SearchStore.ts @@ -2,7 +2,9 @@ import { IS_BROWSER } from '../utils/'; import { IMenuItem } from './MenuStore'; import { OperationModel } from './models'; -let worker; +import Worker, { SearchDocument, SearchResult } from './SearchWorker.worker'; + +let worker: new () => Worker; if (IS_BROWSER) { try { diff --git a/src/services/SearchWorker.worker.ts b/src/services/SearchWorker.worker.ts index af17f3d1..449d1336 100644 --- a/src/services/SearchWorker.worker.ts +++ b/src/services/SearchWorker.worker.ts @@ -60,7 +60,7 @@ export async function load(state: any) { resolveIndex(lunr.Index.load(state.index)); } -export async function search(q: string): Promise { +export async function search(q: string): Promise> { if (q.trim().length === 0) { return []; } diff --git a/src/services/SpecStore.ts b/src/services/SpecStore.ts index 0f6544fd..2e6d67e9 100644 --- a/src/services/SpecStore.ts +++ b/src/services/SpecStore.ts @@ -1,9 +1,8 @@ import { computed, observable } from 'mobx'; -import { OpenAPISpec } from '../types'; - -// import { OpenAPIExternalDocumentation, OpenAPIInfo } from '../types'; +import { OpenAPIExternalDocumentation, OpenAPISpec } from '../types'; import { MenuBuilder } from './MenuBuilder'; +import { GroupModel, OperationModel } from './models/'; import { ApiInfoModel } from './models/ApiInfo'; import { SecuritySchemesModel } from './models/SecuritySchemes'; import { OpenAPIParser } from './OpenAPIParser'; diff --git a/src/services/models/SecurityRequirement.ts b/src/services/models/SecurityRequirement.ts index e35343ec..62fe2ca4 100644 --- a/src/services/models/SecurityRequirement.ts +++ b/src/services/models/SecurityRequirement.ts @@ -2,7 +2,7 @@ import { OpenAPISecurityRequirement } from '../../types'; import { SECURITY_SCHEMES_SECTION } from '../../utils/openapi'; import { OpenAPIParser } from '../OpenAPIParser'; -interface SecurityScheme { +export interface SecurityScheme { id: string; sectionId: string; type: string; diff --git a/src/styled-components.ts b/src/styled-components.ts index d2901844..78dfb015 100644 --- a/src/styled-components.ts +++ b/src/styled-components.ts @@ -1,7 +1,12 @@ +import { ComponentClass, StatelessComponent } from 'react'; import * as styledComponents from 'styled-components'; import { ResolvedThemeInterface } from './theme'; +export { ResolvedThemeInterface }; + +export type InterpolationFunction

= styledComponents.InterpolationFunction

; + export type StyledFunction = styledComponents.ThemedStyledFunction; function withProps( diff --git a/tsconfig.json b/tsconfig.json index 04950bbc..28e98b3c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,8 @@ "noUnusedParameters": true, "strictNullChecks": true, "sourceMap": true, - // "declaration": true, + "declaration": true, + "declarationDir": "typings", "noEmitHelpers": true, "importHelpers": true, "outDir": "lib", diff --git a/tsconfig.lib.json b/tsconfig.lib.json new file mode 100644 index 00000000..c9b132f7 --- /dev/null +++ b/tsconfig.lib.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "include": [ + "./custom.d.ts", + "src/index.ts" + ] +} \ No newline at end of file diff --git a/tslint.json b/tslint.json index 415245bb..352ea5ae 100644 --- a/tslint.json +++ b/tslint.json @@ -17,7 +17,7 @@ "quotemark": [true, "single", "avoid-template", "jsx-double"], "variable-name": [true, "ban-keywords", "check-format", "allow-leading-underscore", "allow-pascal-case"], "arrow-parens": [true, "ban-single-arg-parens"], - "no-submodule-imports": [true, "prismjs", "perfect-scrollbar"], + "no-submodule-imports": [true, "prismjs", "perfect-scrollbar", "core-js"], "object-literal-key-quotes": [true, "as-needed"], "no-unused-expression": [true, "allow-tagged-template"], "semicolon": [true, "always", "ignore-bound-class-methods"],