Skip to content

Commit

Permalink
Added typescript declarations to core-react (#625)
Browse files Browse the repository at this point in the history
* Added missing ts-no-checks

* Added declarations to lib bundle
  • Loading branch information
Michael Marszalek authored and vnys committed Nov 13, 2020
1 parent dad3482 commit c9aa99e
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 25 deletions.
3 changes: 2 additions & 1 deletion libraries/core-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"main": "dist/core-react.cjs.js",
"module": "dist/core-react.es.js",
"browser": "dist/core-react.umd.js",
"types": "dist/types/index.d.ts",
"license": "AGPL-3.0-or-later",
"author": {
"name": "EDS Core Team",
Expand Down Expand Up @@ -46,7 +47,6 @@
"@rollup/plugin-commonjs": "^13.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.0.1",
"@rollup/plugin-typescript": "^5.0.2",
"@testing-library/jest-dom": "^5.9.0",
"@testing-library/react": "^10.2.1",
"@testing-library/user-event": "^10.3.2",
Expand All @@ -65,6 +65,7 @@
"react-dom": "^16.13.1",
"rollup": "^2.15.0",
"rollup-plugin-polyfill": "^3.0.0",
"rollup-plugin-typescript2": "^0.27.2",
"styled-components": "4.4.1",
"ts-jest": "^26.3.0",
"tslib": "^2.0.1",
Expand Down
67 changes: 49 additions & 18 deletions libraries/core-react/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions libraries/core-react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import babel from '@rollup/plugin-babel'
import polyfill from 'rollup-plugin-polyfill'
import typescript from '@rollup/plugin-typescript'
import typescript from 'rollup-plugin-typescript2'

import pkg from './package.json'

Expand All @@ -17,11 +17,10 @@ const globals = {
'styled-components': 'styled',
}

const buildForStorybook = process.env.STORYBOOK
const extensions = ['.jsx', '.js', '.tsx', '.ts']
export default [
{
input: './src/index.js',
input: './src/index.ts',
external: peerDeps,
watch: {
clearScreen: true,
Expand All @@ -30,7 +29,7 @@ export default [
plugins: [
json(),
resolve({ extensions }),
typescript(),
typescript({ useTsconfigDeclarationDir: true }),
babel({
exclude: 'node_modules/**',
babelHelpers: 'bundled',
Expand All @@ -50,7 +49,10 @@ export default [
sourcemap: true,
globals,
},
...(buildForStorybook ? [] : [{ file: pkg.main, format: 'cjs' }]),
{
file: pkg.main,
format: 'cjs',
},
],
},
]
1 change: 1 addition & 0 deletions libraries/core-react/src/Menu/Menu.context.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import React, { useState, useContext } from 'react'
import PropTypes from 'prop-types'

Expand Down
1 change: 1 addition & 0 deletions libraries/core-react/src/Menu/Menu.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import React, { useEffect, useRef } from 'react'
import PropTypes from 'prop-types'
import styled, { css } from 'styled-components'
Expand Down
1 change: 1 addition & 0 deletions libraries/core-react/src/Menu/Menu.test.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
/* eslint-disable no-undef */
import React from 'react'
import { render, cleanup, screen, fireEvent } from './test-utils'
Expand Down
1 change: 1 addition & 0 deletions libraries/core-react/src/Menu/MenuItem.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import React from 'react'
import PropTypes from 'prop-types'
import styled, { css } from 'styled-components'
Expand Down
1 change: 1 addition & 0 deletions libraries/core-react/src/Menu/MenuList.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import React, { useEffect } from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
Expand Down
1 change: 1 addition & 0 deletions libraries/core-react/src/Menu/MenuSection.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import React from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
Expand Down
1 change: 1 addition & 0 deletions libraries/core-react/src/Menu/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import React from 'react'
import { Menu as BaseMenu } from './Menu'
import { MenuItem } from './MenuItem'
Expand Down
1 change: 1 addition & 0 deletions libraries/core-react/src/Paper/Paper.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-nocheck
import React, { forwardRef } from 'react'
import PropTypes from 'prop-types'
import styled from 'styled-components'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable import/prefer-default-export */
// @ts-nocheck
export { Button } from './Button'
export { Typography } from './Typography'
export { Table } from './Table'
Expand Down
5 changes: 5 additions & 0 deletions libraries/core-react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "./dist/types",
"outDir": "./dist"
},
"include": ["./src/**/*.ts*"],
"exclude": ["node_modules"]
}

0 comments on commit c9aa99e

Please sign in to comment.