@types/ember__controller
TypeScript icon, indicating that this package has built-in type declarations

4.0.12 • Public • Published

Installation

npm install --save @types/ember__controller

Summary

This package contains type definitions for @ember/controller (https://emberjs.com/api/ember/4.0/modules/@ember%2Fcontroller).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ember__controller.

index.d.ts

import EmberObject from "@ember/object";
import ActionHandler from "@ember/object/-private/action-handler";
import ComputedProperty from "@ember/object/computed";
import Mixin from "@ember/object/mixin";

// eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers
type QueryParamTypes = "boolean" | "number" | "array" | "string";
// eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers
type QueryParamScopeTypes = "controller" | "model";

// eslint-disable-next-line @definitelytyped/strict-export-declare-modifiers
interface QueryParamConfig {
    type?: QueryParamTypes | undefined;
    scope?: QueryParamScopeTypes | undefined;
    as?: string | undefined;
}

/**
 * Additional methods for the Controller.
 */
interface ControllerMixin extends ActionHandler {
    /**
     * @deprecated until 5.0. Use `RouterService.reaplceWith` instead.
     */
    replaceRoute(name: string, ...args: any[]): void;
    /**
     * @deprecated until 5.0. Use `RouterService.transitionTo` instead.
     */
    transitionToRoute(name: string, ...args: any[]): void;
    /**
     * @deprecated until 5.0. Use `RouterService.transitionTo` instead.
     */
    transitionToRoute(...args: any[]): void;
    model: unknown;
    queryParams: Readonly<Array<string | Record<string, QueryParamConfig | string | undefined>>>;
    target: object;
}

export default class Controller extends EmberObject {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface -- used for declaration merge
export default interface Controller extends ControllerMixin {}

export function inject(): ComputedProperty<Controller>;
export function inject<K extends keyof Registry>(name: K): ComputedProperty<Registry[K]>;
export function inject(target: object, propertyKey: string | symbol): void;

// A type registry for Ember `Controller`s. Meant to be declaration-merged
// so string lookups resolve to the correct type.
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Registry extends Record<string, Controller | undefined> {}

declare module "@ember/owner" {
    interface DIRegistry {
        controller: Registry;
    }
}

// We need to define the `ControllerMixin` type above, but it is not public API
// and should not be importable, so shut off auto-importing.
export {};

Additional Details

Credits

These definitions were written by Krystan HuffMenne, James C. Davis, and Peter Wagenet.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/ember__controller

Weekly Downloads

61,010

Version

4.0.12

License

MIT

Unpacked Size

7.81 kB

Total Files

5

Last publish

Collaborators

  • types