Merge pull request #12174 from meteor/core-packages-types

Type definitions for core packages
This commit is contained in:
Gabriel Grubba
2022-10-21 14:32:31 -03:00
committed by GitHub
6 changed files with 83 additions and 0 deletions

71
packages/ejson/ejson.d.ts vendored Normal file
View File

@@ -0,0 +1,71 @@
export interface EJSONableCustomType {
clone?(): EJSONableCustomType;
equals?(other: Object): boolean;
toJSONValue(): JSONable;
typeName(): string;
}
export type EJSONableProperty =
| number
| string
| boolean
| Object
| number[]
| string[]
| Object[]
| Date
| Uint8Array
| EJSONableCustomType
| undefined
| null;
export interface EJSONable {
[key: string]: EJSONableProperty;
}
export interface JSONable {
[key: string]:
| number
| string
| boolean
| Object
| number[]
| string[]
| Object[]
| undefined
| null;
}
export interface EJSON extends EJSONable {}
export namespace EJSON {
function addType(
name: string,
factory: (val: JSONable) => EJSONableCustomType
): void;
function clone<T>(val: T): T;
function equals(
a: EJSON,
b: EJSON,
options?: { keyOrderSensitive?: boolean | undefined }
): boolean;
function fromJSONValue(val: JSONable): any;
function isBinary(x: Object): x is Uint8Array;
function newBinary(size: number): Uint8Array;
function parse(str: string): EJSON;
function stringify(
val: EJSON,
options?: {
indent?: boolean | number | string | undefined;
canonical?: boolean | undefined;
}
): string;
function toJSONValue(val: EJSON): JSONable;
}

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "ejson.d.ts"
}

View File

@@ -5,6 +5,7 @@ Package.describe({
Package.onUse(function onUse(api) {
api.use(['ecmascript', 'base64']);
api.addAssets('ejson.d.ts', 'server');
api.mainModule('ejson.js');
api.export('EJSON');
});

4
packages/fetch/fetch.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
export declare function fetch(): typeof globalThis.fetch;
export declare var Headers: typeof globalThis.Headers;
export declare var Request: typeof globalThis.Request;
export declare var Response: typeof globalThis.Response;

View File

@@ -0,0 +1,3 @@
{
"typesEntry": "fetch.d.ts"
}

View File

@@ -19,6 +19,7 @@ Package.onUse(function(api) {
api.mainModule("legacy.js", "legacy");
api.mainModule("server.js", "server");
api.addAssets("fetch.d.ts", "server");
// The other exports (Headers, Request, Response) can be imported
// explicitly from the "meteor/fetch" package.
api.export("fetch");