Skip to content

Commit

Permalink
Merge pull request #865 from And012/master
Browse files Browse the repository at this point in the history
Types for ember-cookies
  • Loading branch information
BobrImperator authored Oct 13, 2023
2 parents e3f931a + 546f528 commit a30d843
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 1 deletion.
54 changes: 54 additions & 0 deletions packages/ember-cookies/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
type Options = {
maxAge?: number | string;
domain?: string;
expires?: Date;
secure?: boolean;
httpOnly?: boolean;
path?: string;
sameSite?: string;
}

declare module 'ember-cookies/test-support' {
export default function clearAllCookies(param?: Options): void
}

declare module "ember-cookies/services/cookies" {
import Service from "@ember/service";

type ReadOptions = {
raw?: boolean;
domain?: never;
expires?: never;
maxAge?: never;
path?: never;
};

type WriteOptions = {
domain?: string;
path?: string;
secure?: boolean;
raw?: boolean;
sameSite?: "Strict" | "Lax" | "None";
signed?: never;
} & (
| { expires?: Date; maxAge?: never }
| { maxAge?: number; expires?: never }
);

type ClearOptions = {
domain?: string;
path?: string;
secure?: boolean;

expires?: never;
maxAge?: never;
raw?: never;
};

export default class CookiesService extends Service {
public read(name: string, options?: ReadOptions): string;
public write(name: string, value: unknown, options?: WriteOptions): void;
public clear(name: string, options?: ClearOptions): void;
public exists(name: string): boolean;
}
}
5 changes: 4 additions & 1 deletion packages/ember-cookies/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"repository": "https://github.com/simplabs/ember-cookies",
"license": "MIT",
"author": "",
"types": "./index.d.ts",
"exports": {
".": "./dist/index.js",
"./*": "./dist/*",
Expand All @@ -20,7 +21,8 @@
},
"files": [
"addon-main.js",
"dist"
"dist",
"index.d.ts"
],
"scripts": {
"build": "rollup --config",
Expand All @@ -43,6 +45,7 @@
"@babel/plugin-proposal-decorators": "7.23.0",
"@embroider/addon-dev": "4.1.1",
"@rollup/plugin-babel": "6.0.4",
"@types/ember": "^4.0.6",
"concurrently": "8.2.1",
"eslint": "8.51.0",
"eslint-config-prettier": "9.0.0",
Expand Down
173 changes: 173 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a30d843

Please sign in to comment.