Bug 1911476 - Enable basic IDE types support in toolkit/ and browser/ r=mossop

Differential Revision: https://phabricator.services.mozilla.com/D218503
This commit is contained in:
Tomislav Jovanovic 2024-08-07 02:01:58 +00:00
parent 90ded5b6df
commit c180df69cb
8 changed files with 43 additions and 18 deletions

4
browser/jsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
"extends": "../tools/@types/tsconfig.json",
"include": ["**/*.sys.mjs"]
}

View File

@ -1,20 +1,3 @@
/**
* Gecko globals.
*/
declare global {
const Cc: nsXPCComponents_Classes;
const Ci: nsIXPCComponents_Interfaces;
const Cr: nsIXPCComponents_Results;
const Components: nsIXPCComponents;
// Resolve typed generic overloads before the generated ones.
const Cu: nsXPCComponents_Utils & nsIXPCComponents_Utils;
const Glean: GleanImpl;
const GleanPings: GleanPingsImpl;
const Services: JSServices;
const uneval: (any) => string;
}
// Exports for all modules redirected here by a catch-all rule in tsconfig.json.
export var

4
toolkit/jsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
"extends": "../tools/@types/tsconfig.json",
"include": ["**/*.sys.mjs"]
}

View File

@ -94,6 +94,9 @@ with Files("mozapps/preferences/**"):
with Files("l10n-registry.manifest"):
BUG_COMPONENT = ("Core", "Localization")
with Files("jsconfig.json"):
BUG_COMPONENT = ("Developer Infrastructure", "Lint and Formatting")
GeneratedFile(
"content/neterror/aboutNetErrorCodes.js",
script="content/neterror/gen_aboutneterror_codes.py",

View File

@ -7,3 +7,21 @@
/// <reference types="./lib.gecko.nsresult.d.ts" />
/// <reference types="./lib.gecko.services.d.ts" />
/// <reference types="./lib.gecko.xpcom.d.ts" />
/// Order of references matters here, for overriding type signatures.
/// <reference types="./lib.gecko.tweaks.d.ts" />
declare global {
const Cc: nsXPCComponents_Classes;
const Ci: nsIXPCComponents_Interfaces;
const Components: nsIXPCComponents;
const Cr: nsIXPCComponents_Results;
// Resolve typed generic overloads before the generated ones.
const Cu: nsXPCComponents_Utils & nsIXPCComponents_Utils;
const Services: JSServices;
const uneval: (any) => string;
}
export {};

View File

@ -91,4 +91,7 @@ interface XULBrowserElement extends XULFrameElement, FrameLoader {
remoteType: string;
}
type nsQIResult<iid> = import("gecko/lib.gecko.xpcom").nsQIResult<iid>;
// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1736
interface Localization {
formatValuesSync(aKeys: L10nKey[]): (string | null)[];
}

View File

@ -0,0 +1,7 @@
{
"compilerOptions": {
"noEmit": true,
"target": "es2022",
"types": ["gecko"]
}
}

View File

@ -41,6 +41,9 @@ with Files("tryselect/**"):
with Files("tryselect/selectors/release.py"):
BUG_COMPONENT = ("Release Engineering", "General")
with Files("ts/**"):
BUG_COMPONENT = ("Developer Infrastructure", "Lint and Formatting")
with Files("update-packaging/**"):
BUG_COMPONENT = ("Release Engineering", "General")