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 TypeScript Module Configuration (especially for ESM) #574

Merged
merged 2 commits into from
Jan 10, 2024
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
2 changes: 1 addition & 1 deletion src/lib/Logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { wdi5LogLevel } from "../types/wdi5.types"
import { wdi5LogLevel } from "../types/wdi5.types.js"

const translate = (color) => {
switch (color) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/authentication/BTPAuthenticator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BTPAuthenticator as BTPAuthenticatorType } from "../../types/wdi5.types"
import { BTPAuthenticator as BTPAuthenticatorType } from "../../types/wdi5.types.js"
import Authenticator from "./Authenticator.js"

class BTPAuthenticator extends Authenticator {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/authentication/BasicAuthenticator.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Authenticator from "./Authenticator.js"
import { BasicAuthAuthenticator as BasicAuthenticatorType } from "../../types/wdi5.types"
import { BasicAuthAuthenticator as BasicAuthenticatorType } from "../../types/wdi5.types.js"

class BasicAuthenticator extends Authenticator {
private options: BasicAuthenticatorType
Expand Down
2 changes: 1 addition & 1 deletion src/lib/authentication/CustomAuthenticator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CustomAuthenticator as CustomAuthenticatorType } from "../../types/wdi5.types"
import { CustomAuthenticator as CustomAuthenticatorType } from "../../types/wdi5.types.js"
import { Logger } from "../Logger.js"
import Authenticator from "./Authenticator.js"

Expand Down
2 changes: 1 addition & 1 deletion src/lib/authentication/Office365Authenticator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Office365Authenticator as Office365AuthenticatorType } from "../../types/wdi5.types"
import { Office365Authenticator as Office365AuthenticatorType } from "../../types/wdi5.types.js"
import Authenticator from "./Authenticator.js"

class Office365Authenticator extends Authenticator {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/wdi5-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import * as semver from "semver"
import { mark as marky_mark, stop as marky_stop } from "marky"

import { clientSide_ui5Object, clientSide_ui5Response, wdi5Config, wdi5Selector } from "../types/wdi5.types"
import { clientSide_ui5Object, clientSide_ui5Response, wdi5Config, wdi5Selector } from "../types/wdi5.types.js"
import { MultiRemoteBrowser } from "webdriverio"
import { WDI5Control } from "./wdi5-control.js"
import { WDI5FE } from "./wdi5-fe.js"
Expand All @@ -19,7 +19,7 @@
import { Logger as _Logger } from "./Logger.js"
import { WDI5Object } from "./wdi5-object.js"
import BTPAuthenticator from "./authentication/BTPAuthenticator.js"
import { BTPAuthenticator as BTPAuthenticatorType } from "../types/wdi5.types"
import { BTPAuthenticator as BTPAuthenticatorType } from "../types/wdi5.types.js"
import BasicAuthenticator from "./authentication/BasicAuthenticator.js"
import CustomAuthenticator from "./authentication/CustomAuthenticator.js"
import Office365Authenticator from "./authentication/Office365Authenticator.js"
Expand Down Expand Up @@ -468,7 +468,7 @@
// eslint-disable-next-line @typescript-eslint/no-empty-function
return new Proxy(function () {}, handler)
}
// @ts-ignore

Check warning on line 471 in src/lib/wdi5-bridge.ts

View workflow job for this annotation

GitHub Actions / Run linters

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
return makeFluent(browserInstance._asControl(ui5ControlSelector))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/wdi5-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { clientSide_interactWithControl } from "../../client-side-js/interactWit
import { clientSide_executeControlMethod } from "../../client-side-js/executeControlMethod.cjs"
import { clientSide_getAggregation } from "../../client-side-js/_getAggregation.cjs"
import { clientSide_fireEvent } from "../../client-side-js/fireEvent.cjs"
import { clientSide_ui5Response, wdi5ControlMetadata, wdi5Selector } from "../types/wdi5.types"
import { clientSide_ui5Response, wdi5ControlMetadata, wdi5Selector } from "../types/wdi5.types.js"
import { Logger as _Logger } from "./Logger.js"
import { wdioApi } from "./wdioApi.js"
import { WDI5Object } from "./wdi5-object.js"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/wdi5-object.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clientSide_executeObjectMethod } from "../../client-side-js/executeObjectMethod.cjs"
import { clientSide_ui5Response } from "../types/wdi5.types"
import { clientSide_ui5Response } from "../types/wdi5.types.js"
import { Logger as _Logger } from "./Logger.js"

const Logger = _Logger.getInstance()
Expand Down
2 changes: 1 addition & 1 deletion src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Capabilities, Services } from "@wdio/types"
import { MultiRemoteBrowser } from "webdriverio"

import { start, injectUI5, setup, checkForUI5Page, authenticate } from "./lib/wdi5-bridge.js"
import { wdi5Config } from "./types/wdi5.types"
import { wdi5Config } from "./types/wdi5.types.js"

import { Logger as _Logger } from "./lib/Logger.js"
const Logger = _Logger.getInstance()
Expand Down
4 changes: 2 additions & 2 deletions src/types/browser-commands.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Control from "sap/ui/core/Control"
import { wdi5Config, wdi5Selector } from "./wdi5.types"
import { WDI5Control } from "../lib/wdi5-control"
import { wdi5Config, wdi5Selector } from "./wdi5.types.js"
import { WDI5Control } from "../lib/wdi5-control.js"

/**
* wdi5 control cache aka
Expand Down
4 changes: 2 additions & 2 deletions src/types/wdi5.types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Log from "sap/base/Log"
import RecordReplay from "sap/ui/test/RecordReplay"
import { ControlSelector } from "sap/ui/test/RecordReplay"
import { WDI5Object } from "../lib/wdi5-object"
import { WDI5Object } from "../lib/wdi5-object.js"

// // copypasta from
// // https://stackoverflow.com/questions/41285211/overriding-interface-property-type-defined-in-typescript-d-ts-file/65561287#65561287
Expand Down Expand Up @@ -262,4 +262,4 @@ export interface wdi5Bridge extends Window {
}
}

export type { WDI5Control as wdi5Control } from "../lib/wdi5-control"
export type { WDI5Control as wdi5Control } from "../lib/wdi5-control.js"
1 change: 1 addition & 0 deletions tsconfig-cjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"noEmit": false,
"outDir": "cjs",
"moduleResolution": "Node",
"module": "CommonJS"
}
}
1 change: 0 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"declaration": true,
"declarationMap": true,
"downlevelIteration": true,
"moduleResolution": "node",
"types": ["node", "@wdio/globals/types", "@wdio/mocha-framework", "openui5"]
},
"include": ["src"]
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"noEmit": false,
"outDir": "esm",
"module": "ESNext",
"target": "ESNext"
"module": "Node16",
"moduleResolution": "Node16"
}
}
Loading