Skip to content

Commit

Permalink
add more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingwl committed May 20, 2020
1 parent 6d8ed7b commit 2d61217
Show file tree
Hide file tree
Showing 23 changed files with 936 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/harness/vfsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ namespace vfs {
if (!isFile(node)) throw createIOError("EBADF");

const buffer = this._getBuffer(node).slice();
return encoding ? buffer.toString(encoding) : buffer;
return encoding ? buffer.toString(encoding as any) : buffer;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/staticIndexSignature1.errors.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tests/cases/compiler/staticIndexSignature1.ts(10,1): error TS2322: Type '2' is not assignable to type '42'.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts(10,1): error TS2322: Type '2' is not assignable to type '42'.


==== tests/cases/compiler/staticIndexSignature1.ts (1 errors) ====
==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts (1 errors) ====
class C {
static [s: string]: number;
static [s: number]: 42
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/staticIndexSignature1.symbols
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/staticIndexSignature1.ts ===
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts ===
class C {
>C : Symbol(C, Decl(staticIndexSignature1.ts, 0, 0))

Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/staticIndexSignature1.types
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/staticIndexSignature1.ts ===
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature1.ts ===
class C {
>C : C

Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/staticIndexSignature2.errors.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
tests/cases/compiler/staticIndexSignature2.ts(6,1): error TS2542: Index signature in type 'typeof C' only permits reading.
tests/cases/compiler/staticIndexSignature2.ts(7,1): error TS2542: Index signature in type 'typeof C' only permits reading.
tests/cases/compiler/staticIndexSignature2.ts(9,1): error TS2542: Index signature in type 'typeof C' only permits reading.
tests/cases/compiler/staticIndexSignature2.ts(10,1): error TS2322: Type '2' is not assignable to type '42'.
tests/cases/compiler/staticIndexSignature2.ts(10,1): error TS2542: Index signature in type 'typeof C' only permits reading.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(6,1): error TS2542: Index signature in type 'typeof C' only permits reading.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(7,1): error TS2542: Index signature in type 'typeof C' only permits reading.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(9,1): error TS2542: Index signature in type 'typeof C' only permits reading.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(10,1): error TS2322: Type '2' is not assignable to type '42'.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts(10,1): error TS2542: Index signature in type 'typeof C' only permits reading.


==== tests/cases/compiler/staticIndexSignature2.ts (5 errors) ====
==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts (5 errors) ====
class C {
static readonly [s: string]: number;
static readonly [s: number]: 42
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/staticIndexSignature2.symbols
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/staticIndexSignature2.ts ===
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts ===
class C {
>C : Symbol(C, Decl(staticIndexSignature2.ts, 0, 0))

Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/staticIndexSignature2.types
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/staticIndexSignature2.ts ===
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature2.ts ===
class C {
>C : C

Expand Down
60 changes: 60 additions & 0 deletions tests/baselines/reference/staticIndexSignature3.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(21,11): error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof D'.
Property 'f' does not exist on type 'typeof D'.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(22,11): error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof D'.
Property '42' does not exist on type 'typeof D'.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(23,11): error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof ED'.
Property 'f' does not exist on type 'typeof ED'.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(24,11): error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof ED'.
Property '42' does not exist on type 'typeof ED'.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(25,11): error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof DD'.
Property 'f' does not exist on type 'typeof DD'.
tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts(26,11): error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof DD'.
Property '42' does not exist on type 'typeof DD'.


==== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts (6 errors) ====
class B {
static readonly [s: string]: number;
static readonly [s: number]: 42 | 233
}

class D extends B {
static readonly [s: string]: number
}

class ED extends D {
static readonly [s: string]: boolean
static readonly [s: number]: 1
}

class DD extends D {
static readonly [s: string]: 421
}

const a = B["f"];
const b = B[42];
const c = D["f"]
~~~~~~
!!! error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof D'.
!!! error TS7053: Property 'f' does not exist on type 'typeof D'.
const d = D[42]
~~~~~
!!! error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof D'.
!!! error TS7053: Property '42' does not exist on type 'typeof D'.
const e = ED["f"]
~~~~~~~
!!! error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof ED'.
!!! error TS7053: Property 'f' does not exist on type 'typeof ED'.
const f = ED[42]
~~~~~~
!!! error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof ED'.
!!! error TS7053: Property '42' does not exist on type 'typeof ED'.
const g = DD["f"]
~~~~~~~
!!! error TS7053: Element implicitly has an 'any' type because expression of type '"f"' can't be used to index type 'typeof DD'.
!!! error TS7053: Property 'f' does not exist on type 'typeof DD'.
const h = DD[42]
~~~~~~
!!! error TS7053: Element implicitly has an 'any' type because expression of type '42' can't be used to index type 'typeof DD'.
!!! error TS7053: Property '42' does not exist on type 'typeof DD'.

78 changes: 78 additions & 0 deletions tests/baselines/reference/staticIndexSignature3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//// [staticIndexSignature3.ts]
class B {
static readonly [s: string]: number;
static readonly [s: number]: 42 | 233
}

class D extends B {
static readonly [s: string]: number
}

class ED extends D {
static readonly [s: string]: boolean
static readonly [s: number]: 1
}

class DD extends D {
static readonly [s: string]: 421
}

const a = B["f"];
const b = B[42];
const c = D["f"]
const d = D[42]
const e = ED["f"]
const f = ED[42]
const g = DD["f"]
const h = DD[42]


//// [staticIndexSignature3.js]
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var B = /** @class */ (function () {
function B() {
}
return B;
}());
var D = /** @class */ (function (_super) {
__extends(D, _super);
function D() {
return _super !== null && _super.apply(this, arguments) || this;
}
return D;
}(B));
var ED = /** @class */ (function (_super) {
__extends(ED, _super);
function ED() {
return _super !== null && _super.apply(this, arguments) || this;
}
return ED;
}(D));
var DD = /** @class */ (function (_super) {
__extends(DD, _super);
function DD() {
return _super !== null && _super.apply(this, arguments) || this;
}
return DD;
}(D));
var a = B["f"];
var b = B[42];
var c = D["f"];
var d = D[42];
var e = ED["f"];
var f = ED[42];
var g = DD["f"];
var h = DD[42];
70 changes: 70 additions & 0 deletions tests/baselines/reference/staticIndexSignature3.symbols
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts ===
class B {
>B : Symbol(B, Decl(staticIndexSignature3.ts, 0, 0))

static readonly [s: string]: number;
>s : Symbol(s, Decl(staticIndexSignature3.ts, 1, 21))

static readonly [s: number]: 42 | 233
>s : Symbol(s, Decl(staticIndexSignature3.ts, 2, 21))
}

class D extends B {
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))
>B : Symbol(B, Decl(staticIndexSignature3.ts, 0, 0))

static readonly [s: string]: number
>s : Symbol(s, Decl(staticIndexSignature3.ts, 6, 21))
}

class ED extends D {
>ED : Symbol(ED, Decl(staticIndexSignature3.ts, 7, 1))
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))

static readonly [s: string]: boolean
>s : Symbol(s, Decl(staticIndexSignature3.ts, 10, 21))

static readonly [s: number]: 1
>s : Symbol(s, Decl(staticIndexSignature3.ts, 11, 21))
}

class DD extends D {
>DD : Symbol(DD, Decl(staticIndexSignature3.ts, 12, 1))
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))

static readonly [s: string]: 421
>s : Symbol(s, Decl(staticIndexSignature3.ts, 15, 21))
}

const a = B["f"];
>a : Symbol(a, Decl(staticIndexSignature3.ts, 18, 5))
>B : Symbol(B, Decl(staticIndexSignature3.ts, 0, 0))

const b = B[42];
>b : Symbol(b, Decl(staticIndexSignature3.ts, 19, 5))
>B : Symbol(B, Decl(staticIndexSignature3.ts, 0, 0))

const c = D["f"]
>c : Symbol(c, Decl(staticIndexSignature3.ts, 20, 5))
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))

