chore: update ts parser for description comment fixes and generic types (#28709)

* chore: update ts parser for description comment fixes

* docs: strongly type the getUserDefault API

* spec: add getUserMedia type assertions to smoke run
This commit is contained in:
Samuel Attard 2021-04-19 11:44:58 -07:00 committed by GitHub
parent ac9ec1a6ea
commit 400d7c4bce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 19 deletions

View file

@ -0,0 +1,12 @@
# UserDefaultTypes Object
* `string` String
* `boolean` Boolean
* `integer` Number
* `float` Number
* `double` Number
* `url` String
* `array` Array\<unknown>
* `dictionary` Record\<string, unknown>
This type is a helper alias, no object will never exist of this type.

View file

@ -159,13 +159,13 @@ Same as `unsubscribeNotification`, but removes the subscriber from `NSWorkspace.
Add the specified defaults to your application's `NSUserDefaults`.
### `systemPreferences.getUserDefault(key, type)` _macOS_
### `systemPreferences.getUserDefault<Type extends keyof UserDefaultTypes>(key, type)` _macOS_
* `key` String
* `type` String - Can be `string`, `boolean`, `integer`, `float`, `double`,
* `type` Type - Can be `string`, `boolean`, `integer`, `float`, `double`,
`url`, `array` or `dictionary`.
Returns `any` - The value of `key` in `NSUserDefaults`.
Returns [`UserDefaultTypes[Type]`](structures/user-default-types.md) - The value of `key` in `NSUserDefaults`.
Some popular `key` and `type`s are:

View file

@ -129,6 +129,7 @@ auto_filenames = {
"docs/api/structures/upload-data.md",
"docs/api/structures/upload-file.md",
"docs/api/structures/upload-raw-data.md",
"docs/api/structures/user-default-types.md",
"docs/api/structures/web-source.md",
]

View file

@ -4,8 +4,8 @@
"repository": "https://github.com/electron/electron",
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
"devDependencies": {
"@electron/docs-parser": "^0.10.1",
"@electron/typescript-definitions": "^8.8.0",
"@electron/docs-parser": "^0.11.0",
"@electron/typescript-definitions": "^8.9.0",
"@octokit/auth-app": "^2.10.0",
"@octokit/rest": "^18.0.3",
"@primer/octicons": "^10.0.0",

View file

@ -373,6 +373,12 @@ if (process.platform === 'win32') {
console.log('Color for menu is', systemPreferences.getColor('menu'))
}
if (process.platform === 'darwin') {
const value: string = systemPreferences.getUserDefault('Foo', 'string');
// @ts-expect-error
const value2: number = systemPreferences.getUserDefault('Foo', 'boolean');
}
// Create the window.
const win1 = new BrowserWindow(browserOptions)

View file

@ -18,12 +18,12 @@
esutils "^2.0.2"
js-tokens "^4.0.0"
"@electron/docs-parser@^0.10.1":
version "0.10.1"
resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-0.10.1.tgz#aa5911c4ef2ec237d7a126111019ec45058088db"
integrity sha512-gDKGfc4ilPsKGCCyCCU20iJnHRV3QPYthOocgfAnzm5lOANssxLjl4KeN/DO8nTmKX/BmFsf+XGNa4Penq0L8A==
"@electron/docs-parser@^0.11.0":
version "0.11.0"
resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-0.11.0.tgz#182a9732d2fc7b40e3f506d3ab1a06270cdae6e4"
integrity sha512-i+OSWXXchoKVorR6cANqPKYJ1ccLAp+YCPTB+IJVWZ+Xtp6V2VXqLsjoy4mD32ss4CdX/6MLX62pb2sjGmmR6w==
dependencies:
"@types/markdown-it" "^0.0.9"
"@types/markdown-it" "^10.0.0"
chai "^4.2.0"
chalk "^3.0.0"
fs-extra "^8.1.0"
@ -33,10 +33,10 @@
ora "^4.0.3"
pretty-ms "^5.1.0"
"@electron/typescript-definitions@^8.8.0":
version "8.8.0"
resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.8.0.tgz#3af8989507af50b3b06b23833a45a5631ab31d3f"
integrity sha512-HXcLOzI6zNFTzye3R/aSuqBAiVkUWVnogHwRe4mEdS4nodOqKZQxaB5tzPU2qZ4mS5cpVykBW4s6qAItuptoCA==
"@electron/typescript-definitions@^8.9.0":
version "8.9.0"
resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.9.0.tgz#4a446ef875b55f6d3736df2a33bb19257b8146aa"
integrity sha512-26ze33/Ip2ivpCMHGRMLR+Dcm7DLNzPJL0iLJNonqPu2ikqnwJce1d2vkTDBBLzAiqUV3litVNTpnNS2Zg42MA==
dependencies:
"@types/node" "^11.13.7"
chalk "^2.4.2"
@ -299,6 +299,11 @@
"@types/minimatch" "*"
"@types/node" "*"
"@types/highlight.js@^9.7.0":
version "9.12.4"
resolved "https://registry.yarnpkg.com/@types/highlight.js/-/highlight.js-9.12.4.tgz#8c3496bd1b50cc04aeefd691140aa571d4dbfa34"
integrity sha512-t2szdkwmg2JJyuCM20e8kR2X59WCE5Zkl4bzm1u1Oukjm79zpbiAv+QjnwLnuuV0WHEcX2NgUItu0pAMKuOPww==
"@types/json-schema@^7.0.3":
version "7.0.3"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.3.tgz#bdfd69d61e464dcc81b25159c270d75a73c1a636"
@ -338,12 +343,20 @@
resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.0.tgz#57f228f2b80c046b4a1bd5cac031f81f207f4f03"
integrity sha512-RaE0B+14ToE4l6UqdarKPnXwVDuigfFv+5j9Dze/Nqr23yyuqdNvzcZi3xB+3Agvi5R4EOgAksfv3lXX4vBt9w==
"@types/markdown-it@^0.0.9":
version "0.0.9"
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-0.0.9.tgz#a5d552f95216c478e0a27a5acc1b28dcffd989ce"
integrity sha512-IFSepyZXbF4dgSvsk8EsgaQ/8Msv1I5eTL0BZ0X3iGO9jw6tCVtPG8HchIPm3wrkmGdqZOD42kE0zplVi1gYDA==
"@types/markdown-it@^10.0.0":
version "10.0.3"
resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-10.0.3.tgz#a9800d14b112c17f1de76ec33eff864a4815eec7"
integrity sha512-daHJk22isOUvNssVGF2zDnnSyxHhFYhtjeX4oQaKD6QzL3ZR1QSgiD1g+Q6/WSWYVogNXYDXODtbgW/WiFCtyw==
dependencies:
"@types/highlight.js" "^9.7.0"
"@types/linkify-it" "*"
"@types/mdurl" "*"
highlight.js "^9.7.0"
"@types/mdurl@*":
version "1.0.2"
resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-1.0.2.tgz#e2ce9d83a613bacf284c7be7d491945e39e1f8e9"
integrity sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==
"@types/mime@*":
version "2.0.1"
@ -3559,6 +3572,11 @@ hash.js@^1.0.0, hash.js@^1.0.3:
inherits "^2.0.3"
minimalistic-assert "^1.0.1"
highlight.js@^9.7.0:
version "9.18.5"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.5.tgz#d18a359867f378c138d6819edfc2a8acd5f29825"
integrity sha512-a5bFyofd/BHCX52/8i8uJkjr9DYwXIPnM/plwI6W7ezItLGqzt7X2G2nXuYSfsIJdkwwj/g9DG1LkcGJI/dDoA==
hmac-drbg@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1"