@inlang/core
Advanced tools
Comparing version 0.9.0 to 0.9.1
import type { InlangEnvironment } from "../environment/types.js"; | ||
import type { PluginSetupFunction, Plugin } from "./types.js"; | ||
export declare function createPlugin<PluginSettings extends Record<string, unknown> | undefined = undefined>(callback: (args: { | ||
settings?: PluginSettings; | ||
settings: PluginSettings; | ||
env: InlangEnvironment; | ||
}) => Plugin): PluginSettings extends undefined ? () => PluginSetupFunction : (settings?: PluginSettings) => PluginSetupFunction; | ||
//# sourceMappingURL=createPlugin.d.ts.map |
{ | ||
"name": "@inlang/core", | ||
"type": "module", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"publishConfig": { | ||
@@ -6,0 +6,0 @@ "access": "public" |
import { it, expect } from "vitest" | ||
import { createPlugin } from "./createPlugin.js" | ||
import type { InlangEnvironment } from "../environment/types.js" | ||
import { expectType } from "tsd" | ||
it("should be possible to define a plugin without settings and the type should be undefined", () => { | ||
createPlugin(({ settings }) => { | ||
expectType<undefined>(settings) | ||
return {} as any | ||
}) | ||
}) | ||
it('should have defined settings if "createPlugin" is called with a settings type', () => { | ||
createPlugin<{ pathPattern: string }>((args) => { | ||
expectType<object>(args.settings) | ||
expectType<string>(args.settings?.pathPattern) | ||
return {} as any | ||
}) | ||
}) | ||
it("should be possible to define a plugin", () => { | ||
@@ -6,0 +22,0 @@ const myPlugin = createPlugin<{ pathPattern: string }>(({ settings }) => { |
@@ -7,3 +7,3 @@ import type { InlangEnvironment } from "../environment/types.js" | ||
>( | ||
callback: (args: { settings?: PluginSettings; env: InlangEnvironment }) => Plugin, | ||
callback: (args: { settings: PluginSettings; env: InlangEnvironment }) => Plugin, | ||
): PluginSettings extends undefined | ||
@@ -10,0 +10,0 @@ ? () => PluginSetupFunction |
Sorry, the diff of this file is not supported yet
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
497057
6530