mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 20:14:01 -06:00
Fix extension automatic script kind detection for new extensions (#46205)
* Fix extension script kind detection for new extensions * Accept (correct) changes to existing baselines affected by correct ScriptKind detection
This commit is contained in:
parent
ed9c522fd6
commit
7108646713
@ -6743,10 +6743,14 @@ namespace ts {
|
||||
const ext = fileName.substr(fileName.lastIndexOf("."));
|
||||
switch (ext.toLowerCase()) {
|
||||
case Extension.Js:
|
||||
case Extension.Cjs:
|
||||
case Extension.Mjs:
|
||||
return ScriptKind.JS;
|
||||
case Extension.Jsx:
|
||||
return ScriptKind.JSX;
|
||||
case Extension.Ts:
|
||||
case Extension.Cts:
|
||||
case Extension.Mts:
|
||||
return ScriptKind.TS;
|
||||
case Extension.Tsx:
|
||||
return ScriptKind.TSX;
|
||||
|
||||
@ -9,10 +9,21 @@ tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1471: Module './i
|
||||
tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
|
||||
@ -74,10 +85,21 @@ tests/cases/conformance/node/allowJs/index.mjs(21,22): error TS2307: Cannot find
|
||||
tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
|
||||
@ -292,7 +314,7 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find
|
||||
// esm format file
|
||||
const x = 1;
|
||||
export {x};
|
||||
==== tests/cases/conformance/node/allowJs/index.cjs (27 errors) ====
|
||||
==== tests/cases/conformance/node/allowJs/index.cjs (38 errors) ====
|
||||
// ESM-format imports below should issue errors
|
||||
import * as m1 from "./index.js";
|
||||
~~~~~~~~~~~~
|
||||
@ -366,24 +388,46 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find
|
||||
|
||||
// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
|
||||
import m24 = require("./");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~
|
||||
!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m25 = require("./index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~
|
||||
!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m26 = require("./subfolder");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m27 = require("./subfolder/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m28 = require("./subfolder/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m29 = require("./subfolder2");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m30 = require("./subfolder2/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m31 = require("./subfolder2/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m32 = require("./subfolder2/another");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m33 = require("./subfolder2/another/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m34 = require("./subfolder2/another/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
void m24;
|
||||
@ -435,7 +479,7 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find
|
||||
// cjs format file
|
||||
const x = 1;
|
||||
export {x};
|
||||
==== tests/cases/conformance/node/allowJs/index.mjs (27 errors) ====
|
||||
==== tests/cases/conformance/node/allowJs/index.mjs (38 errors) ====
|
||||
import * as m1 from "./index.js";
|
||||
import * as m2 from "./index.mjs";
|
||||
import * as m3 from "./index.cjs";
|
||||
@ -508,24 +552,46 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find
|
||||
|
||||
// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
|
||||
import m24 = require("./");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~
|
||||
!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m25 = require("./index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~
|
||||
!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m26 = require("./subfolder");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m27 = require("./subfolder/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m28 = require("./subfolder/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m29 = require("./subfolder2");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m30 = require("./subfolder2/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m31 = require("./subfolder2/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m32 = require("./subfolder2/another");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m33 = require("./subfolder2/another/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m34 = require("./subfolder2/another/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
void m24;
|
||||
|
||||
@ -661,32 +661,24 @@ export { x };
|
||||
//// [index.d.ts]
|
||||
export const x: 1;
|
||||
//// [index.d.cts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.mts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.ts]
|
||||
export const x: 1;
|
||||
//// [index.d.cts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.mts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.ts]
|
||||
export const x: 1;
|
||||
//// [index.d.cts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.mts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.cts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.mts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.ts]
|
||||
export const x: 1;
|
||||
|
||||
@ -9,10 +9,21 @@ tests/cases/conformance/node/allowJs/index.cjs(16,22): error TS1471: Module './i
|
||||
tests/cases/conformance/node/allowJs/index.cjs(23,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(24,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(25,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(51,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(52,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(59,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(60,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(61,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(61,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(75,21): error TS2307: Cannot find module './' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.cjs(76,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
|
||||
@ -74,10 +85,21 @@ tests/cases/conformance/node/allowJs/index.mjs(21,22): error TS2307: Cannot find
|
||||
tests/cases/conformance/node/allowJs/index.mjs(22,22): error TS2307: Cannot find module './subfolder2/another' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(23,22): error TS2307: Cannot find module './subfolder2/another/' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(24,22): error TS2307: Cannot find module './subfolder2/another/index' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(50,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(50,22): error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(51,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(51,22): error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(52,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(53,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(54,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(55,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(56,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(57,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(58,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(58,22): error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(59,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(59,22): error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(60,1): error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(60,22): error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(74,21): error TS2307: Cannot find module './' or its corresponding type declarations.
|
||||
tests/cases/conformance/node/allowJs/index.mjs(75,21): error TS2307: Cannot find module './index' or its corresponding type declarations.
|
||||
@ -292,7 +314,7 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find
|
||||
// esm format file
|
||||
const x = 1;
|
||||
export {x};
|
||||
==== tests/cases/conformance/node/allowJs/index.cjs (27 errors) ====
|
||||
==== tests/cases/conformance/node/allowJs/index.cjs (38 errors) ====
|
||||
// ESM-format imports below should issue errors
|
||||
import * as m1 from "./index.js";
|
||||
~~~~~~~~~~~~
|
||||
@ -366,24 +388,46 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find
|
||||
|
||||
// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
|
||||
import m24 = require("./");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~
|
||||
!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m25 = require("./index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~
|
||||
!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m26 = require("./subfolder");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m27 = require("./subfolder/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m28 = require("./subfolder/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m29 = require("./subfolder2");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m30 = require("./subfolder2/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m31 = require("./subfolder2/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m32 = require("./subfolder2/another");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m33 = require("./subfolder2/another/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m34 = require("./subfolder2/another/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
void m24;
|
||||
@ -435,7 +479,7 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find
|
||||
// cjs format file
|
||||
const x = 1;
|
||||
export {x};
|
||||
==== tests/cases/conformance/node/allowJs/index.mjs (27 errors) ====
|
||||
==== tests/cases/conformance/node/allowJs/index.mjs (38 errors) ====
|
||||
import * as m1 from "./index.js";
|
||||
import * as m2 from "./index.mjs";
|
||||
import * as m3 from "./index.cjs";
|
||||
@ -508,24 +552,46 @@ tests/cases/conformance/node/allowJs/index.mjs(84,21): error TS2307: Cannot find
|
||||
|
||||
// These should _mostly_ work - `import = require` always desugars to require calls, which do have extension and index resolution (but can't load anything that resolves to esm!)
|
||||
import m24 = require("./");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~
|
||||
!!! error TS1471: Module './' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m25 = require("./index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~
|
||||
!!! error TS1471: Module './index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m26 = require("./subfolder");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m27 = require("./subfolder/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m28 = require("./subfolder/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m29 = require("./subfolder2");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m30 = require("./subfolder2/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m31 = require("./subfolder2/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
import m32 = require("./subfolder2/another");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m33 = require("./subfolder2/another/");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another/' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
import m34 = require("./subfolder2/another/index");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS8002: 'import ... =' can only be used in TypeScript files.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1471: Module './subfolder2/another/index' cannot be imported using this construct. The specifier only resolves to an ES module, which cannot be imported synchronously. Use dynamic import instead.
|
||||
void m24;
|
||||
|
||||
@ -661,32 +661,24 @@ export { x };
|
||||
//// [index.d.ts]
|
||||
export const x: 1;
|
||||
//// [index.d.cts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.mts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.ts]
|
||||
export const x: 1;
|
||||
//// [index.d.cts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.mts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.ts]
|
||||
export const x: 1;
|
||||
//// [index.d.cts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.mts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.cts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.mts]
|
||||
declare const x = 1;
|
||||
export { x };
|
||||
export const x: 1;
|
||||
//// [index.d.ts]
|
||||
export const x: 1;
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/node/allowJs/foo.cjs ===
|
||||
exports.foo = "foo"
|
||||
>exports.foo : Symbol(foo, Decl(foo.cjs, 0, 0))
|
||||
>exports : Symbol(foo, Decl(foo.cjs, 0, 0))
|
||||
>foo : Symbol(foo, Decl(foo.cjs, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/bar.ts ===
|
||||
import foo from "./foo.cjs"
|
||||
>foo : Symbol(foo, Decl(bar.ts, 0, 6))
|
||||
|
||||
foo.foo;
|
||||
>foo.foo : Symbol(foo.foo, Decl(foo.cjs, 0, 0))
|
||||
>foo : Symbol(foo, Decl(bar.ts, 0, 6))
|
||||
>foo : Symbol(foo.foo, Decl(foo.cjs, 0, 0))
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/node/allowJs/foo.cjs ===
|
||||
exports.foo = "foo"
|
||||
>exports.foo = "foo" : "foo"
|
||||
>exports.foo : string
|
||||
>exports : typeof import("tests/cases/conformance/node/allowJs/foo")
|
||||
>foo : string
|
||||
>"foo" : "foo"
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/bar.ts ===
|
||||
import foo from "./foo.cjs"
|
||||
>foo : typeof foo
|
||||
|
||||
foo.foo;
|
||||
>foo.foo : string
|
||||
>foo : typeof foo
|
||||
>foo : string
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/conformance/node/allowJs/foo.cjs ===
|
||||
exports.foo = "foo"
|
||||
>exports.foo : Symbol(foo, Decl(foo.cjs, 0, 0))
|
||||
>exports : Symbol(foo, Decl(foo.cjs, 0, 0))
|
||||
>foo : Symbol(foo, Decl(foo.cjs, 0, 0))
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/bar.ts ===
|
||||
import foo from "./foo.cjs"
|
||||
>foo : Symbol(foo, Decl(bar.ts, 0, 6))
|
||||
|
||||
foo.foo;
|
||||
>foo.foo : Symbol(foo.foo, Decl(foo.cjs, 0, 0))
|
||||
>foo : Symbol(foo, Decl(bar.ts, 0, 6))
|
||||
>foo : Symbol(foo.foo, Decl(foo.cjs, 0, 0))
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/node/allowJs/foo.cjs ===
|
||||
exports.foo = "foo"
|
||||
>exports.foo = "foo" : "foo"
|
||||
>exports.foo : string
|
||||
>exports : typeof import("tests/cases/conformance/node/allowJs/foo")
|
||||
>foo : string
|
||||
>"foo" : "foo"
|
||||
|
||||
=== tests/cases/conformance/node/allowJs/bar.ts ===
|
||||
import foo from "./foo.cjs"
|
||||
>foo : typeof foo
|
||||
|
||||
foo.foo;
|
||||
>foo.foo : string
|
||||
>foo : typeof foo
|
||||
>foo : string
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
// @module: node12,nodenext
|
||||
// @allowJs: true
|
||||
// @noEmit: true
|
||||
// @filename: foo.cjs
|
||||
exports.foo = "foo"
|
||||
// @filename: bar.ts
|
||||
import foo from "./foo.cjs"
|
||||
foo.foo;
|
||||
Loading…
x
Reference in New Issue
Block a user