mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Fix 'prefer-readonly' lint failures (#22819)
This commit is contained in:
parent
84e265d13a
commit
219dd6df82
@ -196,7 +196,7 @@ myApp.controller('DialogController', ($scope: TestScope, $mdDialog: ng.material.
|
||||
});
|
||||
|
||||
class IconDirective implements ng.IDirective {
|
||||
private $mdIcon: ng.material.IIcon;
|
||||
private readonly $mdIcon: ng.material.IIcon;
|
||||
constructor($mdIcon: ng.material.IIcon) {
|
||||
this.$mdIcon = $mdIcon;
|
||||
}
|
||||
|
||||
@ -50,11 +50,11 @@ namespace TestApp {
|
||||
var horixontalPosition: number = $document.duScrollLeft();
|
||||
}
|
||||
|
||||
private invertedEasingFn = (x: number): number => {
|
||||
private readonly invertedEasingFn = (x: number): number => {
|
||||
return 1 - x;
|
||||
}
|
||||
|
||||
private onScrollCompleted = (): void => {
|
||||
private readonly onScrollCompleted = (): void => {
|
||||
console.log('Done scrolling');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class EmployeesFactory {
|
||||
static $inject = ['$rootScope', 'Hub', '$timeout'];
|
||||
private hub: ngSignalr.Hub;
|
||||
private readonly hub: ngSignalr.Hub;
|
||||
public all: Array<Employee>;
|
||||
|
||||
constructor($rootScope: ng.IRootScopeService, Hub: ngSignalr.HubFactory, $timeout: ng.ITimeoutService) {
|
||||
|
||||
@ -137,10 +137,10 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
static $inject = ["$http", "$rootScope", "$urlRouter", "$state"];
|
||||
|
||||
constructor(
|
||||
private $http: ng.IHttpService,
|
||||
private $rootScope: ng.IRootScopeService,
|
||||
private $urlRouter: ng.ui.IUrlRouterService,
|
||||
private $state: ng.ui.IStateService
|
||||
private readonly $http: ng.IHttpService,
|
||||
private readonly $rootScope: ng.IRootScopeService,
|
||||
private readonly $urlRouter: ng.ui.IUrlRouterService,
|
||||
private readonly $state: ng.ui.IStateService
|
||||
) {
|
||||
$rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event));
|
||||
$rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) =>
|
||||
|
||||
@ -161,7 +161,7 @@ namespace My.Namespace {
|
||||
}
|
||||
|
||||
class TestProvider implements ng.IServiceProvider {
|
||||
constructor(private $scope: ng.IScope) {}
|
||||
constructor(private readonly $scope: ng.IScope) {}
|
||||
|
||||
$get() {}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ interface TestScope extends ng.IScope {
|
||||
}
|
||||
|
||||
class TestController {
|
||||
constructor(private $scope: TestScope, private storage: ng.localStorage.ILocalStorageService) {
|
||||
constructor(private readonly $scope: TestScope, private readonly storage: ng.localStorage.ILocalStorageService) {
|
||||
storage.bind($scope, 'varName');
|
||||
storage.bind($scope,'varName', { defaultValue: 'randomValue123', storeName: 'customStoreKey' });
|
||||
$scope.viewType = 'ANYTHING';
|
||||
|
||||
@ -5,7 +5,7 @@ var expect = chai.expect,
|
||||
assert = chai.assert;
|
||||
|
||||
class MyService {
|
||||
constructor(private $q: angular.IQService) {}
|
||||
constructor(private readonly $q: angular.IQService) {}
|
||||
|
||||
remoteCall(): angular.IPromise<string[]> {
|
||||
return new this.$q((resolve, reject) => {
|
||||
|
||||
@ -22,10 +22,10 @@ class BraftEditorTest extends React.Component<BraftEditor.editorProps> {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
private handleChange = (content: RawDraftContentState) => {
|
||||
private readonly handleChange = (content: RawDraftContentState) => {
|
||||
console.log(content);
|
||||
}
|
||||
private handleHTMLChange = (html: string) => {
|
||||
private readonly handleHTMLChange = (html: string) => {
|
||||
console.log(html);
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,10 +16,10 @@ connect("mongodb://user:password@localhost:27017/database?authSource=admin").the
|
||||
}
|
||||
|
||||
class User extends CamoDocument<UserSchema> {
|
||||
private name: SchemaTypeExtended = String;
|
||||
private password: SchemaTypeExtended = String;
|
||||
private friends: SchemaTypeExtended = [String];
|
||||
private dateCreated: SchemaTypeExtended = {
|
||||
private readonly name: SchemaTypeExtended = String;
|
||||
private readonly password: SchemaTypeExtended = String;
|
||||
private readonly friends: SchemaTypeExtended = [String];
|
||||
private readonly dateCreated: SchemaTypeExtended = {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@ import styles from './main.sass';
|
||||
import * as classNames from 'classnames';
|
||||
|
||||
class App {
|
||||
private theme: string;
|
||||
private readonly theme: string;
|
||||
constructor(theme: string) {
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
@ -205,9 +205,9 @@ class Circulator {
|
||||
return d ? d : [0, 0];
|
||||
});
|
||||
}
|
||||
private r: number;
|
||||
private p: number;
|
||||
private circleGenerator: d3Geo.GeoCircleGenerator<Circulator, [number, number] | undefined>;
|
||||
private readonly r: number;
|
||||
private readonly p: number;
|
||||
private readonly circleGenerator: d3Geo.GeoCircleGenerator<Circulator, [number, number] | undefined>;
|
||||
|
||||
getCirclePolygon(center?: [number, number]): GeoJSON.Polygon {
|
||||
if (center && center.length === 2 && typeof center[0] === 'number' && typeof center[1] === 'number') {
|
||||
|
||||
@ -200,14 +200,14 @@ class Arcer {
|
||||
.endAngle(this.endAngle)
|
||||
.padAngle(this.padAngle);
|
||||
}
|
||||
private startAngle: number;
|
||||
private endAngle: number;
|
||||
private padAngle: number;
|
||||
private innerRadius: number;
|
||||
private outerRadius: number;
|
||||
private cornerRadius: number;
|
||||
private readonly startAngle: number;
|
||||
private readonly endAngle: number;
|
||||
private readonly padAngle: number;
|
||||
private readonly innerRadius: number;
|
||||
private readonly outerRadius: number;
|
||||
private readonly cornerRadius: number;
|
||||
|
||||
private arc: d3Shape.Arc<Arcer, ArcerDatum>;
|
||||
private readonly arc: d3Shape.Arc<Arcer, ArcerDatum>;
|
||||
|
||||
getPathString(d?: ArcerDatum) {
|
||||
return d ? this.arc(d) : this.arc({ innerRadius: this.innerRadius, outerRadius: this.outerRadius });
|
||||
@ -1292,9 +1292,9 @@ class Symbolizer {
|
||||
return type;
|
||||
});
|
||||
}
|
||||
private size: number;
|
||||
private type: d3Shape.SymbolType;
|
||||
private symbol: d3Shape.Symbol<Symbolizer, SymbolDatum>;
|
||||
private readonly size: number;
|
||||
private readonly type: d3Shape.SymbolType;
|
||||
private readonly symbol: d3Shape.Symbol<Symbolizer, SymbolDatum>;
|
||||
|
||||
getPathString(d?: SymbolDatum) {
|
||||
return d ? this.symbol(d) : this.symbol();
|
||||
|
||||
@ -40,9 +40,6 @@ export class TestStorage {
|
||||
// import Storage class
|
||||
static gcs = CloudStorage();
|
||||
|
||||
// the bucket
|
||||
private buckets: Bucket[] = [];
|
||||
|
||||
constructor() {
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ namespace GRealtime {
|
||||
export class MyRealtimeDoc {
|
||||
protected rtmodel: CollabModel;
|
||||
protected rtdoc: CollabDoc;
|
||||
private myRTLoader = new GRealtime.MyRTLoader();
|
||||
private readonly myRTLoader = new GRealtime.MyRTLoader();
|
||||
|
||||
newFile(title: string,
|
||||
initializeModel: (x:CollabModel) => void,
|
||||
|
||||
@ -288,7 +288,7 @@ describe('missing tests', () => {
|
||||
class Closure<T> {
|
||||
private arg: T;
|
||||
|
||||
constructor(private fn: (arg: T) => void) {
|
||||
constructor(private readonly fn: (arg: T) => void) {
|
||||
this.fn = fn;
|
||||
}
|
||||
|
||||
@ -522,7 +522,7 @@ describe('beforeEach with timeout', () => {
|
||||
class TestApi {
|
||||
constructor() { }
|
||||
testProp: boolean;
|
||||
private anotherProp: string;
|
||||
private readonly anotherProp: string;
|
||||
testMethod(a: number): string { return ""; }
|
||||
}
|
||||
|
||||
|
||||
@ -183,7 +183,7 @@ describe('missing tests', function () {
|
||||
class Closure<T> {
|
||||
private arg: T;
|
||||
|
||||
public constructor(private fn: (arg: T) => void) {
|
||||
public constructor(private readonly fn: (arg: T) => void) {
|
||||
this.fn = fn;
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ function test_computed() {
|
||||
}
|
||||
|
||||
class GetterViewModel {
|
||||
private _selectedRange: KnockoutObservable<any>;
|
||||
private readonly _selectedRange: KnockoutObservable<any>;
|
||||
|
||||
constructor() {
|
||||
this._selectedRange = ko.observable();
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
class Server implements App {
|
||||
private usersPlaying: { [nick: string]: number } = {};
|
||||
private readonly usersPlaying = new Map<string, number>();
|
||||
private isShuttingDown = false;
|
||||
|
||||
private htmlFile: HTMLFile = new HTMLFile('start.html');
|
||||
private appContent: AppContent = AppContent.overlayContent(this.htmlFile, 243, 266);
|
||||
private readonly htmlFile: HTMLFile = new HTMLFile('start.html');
|
||||
private readonly appContent: AppContent = AppContent.overlayContent(this.htmlFile, 243, 266);
|
||||
|
||||
onAppStart() {
|
||||
KnuddelsServer.getChannel()
|
||||
@ -21,11 +21,11 @@ class Server implements App {
|
||||
}
|
||||
|
||||
onUserLeft(user: User) {
|
||||
if (this.usersPlaying[user.getNick()] === 1) {
|
||||
if (this.usersPlaying.get(user.getNick()) === 1) {
|
||||
KnuddelsServer.getDefaultBotUser()
|
||||
.transferKnuddel(user, new KnuddelAmount(1), 'Du hast den Channel verlassen.');
|
||||
|
||||
delete this.usersPlaying[user.getNick()];
|
||||
this.usersPlaying.delete(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ class Server implements App {
|
||||
session.remove();
|
||||
});
|
||||
|
||||
delete this.usersPlaying[key];
|
||||
this.usersPlaying.delete(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ class Server implements App {
|
||||
knuddelTransfer.accept();
|
||||
} else if (this.isShuttingDown) {
|
||||
knuddelTransfer.reject('Du App nimmt gerade keine neuen Spieler an.');
|
||||
} else if (this.usersPlaying[sender.getNick()]) {
|
||||
} else if (this.usersPlaying.get(sender.getNick())) {
|
||||
knuddelTransfer.reject('Du spielst bereits.');
|
||||
} else if (knuddelTransfer.getKnuddelAmount().asNumber() !== 1) {
|
||||
const botNick = KnuddelsServer.getDefaultBotUser()
|
||||
@ -75,7 +75,7 @@ class Server implements App {
|
||||
|
||||
onKnuddelReceived(user: User, receiver: User, knuddelAmount: KnuddelAmount) {
|
||||
if (knuddelAmount.asNumber() === 1) {
|
||||
this.usersPlaying[user.getNick()] = 1;
|
||||
this.usersPlaying.set(user.getNick(), 1);
|
||||
user.sendAppContent(this.appContent);
|
||||
} else {
|
||||
user.sendPrivateMessage('Vielen Dank für die Einzahlung.');
|
||||
@ -83,8 +83,8 @@ class Server implements App {
|
||||
}
|
||||
|
||||
onEventReceived(user: User, key: string, data: string) {
|
||||
if (key === 'selectedEntry' && this.usersPlaying[user.getNick()] === 1) {
|
||||
this.usersPlaying[user.getNick()] = 2;
|
||||
if (key === 'selectedEntry' && this.usersPlaying.get(user.getNick()) === 1) {
|
||||
this.usersPlaying.set(user.getNick(), 2);
|
||||
|
||||
setTimeout(() => {
|
||||
const doorNumber = parseInt(data[data.length - 1], 10);
|
||||
@ -116,7 +116,7 @@ class Server implements App {
|
||||
.forEach((session: AppContentSession) => {
|
||||
session.remove();
|
||||
});
|
||||
delete this.usersPlaying[user.getNick()];
|
||||
this.usersPlaying.delete(user.getNick());
|
||||
}, 4000);
|
||||
}, 1500);
|
||||
}
|
||||
|
||||
@ -206,13 +206,7 @@ Posts.insert({ title: "Hello world", body: "First post" });
|
||||
**/
|
||||
|
||||
class Animal {
|
||||
private sound: string;
|
||||
constructor(doc: any) {
|
||||
|
||||
}
|
||||
makeNoise() {
|
||||
console.log(this.sound)
|
||||
}
|
||||
constructor(doc: any) {}
|
||||
}
|
||||
|
||||
interface AnimalDAO {
|
||||
|
||||
@ -7,7 +7,7 @@ import * as es6styleimport from 'nedb';
|
||||
import nedb = require('nedb');
|
||||
|
||||
class BaseCollection<T> {
|
||||
private dataStore: nedb;
|
||||
private readonly dataStore: nedb;
|
||||
|
||||
constructor(dataStore: nedb) {
|
||||
this.dataStore = dataStore;
|
||||
|
||||
@ -17,8 +17,8 @@ namespace demo.appavailability {
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDevice", "$cordovaAppAvailability"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService,
|
||||
private $cordovaDevice:ngCordova.IDeviceService,
|
||||
private $cordovaAppAvailability:ngCordova.IAppAvailabilityService) {
|
||||
private readonly $cordovaDevice:ngCordova.IDeviceService,
|
||||
private readonly $cordovaAppAvailability:ngCordova.IAppAvailabilityService) {
|
||||
|
||||
this.isAvailable = false;
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ namespace demo.devicemotion {
|
||||
msg:string;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDeviceMotion"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaDeviceMotion:ngCordova.IDeviceMotionService) {
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private readonly $cordovaDeviceMotion:ngCordova.IDeviceMotionService) {
|
||||
$ionicPlatform.ready(() => {
|
||||
this.getAcceleration();
|
||||
});
|
||||
|
||||
@ -12,8 +12,8 @@ namespace demo.deviceorientation {
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$timeout", "$cordovaDeviceOrientation"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService,
|
||||
private $timeout:ng.ITimeoutService,
|
||||
private $cordovaDeviceOrientation:ngCordova.IDeviceOrientationService) {
|
||||
private readonly $timeout:ng.ITimeoutService,
|
||||
private readonly $cordovaDeviceOrientation:ngCordova.IDeviceOrientationService) {
|
||||
|
||||
$ionicPlatform.ready(() => {
|
||||
this.getHeading();
|
||||
|
||||
@ -9,7 +9,7 @@ namespace demo.dialog {
|
||||
action:string;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaDialogs"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaDialogs:ngCordova.IDialogsService) {
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private readonly $cordovaDialogs:ngCordova.IDialogsService) {
|
||||
this.action = "Press any button !";
|
||||
}
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ namespace demo.geolocation {
|
||||
position:ngCordova.IGeoPosition;
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaGeolocation"];
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaGeolocation:ngCordova.IGeolocationService) {
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private readonly $cordovaGeolocation:ngCordova.IGeolocationService) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ namespace demo.network {
|
||||
|
||||
static $inject:Array<string> = ["$ionicPlatform", "$cordovaNetwork"];
|
||||
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private $cordovaNetwork:ngCordova.INetworkInformationService) {
|
||||
constructor($ionicPlatform:ionic.platform.IonicPlatformService, private readonly $cordovaNetwork:ngCordova.INetworkInformationService) {
|
||||
|
||||
$ionicPlatform.ready(() => {
|
||||
this.refresh();
|
||||
|
||||
@ -10,7 +10,7 @@ namespace demo.toast {
|
||||
msg:string;
|
||||
|
||||
static $inject:Array<string> = ["$cordovaToast"];
|
||||
constructor(private $cordovaToast:ngCordova.IToastService) {
|
||||
constructor(private readonly $cordovaToast:ngCordova.IToastService) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ let controllerId = "upload";
|
||||
class UploadController {
|
||||
static $inject = ["Upload"];
|
||||
|
||||
constructor(private Upload: angular.angularFileUpload.IUploadService) {
|
||||
constructor(private readonly Upload: angular.angularFileUpload.IUploadService) {
|
||||
this.Upload.setDefaults({
|
||||
ngfAccept: "image/*",
|
||||
ngfAllowDir: true,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class test {
|
||||
constructor(private ngstomp: ngStomp) {
|
||||
constructor(private readonly ngstomp: ngStomp) {
|
||||
const connectHeaders = {
|
||||
Auth: "user",
|
||||
Accept: "lol"
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
class TestBootboxController {
|
||||
|
||||
constructor(private $scope: angular.IScope, $ngBootbox: BootboxService) {
|
||||
constructor(private readonly $scope: angular.IScope, $ngBootbox: BootboxService) {
|
||||
|
||||
$ngBootbox.alert('An important message!').then(function() {
|
||||
console.log('Alert closed');
|
||||
@ -29,15 +29,15 @@ class TestBootboxController {
|
||||
warning: {
|
||||
label: "Cancel",
|
||||
className: "btn-warning",
|
||||
callback: function() {
|
||||
callback: function() {
|
||||
console.log('warning callback');
|
||||
}
|
||||
},
|
||||
success: {
|
||||
label: "Ok",
|
||||
className: "btn-success",
|
||||
callback: function() {
|
||||
console.log('sucess callback');
|
||||
callback: function() {
|
||||
console.log('sucess callback');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,7 +11,7 @@ sap.ui.getCore().attachInit(function () {
|
||||
});
|
||||
|
||||
class Ctrl extends sap.ui.core.mvc.Controller {
|
||||
constructor(private JSONModel: typeof sap.ui.model.json.JSONModel) {
|
||||
constructor(private readonly JSONModel: typeof sap.ui.model.json.JSONModel) {
|
||||
super(undefined);
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ num = queue.size;
|
||||
num = queue.pending;
|
||||
|
||||
class QueueClass implements PQueue.QueueClass<{ any: string }> {
|
||||
private queue: Array<() => void>;
|
||||
private readonly queue: Array<() => void>;
|
||||
|
||||
size = 0;
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
"no-unnecessary-qualifier": false,
|
||||
"one-line": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-readonly": false,
|
||||
"unified-signatures": false,
|
||||
|
||||
"class-name": true,
|
||||
|
||||
@ -153,7 +153,7 @@ Q.nfbind<string>(nodeStyle)('foo').done((result: string) => {
|
||||
});
|
||||
|
||||
class Repo {
|
||||
private items: any[] = [
|
||||
private readonly items: any[] = [
|
||||
{name: 'Max', cute: false},
|
||||
{name: 'Annie', cute: true}
|
||||
];
|
||||
|
||||
@ -144,7 +144,7 @@ Q.nfbind(nodeStyle)('foo').done((result: string) => {});
|
||||
|
||||
|
||||
class Repo {
|
||||
private items: any[] = [
|
||||
private readonly items: any[] = [
|
||||
{ name: 'Max', cute: false },
|
||||
{ name: 'Annie', cute: true }
|
||||
];
|
||||
|
||||
@ -16,7 +16,7 @@ class Component extends React.Component {
|
||||
console.log('input changed');
|
||||
}
|
||||
|
||||
private defaultSelectProps = {
|
||||
private readonly defaultSelectProps = {
|
||||
className: "my-select",
|
||||
prefixCls: "prefix",
|
||||
animation: "slide-up",
|
||||
@ -41,13 +41,13 @@ class Component extends React.Component {
|
||||
defaultActiveFirstOption: false
|
||||
};
|
||||
|
||||
private defaultOptGroupProps = {
|
||||
private readonly defaultOptGroupProps = {
|
||||
label: "Option group",
|
||||
key: "option-group-0",
|
||||
value: "option-group-0"
|
||||
};
|
||||
|
||||
private defaultOptionProps = {
|
||||
private readonly defaultOptionProps = {
|
||||
className: "option",
|
||||
disabled: true,
|
||||
key: "option-0",
|
||||
|
||||
@ -154,7 +154,7 @@ namespace BoardSquare {
|
||||
export class BoardSquare extends React.Component<BoardSquareP> {
|
||||
static defaultProps: BoardSquareP;
|
||||
|
||||
private _renderOverlay = (color: string) => {
|
||||
private readonly _renderOverlay = (color: string) => {
|
||||
return r.div({
|
||||
style: {
|
||||
position: 'absolute',
|
||||
@ -231,7 +231,7 @@ namespace Board {
|
||||
}
|
||||
|
||||
export class Board extends React.Component<BoardP> {
|
||||
private _renderPiece = (x: number, y: number) => {
|
||||
private readonly _renderPiece = (x: number, y: number) => {
|
||||
const knightX = this.props.knightPosition[0];
|
||||
const knightY = this.props.knightPosition[1];
|
||||
return x === knightX && y === knightY ?
|
||||
@ -239,7 +239,7 @@ namespace Board {
|
||||
null;
|
||||
}
|
||||
|
||||
private _renderSquare = (i: number) => {
|
||||
private readonly _renderSquare = (i: number) => {
|
||||
const x = i % 8;
|
||||
const y = Math.floor(i / 8);
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ namespace BoardSquare {
|
||||
export class BoardSquare extends React.Component<BoardSquareP> {
|
||||
static defaultProps: BoardSquareP;
|
||||
|
||||
private _renderOverlay = (color: string) => {
|
||||
private readonly _renderOverlay = (color: string) => {
|
||||
return r.div({
|
||||
style: {
|
||||
position: 'absolute',
|
||||
@ -247,7 +247,7 @@ namespace Board {
|
||||
}
|
||||
|
||||
export class Board extends React.Component<BoardP> {
|
||||
private _renderPiece = (x: number, y: number) => {
|
||||
private readonly _renderPiece = (x: number, y: number) => {
|
||||
var knightX = this.props.knightPosition[0];
|
||||
var knightY = this.props.knightPosition[1];
|
||||
return x === knightX && y === knightY ?
|
||||
@ -255,7 +255,7 @@ namespace Board {
|
||||
null;
|
||||
};
|
||||
|
||||
private _renderSquare = (i: number) => {
|
||||
private readonly _renderSquare = (i: number) => {
|
||||
var x = i % 8;
|
||||
var y = Math.floor(i / 8);
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ export class ReactHamburgerMenuTest extends React.PureComponent<{}, State> {
|
||||
return <HamburgerMenu {...props}/>;
|
||||
}
|
||||
|
||||
private menuClicked = (): void => this.setState({isOpen: !this.state.isOpen});
|
||||
private readonly menuClicked = (): void => this.setState({isOpen: !this.state.isOpen});
|
||||
}
|
||||
|
||||
interface State {
|
||||
|
||||
@ -33,7 +33,7 @@ namespace I18nDirect {
|
||||
|
||||
class I18nDirect extends React.Component<I18nDirect.Props> {
|
||||
|
||||
private _currentLocale: string
|
||||
private readonly _currentLocale: string
|
||||
private _messages: {[key: string]: string}
|
||||
|
||||
constructor( props: I18nDirect.Props ) {
|
||||
@ -69,7 +69,7 @@ class I18nDirect extends React.Component<I18nDirect.Props> {
|
||||
}
|
||||
|
||||
|
||||
private compileMessages = (props: I18nDirect.Props): void => {
|
||||
private readonly compileMessages = (props: I18nDirect.Props): void => {
|
||||
|
||||
let locale: string = ( props.locales && props.locales[ 0 ] ) || 'en-US'
|
||||
|
||||
@ -104,7 +104,7 @@ namespace I18nMixin {
|
||||
@reactMixin.decorate( IntlMixin )
|
||||
class I18nMixin extends React.Component<I18nMixin.Props> implements IntlComponent {
|
||||
|
||||
private _currentLocale: string
|
||||
private readonly _currentLocale: string
|
||||
|
||||
constructor( props: I18nMixin.Props ) {
|
||||
super( props )
|
||||
|
||||
@ -11,11 +11,11 @@ class DrawerTest extends React.Component<{}, DrawerTestState> {
|
||||
open: false
|
||||
};
|
||||
|
||||
private onOpen = () => this.setState({ open: true });
|
||||
private readonly onOpen = () => this.setState({ open: true });
|
||||
|
||||
private onClose = () => this.setState({ open: false });
|
||||
private readonly onClose = () => this.setState({ open: false });
|
||||
|
||||
private renderNavigationView = () => (
|
||||
private readonly renderNavigationView = () => (
|
||||
<View>
|
||||
<Text>Drawer content</Text>
|
||||
</View>
|
||||
|
||||
@ -30,11 +30,11 @@ class DrawerTest extends React.Component<{}, {open: boolean}> {
|
||||
);
|
||||
}
|
||||
|
||||
private onOpen = () => {
|
||||
private readonly onOpen = () => {
|
||||
this.setState({open: true});
|
||||
}
|
||||
|
||||
private onClose = () => {
|
||||
private readonly onClose = () => {
|
||||
this.setState({open: false});
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,15 +46,15 @@ class SnapCarouselTest extends React.Component {
|
||||
);
|
||||
}
|
||||
|
||||
private onSnapToItem = (index: number) => {
|
||||
private readonly onSnapToItem = (index: number) => {
|
||||
console.log("Snapped to: ", index);
|
||||
}
|
||||
|
||||
private onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
||||
private readonly onScroll = (event: NativeSyntheticEvent<NativeScrollEvent>) => {
|
||||
console.log("Scrolled: ", event);
|
||||
}
|
||||
|
||||
private onLayout = (event: LayoutChangeEvent) => {
|
||||
private readonly onLayout = (event: LayoutChangeEvent) => {
|
||||
console.log("Layout: ", event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ class StartScreen extends React.Component<NavigationScreenProps<StartScreenNavig
|
||||
</View>
|
||||
);
|
||||
}
|
||||
private navigateToNextScreen = (): void => {
|
||||
private readonly navigateToNextScreen = (): void => {
|
||||
const params: NextScreenNavigationParams = {
|
||||
id: this.props.navigation.state.params.id,
|
||||
name: this.props.navigation.state.params.s,
|
||||
|
||||
@ -19,7 +19,7 @@ class ComponentThatUsesContext extends React.Component<Props> {
|
||||
router: PropTypes.object.isRequired
|
||||
};
|
||||
context: RouterChildContext<Params>;
|
||||
private onClick = () => {
|
||||
private readonly onClick = () => {
|
||||
const {
|
||||
history,
|
||||
route: {
|
||||
|
||||
@ -114,7 +114,7 @@ describe("react-select", () => {
|
||||
|
||||
it("Focus method", () => {
|
||||
class Component extends React.PureComponent {
|
||||
private selectRef = (component: ReactSelect) => {
|
||||
private readonly selectRef = (component: ReactSelect) => {
|
||||
component.focus();
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ describe("Focus events", () => {
|
||||
describe("Examples", () => {
|
||||
it("Simple example", () => {
|
||||
class Component extends React.Component {
|
||||
private onSelectChange: ReactSelectModule.OnChangeSingleHandler<string> = (option) => {
|
||||
private readonly onSelectChange: ReactSelectModule.OnChangeSingleHandler<string> = (option) => {
|
||||
const optionValue: string = option.value;
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ describe("Examples", () => {
|
||||
|
||||
it("onValueClick", () => {
|
||||
class Component extends React.Component {
|
||||
private onValueClick: ReactSelectModule.OnValueClickHandler<number> = (option) => {
|
||||
private readonly onValueClick: ReactSelectModule.OnValueClickHandler<number> = (option) => {
|
||||
const optionValue: number = option.value;
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ describe("Examples", () => {
|
||||
|
||||
it("Custom value onValueClick", () => {
|
||||
class Component extends React.Component {
|
||||
private onValueClick: ReactSelectModule.OnValueClickHandler<CustomValueType> = (option) => {
|
||||
private readonly onValueClick: ReactSelectModule.OnValueClickHandler<CustomValueType> = (option) => {
|
||||
const optionValue: CustomValueType = option.value;
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ describe("Examples", () => {
|
||||
|
||||
it("Custom value onChange", () => {
|
||||
class Component extends React.Component {
|
||||
private onSelectChange: ReactSelectModule.OnChangeSingleHandler<CustomValueType> = (option) => {
|
||||
private readonly onSelectChange: ReactSelectModule.OnChangeSingleHandler<CustomValueType> = (option) => {
|
||||
const optionValue: CustomValueType = option.value;
|
||||
}
|
||||
|
||||
@ -240,11 +240,11 @@ describe("Examples", () => {
|
||||
|
||||
it("Menu renderer example", () => {
|
||||
class Component extends React.Component {
|
||||
private onSelectChange: ReactSelectModule.OnChangeSingleHandler<string> = option => {
|
||||
private readonly onSelectChange: ReactSelectModule.OnChangeSingleHandler<string> = option => {
|
||||
const optionValue: string = option.value;
|
||||
}
|
||||
|
||||
private menuRenderer: ReactSelectModule.MenuRendererHandler = props => {
|
||||
private readonly menuRenderer: ReactSelectModule.MenuRendererHandler = props => {
|
||||
const options = props.options.map(option => {
|
||||
return <div className="option">{option.label}</div>;
|
||||
});
|
||||
@ -265,7 +265,7 @@ describe("Examples", () => {
|
||||
|
||||
it("Menu renderer with custom value type example", () => {
|
||||
class Component extends React.Component {
|
||||
private menuRenderer: ReactSelectModule.MenuRendererHandler<CustomValueType> = props => {
|
||||
private readonly menuRenderer: ReactSelectModule.MenuRendererHandler<CustomValueType> = props => {
|
||||
const options = props.options.map(option => {
|
||||
return (
|
||||
<div className="option" data-value1={option.value.prop1}
|
||||
@ -291,11 +291,11 @@ describe("Examples", () => {
|
||||
|
||||
it("Input render example", () => {
|
||||
class Component extends React.Component {
|
||||
private onSelectChange: ReactSelectModule.OnChangeSingleHandler<string> = option => {
|
||||
private readonly onSelectChange: ReactSelectModule.OnChangeSingleHandler<string> = option => {
|
||||
const optionValue: string = option.value;
|
||||
}
|
||||
|
||||
private inputRenderer: ReactSelectModule.InputRendererHandler = props => {
|
||||
private readonly inputRenderer: ReactSelectModule.InputRendererHandler = props => {
|
||||
return <input {...props} />;
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ const SortableList = ReactSortableHOC.SortableContainer((props: SortableListProp
|
||||
});
|
||||
|
||||
class SortableComponent extends React.Component<{}, SortableComponentState> {
|
||||
private _onSortEnd: ReactSortableHOC.SortEndHandler;
|
||||
private readonly _onSortEnd: ReactSortableHOC.SortEndHandler;
|
||||
|
||||
private _handleSortEnd(sort: ReactSortableHOC.SortEnd, event: ReactSortableHOC.SortEvent): void {
|
||||
this.setState({items: ReactSortableHOC.arrayMove(this.state.items, sort.oldIndex, sort.newIndex)});
|
||||
|
||||
@ -4,26 +4,26 @@ import * as ReactSwipe from "react-swipe";
|
||||
class ReactSwipeTest extends React.PureComponent {
|
||||
private swipeComponent: ReactSwipe | null = null;
|
||||
|
||||
private onPrev: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
private readonly onPrev: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
if (this.swipeComponent != null) {
|
||||
this.swipeComponent.prev();
|
||||
}
|
||||
}
|
||||
|
||||
private onNext: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
private readonly onNext: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
if (this.swipeComponent != null) {
|
||||
this.swipeComponent.next();
|
||||
}
|
||||
}
|
||||
|
||||
private onSlideToStart: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
private readonly onSlideToStart: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
if (this.swipeComponent != null) {
|
||||
const lastSlide = this.swipeComponent.getNumSlides() - 1;
|
||||
this.swipeComponent.slide(lastSlide, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private onGetCurrentPosition: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
private readonly onGetCurrentPosition: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
const currentPosition = this.swipeComponent != null ? this.swipeComponent.getPos() : 0;
|
||||
alert(currentPosition);
|
||||
}
|
||||
|
||||
@ -2,18 +2,18 @@ import * as React from 'react';
|
||||
import * as Swipeable from 'react-swipeable';
|
||||
|
||||
class SampleComponent extends React.PureComponent<Swipeable.SwipeableProps> {
|
||||
private handleSwiped: Swipeable.OnSwipedCallback = () => {};
|
||||
private handleSwiping: Swipeable.OnSwipingCallback = () => {};
|
||||
private handleSwipingUp: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private handleSwipingRight: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private handleSwipingDown: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private handleSwipingLeft: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private handleSwipedUp: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private handleSwipedRight: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private handleSwipedDown: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private handleSwipedLeft: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private handleTap: Swipeable.OnTapCallback = () => {};
|
||||
private handleClick = () => {};
|
||||
private readonly handleSwiped: Swipeable.OnSwipedCallback = () => {};
|
||||
private readonly handleSwiping: Swipeable.OnSwipingCallback = () => {};
|
||||
private readonly handleSwipingUp: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private readonly handleSwipingRight: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private readonly handleSwipingDown: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private readonly handleSwipingLeft: Swipeable.OnSwipingDirectionCallback = () => {};
|
||||
private readonly handleSwipedUp: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private readonly handleSwipedRight: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private readonly handleSwipedDown: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private readonly handleSwipedLeft: Swipeable.OnSwipedDirectionCallback = () => {};
|
||||
private readonly handleTap: Swipeable.OnTapCallback = () => {};
|
||||
private readonly handleClick = () => {};
|
||||
|
||||
render() {
|
||||
return (
|
||||
|
||||
@ -25,7 +25,7 @@ export class DraggableTest extends React.PureComponent {
|
||||
return <Draggable style={style} children={this.callback} />;
|
||||
}
|
||||
|
||||
private callback = (argument: DraggableCallbackArgument): JSX.Element => {
|
||||
private readonly callback = (argument: DraggableCallbackArgument): JSX.Element => {
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
@ -44,19 +44,19 @@ export class SwipeableTest extends React.PureComponent {
|
||||
</Swipeable>;
|
||||
}
|
||||
|
||||
private swipeHandler = () => {
|
||||
private readonly swipeHandler = () => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
export class CustomGestureTest extends React.PureComponent {
|
||||
private move: moves[] = [moves.UPLEFT, moves.RIGHT, moves.DOWNRIGHT];
|
||||
private readonly move: moves[] = [moves.UPLEFT, moves.RIGHT, moves.DOWNRIGHT];
|
||||
|
||||
render() {
|
||||
return <CustomGesture config={this.move} onGesture={this.handler} />;
|
||||
}
|
||||
|
||||
private handler = () => {
|
||||
private readonly handler = () => {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ class ModernComponent extends React.Component<Props, State>
|
||||
});
|
||||
}
|
||||
|
||||
private _myComponent: MyComponent;
|
||||
private readonly _myComponent: MyComponent;
|
||||
private _input: HTMLInputElement | null;
|
||||
|
||||
render() {
|
||||
|
||||
@ -110,7 +110,7 @@ class ModernComponent extends React.Component<Props, State>
|
||||
});
|
||||
}
|
||||
|
||||
private _myComponent: MyComponent;
|
||||
private readonly _myComponent: MyComponent;
|
||||
private _input: HTMLInputElement | null;
|
||||
|
||||
render() {
|
||||
|
||||
@ -3529,7 +3529,7 @@ render() {
|
||||
class Example115 extends React.Component<any, any> {
|
||||
// https://reactstrap.github.io/components/carousel/
|
||||
|
||||
private items = [
|
||||
private readonly items = [
|
||||
{
|
||||
src: 'data:image/svg+xml...',
|
||||
altText: 'Slide 1',
|
||||
|
||||
@ -59,7 +59,7 @@ SHOW("%f".format(myObj));
|
||||
// ----
|
||||
|
||||
class Item {
|
||||
constructor(private name: string) { }
|
||||
constructor(private readonly name: string) { }
|
||||
|
||||
a() {
|
||||
const first = self.name.charAt(0);
|
||||
@ -83,7 +83,7 @@ SHOW(template.format(banana, banana));
|
||||
// ----
|
||||
|
||||
class Animal {
|
||||
constructor(private name: string) { }
|
||||
constructor(private readonly name: string) { }
|
||||
adjective(x: string) {
|
||||
return `${x} ${this.name}`;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ class RouteOne extends React.Component<RouteComponentProps<{}>> {
|
||||
}
|
||||
|
||||
class RouteTwo extends React.Component<RouteComponentProps<{}>> {
|
||||
private onUpdate: OnUpdateCall = (location) => { console.log("update"); };
|
||||
private readonly onUpdate: OnUpdateCall = (location) => { console.log("update"); };
|
||||
|
||||
render() {
|
||||
return <div>
|
||||
@ -65,11 +65,11 @@ interface Params {
|
||||
}
|
||||
|
||||
class RouteFour extends React.Component<RouteComponentProps<{}>> {
|
||||
private routes: RouteConfiguration[] = [
|
||||
private readonly routes: RouteConfiguration[] = [
|
||||
{ path: "/four/something/:page", component: RouteTwo }
|
||||
];
|
||||
|
||||
private getKey: GetKeyFunction<Params> = (match, route, location) => {
|
||||
private readonly getKey: GetKeyFunction<Params> = (match, route, location) => {
|
||||
return "my-key-" + match.url;
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ function testFunction() {
|
||||
}
|
||||
|
||||
class TestClass {
|
||||
private dummy: string;
|
||||
private readonly dummy: string;
|
||||
}
|
||||
|
||||
const testObj = {
|
||||
|
||||
@ -2355,7 +2355,7 @@ namespace App {
|
||||
|
||||
static $inject: string[] = ["$SharePoint", "$spnotify"];
|
||||
|
||||
constructor(private $SharePoint: App.SharePoint, private $n: App.SpNotify) {
|
||||
constructor(private readonly $SharePoint: App.SharePoint, private readonly $n: App.SpNotify) {
|
||||
this.activate();
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ $('.newSelection');
|
||||
grid.setSelectedRows([0, 1, 2]);
|
||||
|
||||
class SingleCellSelectionModel extends Slick.SelectionModel<MyData, Slick.Range[]> {
|
||||
private self: SingleCellSelectionModel = null;
|
||||
private readonly self: SingleCellSelectionModel = null;
|
||||
private _grid: Slick.Grid<MyData>;
|
||||
|
||||
constructor() {
|
||||
|
||||
@ -37,5 +37,5 @@ export class WallabyConfig implements wallabyjs.IWallabyConfig {
|
||||
}
|
||||
};
|
||||
|
||||
constructor(private wallaby: wallabyjs.IWallaby) { }
|
||||
constructor(private readonly wallaby: wallabyjs.IWallaby) { }
|
||||
}
|
||||
|
||||
@ -295,7 +295,7 @@ function streamifyWebSocket(url: string, protocol: string) {
|
||||
}
|
||||
|
||||
class WebSocketSource implements ReadableStreamSource {
|
||||
private _ws: WebSocket;
|
||||
private readonly _ws: WebSocket;
|
||||
|
||||
constructor(ws: WebSocket) {
|
||||
this._ws = ws;
|
||||
@ -316,7 +316,7 @@ class WebSocketSource implements ReadableStreamSource {
|
||||
}
|
||||
|
||||
class WebSocketSink implements WritableStreamSink {
|
||||
private _ws: WebSocket;
|
||||
private readonly _ws: WebSocket;
|
||||
|
||||
constructor(ws: WebSocket) {
|
||||
this._ws = ws;
|
||||
|
||||
@ -7,7 +7,7 @@ import dns = require('dns');
|
||||
import when = require("when");
|
||||
|
||||
class ForeignPromise<T> {
|
||||
constructor(private value: T) {
|
||||
constructor(private readonly value: T) {
|
||||
}
|
||||
|
||||
then<U>(onFulfilled: (value: T) => U, onRejected?: (reason: any) => U) { return new ForeignPromise<U>(onFulfilled(this.value)); }
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class BasicTest {
|
||||
private graphComponent:yfiles.view.GraphComponent;
|
||||
private readonly graphComponent:yfiles.view.GraphComponent;
|
||||
|
||||
constructor() {
|
||||
this.graphComponent = new yfiles.view.GraphComponent("graphControl");
|
||||
@ -129,7 +129,7 @@ class BasicTest {
|
||||
var args = new yfiles.lang.EventArgs();
|
||||
yfiles.input.KeyEventRecognizers.META_PRESSED(null, args);
|
||||
}
|
||||
|
||||
|
||||
testsForVersion2012() {
|
||||
//isInstance type-guard
|
||||
let r : any;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user