Skip to content

Commit

Permalink
Merge pull request #17885 from ckeditor/update-target-to-es2022
Browse files Browse the repository at this point in the history
Other: Update TypeScript `target` to `es2022`. Closes #17886.
  • Loading branch information
filipsobol authored Feb 7, 2025
2 parents a08312a + 7d4e38d commit 57c46c8
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 26 deletions.
6 changes: 3 additions & 3 deletions docs/_snippets/examples/bottom-toolbar-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ DecoupledEditor
.then( editor => {
window.editor = editor;

const toolbarContainer = document.querySelector( '#editor-toolbar-container' );

toolbarContainer.appendChild( editor.ui.view.toolbar.element );
document
.querySelector( '#editor-toolbar-container' )
?.appendChild( editor.ui.view.toolbar.element );

overrideDropdownPositionsToNorth( editor, editor.ui.view.toolbar );
overrideDropdownPositionsToNorth( editor, editor.plugins.get( 'FormattingOptions' ).toolbarView );
Expand Down
6 changes: 3 additions & 3 deletions docs/_snippets/examples/document-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ DecoupledEditor
licenseKey: 'GPL'
} )
.then( editor => {
const toolbarContainer = document.querySelector( '.document-editor__toolbar' );

toolbarContainer.appendChild( editor.ui.view.toolbar.element );
document
.querySelector( '.document-editor__toolbar' )
?.appendChild( editor.ui.view.toolbar.element );

window.editor = editor;
} )
Expand Down
6 changes: 2 additions & 4 deletions packages/ckeditor5-ckbox/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,13 @@ export function getImageUrls( imageUrls: CKBoxImageUrls ): {
export function getWorkspaceId( token: InitializedToken, defaultWorkspaceId?: string ): string | null {
const [ , binaryTokenPayload ] = token.value.split( '.' );
const payload = JSON.parse( atob( binaryTokenPayload ) );
const workspaces = ( payload.auth && payload.auth.ckbox && payload.auth.ckbox.workspaces ) || [ payload.aud ];
const workspaces = payload.auth?.ckbox?.workspaces || [ payload.aud ];

if ( !defaultWorkspaceId ) {
return workspaces[ 0 ];
}

const role = payload.auth && payload.auth.ckbox && payload.auth.ckbox.role;

if ( role == 'superadmin' || workspaces.includes( defaultWorkspaceId ) ) {
if ( payload.auth?.ckbox?.role == 'superadmin' || workspaces.includes( defaultWorkspaceId ) ) {
return defaultWorkspaceId;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/src/clipboardmarkersutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ export default class ClipboardMarkersUtils extends Plugin {
// set them new unique name.
let skipAssign = false;

if ( prevFakeMarker && prevFakeMarker.start && prevFakeMarker.end ) {
if ( prevFakeMarker?.start && prevFakeMarker?.end ) {
const config = this._getMarkerClipboardConfig( fakeMarker.name )!;

if ( config.duplicateOnPaste ) {
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/src/dragdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export default class DragDrop extends Plugin {
// The handler for the drag start; it is responsible for setting data transfer object.
this.listenTo<ViewDocumentDragStartEvent>( viewDocument, 'dragstart', ( evt, data ) => {
// Don't drag the editable element itself.
if ( data.target && data.target.is( 'editableElement' ) ) {
if ( data.target?.is( 'editableElement' ) ) {
data.preventDefault();

return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,5 @@ function _isBase64( string: string | Blob ): string is string {
return false;
}

const match = string.match( BASE64_HEADER_REG_EXP );
return !!( match && match.length );
return !!string.match( BASE64_HEADER_REG_EXP )?.length;
}
2 changes: 1 addition & 1 deletion packages/ckeditor5-code-block/src/codeblockcommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class CodeBlockCommand extends Command {
private _getValue(): string | false {
const selection = this.editor.model.document.selection;
const firstBlock = first( selection.getSelectedBlocks() );
const isCodeBlock = !!( firstBlock && firstBlock.is( 'element', 'codeBlock' ) );
const isCodeBlock = !!firstBlock?.is( 'element', 'codeBlock' );

return isCodeBlock ? firstBlock.getAttribute( 'language' ) as string : false;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-engine/src/view/stylesmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,12 @@ export default class StylesMap implements ElementAttributeValue {
}

if ( expand ) {
this._cachedExpandedStyleNames = this._cachedExpandedStyleNames || this._styleProcessor.getStyleNames( this._styles );
this._cachedExpandedStyleNames ||= this._styleProcessor.getStyleNames( this._styles );

return this._cachedExpandedStyleNames;
}

this._cachedStyleNames = this._cachedStyleNames || this.getStylesEntries().map( ( [ key ] ) => key );
this._cachedStyleNames ||= this.getStylesEntries().map( ( [ key ] ) => key );

return this._cachedStyleNames;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-ui/src/button/filedialogbuttonview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class FileInputView extends View<HTMLInputElement> {
on: {
// Removing from code coverage since we cannot programmatically set input element files.
change: bind.to( /* istanbul ignore next -- @preserve */ () => {
if ( this.element && this.element.files && this.element.files.length ) {
if ( this.element?.files?.length ) {
this.fire<FileInputViewDoneEvent>( 'done', this.element.files );
}

Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-ui/src/colorgrid/colorgridview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class ColorGridView extends View implements DropdownPanelFocusabl

const colorDefinitions = options && options.colorDefinitions ? options.colorDefinitions : [];

this.columns = options && options.columns ? options.columns : 5;
this.columns = options?.columns || 5;

const viewStyleAttribute = {
gridTemplateColumns: `repeat( ${ this.columns }, 1fr)`
Expand Down Expand Up @@ -179,7 +179,7 @@ export default class ColorGridView extends View implements DropdownPanelFocusabl
focusTracker: this.focusTracker,
gridItems: this.items,
numberOfColumns: this.columns,
uiLanguageDirection: this.locale && this.locale.uiLanguageDirection
uiLanguageDirection: this.locale?.uiLanguageDirection
} );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ export default class ColorGridsFragmentView extends View {

colorTile.set( {
color: colorObj.color,
hasBorder: colorObj.options && colorObj.options.hasBorder
hasBorder: colorObj.options?.hasBorder
} );

if ( colorObj.label ) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ckeditor5-ui/src/search/text/searchtextview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ export default class SearchTextView<
let primaryText, secondaryText;

if ( data.totalItemsCount ) {
if ( defaultTextConfig && defaultTextConfig.notFound ) {
if ( defaultTextConfig?.notFound ) {
primaryText = defaultTextConfig.notFound.primary;
secondaryText = defaultTextConfig.notFound.secondary;
} else {
primaryText = t( 'No results found' );
secondaryText = '';
}
} else {
if ( defaultTextConfig && defaultTextConfig.noSearchableItems ) {
if ( defaultTextConfig?.noSearchableItems ) {
primaryText = defaultTextConfig.noSearchableItems.primary;
secondaryText = defaultTextConfig.noSearchableItems.secondary;
} else {
Expand Down
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
*/
"types": [],
"lib": [
"ES2019", // Must match the "target"
"ES2020.String",
"ES2022", // Must match the "target"
"DOM",
"DOM.Iterable"
],
"noImplicitAny": true,
"noImplicitOverride": true,
"strict": true,
"module": "es6",
"target": "es2019",
"target": "es2022",
"sourceMap": true,
"allowJs": true,
"moduleResolution": "node",
Expand Down

0 comments on commit 57c46c8

Please sign in to comment.