Skip to content

Commit 030a01b

Browse files
authored
Merge pull request #84 from electron/fix-array-multi-type
Fix multi array type
2 parents 5ff6101 + b9aa71b commit 030a01b

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

lib/dynamic-param-interfaces.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,13 @@ const flushParamInterfaces = (API, addToOutput) => {
7373
return
7474
}
7575
if (declared[paramKey]) {
76-
if (!_.isEqual(paramInterfacesToDeclare[paramKey], declared[paramKey])) {
76+
const toDeclareCheck = Object.assign({}, paramInterfacesToDeclare[paramKey])
77+
const declaredCheck = Object.assign({}, declared[paramKey])
78+
for (const prop of ['type', 'collection', 'required', 'description']) {
79+
delete toDeclareCheck[prop]
80+
delete declaredCheck[prop]
81+
}
82+
if (!_.isEqual(toDeclareCheck, declaredCheck)) {
7783
throw new Error('Ruh roh, "' + paramKey + '" is already declared')
7884
}
7985
delete paramInterfacesToDeclare[paramKey]

lib/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,17 @@ const wrapComment = (comment) => {
2727

2828
const typify = (type) => {
2929
// Capture some weird edge cases
30+
const originalType = type
3031
if (type.type && typeof type.type === 'object') {
3132
type = type.type
3233
}
3334

3435
if (Array.isArray(type)) {
35-
return Array.from(new Set(type.map(t => typify(t)))).join(' | ')
36+
const arrayType = Array.from(new Set(type.map(t => typify(t)))).join(' | ')
37+
if (originalType.collection) {
38+
return `Array<${arrayType}>`
39+
}
40+
return arrayType
3641
}
3742

3843
if (!type) return 'any'

test-smoke/electron/test/main.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
systemPreferences,
2525
webContents,
2626
Event,
27+
TouchBar,
2728
} from "electron";
2829

2930
import * as path from "path";
@@ -1141,3 +1142,10 @@ win4.webContents.on("paint", (event, dirty, _image) => {
11411142
});
11421143

11431144
win4.loadURL("http://github.com");
1145+
1146+
const unusedTouchBar = new TouchBar({
1147+
items: [
1148+
new TouchBar.TouchBarButton({ label: '' }),
1149+
new TouchBar.TouchBarLabel({ label: '' }),
1150+
],
1151+
});

test/output_spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ describe('Definition File', function () {
2121
spawn('node', ['cli.js', '-o=electron.d.ts'], {
2222
cwd: path.resolve(__dirname, '..')
2323
}).on('exit', () => done())
24-
done()
2524
})
2625

2726
it('should output a electron.d.ts file', () => {

vendor/fetch-docs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const mkdirp = require('mkdirp').sync
77
const os = require('os')
88

99
const downloadPath = path.join(os.tmpdir(), 'electron-api-tmp')
10-
const ELECTRON_COMMIT = 'cb3c5ded0f99a15edc99b61d227d135f7c3521c8'
10+
const ELECTRON_COMMIT = 'f469059e9059aa0bda756022deb53322688dac29'
1111

1212
rm(downloadPath)
1313

0 commit comments

Comments
 (0)