Skip to content

Commit

Permalink
fix: move types to src dir to escape src / dist dirs in paths (#10993)
Browse files Browse the repository at this point in the history
  • Loading branch information
dangreen authored Dec 16, 2022
1 parent bc84a98 commit 64a0278
Show file tree
Hide file tree
Showing 80 changed files with 74 additions and 81 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
- 'karma.conf.js'
- 'package.json'
types:
- 'types/**'
- 'package.json'
- 'tsconfig.json'
- name: Install
Expand All @@ -64,7 +63,7 @@ jobs:
- name: Test
if: |
(steps.changes.outputs.src == 'true' ||
steps.changes.outputs.test == 'true') &&
steps.changes.outputs.test == 'true') &&
runner.os != 'Windows'
run: |
pnpm run build
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ docs/.vuepress/dist
*.stackdump

# Generated
/types/tests/autogen*.ts
/test/types/autogen*.ts

# Eslint
.eslintcache
2 changes: 1 addition & 1 deletion docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default defineConfig({
}],
['vuepress-plugin-code-copy', true],
['vuepress-plugin-typedoc', {
entryPoints: ['../../types/index.d.ts'],
entryPoints: ['../../src/types/index.d.ts'],
hideInPageTOC: true,
tsconfig: path.resolve(__dirname, '../../tsconfig.json'),
},
Expand Down
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,19 @@
"auto/**",
"dist/**",
"!dist/docs/**",
"helpers/**",
"types/**/*.ts",
"!types/tests/**"
"helpers/**"
],
"scripts": {
"autobuild": "rollup -c -w",
"emitDeclarations": "tsc --emitDeclarationOnly",
"emitDeclarations": "tsc --emitDeclarationOnly && cp -R ./src/types/ ./dist/types/",
"build": "rollup -c && pnpm emitDeclarations",
"dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome --grep",
"dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox --grep",
"docs": "pnpm run build && pnpm --filter \"./docs/**\" build",
"docs:dev": "pnpm run build && pnpm --filter \"./docs/**\" dev",
"lint-js": "eslint \"src/**/*.{js,ts}\" \"test/**/*.js\" \"docs/**/*.js\" --cache",
"lint-md": "eslint \"**/*.md\" --cache",
"lint-types": "eslint \"types/**/*.ts\" --cache && pnpm build && node types/tests/autogen.js && tsc -p types/tests/",
"lint-types": "pnpm build && node test/types/autogen.js && tsc -p test/types",
"lint": "concurrently \"pnpm:lint-*\"",
"test-size": "size-limit",
"test": "pnpm lint && pnpm test-ci",
Expand Down
4 changes: 2 additions & 2 deletions src/core/core.adapters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @private
*/

import type {AnyObject} from '../../types/basic.js';
import type {ChartOptions} from '../../types/index.js';
import type {AnyObject} from '../types/basic.js';
import type {ChartOptions} from '../types/index.js';

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

Expand Down
8 changes: 4 additions & 4 deletions src/core/core.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {version} from '../../package.json';
import {debounce} from '../helpers/helpers.extras.js';

/**
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../../types/index.js').Point } Point
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../types/index.js').Point } Point
*/

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

/**
* @param {ChartEvent} e - The event
* @param {import('../../types/index.js').ActiveElement[]} lastActive - Previously active elements
* @param {import('../types/index.js').ActiveElement[]} lastActive - Previously active elements
* @param {boolean} inChartArea - Is the envent inside chartArea
* @param {boolean} useFinalPosition - Should the evaluation be done with current or final (after animation) element positions
* @returns {import('../../types/index.js').ActiveElement[]} - The active elements
* @returns {import('../types/index.js').ActiveElement[]} - The active elements
* @pravate
*/
_getActiveElements(e, lastActive, inChartArea, useFinalPosition) {
Expand Down
6 changes: 3 additions & 3 deletions src/core/core.element.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {AnyObject} from '../../types/basic.js';
import type {Point} from '../../types/geometric.js';
import type {Animation} from '../../types/animation.js';
import type {AnyObject} from '../types/basic.js';
import type {Point} from '../types/geometric.js';
import type {Animation} from '../types/animation.js';
import {isNumber} from '../helpers/helpers.math.js';

export default class Element<T = AnyObject, O = AnyObject> {
Expand Down
4 changes: 2 additions & 2 deletions src/core/core.interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {_isPointInArea} from '../helpers/index.js';

/**
* @typedef { import('./core.controller.js').default } Chart
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
* @typedef {{axis?: string, intersect?: boolean, includeInvisible?: boolean}} InteractionOptions
* @typedef {{datasetIndex: number, index: number, element: import('./core.element.js').default}} InteractionItem
* @typedef { import('../../types/index.js').Point } Point
* @typedef { import('../types/index.js').Point } Point
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/core.plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {callback as callCallback, isNullOrUndef, valueOrDefault} from '../helper

/**
* @typedef { import('./core.controller.js').default } Chart
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../plugins/plugin.tooltip.js').default } Tooltip
*/

Expand Down
2 changes: 1 addition & 1 deletion src/elements/element.arc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Element from '../core/core.element.js';
import {_angleBetween, getAngleFromPoint, TAU, HALF_PI, valueOrDefault} from '../helpers/index.js';
import {PI, _isBetween, _limitValue} from '../helpers/helpers.math.js';
import {_readValueToProps} from '../helpers/helpers.options.js';
import type {ArcOptions, Point} from '../../types/index.js';
import type {ArcOptions, Point} from '../types/index.js';


function clipArc(ctx: CanvasRenderingContext2D, element: ArcElement, endAngle: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/elements/element.point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
Point,
PointHoverOptions,
PointOptions,
} from '../../types/index.js';
} from '../types/index.js';

function inRange(el: PointElement, pos: number, axis: 'x' | 'y', useFinalPosition?: boolean) {
const options = el.options;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/helpers.canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {PI, TAU, HALF_PI, QUARTER_PI, TWO_THIRDS_PI, RAD_PER_DEG} from './helper
* necessary to avoid duplicates with `export * from './helpers`; see
* https://github.com/microsoft/TypeScript/issues/46011
* @typedef { import('../core/core.controller.js').default } canvas.Chart
* @typedef { import('../../types/index.js').Point } Point
* @typedef { import('../types/index.js').Point } Point
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/helpers.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @namespace Chart.helpers
*/

import type {AnyObject} from '../../types/basic.js';
import type {ActiveDataPoint, ChartEvent} from '../../types/index.js';
import type {AnyObject} from '../types/basic.js';
import type {ActiveDataPoint, ChartEvent} from '../types/index.js';

/**
* An empty function that can be used, for example, for optional callback.
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/helpers.curve.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {almostEquals, distanceBetweenPoints, sign} from './helpers.math.js';
import {_isPointInArea} from './helpers.canvas.js';
import type {ChartArea} from '../../types/index.js';
import type {ChartArea} from '../types/index.js';

export interface SplinePoint {
x: number;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/helpers.dom.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {ChartArea, Scale} from '../../types/index.js';
import type {ChartArea, Scale} from '../types/index.js';
import type Chart from '../core/core.controller.js';
import type {ChartEvent} from '../types.js';
import {INFINITY} from './helpers.math.js';
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/helpers.extras.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {ChartMeta, PointElement} from '../../types/index.js';
import type {ChartMeta, PointElement} from '../types/index.js';

import {_limitValue} from './helpers.math.js';
import {_lookupByKey} from './helpers.collection.js';
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/helpers.interpolation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Point} from '../../types/geometric.js';
import type {Point} from '../types/geometric.js';
import type {SplinePoint} from './helpers.curve.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/helpers.math.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {Point} from '../../types/geometric.js';
import type {Point} from '../types/geometric.js';
import {isFinite as isFiniteNumber} from './helpers.core.js';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/helpers.options.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import defaults from '../core/core.defaults.js';
import {isArray, isObject, toDimension, valueOrDefault} from './helpers.core.js';
import {Point, toFontString} from './helpers.canvas.js';
import type {ChartArea, FontSpec} from '../../types/index.js';
import type {TRBL, TRBLCorners} from '../../types/geometric.js';
import type {ChartArea, FontSpec} from '../types/index.js';
import type {TRBL, TRBLCorners} from '../types/geometric.js';

const LINE_HEIGHT = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/;
const FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ export * from './helpers.intl.js';
export * from './helpers.math.js';
export * from './helpers.options.js';
export * from './helpers.rtl.js';
export * from '../../types/helpers/index.js';
export * from '../types/helpers/index.js';
4 changes: 2 additions & 2 deletions src/plugins/plugin.filler/filler.options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {isObject, isFinite, valueOrDefault} from '../../helpers/helpers.core.js'
/**
* @typedef { import('../../core/core.scale.js').default } Scale
* @typedef { import('../../elements/element.line.js').default } LineElement
* @typedef { import('../../../types/index.js').FillTarget } FillTarget
* @typedef { import('../../../types/index.js').ComplexFillTarget } ComplexFillTarget
* @typedef { import('../../types/index.js').FillTarget } FillTarget
* @typedef { import('../../types/index.js').ComplexFillTarget } ComplexFillTarget
*/

export function _resolveTarget(sources, index, propagate) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plugin.legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {_alignStartEnd, _textX, _toLeftRightCenter} from '../helpers/helpers.ext
import {toTRBLCorners} from '../helpers/helpers.options.js';

/**
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
*/

const getBoxSize = (labelOpts, fontSize) => {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/plugin.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {createContext, drawPoint} from '../helpers/index.js';

/**
* @typedef { import('../platform/platform.base.js').Chart } Chart
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../../types/index.js').ActiveElement } ActiveElement
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
* @typedef { import('../types/index.js').ActiveElement } ActiveElement
* @typedef { import('../core/core.interaction.js').InteractionItem } InteractionItem
*/

Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ export {
TimeScale,
TimeSeriesScale,
registerables
} from '../types/index.js';
export * from '../types/index.js';
} from './types/index.js';
export * from './types/index.js';
4 changes: 2 additions & 2 deletions types/animation.d.ts → src/types/animation.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Chart } from './index.js';
import { AnyObject } from './basic.js';
import {Chart} from './index.js';
import {AnyObject} from './basic.js';

export declare class Animation {
constructor(cfg: AnyObject, target: AnyObject, prop: string, to?: unknown);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PointStyle, Scriptable, ScriptableScaleContext } from '../index.js';
import { Color } from '../color.js';
import { ChartArea, RoundedRect } from '../geometric.js';
import { CanvasFontSpec } from '../../src/helpers/helpers.options.js';
import {PointStyle, Scriptable, ScriptableScaleContext} from '../index.js';
import {Color} from '../color.js';
import {ChartArea, RoundedRect} from '../geometric.js';
import {CanvasFontSpec} from '../../helpers/helpers.options.js';

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

Expand Down
File renamed without changes.
File renamed without changes.
45 changes: 23 additions & 22 deletions types/index.d.ts → src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils.js';

import { TimeUnit } from '../src/core/core.adapters.js';
import PointElement from '../src/elements/element.point.js';
import { EasingFunction } from '../src/helpers/helpers.easing.js';
import { AnimationEvent } from './animation.js';
import { AnyObject, EmptyObject } from './basic.js';
import { Color } from './color.js';
import Element from '../src/core/core.element.js';
import { ChartArea, Padding, Point } from './geometric.js';
import { LayoutItem, LayoutPosition } from './layout.js';
import { RenderTextOpts } from './helpers/helpers.canvas.js';
import { CanvasFontSpec } from '../src/helpers/helpers.options.js';

export { EasingFunction } from '../src/helpers/helpers.easing.js';
export { default as ArcElement, ArcProps } from '../src/elements/element.arc.js';
export { default as PointElement, PointProps } from '../src/elements/element.point.js';
export { Animation, Animations, Animator, AnimationEvent } from './animation.js';
export { Color } from './color.js';
export { ChartArea, Point } from './geometric.js';
export { LayoutItem, LayoutPosition } from './layout.js';
/* eslint-disable @typescript-eslint/ban-types */
import {DeepPartial, DistributiveArray, UnionToIntersection} from './utils.js';

import {TimeUnit} from '../core/core.adapters.js';
import PointElement from '../elements/element.point.js';
import {EasingFunction} from '../helpers/helpers.easing.js';
import {AnimationEvent} from './animation.js';
import {AnyObject, EmptyObject} from './basic.js';
import {Color} from './color.js';
import Element from '../core/core.element.js';
import {ChartArea, Padding, Point} from './geometric.js';
import {LayoutItem, LayoutPosition} from './layout.js';
import {RenderTextOpts} from './helpers/helpers.canvas.js';
import {CanvasFontSpec} from '../helpers/helpers.options.js';

export {EasingFunction} from '../helpers/helpers.easing.js';
export {default as ArcElement, ArcProps} from '../elements/element.arc.js';
export {default as PointElement, PointProps} from '../elements/element.point.js';
export {Animation, Animations, Animator, AnimationEvent} from './animation.js';
export {Color} from './color.js';
export {ChartArea, Point} from './geometric.js';
export {LayoutItem, LayoutPosition} from './layout.js';

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

export type ScatterControllerDatasetOptions = LineControllerDatasetOptions;

export interface ScatterDataPoint extends Point {}
export type ScatterDataPoint = Point

export type ScatterControllerChartOptions = LineControllerChartOptions;

Expand Down
2 changes: 1 addition & 1 deletion types/layout.d.ts → src/types/layout.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChartArea } from './geometric.js';
import {ChartArea} from './geometric.js';

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

Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions types/.eslintrc.yml → test/types/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
rules:
# These rules were set to warning to make the linting pass initially,
# without making any major changes to types.
'@typescript-eslint/no-unused-vars': 'off'
object-curly-spacing: ["warn", "always"]
'@typescript-eslint/no-empty-interface': "warn"
'@typescript-eslint/ban-types': "warn"
Expand Down
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.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnyObject } from '../../basic.js';
import { AnyObject } from '../../../src/types/basic.js';
import { CartesianScaleOptions, Chart, Scale } from '../../../src/types.js';

export type TestScaleOptions = CartesianScaleOptions & {
Expand All @@ -17,7 +17,7 @@ export class TestScale<O extends TestScaleOptions = TestScaleOptions> extends Sc
}
}

declare module '../../index.js' {
declare module '../../../src/types/index.js' {
interface CartesianScaleTypeRegistry {
test: {
options: TestScaleOptions
Expand Down
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.
File renamed without changes.
2 changes: 1 addition & 1 deletion types/tests/tsconfig.json → test/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"rootDir": "../../"
},
"include": [
"../",
"./",
"../../src/",
"../../dist/**/*.d.ts"
],
Expand Down
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@
},
"typedocOptions": {
"name": "Chart.js",
"entryPoints": ["types/index.d.ts"],
"entryPoints": ["src/types/index.d.ts"],
"readme": "none",
"excludeExternals": true,
"includeVersion": true,
"out": "./dist/docs/typedoc"
},
"include": [
"./src/**/*",
"./types"
"./src/**/*"
],
"exclude": [
"./types/tests",
"./dist/**"
]
}
2 changes: 0 additions & 2 deletions types/tests/.eslintrc.yml

This file was deleted.

0 comments on commit 64a0278

Please sign in to comment.