Skip to content

Commit

Permalink
update ts types (#178)
Browse files Browse the repository at this point in the history
* Correct unclear unit test

* Correct limited typing

* Bump dependencies

* Update build

* Bump version to 1.28.2

Co-authored-by: Troy Alford <[email protected]>
  • Loading branch information
TroyAlford and Troy Alford authored Feb 7, 2021
1 parent 972e162 commit bec2ef0
Show file tree
Hide file tree
Showing 11 changed files with 1,758 additions and 3,306 deletions.
2 changes: 1 addition & 1 deletion dist/cjs/react-jsx-parser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cjs/react-jsx-parser.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/components/JsxParser.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, FunctionComponent } from 'react';
import React, { ComponentType, ExoticComponent } from 'react';
export declare type TProps = {
allowUnknownElements?: boolean;
autoCloseVoidElements?: boolean;
Expand All @@ -8,7 +8,7 @@ export declare type TProps = {
blacklistedAttrs?: Array<string | RegExp>;
blacklistedTags?: string[];
className?: string;
components?: Record<string, Component | FunctionComponent>;
components?: Record<string, ComponentType | ExoticComponent>;
componentsOnly?: boolean;
disableFragments?: boolean;
disableKeyGeneration?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion dist/es5/react-jsx-parser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/es5/react-jsx-parser.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/umd/react-jsx-parser.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/umd/react-jsx-parser.min.js.map

Large diffs are not rendered by default.

83 changes: 42 additions & 41 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,75 +14,76 @@
"types": "dist/index.d.ts",
"name": "react-jsx-parser",
"repository": "TroyAlford/react-jsx-parser",
"version": "1.28.1",
"version": "1.28.2",
"dependencies": {
"@types/jsdom": "^16.2.4",
"acorn": "^8.0.4",
"@types/jsdom": "^16.2.6",
"acorn": "^8.0.5",
"acorn-jsx": "^5.3.1",
"core-js": "^3.6.5"
"core-js": "^3.8.3",
"patch-package": "^6.2.2"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-transform-typescript": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@babel/runtime-corejs3": "^7.12.1",
"@babel/core": "^7.12.13",
"@babel/plugin-proposal-class-properties": "^7.12.13",
"@babel/plugin-transform-typescript": "^7.12.13",
"@babel/preset-env": "^7.12.13",
"@babel/preset-react": "^7.12.13",
"@babel/preset-typescript": "^7.12.13",
"@babel/runtime-corejs3": "^7.12.13",
"@types/acorn": "^4.0.5",
"@types/enzyme": "^3.10.7",
"@types/jest": "^26.0.14",
"@typescript-eslint/eslint-plugin": "^4.4.1",
"@typescript-eslint/parser": "^4.4.1",
"@types/enzyme": "^3.10.8",
"@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.5.2",
"babel-loader": "^8.1.0",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"concurrently": "^5.3.0",
"cross-env": "^7.0.2",
"cross-env": "^7.0.3",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint": "^7.11.0",
"eslint-config-airbnb": "^18.2.0",
"enzyme-adapter-react-16": "^1.15.6",
"eslint": "^7.19.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.21.4",
"eslint-plugin-react-hooks": "^4.1.2",
"jest": "^26.5.3",
"jest-cli": "^26.5.3",
"jest-environment-jsdom-fourteen": "^1.0.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.22.0",
"eslint-plugin-react-hooks": "^4.2.0",
"jest": "^26.6.3",
"jest-cli": "^26.6.3",
"mkdirp": "^1.0.4",
"patch-package": "^6.2.2",
"postinstall-postinstall": "^2.1.0",
"react": "^16",
"react-dom": "^16",
"source-map-explorer": "^2.5.0",
"terser-webpack-plugin": "^5.0.0",
"typescript": "^4.0.5",
"webpack": "^5.1.3",
"webpack-cli": "^4.0.0",
"webpack-dev-server": "^3.11.0"
"source-map-explorer": "^2.5.2",
"terser-webpack-plugin": "^5.1.1",
"typescript": "^4.1.3",
"webpack": "^5.21.2",
"webpack-cli": "^4.5.0",
"webpack-dev-server": "^3.11.2"
},
"optionalDependencies": {
"@types/react": "^17.0.0",
"@types/react": "^17.0.1",
"@types/react-dom": "^17.0.0"
},
"peerDependencies": {
"react": ">=16",
"react-dom": ">=16"
"react": ">=17",
"react-dom": ">=17"
},
"resolutions": {
"@types/react": "^17.0.0",
"@types/react": "^17.0.1",
"@types/react-dom": "^17.0.0",
"browserslist": "^4.14.5",
"extend": "^3.0.2",
"merge": "^1.2.1"
"merge": "^1.2.1"
},
"scripts": {
"build": "yarn patch-package && yarn types && cross-env NODE_ENV=production webpack",
"develop": "NODE_ENV=production concurrently -n build,ts,demo -c green,cyan,yellow \"yarn webpack --watch\" \"yarn types --watch\" \"yarn webpack serve --config ./webpack.demo.js\"",
"types": "tsc -p ./tsconfig.json -d --emitDeclarationOnly",
"postinstall": "yarn patch-package",
"prebuild": "mkdirp ./dist && rm -rf ./dist/*",
"sourcemap": "yarn build && source-map-explorer ./dist/es5/react-jsx-parser.min.js",
"test": "yarn patch-package && yarn jest"
"test": "jest",
"types": "tsc -p ./tsconfig.json -d --emitDeclarationOnly"
},
"contributors": [
{
Expand Down
4 changes: 2 additions & 2 deletions source/components/JsxParser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1136,9 +1136,9 @@ describe('JsxParser Component', () => {
expect(rendered.childNodes[0].childNodes).toHaveLength(0)
expect(rendered.getElementsByTagName('div')).toHaveLength(1)
})
test('props.autoCloseVoidElements=true prevents self-closing tags with closing tags from parsing', () => {
test('props.autoCloseVoidElements=false will treats self-closing tags by jsx rules (does not parse)', () => {
const { rendered } = render(
<JsxParser autoCloseVoidElements jsx='<img src="/foo.png"></img><div></div>' />,
<JsxParser autoCloseVoidElements={false} jsx='<img src="/foo.png"><div></div>' />,
)
expect(rendered.childNodes).toHaveLength(0)
})
Expand Down
4 changes: 2 additions & 2 deletions source/components/JsxParser.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global JSX */
import * as Acorn from 'acorn'
import * as AcornJSX from 'acorn-jsx'
import React, { Component, FunctionComponent, Fragment } from 'react'
import React, { Fragment, ComponentType, ExoticComponent } from 'react'
import ATTRIBUTES from '../constants/attributeNames'
import { canHaveChildren, canHaveWhitespace } from '../constants/specialTags'
import { randomHash } from '../helpers/hash'
Expand All @@ -17,7 +17,7 @@ export type TProps = {
blacklistedAttrs?: Array<string | RegExp>,
blacklistedTags?: string[],
className?: string,
components?: Record<string, Component | FunctionComponent>,
components?: Record<string, ComponentType | ExoticComponent>,
componentsOnly?: boolean,
disableFragments?: boolean,
disableKeyGeneration?: boolean,
Expand Down
Loading

0 comments on commit bec2ef0

Please sign in to comment.