Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load only specified typings for TypeScript #14808

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class MutationObserver extends Observer {
/**
* Native mutation observer.
*/
private _mutationObserver: InstanceType<typeof global.MutationObserver>;
private _mutationObserver: InstanceType<typeof window.MutationObserver>;

/**
* @inheritDoc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @module utils/dom/getelementsintersectionrect
*/

import global from './global';
import Rect from './rect';

/**
Expand Down
9 changes: 2 additions & 7 deletions packages/ckeditor5-utils/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* @module utils/version
*/

/* globals window, global */

import CKEditorError from './ckeditorerror';

const version = '39.0.1';
Expand All @@ -18,16 +16,13 @@ export default version;
// The second argument is not a month. It is `monthIndex` and starts from `0`.
export const releaseDate = new Date( 2023, 7, 10 );

/* istanbul ignore next -- @preserve */
const windowOrGlobal = typeof window === 'object' ? window : global;

declare global {
// eslint-disable-next-line no-var
var CKEDITOR_VERSION: string;
}

/* istanbul ignore next -- @preserve */
if ( windowOrGlobal.CKEDITOR_VERSION ) {
if ( globalThis.CKEDITOR_VERSION ) {
/**
* This error is thrown when due to a mistake in how CKEditor 5 was installed or initialized, some
* of its modules were duplicated (evaluated and executed twice). Module duplication leads to inevitable runtime
Expand Down Expand Up @@ -167,5 +162,5 @@ if ( windowOrGlobal.CKEDITOR_VERSION ) {
null
);
} else {
windowOrGlobal.CKEDITOR_VERSION = version;
globalThis.CKEDITOR_VERSION = version;
}
11 changes: 11 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@
*/
{
"compilerOptions": {
/**
* TypeScript automagically loads typings from all "@types/*" packages if the "compilerOptions.types" array is not defined in
* this file. However, if some dependencies have "@types/*" packages as their dependencies, they'll also be loaded as well.
* As a result, TypeScript loaded "@types/node" which we don't want to use, because it allows using Node.js specific APIs that
* are not available in the browsers.
*
* To avoid such issues, we defined this empty "types" to disable automatic inclusion of the "@types/*" packages.
*/
"types": [],
"lib": [
"ES2019", // Must match the "target"
"ES2020.String",
"DOM",
"DOM.Iterable"
],
Expand Down