Skip to content

Commit 7789f54

Browse files
committed
add tests
1 parent b7d8b30 commit 7789f54

6 files changed

+146
-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,9): error TS2322: Type '{}' is not assignable to type 'string'.
2+
/test.js(6,5): error TS8009: The 'declare' modifier can only be used in TypeScript files.
3+
/test.js(6,19): error TS8010: Type annotations can only be used in TypeScript files.
4+
/test.js(9,19): 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, 19), Decl(test.js, 3, 5))
8+
>this : Symbol(Foo, Decl(test.js, 0, 0))
9+
>prop : Symbol(Foo.prop, Decl(test.js, 1, 19), Decl(test.js, 3, 5))
10+
}
11+
12+
declare prop: string;
13+
>prop : Symbol(Foo.prop, Decl(test.js, 1, 19), Decl(test.js, 3, 5))
14+
15+
method() {
16+
>method : Symbol(Foo.method, Decl(test.js, 5, 25))
17+
18+
this.prop.foo
19+
>this.prop : Symbol(Foo.prop, Decl(test.js, 1, 19), Decl(test.js, 3, 5))
20+
>this : Symbol(Foo, Decl(test.js, 0, 0))
21+
>prop : Symbol(Foo.prop, Decl(test.js, 1, 19), Decl(test.js, 3, 5))
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: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
=== /tests/cases/fourslash/quickInfoAtPropWithAmbientDeclarationInJs.ts ===
2+
// class C {
3+
// constructor() {
4+
// this.prop = "";
5+
// }
6+
// declare prop: string;
7+
// method() {
8+
// this.prop.foo
9+
// ^^^
10+
// | ----------------------------------------------------------------------
11+
// | any
12+
// | ----------------------------------------------------------------------
13+
// }
14+
// }
15+
16+
[
17+
{
18+
"marker": {
19+
"fileName": "/tests/cases/fourslash/quickInfoAtPropWithAmbientDeclarationInJs.ts",
20+
"position": 122,
21+
"name": ""
22+
},
23+
"item": {
24+
"kind": "",
25+
"kindModifiers": "",
26+
"textSpan": {
27+
"start": 119,
28+
"length": 3
29+
},
30+
"displayParts": [
31+
{
32+
"text": "any",
33+
"kind": "keyword"
34+
}
35+
]
36+
}
37+
}
38+
]
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+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////class C {
4+
//// constructor() {
5+
//// this.prop = "";
6+
//// }
7+
//// declare prop: string;
8+
//// method() {
9+
//// this.prop.foo/**/
10+
//// }
11+
////}
12+
13+
verify.baselineQuickInfo();

0 commit comments

Comments
 (0)