Skip to content
This repository was archived by the owner on Dec 14, 2020. It is now read-only.

Commit a1bc33b

Browse files
committed
Fix compatibility with TS 1.6 object literal typing
TS 1.6 requires that object literals assigned to variables or parameters with an interface typing may only contain properties that are listed in the interface. See microsoft/TypeScript#3823 for details. This mostly affected React component props interfaces which did not extend react.Props so were missing the common key, ref and children props.
1 parent 1808566 commit a1bc33b

20 files changed

+58
-59
lines changed

lib/agile_keychain_test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ testLib.addAsyncTest('Import item from .1pif file', (assert) => {
9090
actualItems.then((items) => {
9191
assert.equal(items.length, 1, 'Imported expected number of items');
9292
var expectedItem = agile_keychain.fromAgileKeychainItem(null, {
93-
"vault": null,
9493
"updatedAt": 1398413120,
9594
"title": "Facebook",
9695
"securityLevel": "SL5",
@@ -725,4 +724,3 @@ testLib.addAsyncTest('Removing item succeeds if file is already removed', assert
725724
assert.ok(testVault.items[0].isTombstone());
726725
});
727726
});
728-

lib/siteinfo/service.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ import url_util = require('../base/url_util');
5858
// list of known <link> and <meta> tags that point
5959
// to an icon for the site.
6060
//
61-
// See also:
61+
// See also:
6262
// - http://microformats.org/wiki/existing-rel-values (list of known
6363
// values for 'rel' attribute of <link> tags)
6464
// - http://www.iacquire.com/blog/18-meta-tags-every-webpage-should-have-in-2013
6565
// - Google structured data testing tool: http://www.google.com/webmasters/tools/richsnippets
66-
//
66+
//
6767

6868
export enum MetaTagType {
6969
Meta,
@@ -265,7 +265,6 @@ export class SiteInfoService implements site_info.SiteInfoProvider {
265265
var result: site_info.QueryResult = {
266266
info: {
267267
url: url,
268-
iconUrl: null,
269268
icons: []
270269
},
271270
state: site_info.QueryState.Updating
@@ -597,4 +596,3 @@ export class DuckDuckGoClient {
597596
}
598597
}
599598
}
600-

lib/vfs/node.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class FileVFS implements vfs.VFS {
174174
}
175175

176176
login(): Q.Promise<vfs.Credentials> {
177-
return Q<vfs.Credentials>({ user: process.env.USER });
177+
return Q<vfs.Credentials>({});
178178
}
179179

180180
isLoggedIn(): boolean {
@@ -247,4 +247,3 @@ export class FileVFS implements vfs.VFS {
247247
return fullPath;
248248
}
249249
}
250-

typings/argparse.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ declare module "argparse" {
1313
nargs? : any; // number or string
1414
type? : string;
1515
defaultValue? : any;
16+
help?: string;
17+
choices?: string[];
1618
}
1719

1820
export interface Subparsers {
@@ -25,4 +27,3 @@ declare module "argparse" {
2527
parseArgs(args?: string[]) : any;
2628
}
2729
}
28-

webui/app_view.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface AppServices {
5656
fs: vfs.VFS;
5757
}
5858

59-
export interface AppViewProps {
59+
export interface AppViewProps extends react.Props<void> {
6060
services: AppServices;
6161
viewportRect: reactutil.Rect;
6262
itemStore: ui_item_store.Store;
@@ -160,7 +160,7 @@ class AppView extends typed_react.Component<AppViewProps, AppViewState> {
160160
children.push(this.renderItemDetails());
161161
children.push(this.renderToasters());
162162

163-
var menu = reactutil.TransitionGroupF({ key: 'toolbar-menu' },
163+
var menu = reactutil.TransitionGroupF(<any>{ key: 'toolbar-menu' },
164164
this.state.appMenuSourceRect ? this.renderMenu('menu') : null
165165
);
166166
children.push(menu);
@@ -189,7 +189,7 @@ class AppView extends typed_react.Component<AppViewProps, AppViewState> {
189189
progressMax: syncState.total
190190
}));
191191
}
192-
return reactutil.TransitionGroupF({ key: 'toasterList' },
192+
return reactutil.TransitionGroupF(<any>{ key: 'toasterList' },
193193
toasters
194194
);
195195
}
@@ -376,4 +376,3 @@ class AppView extends typed_react.Component<AppViewProps, AppViewState> {
376376
}
377377

378378
export var AppViewF = reactutil.createFactory(AppView);
379-

webui/base/reactutil.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ import env = require('../../lib/base/env');
66
import transition_events = require('./transition_events');
77
import tsutil = require('../../lib/base/tsutil');
88

9+
/** Extends the CSSProperties interface which as of 16/08/15
10+
* only lists a small subset of CSS properties with one with
11+
* a catch-all for other properties.
12+
*
13+
* See also https://github.com/borisyankov/DefinitelyTyped/pull/5089 for
14+
* a discussion on how best to resolve this upstream.
15+
*/
16+
export interface ExtendedCSSProperties extends react.CSSProperties {
17+
[index: string]: number | string;
18+
}
19+
920
/** Component factory returned by createFactory(). This extends
1021
* React.Factory with an additional property that specifies the
1122
* type of component which the factory creates.
@@ -179,4 +190,3 @@ export class TransitionEndListener {
179190
transition_events.removeEndEventListener(this.node, this.listener);
180191
}
181192
}
182-

webui/base/reactutil_test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@
33
import reactutil = require('./reactutil');
44
import testLib = require('../../lib/test');
55

6+
interface PropMergeResult {
7+
id?: string;
8+
className?: string;
9+
onClick?: string;
10+
};
11+
612
testLib.addTest('merge props', (assert) => {
7-
assert.deepEqual(reactutil.mergeProps({
13+
assert.deepEqual<PropMergeResult>(reactutil.mergeProps({
814
id: 'instanceId',
915
className: 'instanceClass',
1016
onClick: 'event handler'
@@ -34,4 +40,3 @@ testLib.addTest('object changes', (assert) => {
3440
});
3541

3642
testLib.start();
37-

webui/controls/button.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export enum Style {
150150
Icon
151151
}
152152

153-
export interface ButtonProps {
153+
export interface ButtonProps extends react.Props<void> {
154154
onClick: (e: react.MouseEvent) => void;
155155

156156
/** Label for the button */
@@ -177,8 +177,6 @@ export interface ButtonProps {
177177

178178
/** Prevents interaction with the button */
179179
disabled?: boolean;
180-
181-
children?: any;
182180
}
183181

184182
export class Button extends typed_react.Component<ButtonProps, {}> {
@@ -295,4 +293,3 @@ export class Button extends typed_react.Component<ButtonProps, {}> {
295293
}
296294

297295
export var ButtonF = reactutil.createFactory(Button);
298-

webui/controls/demo.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var theme = style.create({
4646
}
4747
});
4848

49-
interface ControlDemoAppProps {
49+
interface ControlDemoAppProps extends react.Props<void> {
5050
viewportRect: reactutil.Rect;
5151
}
5252

@@ -203,4 +203,3 @@ function main() {
203203
if (env.isBrowser()) {
204204
main();
205205
}
206-

webui/controls/menu.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ var theme = style.create({
7777
label: {
7878
width: '100%',
7979
height: '100%',
80-
80+
8181
// give menu item label its own stacking context so
8282
// that it renders on top of ripple effect
8383
transform: 'translate3d(0,0,0)'
@@ -97,7 +97,7 @@ interface MenuState {
9797
showTime?: Date;
9898
}
9999

100-
export interface MenuProps {
100+
export interface MenuProps extends react.Props<void> {
101101
/** The source rect of the icon which triggered the
102102
* menu.
103103
*/
@@ -369,4 +369,3 @@ export class Menu extends typed_react.Component<MenuProps, MenuState> {
369369
}
370370

371371
export var MenuF = reactutil.createFactory(Menu);
372-

webui/controls/ripple.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="../../typings/react.d.ts" />
22

33
// Material Design style touch-ripple.
4-
// See https://www.polymer-project.org/docs/elements/paper-elements.html#paper-ripple
4+
// See https://www.polymer-project.org/docs/elements/paper-elements.html#paper-ripple
55

66
import react = require('react');
77
import style = require('ts-style');
@@ -38,7 +38,7 @@ enum Phase {
3838
Release
3939
}
4040

41-
export interface InkRippleProps {
41+
export interface InkRippleProps extends react.Props<void> {
4242
/** Fill style for the expanding ripple.
4343
* The background of the ripple uses a lighter version of
4444
* this color.
@@ -259,4 +259,3 @@ export class InkRipple extends typed_react.Component<InkRippleProps, InkRippleSt
259259
}
260260
}
261261
export var InkRippleF = reactutil.createFactory(InkRipple);
262-

webui/controls/svg_icon.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import underscore = require('underscore');
44

55
import reactutil = require('../base/reactutil');
66

7-
export class SvgIconProps {
7+
export interface SvgIconProps extends react.Props<react.HTMLComponent>, react.HTMLAttributes {
8+
// redeclare 'ref' here to resolve conflict between
9+
// react.Props.ref and react.HTMLAttributes.ref
10+
ref?: string;
11+
812
href: string;
913
fill: string;
1014
viewBox: {
@@ -35,4 +39,3 @@ export class SvgIcon extends typed_react.Component<SvgIconProps, {}> {
3539
}
3640

3741
export var SvgIconF = reactutil.createFactory(SvgIcon);
38-

webui/controls/text_field.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export interface TextFieldStyle {
167167
fontFamily?: string;
168168
}
169169

170-
export interface TextFieldProps {
170+
export interface TextFieldProps extends react.Props<void> {
171171
/** Specifies the type of <input> field */
172172
type?: string;
173173

@@ -414,4 +414,3 @@ export class TextField extends typed_react.Component<TextFieldProps, TextFieldSt
414414
}
415415

416416
export var TextFieldF = reactutil.createFactory(TextField);
417-

webui/controls/toaster.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var theme = style.create({
5252
}
5353
});
5454

55-
export interface ToasterProps {
55+
export interface ToasterProps extends react.Props<void> {
5656
message: string;
5757
progressValue?: number;
5858
progressMax?: number;
@@ -97,4 +97,3 @@ export class Toaster extends typed_react.Component<ToasterProps, ToasterState> {
9797
}
9898

9999
export var ToasterF = reactutil.createFactory(Toaster, transition_mixin.TransitionMixinM);
100-

webui/details_view.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ interface ItemFieldState {
213213
value?: string;
214214
}
215215

216-
interface ItemFieldProps {
216+
interface ItemFieldProps extends react.Props<void> {
217217
label: string;
218218
value: string;
219219
type: FieldType;
@@ -383,7 +383,7 @@ export enum ItemEditMode {
383383
EditItem
384384
}
385385

386-
export interface DetailsViewProps {
386+
export interface DetailsViewProps extends react.Props<void> {
387387
entryRect?: reactutil.Rect;
388388
viewportRect: reactutil.Rect;
389389
animateEntry: boolean;
@@ -972,7 +972,7 @@ export class DetailsView extends typed_react.Component<DetailsViewProps, Details
972972
var itemListDetailsStyle: any[] = [headerTheme.iconAndDetails.details.itemList];
973973
var detailsViewDetailsStyle: any[] = [headerTheme.iconAndDetails.details.detailsView];
974974

975-
var contentStyles: react.CSSProperties[] = [{
975+
var contentStyles: reactutil.ExtendedCSSProperties[] = [{
976976
paddingTop: 16,
977977

978978
// vertically align left edge of details text with item
@@ -1002,7 +1002,6 @@ export class DetailsView extends typed_react.Component<DetailsViewProps, Details
10021002
bottom: 16
10031003
}), button.ButtonF({
10041004
style: button.Style.FloatingAction,
1005-
accessKey: 'a',
10061005
backgroundColor: colors.MATERIAL_COLOR_PRIMARY,
10071006
color: colors.MATERIAL_COLOR_HEADER,
10081007
rippleColor: 'white',
@@ -1058,4 +1057,3 @@ export class DetailsView extends typed_react.Component<DetailsViewProps, Details
10581057
}
10591058

10601059
export var DetailsViewF = reactutil.createFactory(DetailsView, focus_mixin.FocusMixinM);
1061-

webui/item_icons.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class BasicIconProvider implements IconProvider {
164164
private static DEFAULT_ICON = 'dist/icons/default.png';
165165

166166
updated: event_stream.EventStream<string>;
167-
167+
168168
/** Create an icon provider which uses @p provider to fetch
169169
* icon data. @p iconSize specifies the size of icon to make from
170170
* the available icons for a given URL.
@@ -402,7 +402,7 @@ class Cache {
402402
}
403403
}
404404

405-
export interface IconControlProps {
405+
export interface IconControlProps extends react.Props<void> {
406406
location: string;
407407
iconProvider: IconProvider;
408408
isFocused: boolean;
@@ -512,4 +512,3 @@ export class FakeIconProvider implements IconProvider {
512512
}
513513

514514
export var IconControlF = reactutil.createFactory(IconControl);
515-

webui/item_list_view.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ interface ItemListViewState {
152152
filter?: string;
153153
}
154154

155-
export class ItemListViewProps {
155+
export interface ItemListViewProps extends react.Props<void> {
156156
items: item_store.Item[];
157157
selectedItem: item_store.Item;
158158
onSelectedItemChanged: (item: item_store.Item, rect: reactutil.Rect) => void;
@@ -254,7 +254,7 @@ export class ItemListView extends typed_react.Component<ItemListViewProps, ItemL
254254

255255
export var ItemListViewF = reactutil.createFactory(ItemListView, focus_mixin.FocusMixinM);
256256

257-
export interface ItemProps {
257+
export interface ItemProps extends react.Props<void> {
258258
key: string;
259259
item: item_store.Item;
260260
onSelected: () => void;
@@ -327,7 +327,7 @@ interface ItemListState {
327327
itemHeight?: number;
328328
}
329329

330-
class ItemListProps {
330+
export interface ItemListProps extends react.Props<void> {
331331
items: item_store.Item[];
332332
filter: string;
333333
filterUrl: string;
@@ -598,7 +598,7 @@ class ItemList extends typed_react.Component<ItemListProps, ItemListState> {
598598

599599
var ItemListF = reactutil.createFactory(ItemList);
600600

601-
class ItemListToolbarProps {
601+
export interface ItemListToolbarProps extends react.Props<void> {
602602
filterUrl: string;
603603

604604
onQueryChanged: (query: string) => void;

0 commit comments

Comments
 (0)