Skip to content

Commit f635042

Browse files
committed
Improve test and comments
Test asserts that unused locals error works for untyped modules. Comment no longer claims to check for untyped modules.
1 parent 90d5c29 commit f635042

File tree

6 files changed

+31
-19
lines changed

6 files changed

+31
-19
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ namespace ts {
438438
((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral || isGlobalScopeAugmentation(<ModuleDeclaration>node));
439439
}
440440

441-
/** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */
441+
/** Given a symbol for a module, checks that it is a shorthand ambient module. */
442442
export function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean {
443443
return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
444444
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/a.ts(2,8): error TS6133: 'Bar' is declared but never used.
2+
3+
4+
==== /a.ts (1 errors) ====
5+
import Foo from "foo";
6+
import Bar from "bar"; // error: unused
7+
~~~
8+
!!! error TS6133: 'Bar' is declared but never used.
9+
export class A extends Foo { }
10+
11+
==== /node_modules/foo/index.js (0 errors) ====
12+
// Test that extending an untyped module is an error, unlike extending unknownSymbol.
13+
14+
This file is not read.
15+
16+
==== /node_modules/bar/index.js (0 errors) ====
17+
Nor is this one.
18+

tests/baselines/reference/extendsUntypedModule.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55

66
This file is not read.
77

8+
//// [index.js]
9+
Nor is this one.
10+
811
//// [a.ts]
912
import Foo from "foo";
10-
class A extends Foo { }
13+
import Bar from "bar"; // error: unused
14+
export class A extends Foo { }
1115

1216

1317
//// [a.js]
@@ -31,3 +35,4 @@ var A = (function (_super) {
3135
}
3236
return A;
3337
}(foo_1["default"]));
38+
exports.A = A;

tests/baselines/reference/extendsUntypedModule.symbols

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

tests/baselines/reference/extendsUntypedModule.types

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
// Test that extending an untyped module is an error, unlike extending unknownSymbol.
22
// @noImplicitReferences: true
3+
// @noUnusedLocals: true
34

45
// @Filename: /node_modules/foo/index.js
56
This file is not read.
67

8+
// @Filename: /node_modules/bar/index.js
9+
Nor is this one.
10+
711
// @Filename: /a.ts
812
import Foo from "foo";
9-
class A extends Foo { }
13+
import Bar from "bar"; // error: unused
14+
export class A extends Foo { }

0 commit comments

Comments
 (0)