Improve test and comments

Test asserts that unused locals error works for untyped modules.
Comment no longer claims to check for untyped modules.
This commit is contained in:
Nathan Shively-Sanders
2017-04-06 09:02:18 -07:00
parent 90d5c299b0
commit f635042255
6 changed files with 31 additions and 19 deletions

View File

@@ -438,7 +438,7 @@ namespace ts {
((<ModuleDeclaration>node).name.kind === SyntaxKind.StringLiteral || isGlobalScopeAugmentation(<ModuleDeclaration>node));
}
/** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */
/** Given a symbol for a module, checks that it is a shorthand ambient module. */
export function isShorthandAmbientModuleSymbol(moduleSymbol: Symbol): boolean {
return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
}

View File

@@ -0,0 +1,18 @@
/a.ts(2,8): error TS6133: 'Bar' is declared but never used.
==== /a.ts (1 errors) ====
import Foo from "foo";
import Bar from "bar"; // error: unused
~~~
!!! error TS6133: 'Bar' is declared but never used.
export class A extends Foo { }
==== /node_modules/foo/index.js (0 errors) ====
// Test that extending an untyped module is an error, unlike extending unknownSymbol.
This file is not read.
==== /node_modules/bar/index.js (0 errors) ====
Nor is this one.

View File

@@ -5,9 +5,13 @@
This file is not read.
//// [index.js]
Nor is this one.
//// [a.ts]
import Foo from "foo";
class A extends Foo { }
import Bar from "bar"; // error: unused
export class A extends Foo { }
//// [a.js]
@@ -31,3 +35,4 @@ var A = (function (_super) {
}
return A;
}(foo_1["default"]));
exports.A = A;

View File

@@ -1,8 +0,0 @@
=== /a.ts ===
import Foo from "foo";
>Foo : Symbol(Foo, Decl(a.ts, 0, 6))
class A extends Foo { }
>A : Symbol(A, Decl(a.ts, 0, 22))
>Foo : Symbol(Foo, Decl(a.ts, 0, 6))

View File

@@ -1,8 +0,0 @@
=== /a.ts ===
import Foo from "foo";
>Foo : any
class A extends Foo { }
>A : A
>Foo : any

View File

@@ -1,9 +1,14 @@
// Test that extending an untyped module is an error, unlike extending unknownSymbol.
// @noImplicitReferences: true
// @noUnusedLocals: true
// @Filename: /node_modules/foo/index.js
This file is not read.
// @Filename: /node_modules/bar/index.js
Nor is this one.
// @Filename: /a.ts
import Foo from "foo";
class A extends Foo { }
import Bar from "bar"; // error: unused
export class A extends Foo { }