Skip to content

Commit 70ce293

Browse files
committed
add a few more tests
1 parent 85e4b07 commit 70ce293

File tree

9 files changed

+72
-130
lines changed

9 files changed

+72
-130
lines changed

src/compiler/program.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,6 @@ namespace ts {
19471947
const { diagnostics, directives } = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics);
19481948

19491949
for (const errorExpectation of directives.getUnusedExpectations()) {
1950-
// TODO: Need to test ts-expect-error (although it's not a good idea but w/e)
19511950
diagnostics.push(createDiagnosticForRange(sourceFile, errorExpectation.range, Diagnostics.Unused_ts_expect_error_directive));
19521951
}
19531952

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ declare namespace ts {
21142114
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
21152115
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
21162116
/** The first time this is called, it will return global diagnostics (no location). */
2117-
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
2117+
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken, includeUncheckedJS?: boolean): readonly Diagnostic[];
21182118
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
21192119
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
21202120
/**

tests/baselines/reference/api/typescript.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2114,7 +2114,7 @@ declare namespace ts {
21142114
getGlobalDiagnostics(cancellationToken?: CancellationToken): readonly Diagnostic[];
21152115
getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
21162116
/** The first time this is called, it will return global diagnostics (no location). */
2117-
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly Diagnostic[];
2117+
getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken, includeUncheckedJS?: boolean): readonly Diagnostic[];
21182118
getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): readonly DiagnosticWithLocation[];
21192119
getConfigFileParsingDiagnostics(): readonly Diagnostic[];
21202120
/**

tests/baselines/reference/spellingUncheckedJS.errors.txt

Lines changed: 0 additions & 71 deletions
This file was deleted.

tests/baselines/reference/spellingUncheckedJS.symbols

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,53 @@ function f() {
1111
>locals : Symbol(locals, Decl(spellingUncheckedJS.js, 4, 7))
1212

1313
locale.toFixed()
14+
// @ts-expect-error
15+
localf.toExponential()
16+
// @ts-expect-error
17+
"this is fine"
1418
}
1519
class Classe {
16-
>Classe : Symbol(Classe, Decl(spellingUncheckedJS.js, 6, 1))
20+
>Classe : Symbol(Classe, Decl(spellingUncheckedJS.js, 10, 1))
1721

1822
non = 'oui'
19-
>non : Symbol(Classe.non, Decl(spellingUncheckedJS.js, 7, 14))
23+
>non : Symbol(Classe.non, Decl(spellingUncheckedJS.js, 11, 14))
2024

2125
methode() {
22-
>methode : Symbol(Classe.methode, Decl(spellingUncheckedJS.js, 8, 15))
26+
>methode : Symbol(Classe.methode, Decl(spellingUncheckedJS.js, 12, 15))
2327

2428
// no error on 'this' references
2529
return this.none
26-
>this : Symbol(Classe, Decl(spellingUncheckedJS.js, 6, 1))
30+
>this : Symbol(Classe, Decl(spellingUncheckedJS.js, 10, 1))
2731
}
2832
}
2933
class Derivee extends Classe {
30-
>Derivee : Symbol(Derivee, Decl(spellingUncheckedJS.js, 13, 1))
31-
>Classe : Symbol(Classe, Decl(spellingUncheckedJS.js, 6, 1))
34+
>Derivee : Symbol(Derivee, Decl(spellingUncheckedJS.js, 17, 1))
35+
>Classe : Symbol(Classe, Decl(spellingUncheckedJS.js, 10, 1))
3236

3337
methode() {
34-
>methode : Symbol(Derivee.methode, Decl(spellingUncheckedJS.js, 14, 30))
38+
>methode : Symbol(Derivee.methode, Decl(spellingUncheckedJS.js, 18, 30))
3539

3640
// no error on 'super' references
3741
return super.none
38-
>super : Symbol(Classe, Decl(spellingUncheckedJS.js, 6, 1))
42+
>super : Symbol(Classe, Decl(spellingUncheckedJS.js, 10, 1))
3943
}
4044
}
4145

4246

4347
var object = {
44-
>object : Symbol(object, Decl(spellingUncheckedJS.js, 22, 3), Decl(spellingUncheckedJS.js, 25, 15), Decl(spellingUncheckedJS.js, 26, 18))
48+
>object : Symbol(object, Decl(spellingUncheckedJS.js, 26, 3), Decl(spellingUncheckedJS.js, 29, 15), Decl(spellingUncheckedJS.js, 30, 18))
4549

4650
spaaace: 3
47-
>spaaace : Symbol(spaaace, Decl(spellingUncheckedJS.js, 22, 14))
51+
>spaaace : Symbol(spaaace, Decl(spellingUncheckedJS.js, 26, 14))
4852
}
4953
object.spaaaace // error on read
50-
>object : Symbol(object, Decl(spellingUncheckedJS.js, 22, 3), Decl(spellingUncheckedJS.js, 25, 15), Decl(spellingUncheckedJS.js, 26, 18))
54+
>object : Symbol(object, Decl(spellingUncheckedJS.js, 26, 3), Decl(spellingUncheckedJS.js, 29, 15), Decl(spellingUncheckedJS.js, 30, 18))
5155

5256
object.spaace = 12 // error on write
53-
>object : Symbol(object, Decl(spellingUncheckedJS.js, 22, 3), Decl(spellingUncheckedJS.js, 25, 15), Decl(spellingUncheckedJS.js, 26, 18))
57+
>object : Symbol(object, Decl(spellingUncheckedJS.js, 26, 3), Decl(spellingUncheckedJS.js, 29, 15), Decl(spellingUncheckedJS.js, 30, 18))
5458

5559
object.fresh = 12 // OK
56-
>object : Symbol(object, Decl(spellingUncheckedJS.js, 22, 3), Decl(spellingUncheckedJS.js, 25, 15), Decl(spellingUncheckedJS.js, 26, 18))
60+
>object : Symbol(object, Decl(spellingUncheckedJS.js, 26, 3), Decl(spellingUncheckedJS.js, 29, 15), Decl(spellingUncheckedJS.js, 30, 18))
5761

5862
other.puuuce // OK, from another file
5963
>other : Symbol(other, Decl(other.js, 3, 3))
@@ -63,7 +67,7 @@ new Date().getGMTDate() // OK, from another file
6367

6468
// No suggestions for globals from other files
6569
const atoc = setIntegral(() => console.log('ok'), 500)
66-
>atoc : Symbol(atoc, Decl(spellingUncheckedJS.js, 32, 5))
70+
>atoc : Symbol(atoc, Decl(spellingUncheckedJS.js, 36, 5))
6771
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
6872
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
6973
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
@@ -73,11 +77,6 @@ Jimmy
7377
>Jimmy : Symbol(Jimmy, Decl(other.js, 0, 3))
7478

7579
Jon
76-
window.argle
77-
>window : Symbol(window, Decl(lib.dom.d.ts, --, --))
78-
79-
self.blargle
80-
>self : Symbol(self, Decl(lib.dom.d.ts, --, --))
8180

8281
=== tests/cases/conformance/salsa/other.js ===
8382
var Jimmy = 1
@@ -93,9 +92,4 @@ var other = {
9392
puuce: 4
9493
>puuce : Symbol(puuce, Decl(other.js, 3, 13))
9594
}
96-
window.argle
97-
>window : Symbol(window, Decl(lib.dom.d.ts, --, --))
98-
99-
self.blargle
100-
>self : Symbol(self, Decl(lib.dom.d.ts, --, --))
10195

tests/baselines/reference/spellingUncheckedJS.types

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export var inModule = 1
44
>1 : 1
55

66
inmodule.toFixed()
7-
>inmodule.toFixed() : any
8-
>inmodule.toFixed : any
7+
>inmodule.toFixed() : error
8+
>inmodule.toFixed : error
99
>inmodule : any
1010
>toFixed : any
1111

@@ -19,10 +19,21 @@ function f() {
1919
>true : true
2020

2121
locale.toFixed()
22-
>locale.toFixed() : any
23-
>locale.toFixed : any
22+
>locale.toFixed() : error
23+
>locale.toFixed : error
2424
>locale : any
2525
>toFixed : any
26+
27+
// @ts-expect-error
28+
localf.toExponential()
29+
>localf.toExponential() : error
30+
>localf.toExponential : error
31+
>localf : any
32+
>toExponential : any
33+
34+
// @ts-expect-error
35+
"this is fine"
36+
>"this is fine" : "this is fine"
2637
}
2738
class Classe {
2839
>Classe : Classe
@@ -66,20 +77,20 @@ var object = {
6677
>3 : 3
6778
}
6879
object.spaaaace // error on read
69-
>object.spaaaace : any
80+
>object.spaaaace : error
7081
>object : { spaaace: number; }
7182
>spaaaace : any
7283

7384
object.spaace = 12 // error on write
7485
>object.spaace = 12 : 12
75-
>object.spaace : any
86+
>object.spaace : error
7687
>object : { spaaace: number; }
7788
>spaace : any
7889
>12 : 12
7990

8091
object.fresh = 12 // OK
8192
>object.fresh = 12 : 12
82-
>object.fresh : any
93+
>object.fresh : error
8394
>object : { spaaace: number; }
8495
>fresh : any
8596
>12 : 12
@@ -98,9 +109,9 @@ new Date().getGMTDate() // OK, from another file
98109

99110
// No suggestions for globals from other files
100111
const atoc = setIntegral(() => console.log('ok'), 500)
101-
>atoc : any
102-
>setIntegral(() => console.log('ok'), 500) : any
103-
>setIntegral : any
112+
>atoc : error
113+
>setIntegral(() => console.log('ok'), 500) : error
114+
>setIntegral : error
104115
>() => console.log('ok') : () => void
105116
>console.log('ok') : void
106117
>console.log : (...data: any[]) => void
@@ -110,23 +121,13 @@ const atoc = setIntegral(() => console.log('ok'), 500)
110121
>500 : 500
111122

112123
AudioBuffin // etc
113-
>AudioBuffin : any
124+
>AudioBuffin : error
114125

115126
Jimmy
116127
>Jimmy : number
117128

118129
Jon
119-
>Jon : any
120-
121-
window.argle
122-
>window.argle : any
123-
>window : Window & typeof globalThis
124-
>argle : any
125-
126-
self.blargle
127-
>self.blargle : any
128-
>self : Window & typeof globalThis
129-
>blargle : any
130+
>Jon : error
130131

131132
=== tests/cases/conformance/salsa/other.js ===
132133
var Jimmy = 1
@@ -138,7 +139,7 @@ var John = 2
138139
>2 : 2
139140

140141
Jon // error, it's from the same file
141-
>Jon : any
142+
>Jon : error
142143

143144
var other = {
144145
>other : { puuce: number; }
@@ -148,13 +149,4 @@ var other = {
148149
>puuce : number
149150
>4 : 4
150151
}
151-
window.argle
152-
>window.argle : any
153-
>window : Window & typeof globalThis
154-
>argle : any
155-
156-
self.blargle
157-
>self.blargle : any
158-
>self : Window & typeof globalThis
159-
>blargle : any
160152

tests/cases/conformance/salsa/spellingUncheckedJS.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ inmodule.toFixed()
77
function f() {
88
var locals = 2 + true
99
locale.toFixed()
10+
// @ts-expect-error
11+
localf.toExponential()
12+
// @ts-expect-error
13+
"this is fine"
1014
}
1115
class Classe {
1216
non = 'oui'
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @allowjs: true
4+
// @noEmit: true
5+
6+
// @filename: a.js
7+
//// var locals = {}
8+
//// // @ts-expect-error
9+
//// Object.keys(locale)
10+
verify.noErrors()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
// @allowjs: true
4+
// @noEmit: true
5+
6+
// @filename: a.js
7+
//// var locals = {}
8+
//// [|// @ts-expect-error|]
9+
//// Object.keys(locals)
10+
verify.codeFixAvailable([
11+
{ description: "Ignore this error message" },
12+
{ description: "Disable checking for this file" },
13+
]);
14+

0 commit comments

Comments
 (0)