Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 修复 f2 和 react 同时使用时,shape 标签类型提示报错 #1407

Merged
merged 1 commit into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
runner: 'jest-electron/runner',
testEnvironment: 'jest-electron/environment',
preset: 'ts-jest',
preset: 'ts-jest/presets/js-with-ts',
collectCoverage: false,
collectCoverageFrom: ['packages/*/src/**/*.{ts,tsx,js}', '!**/node_modules/**'],
modulePathIgnorePatterns: ['packages/*/dist'],
Expand Down
166 changes: 0 additions & 166 deletions packages/f2/src/base/diff-recursive.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/f2/src/jsx/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jsx from './jsx-classic';
import { jsx } from './jsx-classic';
import Fragment from './fragment';
import render from './render';
import renderJSXElement from './renderJSXElement';
Expand Down
4 changes: 2 additions & 2 deletions packages/f2/src/jsx/jsx-automatic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import JSX from './interface';
import JSX from './types';
import { ElementType } from '../types';

// 实现jsx-automatic 入口
export default function(type: ElementType, config, key?: string): JSX.Element {
export function jsx(type: ElementType, config, key?: string): JSX.Element {
const { ref, ...props } = config || {};
return {
key,
Expand Down
15 changes: 15 additions & 0 deletions packages/f2/src/jsx/jsx-classic.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* ref: https://github.com/microsoft/TypeScript/pull/22207
*/

import GlobalJSX from './types';

export namespace jsx {
export namespace JSX {
export type Element = GlobalJSX.Element;
export type ElementClass = GlobalJSX.ElementClass;
export type IntrinsicElements = GlobalJSX.IntrinsicElements;
}
}

export function jsx(): jsx.JSX.Element;
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import JSX from './interface';
import { ElementType } from '../types';

// 实现jsx-classic 入口
export default function(type: ElementType, config, ...children): JSX.Element {
export function jsx(type, config, ...children) {
const { key, ref, ...props } = config || {};

// 保持和automatic模式一致
Expand Down
2 changes: 1 addition & 1 deletion packages/f2/src/jsx/jsx-runtime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jsx from './jsx-automatic';
import { jsx } from './jsx-automatic';
import Fragment from './fragment';

export { Fragment, jsx, jsx as jsxs };
2 changes: 1 addition & 1 deletion packages/f2/src/jsx/render.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JSX from './interface';
import JSX from './types';
import { extendMap, px2hd } from '../util';
import { omit } from '@antv/util';
import computeLayout from './css-layout';
Expand Down
2 changes: 1 addition & 1 deletion packages/f2/src/jsx/renderJSXElement.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import JSX from './interface';
import JSX from './types';
import Children from '../children';

// 主要是把function节点,全部转换成string标签节点
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions packages/f2/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ export type ElementType =
| ((props: Props, context?: any) => any)
| (new (props: Props, context?: any) => any);



export interface ShapeAttrs extends Partial<SupportPx<Types.ShapeAttrs>>{
[k: string]: any;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/f2/typing.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import '../../typings';
import './src/jsx/interface';
import './src/jsx/types';
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"moduleResolution": "node",
"useDefineForClassFields": false,
"resolveJsonModule": true,
"skipLibCheck": true
"skipLibCheck": true,
"allowJs": true
},
"exclude": [
"scripts",
Expand Down