enonic-types
Advanced tools
Comparing version 0.3.11 to 0.3.12
{ | ||
"name": "enonic-types", | ||
"sideEffects": false, | ||
"version": "0.3.11", | ||
"version": "0.3.12", | ||
"description": "TypeScript types for Enonic XP", | ||
@@ -27,4 +27,4 @@ "typings": "index.d.ts", | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.8.1", | ||
"@typescript-eslint/parser": "^5.8.1", | ||
"@typescript-eslint/eslint-plugin": "^5.9.1", | ||
"@typescript-eslint/parser": "^5.9.1", | ||
"eslint": "^8.6.0", | ||
@@ -31,0 +31,0 @@ "eslint-config-prettier": "^8.3.0", |
@@ -69,3 +69,40 @@ # TypeScript types for Enonic XP | ||
4. `content` is of the type `Content<Article> | null`, so we have to do a null check before proceeding. | ||
# Using vanilla JavaScript | ||
If your project is using vanilla JavaScript, you can still get the benefit of code completion when using libraries. | ||
This is even better if you are using [JsDoc to add types to your code](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html). | ||
All you have to do is the following: | ||
1. Configure *./tsconfig.json* as described above | ||
2. Add a file: *./src/main/resources/types.ts* with the following content: | ||
```typescript | ||
type LibMap = import('enonic-types/libs').EnonicLibraryMap; | ||
declare const require: <K extends keyof LibMap | string = string>( | ||
path: K | ||
) => K extends keyof LibMap ? LibMap[K] : unknown; | ||
declare const resolve: ( | ||
path: string | ||
) => import('enonic-types/thymeleaf').ResourceKey; | ||
declare const app: { | ||
name: string; | ||
version: string; | ||
config: { [key: string]: string }; | ||
}; | ||
declare const log: { | ||
info: (...args: unknown[]) => void; | ||
warning: (...args: unknown[]) => void; | ||
error: (...args: unknown[]) => void; | ||
}; | ||
declare const __: { | ||
newBean: (bean: string) => unknown; | ||
toNativeObject: <A = unknown>(beanResult: A) => A; | ||
}; | ||
``` | ||
## Using `__non_webpack_require__` | ||
@@ -72,0 +109,0 @@ |
@@ -137,5 +137,7 @@ declare module "*/lib/turbo-streams" { | ||
*/ | ||
interface GetWebSocketUrlParams { | ||
service: string; | ||
} | ||
type GetWebSocketUrlParams = Omit<import("/lib/xp/portal").ServiceUrlParams, "params"> & { | ||
params?: { | ||
groupId?: string; | ||
}; | ||
}; | ||
} | ||
@@ -142,0 +144,0 @@ const turboStreamsLib: turboStreamsLib.TurboStreamsLibrary; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192052
4880
168