const d = D[42]
>d : Symbol(d, Decl(staticIndexSignature3.ts, 21, 5))
>D : Symbol(D, Decl(staticIndexSignature3.ts, 3, 1))

const e = ED["f"]
>e : Symbol(e, Decl(staticIndexSignature3.ts, 22, 5))
>ED : Symbol(ED, Decl(staticIndexSignature3.ts, 7, 1))

const f = ED[42]
>f : Symbol(f, Decl(staticIndexSignature3.ts, 23, 5))
>ED : Symbol(ED, Decl(staticIndexSignature3.ts, 7, 1))

const g = DD["f"]
>g : Symbol(g, Decl(staticIndexSignature3.ts, 24, 5))
>DD : Symbol(DD, Decl(staticIndexSignature3.ts, 12, 1))

const h = DD[42]
>h : Symbol(h, Decl(staticIndexSignature3.ts, 25, 5))
>DD : Symbol(DD, Decl(staticIndexSignature3.ts, 12, 1))

86 changes: 86 additions & 0 deletions tests/baselines/reference/staticIndexSignature3.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
=== tests/cases/conformance/classes/staticIndexSignature/staticIndexSignature3.ts ===
class B {
>B : B

static readonly [s: string]: number;
>s : string

static readonly [s: number]: 42 | 233
>s : number
}

class D extends B {
>D : D
>B : B

static readonly [s: string]: number
>s : string
}

class ED extends D {
>ED : ED
>D : D

static readonly [s: string]: boolean
>s : string

static readonly [s: number]: 1
>s : number
}

class DD extends D {
>DD : DD
>D : D

static readonly [s: string]: 421
>s : string
}

const a = B["f"];
>a : number
>B["f"] : number
>B : typeof B
>"f" : "f"

const b = B[42];
>b : 42 | 233
>B[42] : 42 | 233
>B : typeof B
>42 : 42

const c = D["f"]
>c : any
>D["f"] : any
>D : typeof D
>"f" : "f"

const d = D[42]
>d : any
>D[42] : any
>D : typeof D
>42 : 42

const e = ED["f"]
>e : any
>ED["f"] : any
>ED : typeof ED
>"f" : "f"

const f = ED[42]
>f : any
>ED[42] : any
>ED : typeof ED
>42 : 42

const g = DD["f"]
>g : any
>DD["f"] : any
>DD : typeof DD
>"f" : "f"

const h = DD[42]
>h : any
>DD[42] : any
>DD : typeof DD
>42 : 42

Loading

0 comments on commit 2d61217

Please sign in to comment.