Add test case for reporting file preprocessing error in javascript file
This commit is contained in:
parent
6b42712eb2
commit
5772dade97
|
@ -1077,6 +1077,8 @@ namespace ts {
|
|||
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
|
||||
|
||||
if (importedFile && resolution.isExternalLibraryImport) {
|
||||
// Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files,
|
||||
// this check is ok. Otherwise this would be never true for javascript file
|
||||
if (!isExternalModule(importedFile)) {
|
||||
const start = getTokenPosOfNode(file.imports[i], file);
|
||||
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
tests/cases/compiler/moduleA/a.js(2,17): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/b.ts' is not a module. Please contact the package author to update the package definition.
|
||||
|
||||
|
||||
==== tests/cases/compiler/moduleA/a.js (1 errors) ====
|
||||
|
||||
import {a} from "b";
|
||||
~~~
|
||||
!!! error TS2656: Exported external package typings file 'b.ts' is not a module. Please contact the package author to update the package definition.
|
||||
a++;
|
||||
import {c} from "c";
|
||||
c++;
|
||||
|
||||
==== tests/cases/compiler/node_modules/b.ts (0 errors) ====
|
||||
var a = 10;
|
||||
|
||||
==== tests/cases/compiler/node_modules/c.js (0 errors) ====
|
||||
exports.a = 10;
|
||||
c = 10;
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
// @allowJs: true
|
||||
// @noEmit: true
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: moduleA/a.js
|
||||
import {a} from "b";
|
||||
a++;
|
||||
import {c} from "c";
|
||||
c++;
|
||||
|
||||
// @filename: node_modules/b.ts
|
||||
var a = 10;
|
||||
|
||||
// @filename: node_modules/c.js
|
||||
exports.a = 10;
|
||||
c = 10;
|
Loading…
Reference in a new issue