Skip to content

Commit 64a0278

Browse files
authored
fix: move types to src dir to escape src / dist dirs in paths (chartjs#10993)
1 parent bc84a98 commit 64a0278

File tree

80 files changed

+74
-81
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+74
-81
lines changed

Diff for: .github/workflows/ci.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ jobs:
5252
- 'karma.conf.js'
5353
- 'package.json'
5454
types:
55-
- 'types/**'
5655
- 'package.json'
5756
- 'tsconfig.json'
5857
- name: Install
@@ -64,7 +63,7 @@ jobs:
6463
- name: Test
6564
if: |
6665
(steps.changes.outputs.src == 'true' ||
67-
steps.changes.outputs.test == 'true') &&
66+
steps.changes.outputs.test == 'true') &&
6867
runner.os != 'Windows'
6968
run: |
7069
pnpm run build

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ docs/.vuepress/dist
3131
*.stackdump
3232

3333
# Generated
34-
/types/tests/autogen*.ts
34+
/test/types/autogen*.ts
3535

3636
# Eslint
3737
.eslintcache

Diff for: docs/.vuepress/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default defineConfig({
3434
}],
3535
['vuepress-plugin-code-copy', true],
3636
['vuepress-plugin-typedoc', {
37-
entryPoints: ['../../types/index.d.ts'],
37+
entryPoints: ['../../src/types/index.d.ts'],
3838
hideInPageTOC: true,
3939
tsconfig: path.resolve(__dirname, '../../tsconfig.json'),
4040
},

Diff for: package.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,19 @@
5050
"auto/**",
5151
"dist/**",
5252
"!dist/docs/**",
53-
"helpers/**",
54-
"types/**/*.ts",
55-
"!types/tests/**"
53+
"helpers/**"
5654
],
5755
"scripts": {
5856
"autobuild": "rollup -c -w",
59-
"emitDeclarations": "tsc --emitDeclarationOnly",
57+
"emitDeclarations": "tsc --emitDeclarationOnly && cp -R ./src/types/ ./dist/types/",
6058
"build": "rollup -c && pnpm emitDeclarations",
6159
"dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome --grep",
6260
"dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox --grep",
6361
"docs": "pnpm run build && pnpm --filter \"./docs/**\" build",
6462
"docs:dev": "pnpm run build && pnpm --filter \"./docs/**\" dev",
6563
"lint-js": "eslint \"src/**/*.{js,ts}\" \"test/**/*.js\" \"docs/**/*.js\" --cache",
6664
"lint-md": "eslint \"**/*.md\" --cache",
67-
"lint-types": "eslint \"types/**/*.ts\" --cache && pnpm build && node types/tests/autogen.js && tsc -p types/tests/",
65+
"lint-types": "pnpm build && node test/types/autogen.js && tsc -p test/types",
6866
"lint": "concurrently \"pnpm:lint-*\"",
6967
"test-size": "size-limit",
7068
"test": "pnpm lint && pnpm test-ci",

Diff for: src/core/core.adapters.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* @private
55
*/
66

7-
import type {AnyObject} from '../../types/basic.js';
8-
import type {ChartOptions} from '../../types/index.js';
7+
import type {AnyObject} from '../types/basic.js';
8+
import type {ChartOptions} from '../types/index.js';
99

1010
export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
1111

Diff for: src/core/core.controller.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import {version} from '../../package.json';
1414
import {debounce} from '../helpers/helpers.extras.js';
1515

1616
/**
17-
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
18-
* @typedef { import('../../types/index.js').Point } Point
17+
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
18+
* @typedef { import('../types/index.js').Point } Point
1919
*/
2020

2121
const KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];
@@ -1258,10 +1258,10 @@ class Chart {
12581258

12591259
/**
12601260
* @param {ChartEvent} e - The event
1261-
* @param {import('../../types/index.js').ActiveElement[]} lastActive - Previously active elements
1261+
* @param {import('../types/index.js').ActiveElement[]} lastActive - Previously active elements
12621262
* @param {boolean} inChartArea - Is the envent inside chartArea
12631263
* @param {boolean} useFinalPosition - Should the evaluation be done with current or final (after animation) element positions
1264-
* @returns {import('../../types/index.js').ActiveElement[]} - The active elements
1264+
* @returns {import('../types/index.js').ActiveElement[]} - The active elements
12651265
* @pravate
12661266
*/
12671267
_getActiveElements(e, lastActive, inChartArea, useFinalPosition) {

Diff for: src/core/core.element.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type {AnyObject} from '../../types/basic.js';
2-
import type {Point} from '../../types/geometric.js';
3-
import type {Animation} from '../../types/animation.js';
1+
import type {AnyObject} from '../types/basic.js';
2+
import type {Point} from '../types/geometric.js';
3+
import type {Animation} from '../types/animation.js';
44
import {isNumber} from '../helpers/helpers.math.js';
55

66
export default class Element<T = AnyObject, O = AnyObject> {

Diff for: src/core/core.interaction.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import {_isPointInArea} from '../helpers/index.js';
55

66
/**
77
* @typedef { import('./core.controller.js').default } Chart
8-
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
8+
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
99
* @typedef {{axis?: string, intersect?: boolean, includeInvisible?: boolean}} InteractionOptions
1010
* @typedef {{datasetIndex: number, index: number, element: import('./core.element.js').default}} InteractionItem
11-
* @typedef { import('../../types/index.js').Point } Point
11+
* @typedef { import('../types/index.js').Point } Point
1212
*/
1313

1414
/**

Diff for: src/core/core.plugins.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {callback as callCallback, isNullOrUndef, valueOrDefault} from '../helper
33

44
/**
55
* @typedef { import('./core.controller.js').default } Chart
6-
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
6+
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
77
* @typedef { import('../plugins/plugin.tooltip.js').default } Tooltip
88
*/
99

Diff for: src/elements/element.arc.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Element from '../core/core.element.js';
22
import {_angleBetween, getAngleFromPoint, TAU, HALF_PI, valueOrDefault} from '../helpers/index.js';
33
import {PI, _isBetween, _limitValue} from '../helpers/helpers.math.js';
44
import {_readValueToProps} from '../helpers/helpers.options.js';
5-
import type {ArcOptions, Point} from '../../types/index.js';
5+
import type {ArcOptions, Point} from '../types/index.js';
66

77

88
function clipArc(ctx: CanvasRenderingContext2D, element: ArcElement, endAngle: number) {

Diff for: src/elements/element.point.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
Point,
77
PointHoverOptions,
88
PointOptions,
9-
} from '../../types/index.js';
9+
} from '../types/index.js';
1010

1111
function inRange(el: PointElement, pos: number, axis: 'x' | 'y', useFinalPosition?: boolean) {
1212
const options = el.options;

Diff for: src/helpers/helpers.canvas.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {PI, TAU, HALF_PI, QUARTER_PI, TWO_THIRDS_PI, RAD_PER_DEG} from './helper
66
* necessary to avoid duplicates with `export * from './helpers`; see
77
* https://github.com/microsoft/TypeScript/issues/46011
88
* @typedef { import('../core/core.controller.js').default } canvas.Chart
9-
* @typedef { import('../../types/index.js').Point } Point
9+
* @typedef { import('../types/index.js').Point } Point
1010
*/
1111

1212
/**

Diff for: src/helpers/helpers.core.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @namespace Chart.helpers
33
*/
44

5-
import type {AnyObject} from '../../types/basic.js';
6-
import type {ActiveDataPoint, ChartEvent} from '../../types/index.js';
5+
import type {AnyObject} from '../types/basic.js';
6+
import type {ActiveDataPoint, ChartEvent} from '../types/index.js';
77

88
/**
99
* An empty function that can be used, for example, for optional callback.

Diff for: src/helpers/helpers.curve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {almostEquals, distanceBetweenPoints, sign} from './helpers.math.js';
22
import {_isPointInArea} from './helpers.canvas.js';
3-
import type {ChartArea} from '../../types/index.js';
3+
import type {ChartArea} from '../types/index.js';
44

55
export interface SplinePoint {
66
x: number;

Diff for: src/helpers/helpers.dom.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {ChartArea, Scale} from '../../types/index.js';
1+
import type {ChartArea, Scale} from '../types/index.js';
22
import type Chart from '../core/core.controller.js';
33
import type {ChartEvent} from '../types.js';
44
import {INFINITY} from './helpers.math.js';

Diff for: src/helpers/helpers.extras.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {ChartMeta, PointElement} from '../../types/index.js';
1+
import type {ChartMeta, PointElement} from '../types/index.js';
22

33
import {_limitValue} from './helpers.math.js';
44
import {_lookupByKey} from './helpers.collection.js';

Diff for: src/helpers/helpers.interpolation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {Point} from '../../types/geometric.js';
1+
import type {Point} from '../types/geometric.js';
22
import type {SplinePoint} from './helpers.curve.js';
33

44
/**

Diff for: src/helpers/helpers.math.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {Point} from '../../types/geometric.js';
1+
import type {Point} from '../types/geometric.js';
22
import {isFinite as isFiniteNumber} from './helpers.core.js';
33

44
/**

Diff for: src/helpers/helpers.options.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import defaults from '../core/core.defaults.js';
22
import {isArray, isObject, toDimension, valueOrDefault} from './helpers.core.js';
33
import {Point, toFontString} from './helpers.canvas.js';
4-
import type {ChartArea, FontSpec} from '../../types/index.js';
5-
import type {TRBL, TRBLCorners} from '../../types/geometric.js';
4+
import type {ChartArea, FontSpec} from '../types/index.js';
5+
import type {TRBL, TRBLCorners} from '../types/geometric.js';
66

77
const LINE_HEIGHT = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/;
88
const FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;

Diff for: src/helpers/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ export * from './helpers.intl.js';
1616
export * from './helpers.math.js';
1717
export * from './helpers.options.js';
1818
export * from './helpers.rtl.js';
19-
export * from '../../types/helpers/index.js';
19+
export * from '../types/helpers/index.js';

Diff for: src/plugins/plugin.filler/filler.options.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {isObject, isFinite, valueOrDefault} from '../../helpers/helpers.core.js'
33
/**
44
* @typedef { import('../../core/core.scale.js').default } Scale
55
* @typedef { import('../../elements/element.line.js').default } LineElement
6-
* @typedef { import('../../../types/index.js').FillTarget } FillTarget
7-
* @typedef { import('../../../types/index.js').ComplexFillTarget } ComplexFillTarget
6+
* @typedef { import('../../types/index.js').FillTarget } FillTarget
7+
* @typedef { import('../../types/index.js').ComplexFillTarget } ComplexFillTarget
88
*/
99

1010
export function _resolveTarget(sources, index, propagate) {

Diff for: src/plugins/plugin.legend.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {_alignStartEnd, _textX, _toLeftRightCenter} from '../helpers/helpers.ext
1818
import {toTRBLCorners} from '../helpers/helpers.options.js';
1919

2020
/**
21-
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
21+
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
2222
*/
2323

2424
const getBoxSize = (labelOpts, fontSize) => {

Diff for: src/plugins/plugin.tooltip.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import {createContext, drawPoint} from '../helpers/index.js';
99

1010
/**
1111
* @typedef { import('../platform/platform.base.js').Chart } Chart
12-
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
13-
* @typedef { import('../../types/index.js').ActiveElement } ActiveElement
12+
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
13+
* @typedef { import('../types/index.js').ActiveElement } ActiveElement
1414
* @typedef { import('../core/core.interaction.js').InteractionItem } InteractionItem
1515
*/
1616

Diff for: src/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ export {
4646
TimeScale,
4747
TimeSeriesScale,
4848
registerables
49-
} from '../types/index.js';
50-
export * from '../types/index.js';
49+
} from './types/index.js';
50+
export * from './types/index.js';

Diff for: types/animation.d.ts renamed to src/types/animation.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Chart } from './index.js';
2-
import { AnyObject } from './basic.js';
1+
import {Chart} from './index.js';
2+
import {AnyObject} from './basic.js';
33

44
export declare class Animation {
55
constructor(cfg: AnyObject, target: AnyObject, prop: string, to?: unknown);

Diff for: types/basic.d.ts renamed to src/types/basic.d.ts

File renamed without changes.

Diff for: types/color.d.ts renamed to src/types/color.d.ts

File renamed without changes.
File renamed without changes.

Diff for: types/helpers/helpers.canvas.d.ts renamed to src/types/helpers/helpers.canvas.d.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { PointStyle, Scriptable, ScriptableScaleContext } from '../index.js';
2-
import { Color } from '../color.js';
3-
import { ChartArea, RoundedRect } from '../geometric.js';
4-
import { CanvasFontSpec } from '../../src/helpers/helpers.options.js';
1+
import {PointStyle, Scriptable, ScriptableScaleContext} from '../index.js';
2+
import {Color} from '../color.js';
3+
import {ChartArea, RoundedRect} from '../geometric.js';
4+
import {CanvasFontSpec} from '../../helpers/helpers.options.js';
55

66
export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
77

File renamed without changes.
File renamed without changes.

Diff for: types/index.d.ts renamed to src/types/index.d.ts

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils.js';
2-
3-
import { TimeUnit } from '../src/core/core.adapters.js';
4-
import PointElement from '../src/elements/element.point.js';
5-
import { EasingFunction } from '../src/helpers/helpers.easing.js';
6-
import { AnimationEvent } from './animation.js';
7-
import { AnyObject, EmptyObject } from './basic.js';
8-
import { Color } from './color.js';
9-
import Element from '../src/core/core.element.js';
10-
import { ChartArea, Padding, Point } from './geometric.js';
11-
import { LayoutItem, LayoutPosition } from './layout.js';
12-
import { RenderTextOpts } from './helpers/helpers.canvas.js';
13-
import { CanvasFontSpec } from '../src/helpers/helpers.options.js';
14-
15-
export { EasingFunction } from '../src/helpers/helpers.easing.js';
16-
export { default as ArcElement, ArcProps } from '../src/elements/element.arc.js';
17-
export { default as PointElement, PointProps } from '../src/elements/element.point.js';
18-
export { Animation, Animations, Animator, AnimationEvent } from './animation.js';
19-
export { Color } from './color.js';
20-
export { ChartArea, Point } from './geometric.js';
21-
export { LayoutItem, LayoutPosition } from './layout.js';
1+
/* eslint-disable @typescript-eslint/ban-types */
2+
import {DeepPartial, DistributiveArray, UnionToIntersection} from './utils.js';
3+
4+
import {TimeUnit} from '../core/core.adapters.js';
5+
import PointElement from '../elements/element.point.js';
6+
import {EasingFunction} from '../helpers/helpers.easing.js';
7+
import {AnimationEvent} from './animation.js';
8+
import {AnyObject, EmptyObject} from './basic.js';
9+
import {Color} from './color.js';
10+
import Element from '../core/core.element.js';
11+
import {ChartArea, Padding, Point} from './geometric.js';
12+
import {LayoutItem, LayoutPosition} from './layout.js';
13+
import {RenderTextOpts} from './helpers/helpers.canvas.js';
14+
import {CanvasFontSpec} from '../helpers/helpers.options.js';
15+
16+
export {EasingFunction} from '../helpers/helpers.easing.js';
17+
export {default as ArcElement, ArcProps} from '../elements/element.arc.js';
18+
export {default as PointElement, PointProps} from '../elements/element.point.js';
19+
export {Animation, Animations, Animator, AnimationEvent} from './animation.js';
20+
export {Color} from './color.js';
21+
export {ChartArea, Point} from './geometric.js';
22+
export {LayoutItem, LayoutPosition} from './layout.js';
2223

2324
export interface ScriptableContext<TType extends ChartType> {
2425
active: boolean;
@@ -234,7 +235,7 @@ export declare const LineController: ChartComponent & {
234235

235236
export type ScatterControllerDatasetOptions = LineControllerDatasetOptions;
236237

237-
export interface ScatterDataPoint extends Point {}
238+
export type ScatterDataPoint = Point
238239

239240
export type ScatterControllerChartOptions = LineControllerChartOptions;
240241

Diff for: types/layout.d.ts renamed to src/types/layout.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ChartArea } from './geometric.js';
1+
import {ChartArea} from './geometric.js';
22

33
export type LayoutPosition = 'left' | 'top' | 'right' | 'bottom' | 'center' | 'chartArea' | {[scaleId: string]: number};
44

Diff for: types/utils.d.ts renamed to src/types/utils.d.ts

File renamed without changes.

Diff for: types/.eslintrc.yml renamed to test/types/.eslintrc.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
rules:
2-
# These rules were set to warning to make the linting pass initially,
3-
# without making any major changes to types.
2+
'@typescript-eslint/no-unused-vars': 'off'
43
object-curly-spacing: ["warn", "always"]
54
'@typescript-eslint/no-empty-interface': "warn"
65
'@typescript-eslint/ban-types': "warn"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: types/tests/extensions/scale.ts renamed to test/types/extensions/scale.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnyObject } from '../../basic.js';
1+
import { AnyObject } from '../../../src/types/basic.js';
22
import { CartesianScaleOptions, Chart, Scale } from '../../../src/types.js';
33

44
export type TestScaleOptions = CartesianScaleOptions & {
@@ -17,7 +17,7 @@ export class TestScale<O extends TestScaleOptions = TestScaleOptions> extends Sc
1717
}
1818
}
1919

20-
declare module '../../index.js' {
20+
declare module '../../../src/types/index.js' {
2121
interface CartesianScaleTypeRegistry {
2222
test: {
2323
options: TestScaleOptions
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Diff for: types/tests/tsconfig.json renamed to test/types/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"rootDir": "../../"
66
},
77
"include": [
8-
"../",
8+
"./",
99
"../../src/",
1010
"../../dist/**/*.d.ts"
1111
],

Diff for: tsconfig.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,16 @@
3333
},
3434
"typedocOptions": {
3535
"name": "Chart.js",
36-
"entryPoints": ["types/index.d.ts"],
36+
"entryPoints": ["src/types/index.d.ts"],
3737
"readme": "none",
3838
"excludeExternals": true,
3939
"includeVersion": true,
4040
"out": "./dist/docs/typedoc"
4141
},
4242
"include": [
43-
"./src/**/*",
44-
"./types"
43+
"./src/**/*"
4544
],
4645
"exclude": [
47-
"./types/tests",
4846
"./dist/**"
4947
]
5048
}

Diff for: types/tests/.eslintrc.yml

-2
This file was deleted.

0 commit comments

Comments
 (0)