Skip to content

Commit 4111772

Browse files
committed
add tests
1 parent 05d038f commit 4111772

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/test.js(3,8): error TS2322: Type '{}' is not assignable to type 'string'.
2+
/test.js(6,4): error TS8009: The 'declare' modifier can only be used in TypeScript files.
3+
/test.js(6,18): error TS8010: Type annotations can only be used in TypeScript files.
4+
/test.js(9,18): error TS2339: Property 'foo' does not exist on type 'string'.
5+
6+
7+
==== /test.js (4 errors) ====
8+
class Foo {
9+
constructor() {
10+
this.prop = { };
11+
~~~~~~~~~
12+
!!! error TS2322: Type '{}' is not assignable to type 'string'.
13+
}
14+
15+
declare prop: string;
16+
~~~~~~~
17+
!!! error TS8009: The 'declare' modifier can only be used in TypeScript files.
18+
~~~~~~
19+
!!! error TS8010: Type annotations can only be used in TypeScript files.
20+
21+
method() {
22+
this.prop.foo
23+
~~~
24+
!!! error TS2339: Property 'foo' does not exist on type 'string'.
25+
}
26+
}
27+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== /test.js ===
2+
class Foo {
3+
>Foo : Symbol(Foo, Decl(test.js, 0, 0))
4+
5+
constructor() {
6+
this.prop = { };
7+
>this.prop : Symbol(Foo.prop, Decl(test.js, 1, 18), Decl(test.js, 3, 4))
8+
>this : Symbol(Foo, Decl(test.js, 0, 0))
9+
>prop : Symbol(Foo.prop, Decl(test.js, 1, 18), Decl(test.js, 3, 4))
10+
}
11+
12+
declare prop: string;
13+
>prop : Symbol(Foo.prop, Decl(test.js, 1, 18), Decl(test.js, 3, 4))
14+
15+
method() {
16+
>method : Symbol(Foo.method, Decl(test.js, 5, 24))
17+
18+
this.prop.foo
19+
>this.prop : Symbol(Foo.prop, Decl(test.js, 1, 18), Decl(test.js, 3, 4))
20+
>this : Symbol(Foo, Decl(test.js, 0, 0))
21+
>prop : Symbol(Foo.prop, Decl(test.js, 1, 18), Decl(test.js, 3, 4))
22+
}
23+
}
24+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
=== /test.js ===
2+
class Foo {
3+
>Foo : Foo
4+
5+
constructor() {
6+
this.prop = { };
7+
>this.prop = { } : {}
8+
>this.prop : string
9+
>this : this
10+
>prop : string
11+
>{ } : {}
12+
}
13+
14+
declare prop: string;
15+
>prop : string
16+
17+
method() {
18+
>method : () => void
19+
20+
this.prop.foo
21+
>this.prop.foo : any
22+
>this.prop : string
23+
>this : this
24+
>prop : string
25+
>foo : any
26+
}
27+
}
28+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @noEmit: true
4+
// @filename: /test.js
5+
6+
class Foo {
7+
constructor() {
8+
this.prop = { };
9+
}
10+
11+
declare prop: string;
12+
13+
method() {
14+
this.prop.foo
15+
}
16+
}

0 commit comments

Comments
 (0)