From e67a0366907174c05018ce6c1c74b3912018d59a Mon Sep 17 00:00:00 2001 From: Dylan Schiemann Date: Sun, 15 Oct 2023 18:44:48 -0700 Subject: [PATCH] incremental updates for TS 5.0 --- config/typescript/tsconfig.json | 1 - package.json | 2 +- packages/slate-react/src/components/leaf.tsx | 3 ++- packages/slate/src/interfaces/element.ts | 4 ++-- packages/slate/src/interfaces/text.ts | 2 +- .../slate/src/interfaces/transforms/general.ts | 16 ++++++++-------- .../slate/src/transforms-node/set-nodes.ts | 8 ++++---- .../src/transforms-selection/set-selection.ts | 6 +++--- yarn.lock | 18 +++++++++--------- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/config/typescript/tsconfig.json b/config/typescript/tsconfig.json index 5f3f64222a..5384a10d2d 100644 --- a/config/typescript/tsconfig.json +++ b/config/typescript/tsconfig.json @@ -11,7 +11,6 @@ "resolveJsonModule": true, "sourceMap": true, "strict": true, - "suppressImplicitAnyIndexErrors": true, "target": "esnext" } } diff --git a/package.json b/package.json index f034bdf745..8fc28426be 100644 --- a/package.json +++ b/package.json @@ -113,7 +113,7 @@ "slate-react": "workspace:*", "source-map-loader": "^4.0.0", "ts-jest": "^27.1.3", - "typescript": "4.9.5" + "typescript": "5.0.4" }, "simple-git-hooks": { "pre-commit": "yarn lint-staged" diff --git a/packages/slate-react/src/components/leaf.tsx b/packages/slate-react/src/components/leaf.tsx index 9ac9253d7b..b443df3c68 100644 --- a/packages/slate-react/src/components/leaf.tsx +++ b/packages/slate-react/src/components/leaf.tsx @@ -5,6 +5,7 @@ import React, { useState, useEffect, } from 'react' +import type { JSX } from 'react' import { Element, Text } from 'slate' import { ResizeObserver as ResizeObserverPolyfill } from '@juggle/resize-observer' import String from './string' @@ -99,7 +100,7 @@ const Leaf = (props: { useEffect(() => { if (leafIsPlaceholder) { if (!showPlaceholderTimeoutRef.current) { - // Delay the placeholder so it will not render in a selection + // Delay the placeholder, so it will not render in a selection showPlaceholderTimeoutRef.current = setTimeout(() => { setShowPlaceholder(true) showPlaceholderTimeoutRef.current = null diff --git a/packages/slate/src/interfaces/element.ts b/packages/slate/src/interfaces/element.ts index a2c0f36442..750acf76b6 100644 --- a/packages/slate/src/interfaces/element.ts +++ b/packages/slate/src/interfaces/element.ts @@ -85,7 +85,7 @@ export const Element: ElementInterface = { elementVal: string, elementKey: string = 'type' ): value is T => { - return isElement(value) && value[elementKey] === elementVal + return isElement(value) && value[elementKey] === elementVal }, matches(element: Element, props: Partial): boolean { @@ -94,7 +94,7 @@ export const Element: ElementInterface = { continue } - if (element[key] !== props[key]) { + if (element[key] !== props[key]) { return false } } diff --git a/packages/slate/src/interfaces/text.ts b/packages/slate/src/interfaces/text.ts index b3ed0051cd..0bae5f421d 100644 --- a/packages/slate/src/interfaces/text.ts +++ b/packages/slate/src/interfaces/text.ts @@ -92,7 +92,7 @@ export const Text: TextInterface = { continue } - if (!text.hasOwnProperty(key) || text[key] !== props[key]) { + if (!text.hasOwnProperty(key) || text[key] !== props[key]) { return false } } diff --git a/packages/slate/src/interfaces/transforms/general.ts b/packages/slate/src/interfaces/transforms/general.ts index c98750321a..63f9d87e65 100644 --- a/packages/slate/src/interfaces/transforms/general.ts +++ b/packages/slate/src/interfaces/transforms/general.ts @@ -135,7 +135,7 @@ const applyToDraft = (editor: Editor, selection: Selection, op: Operation) => { const parent = Node.parent(editor, path) parent.children.splice(index, 1) - // Transform all of the points in the value, but if the point was in the + // Transform all the points in the value, but if the point was in the // node that was removed we need to update the range or remove it. if (selection) { for (const [point, key] of Range.points(selection)) { @@ -214,19 +214,19 @@ const applyToDraft = (editor: Editor, selection: Selection, op: Operation) => { throw new Error(`Cannot set the "${key}" property of nodes!`) } - const value = newProperties[key] + const value = newProperties[key] if (value == null) { - delete node[key] + delete node[key] } else { - node[key] = value + node[key] = value } } // properties that were previously defined, but are now missing, must be deleted for (const key in properties) { if (!newProperties.hasOwnProperty(key)) { - delete node[key] + delete node[key] } } @@ -252,16 +252,16 @@ const applyToDraft = (editor: Editor, selection: Selection, op: Operation) => { } for (const key in newProperties) { - const value = newProperties[key] + const value = newProperties[key] if (value == null) { if (key === 'anchor' || key === 'focus') { throw new Error(`Cannot remove the "${key}" selection property`) } - delete selection[key] + delete selection[key] } else { - selection[key] = value + selection[key] = value } } } diff --git a/packages/slate/src/transforms-node/set-nodes.ts b/packages/slate/src/transforms-node/set-nodes.ts index bb342f91cb..7c15730266 100644 --- a/packages/slate/src/transforms-node/set-nodes.ts +++ b/packages/slate/src/transforms-node/set-nodes.ts @@ -95,15 +95,15 @@ export const setNodes: NodeTransforms['setNodes'] = ( continue } - if (compare(props[k], node[k])) { + if (compare(props[k], node[k])) { hasChanges = true // Omit new properties from the old properties list - if (node.hasOwnProperty(k)) properties[k] = node[k] + if (node.hasOwnProperty(k)) properties[k] = node[k] // Omit properties that have been removed from the new properties list if (merge) { - if (props[k] != null) newProperties[k] = merge(node[k], props[k]) + if (props[k] != null) newProperties[k] = merge(node[k], props[k]) } else { - if (props[k] != null) newProperties[k] = props[k] + if (props[k] != null) newProperties[k] = props[k] } } } diff --git a/packages/slate/src/transforms-selection/set-selection.ts b/packages/slate/src/transforms-selection/set-selection.ts index f18cba926b..dd60f377ff 100644 --- a/packages/slate/src/transforms-selection/set-selection.ts +++ b/packages/slate/src/transforms-selection/set-selection.ts @@ -22,10 +22,10 @@ export const setSelection: SelectionTransforms['setSelection'] = ( (k === 'focus' && props.focus != null && !Point.equals(props.focus, selection.focus)) || - (k !== 'anchor' && k !== 'focus' && props[k] !== selection[k]) + (k !== 'anchor' && k !== 'focus' && props[k] !== selection[k]) ) { - oldProps[k] = selection[k] - newProps[k] = props[k] + oldProps[k] = selection[k] + newProps[k] = props[k] } } diff --git a/yarn.lock b/yarn.lock index 56dfdb68d9..12dafed65e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13885,7 +13885,7 @@ resolve@^2.0.0-next.3: slate-react: "workspace:*" source-map-loader: ^4.0.0 ts-jest: ^27.1.3 - typescript: 4.9.5 + typescript: 5.0.4 languageName: unknown linkType: soft @@ -15262,23 +15262,23 @@ resolve@^2.0.0-next.3: languageName: node linkType: hard -"typescript@npm:4.9.5": - version: 4.9.5 - resolution: "typescript@npm:4.9.5" +"typescript@npm:5.0.4": + version: 5.0.4 + resolution: "typescript@npm:5.0.4" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: ee000bc26848147ad423b581bd250075662a354d84f0e06eb76d3b892328d8d4440b7487b5a83e851b12b255f55d71835b008a66cbf8f255a11e4400159237db + checksum: 82b94da3f4604a8946da585f7d6c3025fff8410779e5bde2855ab130d05e4fd08938b9e593b6ebed165bda6ad9292b230984f10952cf82f0a0ca07bbeaa08172 languageName: node linkType: hard -"typescript@patch:typescript@4.9.5#~builtin": - version: 4.9.5 - resolution: "typescript@patch:typescript@npm%3A4.9.5#~builtin::version=4.9.5&hash=289587" +"typescript@patch:typescript@5.0.4#~builtin": + version: 5.0.4 + resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin::version=5.0.4&hash=b5f058" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 1f8f3b6aaea19f0f67cba79057674ba580438a7db55057eb89cc06950483c5d632115c14077f6663ea76fd09fce3c190e6414bb98582ec80aa5a4eaf345d5b68 + checksum: d26b6ba97b6d163c55dbdffd9bbb4c211667ebebc743accfeb2c8c0154aace7afd097b51165a72a5bad2cf65a4612259344ff60f8e642362aa1695c760d303ac languageName: node linkType: hard