chore: TypeScript Configuration Modernization and Cleanup (#35159)

This commit is contained in:
Michael S. Molina
2025-09-18 16:27:57 -03:00
committed by GitHub
parent a889ae75fc
commit 6cb3ef9f5d
69 changed files with 392 additions and 481 deletions

View File

@@ -143,7 +143,7 @@ jobs:
- name: tsc
run: |
docker run --rm $TAG bash -c \
"npm run type"
"npm run plugins:build && npm run type"
validate-frontend:
needs: frontend-build

View File

@@ -33,6 +33,7 @@ module.exports = {
'^@superset-ui/([^/]+)$': '<rootDir>/node_modules/@superset-ui/$1/src',
// mapping @apache-superset/core to local package
'^@apache-superset/core$': '<rootDir>/packages/superset-core/src',
'^@apache-superset/core/(.*)$': '<rootDir>/packages/superset-core/src/$1',
},
testEnvironment: '<rootDir>/spec/helpers/jsDomWithFetchAPI.ts',
modulePathIgnorePatterns: ['<rootDir>/packages/generator-superset'],

View File

@@ -63387,6 +63387,7 @@
"version": "0.20.3",
"license": "Apache-2.0",
"dependencies": {
"@apache-superset/core": "*",
"@react-icons/all-files": "^4.1.0",
"@types/react": "*",
"lodash": "^4.17.21"
@@ -63414,6 +63415,7 @@
"license": "Apache-2.0",
"dependencies": {
"@ant-design/icons": "^5.2.6",
"@apache-superset/core": "*",
"@babel/runtime": "^7.28.2",
"@fontsource/fira-code": "^5.2.6",
"@fontsource/inter": "^5.2.6",
@@ -65460,6 +65462,7 @@
},
"peerDependencies": {
"@ant-design/icons": "^5.2.6",
"@apache-superset/core": "*",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",
"@testing-library/dom": "^8.20.1",
@@ -65511,6 +65514,7 @@
"lodash": "^4.17.21"
},
"peerDependencies": {
"@apache-superset/core": "*",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",
"echarts": "*",
@@ -66688,6 +66692,7 @@
},
"peerDependencies": {
"@ant-design/icons": "^5.2.6",
"@apache-superset/core": "*",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",
"lodash": "^4.17.11",
@@ -67819,6 +67824,7 @@
},
"peerDependencies": {
"@ant-design/icons": "^5.2.6",
"@apache-superset/core": "*",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",
"@testing-library/dom": "^8.20.1",

View File

@@ -22,19 +22,6 @@ To add the package to Superset, go to the `superset-frontend` subdirectory in yo
npm i -S ../../<%= packageName %>
```
If your Superset plugin exists in the `superset-frontend` directory and you wish to resolve TypeScript errors about `@superset-ui/core` not being resolved correctly, add the following to your `tsconfig.json` file:
```
"references": [
{
"path": "../../packages/superset-ui-chart-controls"
},
{
"path": "../../packages/superset-ui-core"
}
]
```
You may also wish to add the following to the `include` array in `tsconfig.json` to make Superset types available to your plugin:
```

View File

@@ -1,44 +1,19 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationDir": "lib",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": false,
"jsx": "react",
"lib": [
"dom",
"esnext"
],
"module": "esnext",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"pretty": true,
"removeComments": false,
"strict": true,
"target": "es2015",
"useDefineForClassFields": false,
"composite": true,
"declarationMap": true,
"rootDir": "src",
"skipLibCheck": true,
"emitDeclarationOnly": true,
"resolveJsonModule": true,
"types": ["jest"],
"typeRoots": [
"./node_modules/@types"
]
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"lib",
"test"
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"include": [
"src/**/*",
"types/**/*"
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]
}

View File

@@ -1,19 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": true,
"declarationDir": "lib",
"outDir": "lib",
"strict": true,
"rootDir": "src",
"jsx": "preserve",
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "node",
"skipLibCheck": true,
"target": "es2020",
"esModuleInterop": true
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*.ts*"],
"exclude": ["lib"]
"include": ["src/**/*", "types/**/*"],
"exclude": ["src/**/*.test.*", "src/**/*.stories.*"]
}

View File

@@ -24,6 +24,7 @@
"lib"
],
"dependencies": {
"@apache-superset/core": "*",
"@react-icons/all-files": "^4.1.0",
"@types/react": "*",
"lodash": "^4.17.21"

View File

@@ -17,11 +17,7 @@
* under the License.
*/
import { ensureIsArray, GenericDataType, ValueOf } from '@superset-ui/core';
import {
ControlPanelState,
isDataset,
isQueryResponse,
} from '@superset-ui/chart-controls';
import { ControlPanelState, isDataset, isQueryResponse } from '../types';
export function checkColumnType(
columnName: string,

View File

@@ -2,18 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "."
},
"extends": "../../../tsconfig.json",
"include": [
"**/*",
"../types/**/*",
"../../../types/**/*"
],
"references": [
{
"path": ".."
}
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,22 +1,13 @@
{
"compilerOptions": {
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "src"
},
"exclude": [
"lib",
"test"
],
"extends": "../../tsconfig.json",
"include": [
"src/**/*",
"types/**/*",
"../../types/**/*"
],
"compilerOptions": {
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["src/**/*.test.*", "src/**/*.stories.*"],
"references": [
{
"path": "../superset-ui-core"
}
{ "path": "../superset-core" },
{ "path": "../superset-ui-core" }
]
}

View File

@@ -24,6 +24,7 @@
"lib"
],
"dependencies": {
"@apache-superset/core": "*",
"@ant-design/icons": "^5.2.6",
"@babel/runtime": "^7.28.2",
"@fontsource/fira-code": "^5.2.6",

View File

@@ -19,8 +19,10 @@
import { useEffect, useState, FunctionComponent } from 'react';
import { t, styled, css, useTheme } from '@superset-ui/core';
import dayjs from 'dayjs';
import { Dayjs } from 'dayjs';
import { extendedDayjs } from '../../utils/dates';
import 'dayjs/plugin/updateLocale';
import 'dayjs/plugin/calendar';
import { Icons } from '../Icons';
import type { LastUpdatedProps } from './types';
@@ -46,9 +48,7 @@ export const LastUpdated: FunctionComponent<LastUpdatedProps> = ({
update,
}) => {
const theme = useTheme();
const [timeSince, setTimeSince] = useState<dayjs.Dayjs>(
extendedDayjs(updatedAt),
);
const [timeSince, setTimeSince] = useState<Dayjs>(extendedDayjs(updatedAt));
useEffect(() => {
setTimeSince(() => extendedDayjs(updatedAt));

View File

@@ -43,6 +43,7 @@ dayjs.updateLocale('en', {
});
export const extendedDayjs = dayjs;
export type { Dayjs };
export const fDuration = function (
t1: number,

View File

@@ -2,14 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "."
},
"extends": "../../../tsconfig.json",
"include": ["**/*", "../types/**/*", "../../../types/**/*"],
"references": [
{
"path": ".."
}
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,24 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "src",
"baseUrl": ".",
"paths": {
"src/*": ["./src/*"],
"@superset-ui/core": ["src"],
"@superset-ui/core/*": ["src/*"]
}
"baseUrl": "../..",
"outDir": "lib"
},
"exclude": [
"lib",
"test"
],
"include": [
"src/**/*",
"spec/**/*",
"types/**/*"
],
"references": []
"include": ["src/**/*", "types/**/*"],
"exclude": ["src/**/*.test.*", "src/**/*.stories.*"],
"references": [{ "path": "../superset-core" }]
}

View File

@@ -19,3 +19,5 @@
declare module '*.gif';
declare module '*.svg';
declare module '*.png';
declare module '*.jpg';
declare module '*.jpeg';

View File

@@ -1,18 +1,9 @@
{
"compilerOptions": {
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "src"
},
"exclude": [
"lib",
"src/**/*.test.ts"
],
"extends": "../../tsconfig.json",
"include": [
"src/**/*",
"types/**/*",
"../../types/**/*"
],
"references": []
"compilerOptions": {
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["src/**/*.test.*", "src/**/*.stories.*"]
}

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -2,18 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "."
},
"extends": "../../../tsconfig.json",
"include": [
"**/*",
"../types/**/*",
"../../../types/**/*"
],
"references": [
{
"path": ".."
}
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -1,19 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": ".",
"paths": {
"d3v3": ["./types/d3v3"]
}
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -2,18 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "."
},
"extends": "../../../tsconfig.json",
"include": [
"**/*",
"../types/**/*",
"../../../types/**/*"
],
"references": [
{
"path": ".."
}
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,17 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": ".",
"paths": {
"@superset-ui/core/components": ["../../packages/superset-ui-core/src/components"]
}
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -18,9 +18,9 @@
*/
import { useEffect, useState, memo } from 'react';
import { styled, t } from '@superset-ui/core';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import { SafeMarkdown } from '@superset-ui/core/components';
import Handlebars from 'handlebars';
import dayjs from 'dayjs';
import { isPlainObject } from 'lodash';
export interface HandlebarsRendererProps {

View File

@@ -1,17 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": ".",
"paths": {
"@superset-ui/core/components": ["../../packages/superset-ui-core/src/components"]
}
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"exclude": ["src/**/*.test.*", "src/**/*.stories.*"],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -19,7 +19,6 @@
*/
import { kebabCase, throttle } from 'lodash';
import d3 from 'd3';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import nv from 'nvd3-fork';
import PropTypes from 'prop-types';
@@ -34,6 +33,7 @@ import {
t,
VizType,
} from '@superset-ui/core';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import 'nvd3-fork/build/nv.d3.css';

View File

@@ -2,18 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "."
},
"extends": "../../../tsconfig.json",
"include": [
"**/*",
"../types/**/*",
"../../../types/**/*"
],
"references": [
{
"path": ".."
}
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,14 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"exclude": ["src/**/*.test.*", "src/**/*.stories.*"],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -36,6 +36,7 @@
"xss": "^1.0.15"
},
"peerDependencies": {
"@apache-superset/core": "*",
"@ant-design/icons": "^5.2.6",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",

View File

@@ -1,18 +1,19 @@
{
"compilerOptions": {
"declarationDir": "lib",
"outDir": "lib",
"rootDir": "src"
},
"exclude": ["lib", "test"],
"extends": "../../tsconfig.json",
"include": ["src/**/*", "types/**/*", "../../types/**/*"],
"compilerOptions": {
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{
"path": "../../packages/superset-ui-chart-controls"
},
{
"path": "../../packages/superset-ui-core"
}
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]
}

View File

@@ -2,21 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "."
},
"extends": "../../../tsconfig.json",
"include": [
"**/*",
"../types/**/*",
"../../../types/**/*"
],
"references": [
{
"path": "../../../packages/superset-ui-chart-controls"
},
{
"path": "../../../packages/superset-ui-core"
},
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -30,6 +30,7 @@
"lodash": "^4.17.21"
},
"peerDependencies": {
"@apache-superset/core": "*",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",
"echarts": "*",

View File

@@ -16,8 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import { Metric } from '@superset-ui/chart-controls';
import {
ChartProps,
@@ -27,6 +25,8 @@ import {
SimpleAdhocFilter,
ensureIsArray,
} from '@superset-ui/core';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import 'dayjs/plugin/utc';
import {
getComparisonFontSize,
getHeaderFontSize,
@@ -35,8 +35,6 @@ import {
import { getOriginalLabel } from '../utils';
dayjs.extend(utc);
export const parseMetricValue = (metricValue: number | string | null) => {
if (typeof metricValue === 'string') {
const dateObject = dayjs.utc(metricValue, undefined, true);

View File

@@ -17,7 +17,6 @@
* under the License.
*/
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import {
getTimeFormatter,
@@ -29,6 +28,7 @@ import {
SMART_DATE_ID,
TimeGranularity,
} from '@superset-ui/core';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
dayjs.extend(utc);

View File

@@ -33,8 +33,8 @@ import {
t,
tooltipHtml,
} from '@superset-ui/core';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import { CallbackDataParams } from 'echarts/types/src/util/types';
import dayjs from 'dayjs';
import {
Cartesian2dCoordSys,
EchartsGanttChartProps,

View File

@@ -23,8 +23,7 @@ import {
SqlaFormData,
supersetTheme,
} from '@superset-ui/core';
import { EchartsBubbleChartProps } from 'plugins/plugin-chart-echarts/src/Bubble/types';
import { EchartsBubbleChartProps } from '../../src/Bubble/types';
import transformProps, { formatTooltip } from '../../src/Bubble/transformProps';
const defaultFormData: SqlaFormData = {

View File

@@ -2,21 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "."
},
"extends": "../../../tsconfig.json",
"include": [
"**/*",
"../types/**/*",
"../../../types/**/*"
],
"references": [
{
"path": "../../../packages/superset-ui-chart-controls"
},
{
"path": "../../../packages/superset-ui-core"
}
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,17 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": ".",
"paths": {
"@superset-ui/core/components": ["../../packages/superset-ui-core/src/components"]
}
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -18,8 +18,8 @@
*/
import { styled, t } from '@superset-ui/core';
import { SafeMarkdown } from '@superset-ui/core/components';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import Handlebars from 'handlebars';
import dayjs from 'dayjs';
import { useMemo, useState } from 'react';
import { isPlainObject } from 'lodash';
import Helpers from 'just-handlebars-helpers';

View File

@@ -1,17 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": ".",
"paths": {
"@superset-ui/core/components": ["../../packages/superset-ui-core/src/components"]
}
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -27,6 +27,7 @@
"access": "public"
},
"peerDependencies": {
"@apache-superset/core": "*",
"@ant-design/icons": "^5.2.6",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",

View File

@@ -1,14 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"exclude": ["src/**/*.test.*", "src/**/*.stories.*"],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -36,6 +36,7 @@
"xss": "^1.0.15"
},
"peerDependencies": {
"@apache-superset/core": "*",
"@ant-design/icons": "^5.2.6",
"@superset-ui/chart-controls": "*",
"@superset-ui/core": "*",

View File

@@ -2,18 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "../../../"
},
"extends": "../../../tsconfig.json",
"include": [
"**/*",
"../types/**/*",
"../../../types/**/*"
],
"references": [
{
"path": ".."
}
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,17 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": ".",
"paths": {
"@superset-ui/core/components": ["../../packages/superset-ui-core/src/components"]
}
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -2,18 +2,8 @@
"compilerOptions": {
"composite": false,
"emitDeclarationOnly": false,
"noEmit": true,
"rootDir": "."
},
"extends": "../../../tsconfig.json",
"include": [
"**/*",
"../types/**/*",
"../../../types/**/*"
],
"references": [
{
"path": ".."
}
]
"include": ["**/*", "../types/**/*", "../../../types/**/*"]
}

View File

@@ -1,14 +1,18 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.json",
"compilerOptions": {
"composite": true,
"rootDir": "src",
"outDir": "lib",
"baseUrl": "."
"baseUrl": "../..",
"outDir": "lib"
},
"include": ["src/**/*", "types/**/*"],
"exclude": ["lib", "test"],
"include": ["src/**/*.ts", "src/**/*.tsx", "types/**/*"],
"exclude": [
"src/**/*.js",
"src/**/*.jsx",
"src/**/*.test.*",
"src/**/*.stories.*"
],
"references": [
{ "path": "../../packages/superset-core" },
{ "path": "../../packages/superset-ui-core" },
{ "path": "../../packages/superset-ui-chart-controls" }
]

View File

@@ -42,8 +42,8 @@ import {
FeatureFlag,
isFeatureEnabled,
} from '@superset-ui/core';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import { useSelector, useDispatch } from 'react-redux';
import dayjs from 'dayjs';
import rison from 'rison';
import { createDatasource } from 'src/SqlLab/actions/sqlLab';
import { addDangerToast } from 'src/components/MessageToasts/actions';

View File

@@ -17,7 +17,7 @@
* under the License.
*/
import { ReactNode, MouseEvent as ReactMouseEvent } from 'react';
import { TableInstance, Row } from 'react-table';
import { TableInstance, Row, UseRowSelectRowProps } from 'react-table';
import { styled } from '@superset-ui/core';
import cx from 'classnames';
@@ -65,7 +65,7 @@ export default function CardCollection({
}: CardCollectionProps) {
function handleClick(
event: ReactMouseEvent<HTMLDivElement, MouseEvent>,
toggleRowSelected: Row['toggleRowSelected'],
toggleRowSelected: (value?: boolean) => void,
) {
if (bulkSelectEnabled) {
event.preventDefault();
@@ -89,11 +89,18 @@ export default function CardCollection({
return (
<CardWrapper
className={cx({
'card-selected': bulkSelectEnabled && row.isSelected,
'card-selected':
bulkSelectEnabled &&
(row as Row & UseRowSelectRowProps<any>).isSelected,
'bulk-select': bulkSelectEnabled,
})}
key={row.id}
onClick={e => handleClick(e, row.toggleRowSelected)}
onClick={e =>
handleClick(
e,
(row as Row & UseRowSelectRowProps<any>).toggleRowSelected,
)
}
role="none"
>
{renderCard({ ...row.original, loading })}

View File

@@ -419,7 +419,7 @@ export function ListView<T extends object = any>({
cta
onClick={() =>
action.onSelect(
selectedFlatRows.map(r => r.original),
selectedFlatRows.map((r: any) => r.original),
)
}
>
@@ -475,10 +475,10 @@ export function ListView<T extends object = any>({
bulkSelectEnabled={bulkSelectEnabled}
selectedFlatRows={selectedFlatRows}
toggleRowSelected={(rowId, value) => {
const row = rows.find(r => r.id === rowId);
const row = rows.find((r: any) => r.id === rowId);
if (row) {
prepareRow(row);
row.toggleRowSelected(value);
(row as any).toggleRowSelected(value);
}
}}
toggleAllRowsSelected={toggleAllRowsSelected}

View File

@@ -273,23 +273,23 @@ export function useListViewState({
} = useTable(
{
columns: columnsWithSelect,
count,
data,
disableFilters: true,
disableSortRemove: true,
initialState,
initialState: initialState as any,
manualFilters: true,
manualPagination: true,
manualSortBy: true,
autoResetFilters: false,
pageCount: Math.ceil(count / initialPageSize),
...({ count } as any),
},
useFilters,
useSortBy,
usePagination,
useRowState,
useRowSelect,
);
) as any;
const [internalFilters, setInternalFilters] = useState<InternalFilter[]>(
query.filters && initialFilters.length

View File

@@ -206,7 +206,7 @@ export default function TimeOffsetControls({
.subtract(1, 'day');
setStartDate(resetDate.toString());
setFormatedDate(resetDate);
onChange(extendedDayjs.utc(resetDate).format(DAYJS_FORMAT));
onChange(extendedDayjs(resetDate).utc().format(DAYJS_FORMAT));
setIsDateSelected(true);
}
}, [formatedFilterDate, formatedDate, customStartDateInFilter]);

View File

@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import dayjs from 'dayjs';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import { Dayjs } from 'dayjs';
import { TimeRangePicker } from 'src/components/TimePicker';
import ControlHeader, { ControlHeaderProps } from '../../ControlHeader';
@@ -38,7 +39,7 @@ export default function TimeRangeControl({
allowEmpty,
...rest
}: TimeRangeControlProps) {
const dayjsValue: [dayjs.Dayjs | null, dayjs.Dayjs | null] = [
const dayjsValue: [Dayjs | null, Dayjs | null] = [
stringValue?.[0] ? dayjs.utc(stringValue[0], 'HH:mm:ss') : null,
stringValue?.[1] ? dayjs.utc(stringValue[1], 'HH:mm:ss') : null,
];

View File

@@ -73,7 +73,7 @@ export default function AllEntitiesTable({
const renderTable = (type: objectType) => {
const data = objects[type].map((o: TaggedObject) => ({
[type]: <Typography.Link href={o.url}>{o.name}</Typography.Link>,
modified: extendedDayjs.utc(o.changed_on).fromNow(),
modified: o.changed_on ? extendedDayjs.utc(o.changed_on).fromNow() : '',
tags: o.tags,
owners: o.owners,
}));

View File

@@ -16,8 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import dayjs from 'dayjs';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
import { ExplorePageState } from 'src/explore/types';

View File

@@ -26,7 +26,7 @@ import {
SupersetClient,
getClientErrorObject,
} from '@superset-ui/core';
import dayjs from 'dayjs';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import rison from 'rison';
import { ConfirmStatusChange, DeleteModal } from '@superset-ui/core/components';

View File

@@ -18,14 +18,16 @@
*/
import { css, styled, t } from '@superset-ui/core';
import dayjs from 'dayjs';
import {
extendedDayjs as dayjs,
fDuration,
} from '@superset-ui/core/utils/dates';
import { useEffect, useMemo } from 'react';
import { Link, useParams } from 'react-router-dom';
import { Tooltip } from '@superset-ui/core/components';
import { ListView } from 'src/components';
import SubMenu from 'src/features/home/SubMenu';
import withToasts from 'src/components/MessageToasts/withToasts';
import { fDuration } from '@superset-ui/core/utils/dates';
import AlertStatusIcon from 'src/features/alerts/components/AlertStatusIcon';
import {
useListViewResource,

View File

@@ -12,7 +12,7 @@
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

View File

@@ -17,7 +17,6 @@
* under the License.
*/
import { setConfig as setHotLoaderConfig } from 'react-hot-loader';
import dayjs from 'dayjs';
// eslint-disable-next-line no-restricted-imports
import {
configure,
@@ -26,6 +25,7 @@ import {
SupersetClient,
LanguagePack,
} from '@superset-ui/core';
import { extendedDayjs as dayjs } from '@superset-ui/core/utils/dates';
import setupClient from './setup/setupClient';
import setupColors from './setup/setupColors';
import setupFormatters from './setup/setupFormatters';
@@ -34,6 +34,17 @@ import { User } from './types/bootstrapTypes';
import getBootstrapData, { applicationRoot } from './utils/getBootstrapData';
import './hooks/useLocale';
// Import dayjs plugin types for global TypeScript support
import 'dayjs/plugin/utc';
import 'dayjs/plugin/timezone';
import 'dayjs/plugin/calendar';
import 'dayjs/plugin/relativeTime';
import 'dayjs/plugin/customParseFormat';
import 'dayjs/plugin/duration';
import 'dayjs/plugin/updateLocale';
import 'dayjs/plugin/localizedFormat';
import 'dayjs/plugin/isSameOrBefore';
configure();
// Set hot reloader config

View File

@@ -19,3 +19,6 @@
declare module '*.svg';
declare module '*.gif';
declare module '*.png';
declare module '*.jpg';
declare module '*.jpeg';

View File

@@ -1,43 +0,0 @@
{
"compilerOptions": {
/* Type Checking */
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"module": "esnext",
"moduleResolution": "node",
"types": ["jest", "node", "@testing-library/jest-dom"],
"typeRoots": ["node_modules/@types"],
/* Emit */
"declaration": true,
"declarationMap": true,
"importHelpers": false,
"noEmitOnError": true,
"outDir": "./dist",
"sourceMap": true,
/* JavaScript Support */
"allowJs": true,
/* Interop Constraints */
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
/* Language and Environment */
"target": "esnext",
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react",
"lib": ["dom", "dom.iterable", "esnext"],
/* Projects */
"composite": true,
/* Completeness */
"skipLibCheck": true
}
}

View File

@@ -1,6 +1,47 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
/* Type Checking */
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"strictNullChecks": true,
"module": "esnext",
"moduleResolution": "bundler",
"types": ["jest", "node", "@testing-library/jest-dom"],
"typeRoots": ["src/types", "node_modules/@types"],
/* Emit */
"declaration": true,
"declarationMap": true,
"importHelpers": false,
"noEmitOnError": true,
"outDir": "./dist",
"rootDir": ".",
"declarationDir": "lib",
"sourceMap": true,
/* JavaScript Support */
"allowJs": true,
/* Interop Constraints */
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
/* Language and Environment */
"target": "es2020",
"jsx": "react-jsx",
"jsxImportSource": "@emotion/react",
"lib": ["dom", "dom.iterable", "esnext"],
/* Projects */
"composite": true,
/* Completeness */
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"@superset-ui/core": ["./packages/superset-ui-core/src"],
@@ -8,29 +49,44 @@
"@superset-ui/chart-controls": [
"./packages/superset-ui-chart-controls/src"
],
"@superset-ui/legacy-plugin-chart-*": [
"./plugins/legacy-plugin-chart-*/src"
"@superset-ui/chart-controls/*": [
"./packages/superset-ui-chart-controls/src/*"
],
"@superset-ui/legacy-preset-chart-*": [
"./plugins/legacy-preset-chart-*/src"
],
"@superset-ui/plugin-chart-*": ["./plugins/plugin-chart-*/src"],
"@superset-ui/preset-chart-*": ["./plugins/preset-chart-*/src"],
"@superset-ui/switchboard": ["./packages/superset-ui-switchboard/src"],
"@apache-superset/core": ["./packages/superset-core/src"]
},
"typeRoots": ["src/types", "node_modules/@types"]
"@apache-superset/core": ["./packages/superset-core/src"],
"@apache-superset/core/*": ["./packages/superset-core/src/*"],
"@superset-ui/plugin-chart-*": ["./plugins/plugin-chart-*/src"],
"echarts/types/src/*": ["./node_modules/echarts/types/src/*"]
}
},
"exclude": ["./packages/generator-superset/test/**/*"],
"include": [
"./src/**/*",
"./spec/**/*",
"./packages/*/src/**/*",
"./packages/*/types/**/*",
"./plugins/*/src/**/*",
"./plugins/*/types/**/*",
"./packages/*/test/**/*",
"./plugins/*/test/**/*"
]
"./spec/**/*"
],
"references": [
{ "path": "./packages/superset-core" },
{ "path": "./packages/superset-ui-core" },
{ "path": "./packages/superset-ui-chart-controls" },
{ "path": "./packages/superset-ui-switchboard" },
{ "path": "./plugins/legacy-plugin-chart-calendar" },
{ "path": "./plugins/legacy-plugin-chart-chord" },
{ "path": "./plugins/legacy-plugin-chart-country-map" },
{ "path": "./plugins/legacy-plugin-chart-horizon" },
{ "path": "./plugins/legacy-plugin-chart-map-box" },
{ "path": "./plugins/legacy-plugin-chart-paired-t-test" },
{ "path": "./plugins/legacy-plugin-chart-parallel-coordinates" },
{ "path": "./plugins/legacy-plugin-chart-partition" },
{ "path": "./plugins/legacy-plugin-chart-rose" },
{ "path": "./plugins/legacy-plugin-chart-world-map" },
{ "path": "./plugins/legacy-preset-chart-deckgl" },
{ "path": "./plugins/legacy-preset-chart-nvd3" },
{ "path": "./plugins/plugin-chart-ag-grid-table" },
{ "path": "./plugins/plugin-chart-cartodiagram" },
{ "path": "./plugins/plugin-chart-echarts" },
{ "path": "./plugins/plugin-chart-handlebars" },
{ "path": "./plugins/plugin-chart-pivot-table" },
{ "path": "./plugins/plugin-chart-table" },
{ "path": "./plugins/plugin-chart-word-cloud" }
],
"exclude": []
}