Skip to content

Commit 8baf512

Browse files
committed
tslint.jsonを更新して引っかかった箇所を直した
1 parent e10e7ff commit 8baf512

File tree

17 files changed

+156
-80
lines changed

17 files changed

+156
-80
lines changed

articles/definition-file.re

+5-3
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ declare var foo: Foo;
515515
#@mapfile(../code/definition-file/interfaceAntipattern/moduleByInterfaceGood-ignore.d.ts)
516516
// 普通にコレでいいだろ!!
517517
declare namespace foo.bar.buzz {
518-
var str: string;
518+
let str: string;
519519
}
520520
#@end
521521
//}
@@ -685,11 +685,13 @@ interface AnimalConstructor {
685685
interface Animal {
686686
speak(): string;
687687
}
688+
/* tslint:disable:variable-name */
688689
let Animal: AnimalConstructor = class {
689690
speak() {
690691
return "???";
691692
}
692693
};
694+
/* tslint:enable:variable-name */
693695
// Animalはただの変数だが普通に継承できる!
694696
class Cat extends Animal {
695697
speak() {
@@ -708,7 +710,7 @@ let cat2: Cat = new class extends class {
708710
speak() {
709711
return "meow";
710712
}
711-
}
713+
}();
712714
console.log(cat2.speak());
713715

714716
export { }
@@ -913,7 +915,7 @@ declare module "bar" {
913915
}
914916

915917
// この_は外部からは参照できない。exportしてないので。
916-
var _: Bar;
918+
let _: Bar;
917919
export = _;
918920
}
919921
#@end

articles/types-advanced.re

+11-11
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ class Sample {
601601

602602
// 構造的部分型!
603603
let obj: Sample = {
604-
str: "Hi!"
604+
str: "Hi!",
605605
};
606606

607607
if (obj instanceof Sample) {
@@ -625,7 +625,7 @@ class Sample {
625625
}
626626
// 構造的部分型!
627627
let obj = {
628-
str: "Hi!"
628+
str: "Hi!",
629629
};
630630
if (obj instanceof Sample) {
631631
// 型はSampleに絞られている しかし、絶対に到達しない
@@ -647,17 +647,17 @@ class Sample {
647647
}
648648

649649
// 構造的部分型!
650-
var obj: Sample = {
651-
str: "Hi!"
650+
let obj: Sample = {
651+
str: "Hi!",
652652
};
653653

654654
// 独自にSample型である事の判定を実装する
655-
function isSample(obj: Sample): obj is Sample {
656-
if (!obj) {
655+
function isSample(s: Sample): s is Sample {
656+
if (!s) {
657657
return false;
658658
}
659659
// とりあえず、strプロパティがあって値がstringならSample型コンパチということでOK という基準にする
660-
return typeof obj.str === "string";
660+
return typeof s.str === "string";
661661
}
662662

663663
if (isSample(obj)) {
@@ -674,17 +674,17 @@ export { }
674674
//list[typeGuards/vsWeakspot2-invalid][privateな要素があれば構造的部分型で値を偽造できない]{
675675
#@mapfile(../code/types-advanced/typeGuards/vsWeakspot2-invalid.ts)
676676
class Sample {
677-
private _tmp: any;
678677
str: string;
678+
private _tmp: any;
679679
}
680680

681681
// privateなインスタンス変数があるクラスのインスタンスは偽造できない!
682682
// error TS2322: Type '{ _tmp: null; str: string; }' is not
683683
// assignable to type 'Sample'. Property '_tmp' is private
684684
// in type 'Sample' but not in type '{ _tmp: null; str: string; }'.
685685
let obj: Sample = {
686-
_tmp: null,
687686
str: "Hi!",
687+
_tmp: null,
688688
};
689689
#@end
690690
//}
@@ -744,8 +744,8 @@ namespace alternative {
744744
constructor(public p: Point, public r: number) {
745745
}
746746
}
747-
let c: Circle = new Circle(new Point(1, 2), 3);
748-
console.log(c.p, c.r);
747+
let c2: Circle = new Circle(new Point(1, 2), 3);
748+
console.log(c2.p, c2.r);
749749
}
750750

751751
export { c, alternative }

articles/types-basic.re

+5-5
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ export { s1, s3, s4 }
271271
#@mapfile(../code/types-basic/objectTypeLiteral/indexAccessSample.ts)
272272
let obj = {
273273
str: "string",
274-
num: 1
274+
num: 1,
275275
};
276276

277277
// 文字列リテラルによるアクセスだと普通に . アクセス同様に型情報が得られる
@@ -313,15 +313,15 @@ let obj: {
313313
obj = {
314314
hello(word: string) {
315315
return "Hello, " + word;
316-
}
316+
},
317317
};
318318
obj = {
319-
hello: (word: string) => "Hello, " + word
319+
hello: (word: string) => "Hello, " + word,
320320
};
321321
obj = {
322322
hello: function(word: string) {
323323
return "Hello, " + word;
324-
}
324+
},
325325
};
326326

327327
// プロパティシグニチャ + 関数型 の別の書き方なだけだな!
@@ -560,7 +560,7 @@ export { }
560560
let str = "str";
561561
// anyを経由しない場合、整合性の無い型アサーションは成功しない!安全!
562562
// error TS2352: Type 'string' cannot be converted to type 'number'.
563-
var num: number = <number>str;
563+
let num: number = <number>str;
564564
#@end
565565
//}
566566

articles/typescript-basic.re

+1-3
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ class Base {
105105
// インスタンス変数
106106
numA: number;
107107
strA = "string";
108-
109108
public numB: number;
110109
private numC: number;
111-
// TypeScript 1.3.0 から protected 利用可
112110
protected numD: number;
113111

114112
// クラス変数
@@ -649,7 +647,7 @@ namespace b {
649647
// めんどくさいなら import句 を使えばいい
650648
import Sample = a.Sample;
651649
let objB: Sample;
652-
objB = new Sample;
650+
objB = new Sample();
653651

654652
// 別に違う名前をつけてもいい(けど混乱しちゃうかも?
655653
import Test = a.Sample;

code/definition-file/declareClass/stretch.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ interface AnimalConstructor {
1616
interface Animal {
1717
speak(): string;
1818
}
19+
/* tslint:disable:variable-name */
1920
let Animal: AnimalConstructor = class {
2021
speak() {
2122
return "???";
2223
}
2324
};
25+
/* tslint:enable:variable-name */
2426
// Animalはただの変数だが普通に継承できる!
2527
class Cat extends Animal {
2628
speak() {
@@ -39,7 +41,7 @@ let cat2: Cat = new class extends class {
3941
speak() {
4042
return "meow";
4143
}
42-
}
44+
}();
4345
console.log(cat2.speak());
4446

4547
export { }

code/definition-file/export/sample1.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ declare module "bar" {
44
}
55

66
// この_は外部からは参照できない。exportしてないので。
7-
var _: Bar;
7+
let _: Bar;
88
export = _;
99
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// 普通にコレでいいだろ!!
22
declare namespace foo.bar.buzz {
3-
var str: string;
3+
let str: string;
44
}

code/types-advanced/typeAlias/tuple.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace alternative {
1414
constructor(public p: Point, public r: number) {
1515
}
1616
}
17-
let c: Circle = new Circle(new Point(1, 2), 3);
18-
console.log(c.p, c.r);
17+
let c2: Circle = new Circle(new Point(1, 2), 3);
18+
console.log(c2.p, c2.r);
1919
}
2020

2121
export { c, alternative }

code/types-advanced/typeGuards/userDefined.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ class Sample {
33
}
44

55
// 構造的部分型!
6-
var obj: Sample = {
7-
str: "Hi!"
6+
let obj: Sample = {
7+
str: "Hi!",
88
};
99

1010
// 独自にSample型である事の判定を実装する
11-
function isSample(obj: Sample): obj is Sample {
12-
if (!obj) {
11+
function isSample(s: Sample): s is Sample {
12+
if (!s) {
1313
return false;
1414
}
1515
// とりあえず、strプロパティがあって値がstringならSample型コンパチということでOK という基準にする
16-
return typeof obj.str === "string";
16+
return typeof s.str === "string";
1717
}
1818

1919
if (isSample(obj)) {
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
class Sample {
2-
private _tmp: any;
32
str: string;
3+
private _tmp: any;
44
}
55

66
// privateなインスタンス変数があるクラスのインスタンスは偽造できない!
77
// error TS2322: Type '{ _tmp: null; str: string; }' is not
88
// assignable to type 'Sample'. Property '_tmp' is private
99
// in type 'Sample' but not in type '{ _tmp: null; str: string; }'.
1010
let obj: Sample = {
11-
_tmp: null,
1211
str: "Hi!",
12+
_tmp: null,
1313
};

code/types-advanced/typeGuards/weakspot.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Sample {
44

55
// 構造的部分型!
66
let obj: Sample = {
7-
str: "Hi!"
7+
str: "Hi!",
88
};
99

1010
if (obj instanceof Sample) {

code/types-basic/objectTypeLiteral/indexAccessSample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let obj = {
22
str: "string",
3-
num: 1
3+
num: 1,
44
};
55

66
// 文字列リテラルによるアクセスだと普通に . アクセス同様に型情報が得られる

code/types-basic/objectTypeLiteral/methodSignature.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ let obj: {
66
obj = {
77
hello(word: string) {
88
return "Hello, " + word;
9-
}
9+
},
1010
};
1111
obj = {
12-
hello: (word: string) => "Hello, " + word
12+
hello: (word: string) => "Hello, " + word,
1313
};
1414
obj = {
1515
hello: function(word: string) {
1616
return "Hello, " + word;
17-
}
17+
},
1818
};
1919

2020
// プロパティシグニチャ + 関数型 の別の書き方なだけだな!
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
let str = "str";
22
// anyを経由しない場合、整合性の無い型アサーションは成功しない!安全!
33
// error TS2352: Type 'string' cannot be converted to type 'number'.
4-
var num: number = <number>str;
4+
let num: number = <number>str;

code/typescript-basic/class/basic.ts

-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ class Base {
22
// インスタンス変数
33
numA: number;
44
strA = "string";
5-
65
public numB: number;
76
private numC: number;
8-
// TypeScript 1.3.0 から protected 利用可
97
protected numD: number;
108

119
// クラス変数

code/typescript-basic/internalModule/import.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace b {
1010
// めんどくさいなら import句 を使えばいい
1111
import Sample = a.Sample;
1212
let objB: Sample;
13-
objB = new Sample;
13+
objB = new Sample();
1414

1515
// 別に違う名前をつけてもいい(けど混乱しちゃうかも?
1616
import Test = a.Sample;

0 commit comments

Comments
 (0)